static int mymain(void) { int ret = 0; virCapsPtr caps; if (virThreadInitialize() < 0) exit(EXIT_FAILURE); if (!(caps = testQemuCapsInit())) exit(EXIT_FAILURE); virEventRegisterDefaultImpl(); #define DO_TEST(name) \ if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, caps) < 0) \ ret = -1 DO_TEST(GetStatus); DO_TEST(GetVersion); DO_TEST(GetMachines); DO_TEST(GetCPUDefinitions); DO_TEST(GetCommands); virObjectUnref(caps); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static void virAdmGlobalInit(void) { /* It would be nice if we could trace the use of this call, to * help diagnose in log files if a user calls something other than * virAdmConnectOpen first. But we can't rely on VIR_DEBUG working * until after initialization is complete, and since this is * one-shot, we never get here again. */ if (virThreadInitialize() < 0 || virErrorInitialize() < 0) goto error; virLogSetFromEnv(); if (!bindtextdomain(PACKAGE, LOCALEDIR)) goto error; if (!(remoteAdminPrivClass = virClassNew(virClassForObjectLockable(), "remoteAdminPriv", sizeof(remoteAdminPriv), remoteAdminPrivDispose))) goto error; return; error: virAdmGlobalError = true; }
static int mymain(void) { int ret = 0; virDomainXMLOptionPtr xmlopt; testQemuData data; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); data.xmlopt = xmlopt; #define DO_TEST(name) \ data.base = name; \ if (virtTestRun(name, testQemuCaps, &data) < 0) \ ret = -1 DO_TEST("caps_1.2.2-1"); DO_TEST("caps_1.3.1-1"); DO_TEST("caps_1.4.2-1"); DO_TEST("caps_1.5.3-1"); DO_TEST("caps_1.6.0-1"); DO_TEST("caps_1.6.50-1"); virObjectUnref(xmlopt); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; virDomainXMLOptionPtr xmlopt; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); #define DO_TEST(name) \ if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlopt) < 0) \ ret = -1 DO_TEST(GetStatus); DO_TEST(GetVersion); DO_TEST(GetMachines); DO_TEST(GetCPUDefinitions); DO_TEST(GetCommands); DO_TEST(GetTPMModels); DO_TEST(GetCommandLineOptionParameters); virObjectUnref(xmlopt); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; testQemuData data; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0) return EXIT_FAILURE; virEventRegisterDefaultImpl(); #define DO_TEST_FULL(name, guest) \ data.base = name; \ data.guestarch = guest; \ if (virtTestRun(name, testQemuCapsXML, &data) < 0) \ ret = -1 #define DO_TEST(name) DO_TEST_FULL(name, VIR_ARCH_I686) DO_TEST("all_1.6.0-1"); DO_TEST("nodisksnapshot_1.6.0-1"); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; virQEMUDriver driver; testQemuData data; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; virEventRegisterDefaultImpl(); data.xmlopt = driver.xmlopt; #define DO_TEST(arch, name) \ do { \ data.archName = arch; \ data.base = name; \ if (virTestRun(name "(" arch ")", testQemuCaps, &data) < 0) \ ret = -1; \ } while (0) DO_TEST("x86_64", "caps_1.2.2"); DO_TEST("x86_64", "caps_1.3.1"); DO_TEST("x86_64", "caps_1.4.2"); DO_TEST("x86_64", "caps_1.5.3"); DO_TEST("x86_64", "caps_1.6.0"); DO_TEST("x86_64", "caps_1.7.0"); DO_TEST("x86_64", "caps_2.1.1"); DO_TEST("x86_64", "caps_2.4.0"); DO_TEST("x86_64", "caps_2.5.0"); DO_TEST("x86_64", "caps_2.6.0"); DO_TEST("aarch64", "caps_2.6.0-gicv2"); DO_TEST("aarch64", "caps_2.6.0-gicv3"); DO_TEST("ppc64le", "caps_2.6.0"); /* * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies" * to generate updated or new *.replies data files. */ qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; virQEMUDriver driver; testQemuData data; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; virEventRegisterDefaultImpl(); data.xmlopt = driver.xmlopt; #define DO_TEST(name) \ do { \ data.base = name; \ if (virtTestRun(name, testQemuCaps, &data) < 0) \ ret = -1; \ } while (0) DO_TEST("caps_1.2.2-1"); DO_TEST("caps_1.3.1-1"); DO_TEST("caps_1.4.2-1"); DO_TEST("caps_1.5.3-1"); DO_TEST("caps_1.6.0-1"); DO_TEST("caps_1.6.50-1"); DO_TEST("caps_2.1.1-1"); DO_TEST("caps_2.4.0-1"); DO_TEST("caps_2.5.0-1"); qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; struct qemuHotplugTestData data = {0}; virSecurityManagerPtr mgr; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; virEventRegisterDefaultImpl(); VIR_FREE(driver.config->spiceListen); VIR_FREE(driver.config->vncListen); /* some dummy values from 'config file' */ if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) return EXIT_FAILURE; if (!(driver.domainEventState = virObjectEventStateNew())) return EXIT_FAILURE; driver.lockManager = virLockManagerPluginNew("nop", "qemu", driver.config->configBaseDir, 0); if (!driver.lockManager) return EXIT_FAILURE; if (!(mgr = virSecurityManagerNew("none", "qemu", VIR_SECURITY_MANAGER_PRIVILEGED))) return EXIT_FAILURE; if (!(driver.securityManager = virSecurityManagerNewStack(mgr))) return EXIT_FAILURE; /* wait only 100ms for DEVICE_DELETED event */ qemuDomainRemoveDeviceWaitTime = 100; #define DO_TEST(file, ACTION, dev, event, fial, kep, ...) \ do { \ const char *my_mon[] = { __VA_ARGS__, NULL}; \ const char *name = file " " #ACTION " " dev; \ data.action = ACTION; \ data.domain_filename = file; \ data.device_filename = dev; \ data.fail = fial; \ data.mon = my_mon; \ data.keep = kep; \ data.deviceDeletedEvent = event; \ if (virtTestRun(name, testQemuHotplug, &data) < 0) \ ret = -1; \ } while (0) #define DO_TEST_ATTACH(file, dev, fial, kep, ...) \ DO_TEST(file, ATTACH, dev, false, fial, kep, __VA_ARGS__) #define DO_TEST_DETACH(file, dev, fial, kep, ...) \ DO_TEST(file, DETACH, dev, false, fial, kep, __VA_ARGS__) #define DO_TEST_ATTACH_EVENT(file, dev, fial, kep, ...) \ DO_TEST(file, ATTACH, dev, true, fial, kep, __VA_ARGS__) #define DO_TEST_DETACH_EVENT(file, dev, fial, kep, ...) \ DO_TEST(file, DETACH, dev, true, fial, kep, __VA_ARGS__) #define DO_TEST_UPDATE(file, dev, fial, kep, ...) \ DO_TEST(file, UPDATE, dev, false, fial, kep, __VA_ARGS__) #define QMP_OK "{\"return\": {}}" #define HMP(msg) "{\"return\": \"" msg "\"}" #define QMP_DEVICE_DELETED(dev) \ "{" \ " \"timestamp\": {" \ " \"seconds\": 1374137171," \ " \"microseconds\": 2659" \ " }," \ " \"event\": \"DEVICE_DELETED\"," \ " \"data\": {" \ " \"device\": \"" dev "\"," \ " \"path\": \"/machine/peripheral/" dev "\"" \ " }" \ "}\r\n" DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL); DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false, "set_password", QMP_OK, "expire_password", QMP_OK); DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-password", false, false, "set_password", QMP_OK, "expire_password", QMP_OK); DO_TEST_UPDATE("graphics-spice", "graphics-spice-listen", true, false, NULL); DO_TEST_UPDATE("graphics-spice-listen-network", "graphics-spice-listen-network", false, false, "set_password", QMP_OK, "expire_password", QMP_OK); /* Strange huh? Currently, only graphics can be updated :-P */ DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, NULL); DO_TEST_ATTACH("console-compat-2", "console-virtio", false, true, "chardev-add", "{\"return\": {\"pty\": \"/dev/pts/26\"}}", "device_add", QMP_OK); DO_TEST_DETACH("console-compat-2", "console-virtio", false, false, "device_del", QMP_OK, "chardev-remove", QMP_OK); DO_TEST_ATTACH("hotplug-base", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-virtio", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_ATTACH_EVENT("hotplug-base", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-virtio", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_DETACH("hotplug-base", "disk-virtio", false, false, "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK, "human-monitor-command", HMP("")); DO_TEST_ATTACH("hotplug-base", "disk-usb", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-usb", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_ATTACH_EVENT("hotplug-base", "disk-usb", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-usb", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_DETACH("hotplug-base", "disk-usb", false, false, "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK, "human-monitor-command", HMP("")); DO_TEST_ATTACH("hotplug-base", "disk-scsi", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-scsi", false, false, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_ATTACH_EVENT("hotplug-base", "disk-scsi", false, true, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); DO_TEST_DETACH("hotplug-base", "disk-scsi", true, true, "device_del", QMP_OK, "human-monitor-command", HMP("")); DO_TEST_DETACH("hotplug-base", "disk-scsi", false, false, "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, "human-monitor-command", HMP("")); qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; struct qemuHotplugTestData data = {0}; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif if (virThreadInitialize() < 0 || !(driver.caps = testQemuCapsInit()) || !(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); driver.config = virQEMUDriverConfigNew(false); VIR_FREE(driver.config->spiceListen); VIR_FREE(driver.config->vncListen); if (!(driver.domainEventState = virDomainEventStateNew())) return EXIT_FAILURE; /* some dummy values from 'config file' */ if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) return EXIT_FAILURE; #define DO_TEST(file, dev, fial, kep, ...) \ const char *my_mon[] = { __VA_ARGS__, NULL}; \ data.domain_filename = file; \ data.device_filename = dev; \ data.fail = fial; \ data.mon = my_mon; \ data.keep = kep; \ if (virtTestRun(#file, 1, testQemuHotplug, &data) < 0) \ ret = -1; \ #define DO_TEST_ATTACH(file, dev, fial, kep, ...) \ do { \ data.action = ATTACH; \ DO_TEST(file, dev, fial, kep, __VA_ARGS__) \ } while (0) #define DO_TEST_DETACH(file, dev, fial, kep, ...) \ do { \ data.action = DETACH; \ DO_TEST(file, dev, fial, kep, __VA_ARGS__) \ } while (0) #define DO_TEST_UPDATE(file, dev, fial, kep, ...) \ do { \ data.action = UPDATE; \ DO_TEST(file, dev, fial, kep, __VA_ARGS__) \ } while (0) DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL); DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false, "set_password", "{\"return\":{}}", "expire_password", "{\"return\":{}}"); DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-password", false, false, "set_password", "{\"return\":{}}", "expire_password", "{\"return\":{}}"); DO_TEST_UPDATE("graphics-spice", "graphics-spice-listen", true, false, NULL); DO_TEST_UPDATE("graphics-spice-listen-network", "graphics-spice-listen-network", false, false, "set_password", "{\"return\":{}}", "expire_password", "{\"return\":{}}"); /* Strange huh? Currently, only graphics can be updated :-P */ DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, NULL); DO_TEST_ATTACH("console-compat-2", "console-virtio", false, true, "chardev-add", "{\"return\": {\"pty\": \"/dev/pts/26\"}}", "device_add", "{\"return\": {}}"); DO_TEST_DETACH("console-compat-2", "console-virtio", false, false, "device_del", "{\"return\": {}}", "chardev-remove", "{\"return\": {}}"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); virObjectUnref(driver.config); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }