qemuxml2argvtest.c 19.1 KB
Newer Older
1
#include <config.h>
2

3
#include <stdio.h>
4 5
#include <stdlib.h>
#include <unistd.h>
6 7 8 9 10
#include <string.h>

#include <sys/types.h>
#include <fcntl.h>

11 12
#ifdef WITH_QEMU

13 14
# include "internal.h"
# include "testutils.h"
15 16
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_command.h"
17
# include "datatypes.h"
18
# include "cpu/cpu_map.h"
19

20
# include "testutilsqemu.h"
21

22
static char *progname;
23
static char *abs_srcdir;
24
static const char *abs_top_srcdir;
25
static struct qemud_driver driver;
26

27
# define MAX_FILE 4096
28

29
static int testCompareXMLToArgvFiles(const char *xml,
E
Eric Blake 已提交
30
                                     const char *cmdline,
31
                                     virBitmapPtr extraFlags,
J
Jiri Denemark 已提交
32
                                     const char *migrateFrom,
33
                                     int migrateFd,
J
Jiri Denemark 已提交
34
                                     bool expectError) {
35 36
    char argvData[MAX_FILE];
    char *expectargv = &(argvData[0]);
E
Eric Blake 已提交
37
    int len;
38
    char *actualargv = NULL;
E
Eric Blake 已提交
39
    int ret = -1;
40
    virDomainDefPtr vmdef = NULL;
41
    virDomainChrSourceDef monitor_chr;
42
    virConnectPtr conn;
J
Jiri Denemark 已提交
43
    char *log = NULL;
44
    char *emulator = NULL;
E
Eric Blake 已提交
45
    virCommandPtr cmd = NULL;
46 47 48

    if (!(conn = virGetConnect()))
        goto fail;
49

E
Eric Blake 已提交
50 51
    len = virtTestLoadFile(cmdline, &expectargv, MAX_FILE);
    if (len < 0)
52
        goto fail;
E
Eric Blake 已提交
53 54
    if (len && expectargv[len - 1] == '\n')
        expectargv[len - 1] = '\0';
55

56
    if (!(vmdef = virDomainDefParseFile(driver.caps, xml,
57
                                        VIR_DOMAIN_XML_INACTIVE)))
58 59
        goto fail;

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    /*
     * For test purposes, we may want to fake emulator's output by providing
     * our own script instead of a real emulator. For this to work we need to
     * specify a relative path in <emulator/> element, which, however, is not
     * allowed by RelaxNG schema for domain XML. To work around it we add an
     * extra '/' at the beginning of relative emulator path so that it looks
     * like, e.g., "/./qemu.sh" or "/../emulator/qemu.sh" instead of
     * "./qemu.sh" or "../emulator/qemu.sh" respectively. The following code
     * detects such paths, strips the extra '/' and makes the path absolute.
     */
    if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
        if (!(emulator = strdup(vmdef->emulator + 1)))
            goto fail;
        free(vmdef->emulator);
        vmdef->emulator = NULL;
        if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
                        abs_srcdir, emulator) < 0)
            goto fail;
    }

80
    if (qemuCapsGet(extraFlags, QEMU_CAPS_DOMID))
81
        vmdef->id = 6;
82
    else
83
        vmdef->id = -1;
84

85
    memset(&monitor_chr, 0, sizeof(monitor_chr));
86 87 88
    monitor_chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
    monitor_chr.data.nix.path = (char *)"/tmp/test-monitor";
    monitor_chr.data.nix.listen = true;
89

90 91 92 93
    qemuCapsSetList(extraFlags,
                    QEMU_CAPS_VNC_COLON,
                    QEMU_CAPS_NO_REBOOT,
                    QEMU_CAPS_LAST);
94

95 96 97
    if (qemudCanonicalizeMachine(&driver, vmdef) < 0)
        goto fail;

98
    if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
99 100 101 102 103 104 105 106 107 108 109
        qemuDomainPCIAddressSetPtr pciaddrs;
        if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
            goto fail;

        if (qemuAssignDevicePCISlots(vmdef, pciaddrs) < 0)
            goto fail;

        qemuDomainPCIAddressSetFree(pciaddrs);
    }


J
Jiri Denemark 已提交
110
    free(virtTestLogContentAndReset());
111
    virResetLastError();
J
Jiri Denemark 已提交
112

113
    /* We do not call qemuCapsExtractVersionInfo() before calling
114
     * qemuBuildCommandLine(), so we should set QEMU_CAPS_PCI_MULTIBUS for
115 116 117 118
     * x86_64 and i686 architectures here.
     */
    if (STREQLEN(vmdef->os.arch, "x86_64", 6) ||
        STREQLEN(vmdef->os.arch, "i686", 4)) {
119
        qemuCapsSet(extraFlags, QEMU_CAPS_PCI_MULTIBUS);
120 121
    }

122
    if (!(cmd = qemuBuildCommandLine(conn, &driver,
123
                                     vmdef, &monitor_chr, false, extraFlags,
124 125
                                     migrateFrom, migrateFd, NULL,
                                     VIR_VM_OP_CREATE)))
126 127
        goto fail;

128 129
    if (!!virGetLastError() != expectError) {
        if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
J
Jiri Denemark 已提交
130 131 132 133 134 135 136 137 138
            fprintf(stderr, "\n%s", log);
        goto fail;
    }

    if (expectError) {
        /* need to suppress the errors */
        virResetLastError();
    }

E
Eric Blake 已提交
139
    if (!(actualargv = virCommandToString(cmd)))
140
        goto fail;
E
Eric Blake 已提交
141 142 143 144 145 146 147 148

    if (emulator) {
        /* Skip the abs_srcdir portion of replacement emulator.  */
        char *start_skip = strstr(actualargv, abs_srcdir);
        char *end_skip = strstr(actualargv, emulator);
        if (!start_skip || !end_skip)
            goto fail;
        memmove(start_skip, end_skip, strlen(end_skip) + 1);
149 150
    }

151 152
    if (STRNEQ(expectargv, actualargv)) {
        virtTestDifference(stderr, expectargv, actualargv);
153 154 155 156 157 158
        goto fail;
    }

    ret = 0;

 fail:
J
Jiri Denemark 已提交
159
    free(log);
160
    free(emulator);
161
    free(actualargv);
E
Eric Blake 已提交
162
    virCommandFree(cmd);
163
    virDomainDefFree(vmdef);
164
    virUnrefConnect(conn);
165 166 167 168
    return ret;
}


169 170
struct testInfo {
    const char *name;
171
    virBitmapPtr extraFlags;
172
    const char *migrateFrom;
173
    int migrateFd;
J
Jiri Denemark 已提交
174
    bool expectError;
175 176
};

177
static int testCompareXMLToArgvHelper(const void *data) {
178
    const struct testInfo *info = data;
179 180
    char xml[PATH_MAX];
    char args[PATH_MAX];
181
    snprintf(xml, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
182
             abs_srcdir, info->name);
183
    snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
184
             abs_srcdir, info->name);
J
Jiri Denemark 已提交
185
    return testCompareXMLToArgvFiles(xml, args, info->extraFlags,
186 187
                                     info->migrateFrom, info->migrateFd,
                                     info->expectError);
188 189 190 191
}



192 193
static int
mymain(int argc, char **argv)
194 195
{
    int ret = 0;
196
    char cwd[PATH_MAX];
197
    char map[PATH_MAX];
198 199 200 201 202

    progname = argv[0];

    if (argc > 1) {
        fprintf(stderr, "Usage: %s\n", progname);
203
        return (EXIT_FAILURE);
204 205
    }

206 207 208
    abs_srcdir = getenv("abs_srcdir");
    if (!abs_srcdir)
        abs_srcdir = getcwd(cwd, sizeof(cwd));
209

210 211 212 213
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
        abs_top_srcdir = "..";

214 215
    if ((driver.caps = testQemuCapsInit()) == NULL)
        return EXIT_FAILURE;
216 217 218 219 220
    if ((driver.stateDir = strdup("/nowhere")) == NULL)
        return EXIT_FAILURE;
    if ((driver.hugetlbfs_mount = strdup("/dev/hugepages")) == NULL)
        return EXIT_FAILURE;
    if ((driver.hugepage_path = strdup("/dev/hugepages/libvirt/qemu")) == NULL)
221
        return EXIT_FAILURE;
222 223 224 225 226
    driver.spiceTLS = 1;
    if (!(driver.spiceTLSx509certdir = strdup("/etc/pki/libvirt-spice")))
        return EXIT_FAILURE;
    if (!(driver.spicePassword = strdup("123456")))
        return EXIT_FAILURE;
227

228 229 230 231
    snprintf(map, PATH_MAX, "%s/src/cpu/cpu_map.xml", abs_top_srcdir);
    if (cpuMapOverride(map) < 0)
        return EXIT_FAILURE;

232
# define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...)   \
233
    do {                                                                \
234 235
        struct testInfo info = {                                        \
            name, NULL, migrateFrom, migrateFd, expectError             \
J
Jiri Denemark 已提交
236
        };                                                              \
237 238 239
        if (!(info.extraFlags = qemuCapsNew()))                         \
            return EXIT_FAILURE;                                        \
        qemuCapsSetList(info.extraFlags, __VA_ARGS__, QEMU_CAPS_LAST);  \
240 241 242
        if (virtTestRun("QEMU XML-2-ARGV " name,                        \
                        1, testCompareXMLToArgvHelper, &info) < 0)      \
            ret = -1;                                                   \
243
        qemuCapsFree(info.extraFlags);                                  \
244 245
    } while (0)

246 247 248 249
# define DO_TEST(name, expectError, ...)                                \
    DO_TEST_FULL(name, NULL, -1, expectError, __VA_ARGS__)

# define NONE QEMU_CAPS_LAST
250

251 252 253
    /* Unset or set all envvars here that are copied in qemudBuildCommandLine
     * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
     * values for these envvars */
254 255 256 257 258 259 260
    setenv("PATH", "/bin", 1);
    setenv("USER", "test", 1);
    setenv("LOGNAME", "test", 1);
    setenv("HOME", "/home/test", 1);
    unsetenv("TMPDIR");
    unsetenv("LD_PRELOAD");
    unsetenv("LD_LIBRARY_PATH");
261 262
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
263

264 265 266 267 268 269 270 271 272 273 274 275 276
    DO_TEST("minimal", false, QEMU_CAPS_NAME);
    DO_TEST("machine-aliases1", false, NONE);
    DO_TEST("machine-aliases2", true, NONE);
    DO_TEST("boot-cdrom", false, NONE);
    DO_TEST("boot-network", false, NONE);
    DO_TEST("boot-floppy", false, NONE);
    DO_TEST("boot-multi", false, QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-disable", false, QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-order", false,
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE);
    DO_TEST("bootloader", true, QEMU_CAPS_DOMID);
    DO_TEST("clock-utc", false, NONE);
    DO_TEST("clock-localtime", false, NONE);
277 278
    /*
     * Can't be enabled since the absolute timestamp changes every time
279
    DO_TEST("clock-variable", false, QEMU_CAPS_RTC);
280
    */
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
    DO_TEST("clock-france", false, QEMU_CAPS_RTC);

    DO_TEST("hugepages", false, QEMU_CAPS_MEM_PATH);
    DO_TEST("disk-cdrom", false, NONE);
    DO_TEST("disk-cdrom-empty", false, QEMU_CAPS_DRIVE);
    DO_TEST("disk-floppy", false, NONE);
    DO_TEST("disk-many", false, NONE);
    DO_TEST("disk-virtio", false, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-xenvbd", false, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-drive-boot-disk", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-drive-boot-cdrom", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("floppy-drive-fat", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-fat", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-readonly-disk", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("disk-drive-readonly-no-device", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("disk-drive-fmt-qcow", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-shared", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT, QEMU_CAPS_DRIVE_SERIAL);
    DO_TEST("disk-drive-cache-v1-wt", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-cache-v1-wb", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-cache-v1-none", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-error-policy-stop", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-cache-v2-wt", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-cache-v2-wb", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-cache-v2-none", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-network-nbd", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-network-rbd", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-network-sheepdog", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-usb", false, NONE);
    DO_TEST("disk-usb-device", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("disk-scsi-device", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("disk-scsi-device-auto", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("disk-aio", false,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_AIO,
            QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("graphics-vnc", false, NONE);
    DO_TEST("graphics-vnc-socket", false, NONE);
339 340 341

    driver.vncSASL = 1;
    driver.vncSASLdir = strdup("/root/.sasl2");
342
    DO_TEST("graphics-vnc-sasl", false, QEMU_CAPS_VGA);
343 344 345
    driver.vncTLS = 1;
    driver.vncTLSx509verify = 1;
    driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
346
    DO_TEST("graphics-vnc-tls", false, NONE);
347 348 349 350 351
    driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
    free(driver.vncSASLdir);
    free(driver.vncTLSx509certdir);
    driver.vncSASLdir = driver.vncTLSx509certdir = NULL;

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
    DO_TEST("graphics-sdl", false, NONE);
    DO_TEST("graphics-sdl-fullscreen", false, NONE);
    DO_TEST("nographics", false, QEMU_CAPS_VGA);
    DO_TEST("nographics-vga", false,
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_NONE);
    DO_TEST("graphics-spice", false,
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE);

    DO_TEST("input-usbmouse", false, NONE);
    DO_TEST("input-usbtablet", false, NONE);
    DO_TEST("input-xen", true, QEMU_CAPS_DOMID);
    DO_TEST("misc-acpi", false, NONE);
    DO_TEST("misc-no-reboot", false, NONE);
    DO_TEST("misc-uuid", false, QEMU_CAPS_NAME, QEMU_CAPS_UUID);
    DO_TEST("net-user", false, NONE);
    DO_TEST("net-virtio", false, NONE);
    DO_TEST("net-virtio-device", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_TX_ALG);
    DO_TEST("net-virtio-netdev", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("net-eth", false, NONE);
    DO_TEST("net-eth-ifname", false, NONE);
    DO_TEST("net-eth-names", false, QEMU_CAPS_NET_NAME);

    DO_TEST("serial-vc", false, NONE);
    DO_TEST("serial-pty", false, NONE);
    DO_TEST("serial-dev", false, NONE);
    DO_TEST("serial-file", false, NONE);
    DO_TEST("serial-unix", false, NONE);
    DO_TEST("serial-tcp", false, NONE);
    DO_TEST("serial-udp", false, NONE);
    DO_TEST("serial-tcp-telnet", false, NONE);
    DO_TEST("serial-many", false, NONE);
    DO_TEST("parallel-tcp", false, NONE);
    DO_TEST("console-compat", false, NONE);
    DO_TEST("console-compat-auto", false, NONE);

    DO_TEST("serial-vc-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-pty-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-dev-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-file-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-unix-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-tcp-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-udp-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-tcp-telnet-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("serial-many-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("parallel-tcp-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("console-compat-chardev", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);

    DO_TEST("channel-guestfwd", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("channel-virtio", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("channel-virtio-auto", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("console-virtio", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("channel-spicevmc", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
    DO_TEST("channel-spicevmc-old", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_SPICEVMC);

    DO_TEST("smartcard-host", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
    DO_TEST("smartcard-host-certificates", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
    DO_TEST("smartcard-passthrough-tcp", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_PASSTHRU);
    DO_TEST("smartcard-passthrough-spicevmc", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_PASSTHRU, QEMU_CAPS_CHARDEV_SPICEVMC);
    DO_TEST("smartcard-controller", false,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);

    DO_TEST("smbios", false, QEMU_CAPS_SMBIOS_TYPE);

    DO_TEST("watchdog", false, NONE);
    DO_TEST("watchdog-device", false, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("watchdog-dump", false, NONE);
    DO_TEST("balloon-device", false, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-auto", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("sound", false, NONE);
    DO_TEST("sound-device", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_HDA_DUPLEX);
    DO_TEST("fs9p", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV);

    DO_TEST("hostdev-usb-address", false, NONE);
    DO_TEST("hostdev-usb-address-device", false,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("hostdev-pci-address", false, QEMU_CAPS_PCIDEVICE);
    DO_TEST("hostdev-pci-address-device", false,
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);

    DO_TEST_FULL("restore-v1", "stdio", 7, false,
            QEMU_CAPS_MIGRATE_KVM_STDIO);
    DO_TEST_FULL("restore-v2", "stdio", 7, false,
            QEMU_CAPS_MIGRATE_QEMU_EXEC);
    DO_TEST_FULL("restore-v2", "exec:cat", 7, false,
            QEMU_CAPS_MIGRATE_QEMU_EXEC);
    DO_TEST_FULL("restore-v2-fd", "stdio", 7, false,
            QEMU_CAPS_MIGRATE_QEMU_FD);
    DO_TEST_FULL("restore-v2-fd", "fd:7", 7, false,
            QEMU_CAPS_MIGRATE_QEMU_FD);
    DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, false,
            QEMU_CAPS_MIGRATE_QEMU_TCP);

    DO_TEST("qemu-ns", false, NONE);

    DO_TEST("smp", false, QEMU_CAPS_SMP_TOPOLOGY);

    DO_TEST("cpu-topology1", false, QEMU_CAPS_SMP_TOPOLOGY);
    DO_TEST("cpu-topology2", false, QEMU_CAPS_SMP_TOPOLOGY);
    DO_TEST("cpu-topology3", false, NONE);
    DO_TEST("cpu-minimum1", false, NONE);
    DO_TEST("cpu-minimum2", false, NONE);
    DO_TEST("cpu-exact1", false, NONE);
    DO_TEST("cpu-exact2", false, NONE);
    DO_TEST("cpu-strict1", false, NONE);

    DO_TEST("memtune", false, QEMU_CAPS_NAME);
    DO_TEST("blkiotune", false, QEMU_CAPS_NAME);
493

D
Daniel P. Berrange 已提交
494
    free(driver.stateDir);
495 496
    virCapabilitiesFree(driver.caps);

497
    return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
498 499
}

500 501
VIRT_TEST_MAIN(mymain)

502 503
#else

504
int main (void) { return (77); /* means 'test skipped' for automake */ }
505 506

#endif /* WITH_QEMU */