qemuxml2argvtest.c 53.8 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
#include "testutils.h"

13 14
#ifdef WITH_QEMU

15
# include "internal.h"
16
# include "viralloc.h"
17 18
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_command.h"
M
Matthias Bolte 已提交
19
# include "qemu/qemu_domain.h"
20
# include "datatypes.h"
21
# include "conf/storage_conf.h"
22
# include "cpu/cpu_map.h"
23
# include "virstring.h"
24

25
# include "testutilsqemu.h"
26

27 28
# define VIR_FROM_THIS VIR_FROM_QEMU

29
static const char *abs_top_srcdir;
30
static virQEMUDriver driver;
31

32 33 34 35 36 37
static unsigned char *
fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED,
                   size_t *value_size,
                   unsigned int fakeflags ATTRIBUTE_UNUSED,
                   unsigned int internalFlags ATTRIBUTE_UNUSED)
{
38 39
    char *secret;
    if (VIR_STRDUP(secret, "AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A") < 0)
40
        return NULL;
41 42 43 44 45 46 47 48 49
    *value_size = strlen(secret);
    return (unsigned char *) secret;
}

static virSecretPtr
fakeSecretLookupByUsage(virConnectPtr conn,
                        int usageType ATTRIBUTE_UNUSED,
                        const char *usageID)
{
50
    unsigned char uuid[VIR_UUID_BUFLEN];
51 52
    if (STRNEQ(usageID, "mycluster_myname"))
        return NULL;
53 54 55

    virUUIDGenerate(uuid);
    return virGetSecret(conn, uuid, usageType, usageID);
56 57 58 59 60 61 62 63 64 65
}

static int
fakeSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED)
{
    return 0;
}

static virSecretDriver fakeSecretDriver = {
    .name = "fake_secret",
66 67
    .secretOpen = NULL,
    .secretClose = fakeSecretClose,
68 69 70 71 72 73 74 75 76
    .connectNumOfSecrets = NULL,
    .connectListSecrets = NULL,
    .secretLookupByUUID = NULL,
    .secretLookupByUsage = fakeSecretLookupByUsage,
    .secretDefineXML = NULL,
    .secretGetXMLDesc = NULL,
    .secretSetValue = NULL,
    .secretGetValue = fakeSecretGetValue,
    .secretUndefine = NULL,
77 78
};

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229

# define STORAGE_POOL_XML_PATH "storagepoolxml2xmlout/"
static const unsigned char fakeUUID[VIR_UUID_BUFLEN] = "fakeuuid";

static virStoragePoolPtr
fakeStoragePoolLookupByName(virConnectPtr conn,
                            const char *name)
{
    char *xmlpath = NULL;
    virStoragePoolPtr ret = NULL;

    if (STRNEQ(name, "inactive")) {
        if (virAsprintf(&xmlpath, "%s/%s%s.xml",
                        abs_srcdir,
                        STORAGE_POOL_XML_PATH,
                        name) < 0)
            return NULL;

        if (!virFileExists(xmlpath)) {
            virReportError(VIR_ERR_NO_STORAGE_POOL,
                           "File '%s' not found", xmlpath);
            goto cleanup;
        }
    }

    ret = virGetStoragePool(conn, name, fakeUUID, NULL, NULL);

cleanup:
    VIR_FREE(xmlpath);
    return ret;
}


static virStorageVolPtr
fakeStorageVolLookupByName(virStoragePoolPtr pool,
                           const char *name)
{
    char **volinfo = NULL;
    virStorageVolPtr ret = NULL;

    if (STREQ(pool->name, "inactive")) {
        virReportError(VIR_ERR_OPERATION_INVALID,
                       "storage pool '%s' is not active", pool->name);
        return NULL;
    }

    if (STREQ(name, "nonexistent")) {
        virReportError(VIR_ERR_NO_STORAGE_VOL,
                       "no storage vol with matching name '%s'", name);
        return NULL;
    }

    if (!strchr(name, '+'))
        goto fallback;

    if (!(volinfo = virStringSplit(name, "+", 2)))
        return NULL;

    if (!volinfo[1])
        goto fallback;

    ret = virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0],
                           NULL, NULL);

cleanup:
    virStringFreeList(volinfo);
    return ret;

fallback:
    ret = virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
    goto cleanup;
}

static int
fakeStorageVolGetInfo(virStorageVolPtr vol,
                      virStorageVolInfoPtr info)
{
    memset(info, 0, sizeof(*info));

    info->type = virStorageVolTypeFromString(vol->key);

    if (info->type < 0) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "Invalid volume type '%s'", vol->key);
        return -1;
    }

    return 0;
}


static char *
fakeStorageVolGetPath(virStorageVolPtr vol)
{
    char *ret = NULL;

    ignore_value(virAsprintf(&ret, "/some/%s/device/%s", vol->key, vol->name));

    return ret;
}


static char *
fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
                          unsigned int flags_unused ATTRIBUTE_UNUSED)
{
    char *xmlpath = NULL;
    char *xmlbuf = NULL;

    if (STREQ(pool->name, "inactive")) {
        virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
        return NULL;
    }

    if (virAsprintf(&xmlpath, "%s/%s%s.xml",
                    abs_srcdir,
                    STORAGE_POOL_XML_PATH,
                    pool->name) < 0)
        return NULL;

    if (virtTestLoadFile(xmlpath, &xmlbuf) < 0) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "failed to load XML file '%s'",
                       xmlpath);
        goto cleanup;
    }

cleanup:
    VIR_FREE(xmlpath);

    return xmlbuf;
}

static int
fakeStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED)
{
    return 0;
}

static int
fakeStoragePoolIsActive(virStoragePoolPtr pool)
{
    if (STREQ(pool->name, "inactive"))
        return 0;

    return 1;
}

/* Test storage pool implementation
 *
 * These functions aid testing of storage pool related stuff when creating a
230
 * qemu command line.
231 232 233
 *
 * There are a few "magic" values to pass to these functions:
 *
234 235
 * 1) "inactive" as a pool name to create an inactive pool. All other names are
 * interpreted as file names in storagepoolxml2xmlout/ and are used as the
236 237 238
 * definition for the pool. If the file doesn't exist the pool doesn't exist.
 *
 * 2) "nonexistent" returns an error while looking up a volume. Otherwise
239
 * pattern VOLUME_TYPE+VOLUME_PATH can be used to simulate a volume in a pool.
240 241 242 243 244 245 246 247 248 249 250 251 252 253
 * This creates a fake path for this volume. If the '+' sign is omitted, block
 * type is assumed.
 */
static virStorageDriver fakeStorageDriver = {
    .name = "fake_storage",
    .storageClose = fakeStorageClose,
    .storagePoolLookupByName = fakeStoragePoolLookupByName,
    .storageVolLookupByName = fakeStorageVolLookupByName,
    .storagePoolGetXMLDesc = fakeStoragePoolGetXMLDesc,
    .storageVolGetPath = fakeStorageVolGetPath,
    .storageVolGetInfo = fakeStorageVolGetInfo,
    .storagePoolIsActive = fakeStoragePoolIsActive,
};

254 255 256 257 258 259 260
typedef enum {
    FLAG_EXPECT_ERROR       = 1 << 0,
    FLAG_EXPECT_FAILURE     = 1 << 1,
    FLAG_EXPECT_PARSE_ERROR = 1 << 2,
    FLAG_JSON               = 1 << 3,
} virQemuXML2ArgvTestFlags;

261
static int testCompareXMLToArgvFiles(const char *xml,
E
Eric Blake 已提交
262
                                     const char *cmdline,
263
                                     virQEMUCapsPtr extraFlags,
J
Jiri Denemark 已提交
264
                                     const char *migrateFrom,
265
                                     int migrateFd,
266
                                     virQemuXML2ArgvTestFlags flags)
267 268
{
    char *expectargv = NULL;
E
Eric Blake 已提交
269
    int len;
270
    char *actualargv = NULL;
E
Eric Blake 已提交
271
    int ret = -1;
272
    virDomainDefPtr vmdef = NULL;
273
    virDomainChrSourceDef monitor_chr;
274
    virConnectPtr conn;
J
Jiri Denemark 已提交
275
    char *log = NULL;
E
Eric Blake 已提交
276
    virCommandPtr cmd = NULL;
277
    size_t i;
278 279

    if (!(conn = virGetConnect()))
280
        goto out;
281
    conn->secretDriver = &fakeSecretDriver;
282
    conn->storageDriver = &fakeStorageDriver;
283

284
    if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
M
Matthias Bolte 已提交
285
                                        QEMU_EXPECTED_VIRT_TYPES,
286 287 288
                                        VIR_DOMAIN_XML_INACTIVE))) {
        if (flags & FLAG_EXPECT_PARSE_ERROR)
            goto ok;
289
        goto out;
290
    }
291

292 293 294 295 296
    if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
        fprintf(stderr, "ABI stability check failed on %s", xml);
        goto out;
    }

297
    if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DOMID))
298
        vmdef->id = 6;
299
    else
300
        vmdef->id = -1;
301

302
    memset(&monitor_chr, 0, sizeof(monitor_chr));
303 304 305
    monitor_chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
    monitor_chr.data.nix.path = (char *)"/tmp/test-monitor";
    monitor_chr.data.nix.listen = true;
306

307 308 309 310 311
    virQEMUCapsSetList(extraFlags,
                       QEMU_CAPS_VNC_COLON,
                       QEMU_CAPS_NO_REBOOT,
                       QEMU_CAPS_NO_ACPI,
                       QEMU_CAPS_LAST);
312

313 314 315
    if (STREQ(vmdef->os.machine, "pc") &&
        STREQ(vmdef->emulator, "/usr/bin/qemu-system-x86_64")) {
        VIR_FREE(vmdef->os.machine);
316
        if (VIR_STRDUP(vmdef->os.machine, "pc-0.11") < 0)
317 318
            goto out;
    }
319

320
    if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
321
        if (qemuDomainAssignAddresses(vmdef, extraFlags, NULL)) {
322
            if (flags & FLAG_EXPECT_ERROR)
323
                goto ok;
324
            goto out;
325
        }
326 327
    }

328 329
    log = virtTestLogContentAndReset();
    VIR_FREE(log);
330
    virResetLastError();
J
Jiri Denemark 已提交
331

332 333
    if (vmdef->os.arch == VIR_ARCH_X86_64 ||
        vmdef->os.arch == VIR_ARCH_I686) {
334
        virQEMUCapsSet(extraFlags, QEMU_CAPS_PCI_MULTIBUS);
335 336
    }

337
    if (qemuAssignDeviceAliases(vmdef, extraFlags) < 0)
338
        goto out;
339

340 341 342 343 344 345 346 347 348 349
    for (i = 0; i < vmdef->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vmdef->hostdevs[i];

        if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
            hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
            hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
            hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
        }
    }

350 351 352 353 354
    for (i = 0; i < vmdef->ndisks; i++) {
        if (qemuTranslateDiskSourcePool(conn, vmdef->disks[i]) < 0)
            goto out;
    }

355 356
    if (!(cmd = qemuBuildCommandLine(conn, &driver, vmdef, &monitor_chr,
                                     (flags & FLAG_JSON), extraFlags,
357
                                     migrateFrom, migrateFd, NULL,
358 359
                                     VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
                                     &testCallbacks))) {
360
        if (flags & FLAG_EXPECT_FAILURE) {
361
            ret = 0;
362 363 364
            if (virTestGetDebug() > 1)
                fprintf(stderr, "Got expected error: %s\n",
                        virGetLastErrorMessage());
365 366 367
            virResetLastError();
        }
        goto out;
368
    } else if (flags & FLAG_EXPECT_FAILURE) {
369 370 371 372
        if (virTestGetDebug())
            fprintf(stderr, "qemuBuildCommandLine should have failed\n");
        goto out;
    }
373

374
    if (!!virGetLastError() != !!(flags & FLAG_EXPECT_ERROR)) {
375
        if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
J
Jiri Denemark 已提交
376
            fprintf(stderr, "\n%s", log);
377
        goto out;
J
Jiri Denemark 已提交
378 379
    }

E
Eric Blake 已提交
380
    if (!(actualargv = virCommandToString(cmd)))
381
        goto out;
E
Eric Blake 已提交
382

383 384 385 386 387 388
    len = virtTestLoadFile(cmdline, &expectargv);
    if (len < 0)
        goto out;
    if (len && expectargv[len - 1] == '\n')
        expectargv[len - 1] = '\0';

389 390
    if (STRNEQ(expectargv, actualargv)) {
        virtTestDifference(stderr, expectargv, actualargv);
391
        goto out;
392 393
    }

394
 ok:
395
    if (flags & FLAG_EXPECT_ERROR) {
396 397 398 399
        /* need to suppress the errors */
        virResetLastError();
    }

400 401
    ret = 0;

402
out:
403 404 405
    VIR_FREE(log);
    VIR_FREE(expectargv);
    VIR_FREE(actualargv);
E
Eric Blake 已提交
406
    virCommandFree(cmd);
407
    virDomainDefFree(vmdef);
408
    virObjectUnref(conn);
409 410 411 412
    return ret;
}


413 414
struct testInfo {
    const char *name;
415
    virQEMUCapsPtr extraFlags;
416
    const char *migrateFrom;
417
    int migrateFd;
418
    unsigned int flags;
419 420
};

421 422 423 424
static int
testCompareXMLToArgvHelper(const void *data)
{
    int result = -1;
425
    const struct testInfo *info = data;
426 427
    char *xml = NULL;
    char *args = NULL;
428
    unsigned int flags = info->flags;
429 430 431 432 433 434 435

    if (virAsprintf(&xml, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
                    abs_srcdir, info->name) < 0 ||
        virAsprintf(&args, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
                    abs_srcdir, info->name) < 0)
        goto cleanup;

436
    if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_MONITOR_JSON))
437 438
        flags |= FLAG_JSON;

439
    result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
440
                                       info->migrateFrom, info->migrateFd,
441
                                       flags);
442 443

cleanup:
444 445
    VIR_FREE(xml);
    VIR_FREE(args);
446
    return result;
447 448 449
}


450
static int
451
testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
452 453 454 455 456 457 458 459 460 461 462 463
{
    const char *newModels[] = {
        "Opteron_G3", "Opteron_G2", "Opteron_G1",
        "Nehalem", "Penryn", "Conroe",
    };
    const char *legacyModels[] = {
        "n270", "athlon", "pentium3", "pentium2", "pentium",
        "486", "coreduo", "kvm32", "qemu32", "kvm64",
        "core2duo", "phenom", "qemu64",
    };
    size_t i;

464
    for (i = 0; i < ARRAY_CARDINALITY(newModels); i++) {
465
        if (virQEMUCapsAddCPUDefinition(caps, newModels[i]) < 0)
466 467 468 469
            return -1;
    }
    if (skipLegacy)
        return 0;
470
    for (i = 0; i < ARRAY_CARDINALITY(legacyModels); i++) {
471
        if (virQEMUCapsAddCPUDefinition(caps, legacyModels[i]) < 0)
472 473 474 475 476
            return -1;
    }
    return 0;
}

477

478
static int
E
Eric Blake 已提交
479
mymain(void)
480 481
{
    int ret = 0;
482
    char *map = NULL;
483
    bool skipLegacyCPUs = false;
484

485 486
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
487
        abs_top_srcdir = abs_srcdir "/..";
488

489 490 491 492 493 494 495 496 497 498
    /* Set the timezone because we are mocking the time() function.
     * If we don't do that, then localtime() may return unpredictable
     * results. In order to detect things that just work by a blind
     * chance, we need to set an virtual timezone that no libvirt
     * developer resides in. */
    if (setenv("TZ", "VIR00:30", 1) < 0) {
        perror("setenv");
        return EXIT_FAILURE;
    }

499 500 501 502
    driver.config = virQEMUDriverConfigNew(false);
    VIR_FREE(driver.config->spiceListen);
    VIR_FREE(driver.config->vncListen);

503
    VIR_FREE(driver.config->vncTLSx509certdir);
504
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
505 506
        return EXIT_FAILURE;
    VIR_FREE(driver.config->spiceTLSx509certdir);
507
    if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
508 509
        return EXIT_FAILURE;

510 511
    if ((driver.caps = testQemuCapsInit()) == NULL)
        return EXIT_FAILURE;
512
    if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
513
        return EXIT_FAILURE;
514
    VIR_FREE(driver.config->stateDir);
515
    if (VIR_STRDUP_QUIET(driver.config->stateDir, "/nowhere") < 0)
516
        return EXIT_FAILURE;
517
    VIR_FREE(driver.config->hugetlbfsMount);
518
    if (VIR_STRDUP_QUIET(driver.config->hugetlbfsMount, "/dev/hugepages") < 0)
519
        return EXIT_FAILURE;
520
    VIR_FREE(driver.config->hugepagePath);
521
    if (VIR_STRDUP_QUIET(driver.config->hugepagePath, "/dev/hugepages/libvirt/qemu") < 0)
522
        return EXIT_FAILURE;
523
    driver.config->spiceTLS = 1;
524
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
525
        return EXIT_FAILURE;
526 527
    if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
        cpuMapOverride(map) < 0) {
528
        VIR_FREE(map);
529
        return EXIT_FAILURE;
530
    }
531

532
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, ...)         \
533
    do {                                                                \
534
        static struct testInfo info = {                                 \
535
            name, NULL, migrateFrom, migrateFd, (flags)                 \
J
Jiri Denemark 已提交
536
        };                                                              \
537
        if (!(info.extraFlags = virQEMUCapsNew()))                      \
538
            return EXIT_FAILURE;                                        \
539 540
        if (testAddCPUModels(info.extraFlags, skipLegacyCPUs) < 0)      \
            return EXIT_FAILURE;                                        \
541
        virQEMUCapsSetList(info.extraFlags, __VA_ARGS__, QEMU_CAPS_LAST);\
542
        if (virtTestRun("QEMU XML-2-ARGV " name,                        \
543
                        testCompareXMLToArgvHelper, &info) < 0)         \
544
            ret = -1;                                                   \
545
        virObjectUnref(info.extraFlags);                                \
546 547
    } while (0)

548 549 550 551 552
# define DO_TEST(name, ...)                                             \
    DO_TEST_FULL(name, NULL, -1, 0, __VA_ARGS__)

# define DO_TEST_ERROR(name, ...)                                       \
    DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_ERROR, __VA_ARGS__)
553 554

# define DO_TEST_FAILURE(name, ...)                                     \
555 556 557 558 559 560
    DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, __VA_ARGS__)

# define DO_TEST_PARSE_ERROR(name, ...)                                 \
    DO_TEST_FULL(name, NULL, -1,                                        \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_ERROR,           \
                 __VA_ARGS__)
561 562

# define NONE QEMU_CAPS_LAST
563

564 565 566
    /* 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 */
567 568 569 570 571 572 573
    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");
574 575
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
576

577 578 579
    DO_TEST("minimal", QEMU_CAPS_NAME);
    DO_TEST("minimal-s390", QEMU_CAPS_NAME);
    DO_TEST("machine-aliases1", NONE);
580
    DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
581 582 583 584
    DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
    DO_TEST("machine-core-off", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
585
    DO_TEST_FAILURE("machine-core-on", NONE);
586
    DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT);
L
Li Zhang 已提交
587 588
    DO_TEST("machine-usb-opt", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_USB_OPT);
589
    DO_TEST("kvm", QEMU_CAPS_MACHINE_OPT);
590 591 592 593 594
    DO_TEST("boot-cdrom", NONE);
    DO_TEST("boot-network", NONE);
    DO_TEST("boot-floppy", NONE);
    DO_TEST("boot-multi", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-enable",
595
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE);
596
    DO_TEST("boot-menu-enable",
597 598
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_BOOTINDEX);
599 600
    DO_TEST("boot-menu-disable", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-disable-drive",
601
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE);
602
    DO_TEST("boot-menu-disable-drive-bootindex",
603 604
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_BOOTINDEX);
605 606 607
    DO_TEST_PARSE_ERROR("boot-dev+order",
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
608
    DO_TEST("boot-order",
609 610
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
611
    DO_TEST("boot-complex",
612 613
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
614
    DO_TEST("boot-complex-bootindex",
615
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
616 617
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
618 619 620 621
    DO_TEST("boot-strict",
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
622
    DO_TEST("bootloader", QEMU_CAPS_DOMID, QEMU_CAPS_KVM);
623 624 625 626 627

    DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
    DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
    DO_TEST_FAILURE("reboot-timeout-enabled", NONE);

628 629 630
    DO_TEST("bios", QEMU_CAPS_DEVICE, QEMU_CAPS_SGA);
    DO_TEST("clock-utc", NONE);
    DO_TEST("clock-localtime", NONE);
631
    DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
632 633
    DO_TEST("clock-variable", QEMU_CAPS_RTC);
    DO_TEST("clock-france", QEMU_CAPS_RTC);
634 635
    DO_TEST("clock-hpet-off", QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET,
            QEMU_CAPS_NO_KVM_PIT);
636
    DO_TEST("clock-catchup", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT);
637 638 639
    DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_CPU_HOST);
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
640
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
641

642 643
    DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM);
644 645 646 647 648 649
    DO_TEST("controller-order", QEMU_CAPS_DRIVE, QEMU_CAPS_PCIDEVICE,
            QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_ENABLE_KVM,
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DRIVE_AIO,
            QEMU_CAPS_CCID_PASSTHRU, QEMU_CAPS_CHARDEV,
            QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_SPICE, QEMU_CAPS_HDA_DUPLEX);
650 651
    DO_TEST("eoi-disabled", NONE);
    DO_TEST("eoi-enabled", NONE);
652 653
    DO_TEST("pv-spinlock-disabled", NONE);
    DO_TEST("pv-spinlock-enabled", NONE);
M
Martin Kletzander 已提交
654
    DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
655

656
    DO_TEST("hyperv", NONE);
657
    DO_TEST("hyperv-off", NONE);
658

659
    DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
660
    DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
661
    DO_TEST("disk-cdrom", NONE);
662 663
    DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
            QEMU_CAPS_DRIVE);
664 665
    DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
            QEMU_CAPS_DRIVE);
666 667
    DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
            QEMU_CAPS_DRIVE);
668 669
    DO_TEST("disk-cdrom-network-ftps", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
            QEMU_CAPS_DRIVE);
670 671
    DO_TEST("disk-cdrom-network-tftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
            QEMU_CAPS_DRIVE);
672 673
    DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE);
    DO_TEST("disk-cdrom-tray",
674
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_TX_ALG);
675 676 677 678
    DO_TEST("disk-cdrom-tray-no-device-cap", NONE);
    DO_TEST("disk-floppy", NONE);
    DO_TEST("disk-floppy-tray-no-device-cap", NONE);
    DO_TEST("disk-floppy-tray",
679
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE);
680
    DO_TEST("disk-virtio-s390", QEMU_CAPS_DRIVE,
681
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_S390);
682 683
    DO_TEST("disk-many", NONE);
    DO_TEST("disk-virtio", QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
684 685 686 687
    DO_TEST("disk-virtio-ccw", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST("disk-virtio-ccw-many", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
688 689
    DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
690
    DO_TEST("disk-order",
691 692
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE_BOOT,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
693 694
    DO_TEST("disk-xenvbd", QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-drive-boot-disk",
695
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
696
    DO_TEST("disk-drive-boot-cdrom",
697
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT);
698
    DO_TEST("floppy-drive-fat",
699
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
700
    DO_TEST("disk-drive-fat",
701
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
702
    DO_TEST("disk-drive-readonly-disk",
703 704
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
705
    DO_TEST("disk-drive-readonly-no-device",
706
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY, QEMU_CAPS_NODEFCONFIG);
707
    DO_TEST("disk-drive-fmt-qcow",
708
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_DRIVE_FORMAT);
709
    DO_TEST("disk-drive-shared",
710
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT, QEMU_CAPS_DRIVE_SERIAL);
711
    DO_TEST("disk-drive-cache-v1-wt",
712
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
713
    DO_TEST("disk-drive-cache-v1-wb",
714
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
715
    DO_TEST("disk-drive-cache-v1-none",
716
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
717
    DO_TEST("disk-drive-error-policy-stop",
718
            QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
719
    DO_TEST("disk-drive-error-policy-enospace",
720
            QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
721
    DO_TEST("disk-drive-error-policy-wreport-rignore",
722
            QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
723
    DO_TEST("disk-drive-cache-v2-wt",
724
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
725
    DO_TEST("disk-drive-cache-v2-wb",
726
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
727
    DO_TEST("disk-drive-cache-v2-none",
728
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
729
    DO_TEST("disk-drive-cache-directsync",
730 731
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2,
            QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC, QEMU_CAPS_DRIVE_FORMAT);
732
    DO_TEST("disk-drive-cache-unsafe",
733 734
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2,
            QEMU_CAPS_DRIVE_CACHE_UNSAFE, QEMU_CAPS_DRIVE_FORMAT);
735
    DO_TEST("disk-drive-network-nbd",
736
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
P
Paolo Bonzini 已提交
737 738
    DO_TEST("disk-drive-network-nbd-export",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
P
Paolo Bonzini 已提交
739 740 741 742
    DO_TEST("disk-drive-network-nbd-ipv6",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
    DO_TEST("disk-drive-network-nbd-ipv6-export",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
743 744
    DO_TEST("disk-drive-network-nbd-unix",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
P
Paolo Bonzini 已提交
745 746
    DO_TEST("disk-drive-network-iscsi",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
747 748
    DO_TEST("disk-drive-network-iscsi-auth",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
749 750 751 752
    DO_TEST("disk-drive-network-iscsi-lun",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE_FORMAT,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_VIRTIO_BLK_SG_IO, QEMU_CAPS_SCSI_BLOCK);
753 754
    DO_TEST("disk-drive-network-gluster",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
755
    DO_TEST("disk-drive-network-rbd",
756
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
757
    DO_TEST("disk-drive-network-sheepdog",
758
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
759
    DO_TEST("disk-drive-network-rbd-auth",
760
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
761 762
    DO_TEST("disk-drive-network-rbd-ipv6",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
763
    DO_TEST_FAILURE("disk-drive-network-rbd-no-colon",
764
                    QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
765
    DO_TEST("disk-drive-no-boot",
766
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX);
767 768
    DO_TEST("disk-usb",  NONE);
    DO_TEST("disk-usb-device",
769 770
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_USB_STORAGE,
            QEMU_CAPS_NODEFCONFIG);
771 772 773
    DO_TEST("disk-usb-device-removable",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_USB_STORAGE,
            QEMU_CAPS_USB_STORAGE_REMOVABLE, QEMU_CAPS_NODEFCONFIG);
774
    DO_TEST("disk-scsi-device",
775 776
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SCSI_LSI);
777
    DO_TEST("disk-scsi-device-auto",
778 779
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SCSI_LSI);
780
    DO_TEST("disk-scsi-disk-split",
781
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
782
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
783 784
    DO_TEST("disk-scsi-disk-wwn",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
785
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
786 787 788
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST("disk-scsi-disk-vpd",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
789
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
790 791 792
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
793
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
794
            QEMU_CAPS_SCSI_DISK_WWN);
795
    DO_TEST("disk-scsi-vscsi",
796
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
797
    DO_TEST("disk-scsi-virtio-scsi",
798
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
799
            QEMU_CAPS_VIRTIO_SCSI);
800 801 802
    DO_TEST("disk-virtio-scsi-num_queues",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_SCSI);
803 804 805
    DO_TEST("disk-scsi-megasas",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SCSI_MEGASAS);
806
    DO_TEST("disk-sata-device",
J
Jim Fehlig 已提交
807 808
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI);
809
    DO_TEST("disk-aio",
810 811
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_AIO,
            QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
812 813
    DO_TEST("disk-source-pool",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
814 815
    DO_TEST("disk-source-pool-mode",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
816
    DO_TEST("disk-ioeventfd",
817
            QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_IOEVENTFD,
818
            QEMU_CAPS_VIRTIO_TX_ALG, QEMU_CAPS_DEVICE,
O
Osier Yang 已提交
819
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
820
    DO_TEST("disk-copy_on_read",
O
Osier Yang 已提交
821 822
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_COPY_ON_READ,
            QEMU_CAPS_VIRTIO_TX_ALG, QEMU_CAPS_DEVICE,
823
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
O
Osier Yang 已提交
824 825 826
    DO_TEST("disk-drive-discard",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DEVICE);
827
    DO_TEST("disk-snapshot",
828
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
829
    DO_TEST("event_idx",
830 831 832
            QEMU_CAPS_DRIVE,
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
833 834
            QEMU_CAPS_DEVICE,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
835
    DO_TEST("virtio-lun",
836 837 838
            QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE,
            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
839
    DO_TEST("disk-scsi-lun-passthrough",
840 841
            QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE,
842
            QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_VIRTIO_BLK_SG_IO,
843
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
844

845 846
    DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
    DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
847
    DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET);
848
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY);
849

850 851
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
852
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
853
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_VGA);
854 855
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
856
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC);
857
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
858 859
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
860

861 862 863 864
    DO_TEST("graphics-sdl", NONE);
    DO_TEST("graphics-sdl-fullscreen", NONE);
    DO_TEST("nographics", QEMU_CAPS_VGA);
    DO_TEST("nographics-vga",
865
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_NONE);
866
    DO_TEST("graphics-spice",
867
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
868
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
869 870
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
871 872 873 874 875 876 877 878
    driver.config->spiceSASL = 1;
    ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
    DO_TEST("graphics-spice-sasl",
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
879
    DO_TEST("graphics-spice-agentmouse",
P
Peng Zhou 已提交
880
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
881 882 883
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_NODEFCONFIG);
884
    DO_TEST("graphics-spice-compression",
885
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
886 887
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_QXL);
888
    DO_TEST("graphics-spice-timeout",
889 890 891 892
            QEMU_CAPS_DRIVE,
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_QXL_VGA);
893
    DO_TEST("graphics-spice-qxl-vga",
894 895
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
896 897
            QEMU_CAPS_DEVICE_QXL_VGA,
            QEMU_CAPS_DEVICE_QXL);
898
    DO_TEST("graphics-spice-usb-redir",
899 900 901 902 903
            QEMU_CAPS_VGA, QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_CHARDEV_SPICEVMC);
904 905 906 907 908 909
    DO_TEST("graphics-spice-agent-file-xfer",
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
            QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_QXL_VGA,
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
910

911 912
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
913
    DO_TEST("input-xen", QEMU_CAPS_DOMID, QEMU_CAPS_KVM, QEMU_CAPS_VNC);
914
    DO_TEST("misc-acpi", NONE);
915 916 917 918
    DO_TEST("misc-disable-s3", QEMU_CAPS_DISABLE_S3);
    DO_TEST("misc-disable-suspends", QEMU_CAPS_DISABLE_S3, QEMU_CAPS_DISABLE_S4);
    DO_TEST("misc-enable-s4", QEMU_CAPS_DISABLE_S4);
    DO_TEST_FAILURE("misc-enable-s4", NONE);
919 920 921 922 923
    DO_TEST("misc-no-reboot", NONE);
    DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID);
    DO_TEST("net-user", NONE);
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
924
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_TX_ALG);
925
    DO_TEST("net-virtio-netdev",
926
            QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
927
    DO_TEST("net-virtio-s390",
928
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_S390);
929 930
    DO_TEST("net-virtio-ccw",
            QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
931 932 933 934 935 936 937
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
    DO_TEST("net-eth-names", QEMU_CAPS_NET_NAME);
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
    DO_TEST("net-mcast", NONE);
    DO_TEST("net-hostdev",
938
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
939 940 941
    DO_TEST("net-hostdev-vfio",
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VFIO_PCI);
942

943 944 945 946 947 948 949 950 951
    DO_TEST("serial-vc", NONE);
    DO_TEST("serial-pty", NONE);
    DO_TEST("serial-dev", NONE);
    DO_TEST("serial-file", NONE);
    DO_TEST("serial-unix", NONE);
    DO_TEST("serial-tcp", NONE);
    DO_TEST("serial-udp", NONE);
    DO_TEST("serial-tcp-telnet", NONE);
    DO_TEST("serial-many", NONE);
952 953 954 955 956 957 958
    DO_TEST("serial-spiceport",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEPORT);
    DO_TEST("serial-spiceport-nospice", QEMU_CAPS_NAME);

959 960 961 962 963
    DO_TEST("parallel-tcp", NONE);
    DO_TEST("console-compat", NONE);
    DO_TEST("console-compat-auto", NONE);

    DO_TEST("serial-vc-chardev",
964
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
965
    DO_TEST("serial-pty-chardev",
966
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
967
    DO_TEST("serial-dev-chardev",
968
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
969
    DO_TEST("serial-file-chardev",
970
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
971
    DO_TEST("serial-unix-chardev",
972
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
973
    DO_TEST("serial-tcp-chardev",
974
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
975
    DO_TEST("serial-udp-chardev",
976
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
977
    DO_TEST("serial-tcp-telnet-chardev",
978
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
979
    DO_TEST("serial-many-chardev",
980
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
981
    DO_TEST("parallel-tcp-chardev",
982
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
983
    DO_TEST("parallel-parport-chardev",
984
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
985
    DO_TEST("console-compat-chardev",
986 987
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);

988
    DO_TEST("channel-guestfwd",
989
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
990
    DO_TEST("channel-virtio",
991
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
992
    DO_TEST("channel-virtio-auto",
993
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
994
    DO_TEST("console-virtio",
995
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
996
    DO_TEST("console-virtio-many",
997
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
998
    DO_TEST("console-virtio-s390",
999
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1000 1001 1002 1003 1004
            QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
    DO_TEST("console-virtio-ccw",
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390);
1005 1006 1007
    DO_TEST("console-sclp",
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_SCLP_S390);
1008
    DO_TEST("channel-spicevmc",
1009 1010
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
1011
    DO_TEST("channel-spicevmc-old",
1012 1013 1014
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_SPICEVMC);

1015
    DO_TEST("smartcard-host",
1016 1017
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
1018
    DO_TEST("smartcard-host-certificates",
1019 1020
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
1021
    DO_TEST("smartcard-passthrough-tcp",
1022 1023
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_PASSTHRU);
1024
    DO_TEST("smartcard-passthrough-spicevmc",
1025 1026
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_PASSTHRU, QEMU_CAPS_CHARDEV_SPICEVMC);
1027
    DO_TEST("smartcard-controller",
1028 1029 1030
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);

1031
    DO_TEST("usb-controller",
1032 1033
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG);
1034
    DO_TEST("usb-piix3-controller",
1035
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_PIIX3_USB_UHCI,
1036
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_NODEFCONFIG);
1037
    DO_TEST("usb-ich9-ehci-addr",
1038 1039
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1040
    DO_TEST("input-usbmouse-addr",
1041
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1042
    DO_TEST("usb-ich9-companion",
1043 1044
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1045 1046 1047
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1048
    DO_TEST("usb-hub",
M
Marc-André Lureau 已提交
1049 1050
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
1051
    DO_TEST("usb-ports",
1052 1053
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
1054
    DO_TEST("usb-redir",
1055 1056
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
1057 1058
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
1059 1060 1061 1062 1063 1064
    DO_TEST("usb-redir-boot",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_USB_REDIR_BOOTINDEX);
1065 1066 1067 1068 1069 1070
    DO_TEST("usb-redir-filter",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_USB_REDIR_FILTER);
1071
    DO_TEST("usb1-usb2",
1072 1073 1074
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB, QEMU_CAPS_ICH9_USB_EHCI1);
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
    DO_TEST("usb-none",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST_PARSE_ERROR("usb-none-other",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST_PARSE_ERROR("usb-none-hub",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_USB_HUB);
    DO_TEST_PARSE_ERROR("usb-none-usbtablet",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);

1085

1086
    DO_TEST("smbios", QEMU_CAPS_SMBIOS_TYPE);
1087
    DO_TEST_PARSE_ERROR("smbios-date", QEMU_CAPS_SMBIOS_TYPE);
1088
    DO_TEST_PARSE_ERROR("smbios-uuid-match", QEMU_CAPS_SMBIOS_TYPE);
1089

1090 1091 1092 1093 1094
    DO_TEST("watchdog", NONE);
    DO_TEST("watchdog-device", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("watchdog-dump", NONE);
    DO_TEST("balloon-device", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-auto",
1095
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1096
    DO_TEST("balloon-device-period", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1097 1098
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1099
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
1100 1101
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA);
1102
    DO_TEST("fs9p",
1103 1104
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
            QEMU_CAPS_FSDEV_WRITEOUT);
1105

1106 1107
    DO_TEST("hostdev-usb-address", NONE);
    DO_TEST("hostdev-usb-address-device",
1108
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1109 1110 1111
    DO_TEST("hostdev-usb-address-device-boot", QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_USB_HOST_BOOTINDEX);
1112 1113
    DO_TEST("hostdev-pci-address", QEMU_CAPS_PCIDEVICE);
    DO_TEST("hostdev-pci-address-device",
1114
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1115 1116 1117
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VFIO_PCI);
1118
    DO_TEST("pci-rom",
1119 1120
            QEMU_CAPS_PCIDEVICE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_ROMBAR);
1121

1122 1123 1124 1125 1126 1127
    DO_TEST_FULL("restore-v1", "stdio", 7, 0, QEMU_CAPS_MIGRATE_KVM_STDIO);
    DO_TEST_FULL("restore-v2", "stdio", 7, 0, QEMU_CAPS_MIGRATE_QEMU_EXEC);
    DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, QEMU_CAPS_MIGRATE_QEMU_EXEC);
    DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, QEMU_CAPS_MIGRATE_QEMU_FD);
    DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, QEMU_CAPS_MIGRATE_QEMU_FD);
    DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0,
1128 1129
            QEMU_CAPS_MIGRATE_QEMU_TCP);

1130
    DO_TEST("qemu-ns", NONE);
1131

1132
    DO_TEST("smp", QEMU_CAPS_SMP_TOPOLOGY);
1133

1134 1135 1136 1137 1138 1139 1140 1141 1142
    DO_TEST("cpu-topology1", QEMU_CAPS_SMP_TOPOLOGY);
    DO_TEST("cpu-topology2", QEMU_CAPS_SMP_TOPOLOGY);
    DO_TEST("cpu-topology3", NONE);
    DO_TEST("cpu-minimum1", NONE);
    DO_TEST("cpu-minimum2", NONE);
    DO_TEST("cpu-exact1", NONE);
    DO_TEST("cpu-exact2", NONE);
    DO_TEST("cpu-exact2-nofallback", NONE);
    DO_TEST("cpu-fallback", NONE);
1143
    DO_TEST_FAILURE("cpu-nofallback", NONE);
1144 1145 1146 1147
    DO_TEST("cpu-strict1", NONE);
    DO_TEST("cpu-numa1", NONE);
    DO_TEST("cpu-numa2", QEMU_CAPS_SMP_TOPOLOGY);
    DO_TEST("cpu-host-model", NONE);
1148
    skipLegacyCPUs = true;
1149
    DO_TEST("cpu-host-model-fallback", NONE);
1150
    DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
1151
    skipLegacyCPUs = false;
1152
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST);
1153 1154 1155
    DO_TEST_FAILURE("cpu-host-passthrough", NONE);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough",
                    QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST);
1156

1157
    DO_TEST("memtune", QEMU_CAPS_NAME);
1158
    DO_TEST("memtune-unlimited", QEMU_CAPS_NAME);
1159 1160 1161 1162
    DO_TEST("blkiotune", QEMU_CAPS_NAME);
    DO_TEST("blkiotune-device", QEMU_CAPS_NAME);
    DO_TEST("cputune", QEMU_CAPS_NAME);
    DO_TEST("numatune-memory", NONE);
1163
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1164 1165 1166 1167 1168 1169
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
    DO_TEST("numad-auto-memory-vcpu-cpuset", NONE);
    DO_TEST("numad-auto-memory-vcpu-no-cpuset-and-placement", NONE);
    DO_TEST("numad-static-memory-auto-vcpu", NONE);
    DO_TEST("blkdeviotune", QEMU_CAPS_NAME, QEMU_CAPS_DEVICE,
1170
            QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_IOTUNE);
1171

1172
    DO_TEST("multifunction-pci-device",
1173
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
1174
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_SCSI_LSI);
1175

1176
    DO_TEST("monitor-json", QEMU_CAPS_DEVICE,
1177
            QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG);
1178
    DO_TEST("no-shutdown", QEMU_CAPS_DEVICE,
1179 1180
            QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_NO_SHUTDOWN);
1181

1182 1183 1184
    DO_TEST("seclabel-dynamic", QEMU_CAPS_NAME);
    DO_TEST("seclabel-dynamic-baselabel", QEMU_CAPS_NAME);
    DO_TEST("seclabel-dynamic-override", QEMU_CAPS_NAME);
1185
    DO_TEST("seclabel-dynamic-labelskip", QEMU_CAPS_NAME);
1186
    DO_TEST("seclabel-dynamic-relabel", QEMU_CAPS_NAME);
1187 1188
    DO_TEST("seclabel-static", QEMU_CAPS_NAME);
    DO_TEST("seclabel-static-relabel", QEMU_CAPS_NAME);
1189
    DO_TEST("seclabel-static-labelskip", QEMU_CAPS_NAME);
1190
    DO_TEST("seclabel-none", QEMU_CAPS_NAME);
1191

1192
    DO_TEST("pseries-basic",
1193
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1194
    DO_TEST("pseries-vio", QEMU_CAPS_DRIVE,
1195
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1196 1197 1198 1199 1200 1201 1202 1203
    DO_TEST("pseries-usb-default", QEMU_CAPS_DRIVE,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
    DO_TEST("pseries-usb-multi", QEMU_CAPS_DRIVE,
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
1204
    DO_TEST("pseries-vio-user-assigned", QEMU_CAPS_DRIVE,
1205
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1206
    DO_TEST_ERROR("pseries-vio-address-clash", QEMU_CAPS_DRIVE,
1207
            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1208
    DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
1209 1210 1211
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_CHARDEV,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1212
    DO_TEST_FAILURE("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
1213
    DO_TEST("disk-ide-drive-split",
1214 1215
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_IDE_CD);
1216 1217 1218
    DO_TEST("disk-ide-wwn",
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_IDE_CD,
            QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_IDE_DRIVE_WWN);
1219

1220
    DO_TEST("disk-geometry", QEMU_CAPS_DRIVE);
V
Viktor Mihajlovski 已提交
1221
    DO_TEST("disk-blockio",
1222
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
V
Viktor Mihajlovski 已提交
1223
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1224

1225 1226 1227
    DO_TEST("video-device-pciaddr-default",
            QEMU_CAPS_KVM, QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1228 1229
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
1230

1231 1232
    DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1233 1234 1235 1236
    DO_TEST("virtio-rng-random", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
    DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
1237 1238
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash", QEMU_CAPS_DEVICE,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_EGD);
1239 1240 1241 1242 1243
    DO_TEST("virtio-rng-ccw",
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1244

1245 1246 1247 1248 1249
    DO_TEST("s390-usb-none",
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);

1250 1251 1252 1253 1254
    DO_TEST("s390-piix-controllers",
            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);

O
Olivia Yin 已提交
1255 1256
    DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);

1257 1258
    DO_TEST("tpm-passthrough", QEMU_CAPS_DEVICE,
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
1259 1260
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid", QEMU_CAPS_DEVICE,
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
1261

1262 1263
    DO_TEST("pci-autoadd-addr", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
    DO_TEST("pci-autoadd-idx", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
1264 1265
    DO_TEST("pci-bridge-many-disks",
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
1266
    DO_TEST("pcie-root",
1267
            QEMU_CAPS_ICH9_AHCI,
1268 1269 1270 1271 1272
            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
    DO_TEST("q35",
            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
1273
            QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
1274 1275
            QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
1276

1277 1278 1279 1280 1281 1282 1283 1284
    DO_TEST("hostdev-scsi-lsi", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
    DO_TEST("hostdev-scsi-virtio-scsi", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
O
Osier Yang 已提交
1285 1286 1287 1288
    DO_TEST("hostdev-scsi-readonly", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_DRIVE_READONLY, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
1289 1290 1291 1292 1293
    DO_TEST("hostdev-scsi-virtio-scsi", QEMU_CAPS_DRIVE,
            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
1294

1295 1296 1297 1298 1299
    DO_TEST("mlock-on", QEMU_CAPS_MLOCK);
    DO_TEST_FAILURE("mlock-on", NONE);
    DO_TEST("mlock-off", QEMU_CAPS_MLOCK);
    DO_TEST("mlock-unsupported", NONE);

1300 1301
    DO_TEST_PARSE_ERROR("pci-bridge-negative-index-invalid",
                        QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
J
Ján Tomko 已提交
1302 1303 1304 1305 1306 1307
    DO_TEST_PARSE_ERROR("pci-bridge-duplicate-index",
                        QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
    DO_TEST_PARSE_ERROR("pci-root-nonzero-index",
                        QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
    DO_TEST_PARSE_ERROR("pci-root-address",
                        QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
1308

1309 1310 1311 1312
    DO_TEST("hotplug-base",
            QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
            QEMU_CAPS_VIRTIO_SCSI);

1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
    DO_TEST("pcihole64", QEMU_CAPS_DEVICE, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", QEMU_CAPS_DEVICE);
    DO_TEST("pcihole64-q35",
            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

1323 1324
    DO_TEST("arm-vexpressa9-nodevs",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB);
1325 1326 1327
    DO_TEST("arm-vexpressa9-basic",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
            QEMU_CAPS_DRIVE);
1328 1329 1330 1331
    DO_TEST("arm-vexpressa9-virtio",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1332 1333 1334 1335
    DO_TEST("arm-virt-virtio",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1336

1337 1338 1339 1340
    DO_TEST("aarch64-virt-virtio",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1341 1342 1343
    DO_TEST("aarch64-virt-default-nic",
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
1344

1345 1346 1347 1348 1349
    DO_TEST("kvm-pit-device", QEMU_CAPS_KVM_PIT_TICK_POLICY);
    DO_TEST("kvm-pit-delay", QEMU_CAPS_NO_KVM_PIT);
    DO_TEST("kvm-pit-device", QEMU_CAPS_NO_KVM_PIT,
            QEMU_CAPS_KVM_PIT_TICK_POLICY);

H
Hu Tao 已提交
1350 1351 1352
    DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);

1353
    virObjectUnref(driver.config);
1354
    virObjectUnref(driver.caps);
1355
    virObjectUnref(driver.xmlopt);
1356
    VIR_FREE(map);
1357

1358
    return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
1359 1360
}

1361
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2argvmock.so")
1362

1363 1364
#else

1365 1366 1367 1368
int main(void)
{
    return EXIT_AM_SKIP;
}
1369 1370

#endif /* WITH_QEMU */