qemuxml2argvtest.c 85.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
# include "qemu/qemu_alias.h"
18 19
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_command.h"
M
Matthias Bolte 已提交
20
# include "qemu/qemu_domain.h"
21
# include "qemu/qemu_migration.h"
22
# include "qemu/qemu_process.h"
23
# include "datatypes.h"
24
# include "conf/storage_conf.h"
25
# include "cpu/cpu_map.h"
26
# include "virstring.h"
27
# include "storage/storage_driver.h"
28
# include "virmock.h"
29

30 31 32 33
# define __QEMU_CAPSRIV_H_ALLOW__
# include "qemu/qemu_capspriv.h"
# undef __QEMU_CAPSRIV_H_ALLOW__

34
# include "testutilsqemu.h"
35

36 37
# define VIR_FROM_THIS VIR_FROM_QEMU

38
static const char *abs_top_srcdir;
39
static virQEMUDriver driver;
40

41 42 43 44 45 46
static unsigned char *
fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED,
                   size_t *value_size,
                   unsigned int fakeflags ATTRIBUTE_UNUSED,
                   unsigned int internalFlags ATTRIBUTE_UNUSED)
{
47 48
    char *secret;
    if (VIR_STRDUP(secret, "AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A") < 0)
49
        return NULL;
50 51 52 53 54 55
    *value_size = strlen(secret);
    return (unsigned char *) secret;
}

static virSecretPtr
fakeSecretLookupByUsage(virConnectPtr conn,
56
                        int usageType,
57 58
                        const char *usageID)
{
59
    unsigned char uuid[VIR_UUID_BUFLEN];
60 61 62 63 64 65 66 67 68 69
    if (usageType == VIR_SECRET_USAGE_TYPE_VOLUME) {
        if (!STRPREFIX(usageID, "/storage/guest_disks/")) {
            virReportError(VIR_ERR_INTERNAL_ERROR,
                           "test provided invalid volume storage prefix '%s'",
                           usageID);
            return NULL;
        }
    } else if (STRNEQ(usageID, "mycluster_myname")) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "test provided incorrect usage '%s'", usageID);
70
        return NULL;
71
    }
72

73 74 75
    if (virUUIDGenerate(uuid) < 0)
        return NULL;

76
    return virGetSecret(conn, uuid, usageType, usageID);
77 78
}

79 80 81 82 83 84 85
static virSecretPtr
fakeSecretLookupByUUID(virConnectPtr conn,
                       const unsigned char *uuid)
{
    return virGetSecret(conn, uuid, 0, "");
}

86
static virSecretDriver fakeSecretDriver = {
87 88
    .connectNumOfSecrets = NULL,
    .connectListSecrets = NULL,
89
    .secretLookupByUUID = fakeSecretLookupByUUID,
90 91 92 93 94 95
    .secretLookupByUsage = fakeSecretLookupByUsage,
    .secretDefineXML = NULL,
    .secretGetXMLDesc = NULL,
    .secretSetValue = NULL,
    .secretGetValue = fakeSecretGetValue,
    .secretUndefine = NULL,
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

# 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);

125
 cleanup:
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
    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);

162
 cleanup:
163 164 165
    virStringFreeList(volinfo);
    return ret;

166
 fallback:
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
    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;

218
    if (virTestLoadFile(xmlpath, &xmlbuf) < 0) {
219 220 221 222 223 224
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "failed to load XML file '%s'",
                       xmlpath);
        goto cleanup;
    }

225
 cleanup:
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
    VIR_FREE(xmlpath);

    return xmlbuf;
}

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
243
 * qemu command line.
244 245 246
 *
 * There are a few "magic" values to pass to these functions:
 *
247 248
 * 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
249 250 251
 * 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
252
 * pattern VOLUME_TYPE+VOLUME_PATH can be used to simulate a volume in a pool.
253 254 255 256 257 258 259 260 261 262 263 264
 * This creates a fake path for this volume. If the '+' sign is omitted, block
 * type is assumed.
 */
static virStorageDriver fakeStorageDriver = {
    .storagePoolLookupByName = fakeStoragePoolLookupByName,
    .storageVolLookupByName = fakeStorageVolLookupByName,
    .storagePoolGetXMLDesc = fakeStoragePoolGetXMLDesc,
    .storageVolGetPath = fakeStorageVolGetPath,
    .storageVolGetInfo = fakeStorageVolGetInfo,
    .storagePoolIsActive = fakeStoragePoolIsActive,
};

265
typedef enum {
266 267 268 269
    FLAG_EXPECT_FAILURE     = 1 << 0,
    FLAG_EXPECT_PARSE_ERROR = 1 << 1,
    FLAG_JSON               = 1 << 2,
    FLAG_FIPS               = 1 << 3,
270 271
} virQemuXML2ArgvTestFlags;

272 273 274 275 276 277 278
struct testInfo {
    const char *name;
    virQEMUCapsPtr qemuCaps;
    const char *migrateFrom;
    int migrateFd;
    unsigned int flags;
    unsigned int parseFlags;
279
    bool skipLegacyCPUs;
280 281
};

282 283 284 285

static int
testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
{
286 287
    virArch arch = virQEMUCapsGetArch(caps);
    const char *x86Models[] = {
288 289 290 291
        "Opteron_G3", "Opteron_G2", "Opteron_G1",
        "Nehalem", "Penryn", "Conroe",
        "Haswell-noTSX", "Haswell",
    };
292
    const char *x86LegacyModels[] = {
293 294 295 296
        "n270", "athlon", "pentium3", "pentium2", "pentium",
        "486", "coreduo", "kvm32", "qemu32", "kvm64",
        "core2duo", "phenom", "qemu64",
    };
297 298 299 300 301 302
    const char *armModels[] = {
        "cortex-a9", "cortex-a8", "cortex-a57", "cortex-a53",
    };
    const char *ppc64Models[] = {
        "POWER8", "POWER7",
    };
303

304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
    if (ARCH_IS_X86(arch)) {
        if (virQEMUCapsAddCPUDefinitions(caps, x86Models,
                                         ARRAY_CARDINALITY(x86Models)) < 0)
            return -1;

        if (!skipLegacy &&
            virQEMUCapsAddCPUDefinitions(caps, x86LegacyModels,
                                         ARRAY_CARDINALITY(x86LegacyModels)) < 0)
            return -1;
    } else if (ARCH_IS_ARM(arch)) {
        if (virQEMUCapsAddCPUDefinitions(caps, armModels,
                                         ARRAY_CARDINALITY(armModels)) < 0)
            return -1;
    } else if (ARCH_IS_PPC64(arch)) {
        if (virQEMUCapsAddCPUDefinitions(caps, ppc64Models,
                                         ARRAY_CARDINALITY(ppc64Models)) < 0)
            return -1;
    }
322 323 324 325 326 327

    return 0;
}


static int
328 329
testInitQEMUCaps(struct testInfo *info,
                 int gic)
330 331 332 333 334 335
{
    int ret = -1;

    if (!(info->qemuCaps = virQEMUCapsNew()))
        goto cleanup;

336
    virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_NO_ACPI);
337 338 339 340 341 342 343 344 345 346 347

    if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
        goto cleanup;

    ret = 0;

 cleanup:
    return ret;
}


348 349
static int
testUpdateQEMUCaps(const struct testInfo *info,
350 351
                   virDomainObjPtr vm,
                   virCapsPtr caps)
352 353 354
{
    int ret = -1;

355 356
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

357 358 359
    if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
        goto cleanup;

J
Jiri Denemark 已提交
360
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps);
361

362 363 364 365 366 367 368 369 370 371 372 373
    virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);

    if (ARCH_IS_X86(vm->def->os.arch))
        virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_PCI_MULTIBUS);

    ret = 0;

 cleanup:
    return ret;
}


374 375
static int
testCompareXMLToArgv(const void *data)
376
{
377 378 379 380
    const struct testInfo *info = data;
    char *xml = NULL;
    char *args = NULL;
    char *migrateURI = NULL;
381
    char *actualargv = NULL;
382 383
    unsigned int flags = info->flags;
    unsigned int parseFlags = info->parseFlags;
E
Eric Blake 已提交
384
    int ret = -1;
385
    virDomainObjPtr vm = NULL;
386
    virDomainChrSourceDef monitor_chr;
387
    virConnectPtr conn;
J
Jiri Denemark 已提交
388
    char *log = NULL;
E
Eric Blake 已提交
389
    virCommandPtr cmd = NULL;
390
    size_t i;
391
    qemuDomainObjPrivatePtr priv = NULL;
392

393 394
    memset(&monitor_chr, 0, sizeof(monitor_chr));

395
    if (!(conn = virGetConnect()))
396
        goto cleanup;
397

398
    conn->secretDriver = &fakeSecretDriver;
399
    conn->storageDriver = &fakeStorageDriver;
400

401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
    if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_MONITOR_JSON))
        flags |= FLAG_JSON;

    if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_ENABLE_FIPS))
        flags |= FLAG_FIPS;

    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name,
                                info->qemuCaps) < 0)
        goto cleanup;

    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;

    if (info->migrateFrom &&
        !(migrateURI = qemuMigrationIncomingURI(info->migrateFrom,
                                                info->migrateFd)))
        goto cleanup;

422
    if (!(vm = virDomainObjNew(driver.xmlopt)))
423
        goto cleanup;
424

425
    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
426
    if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
427
                                          NULL, parseFlags))) {
P
Pavel Hrdina 已提交
428
        if (flags & FLAG_EXPECT_PARSE_ERROR)
429
            goto ok;
430
        goto cleanup;
431
    }
432
    priv = vm->privateData;
433

434
    if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0)
435
        goto cleanup;
P
Pavel Hrdina 已提交
436

437
    if (!virDomainDefCheckABIStability(vm->def, vm->def)) {
438
        VIR_TEST_DEBUG("ABI stability check failed on %s", xml);
439
        goto cleanup;
440 441
    }

442
    vm->def->id = -1;
443

444
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
445
        goto cleanup;
446

447 448 449 450
    if (STREQ(vm->def->os.machine, "pc") &&
        STREQ(vm->def->emulator, "/usr/bin/qemu-system-x86_64")) {
        VIR_FREE(vm->def->os.machine);
        if (VIR_STRDUP(vm->def->os.machine, "pc-0.11") < 0)
451
            goto cleanup;
452
    }
453

454
    if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
455
        goto cleanup;
456

457
    log = virTestLogContentAndReset();
458
    VIR_FREE(log);
459
    virResetLastError();
J
Jiri Denemark 已提交
460

461 462
    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
463 464 465 466 467 468 469 470

        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;
        }
    }

P
Pavel Hrdina 已提交
471 472 473
    if (!(cmd = qemuProcessCreatePretendCmd(conn, &driver, vm, migrateURI,
                                            (flags & FLAG_FIPS), false,
                                            VIR_QEMU_PROCESS_START_COLD))) {
P
Pavel Hrdina 已提交
474 475
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
476
        goto cleanup;
J
Jiri Denemark 已提交
477 478
    }

E
Eric Blake 已提交
479
    if (!(actualargv = virCommandToString(cmd)))
480
        goto cleanup;
E
Eric Blake 已提交
481

482
    if (virTestCompareToFile(actualargv, args) < 0)
483
        goto cleanup;
484

P
Pavel Hrdina 已提交
485 486
    ret = 0;

487
 ok:
488
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
489 490
        ret = -1;
        VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
491
        goto cleanup;
P
Pavel Hrdina 已提交
492
    }
493
    if (!virTestOOMActive()) {
494
        if (flags & FLAG_EXPECT_FAILURE) {
495
            if ((log = virTestLogContentAndReset()))
P
Pavel Hrdina 已提交
496 497
                VIR_TEST_DEBUG("Got expected error: \n%s", log);
        }
498
        virResetLastError();
P
Pavel Hrdina 已提交
499
        ret = 0;
500 501
    }

502
 cleanup:
503 504
    VIR_FREE(log);
    VIR_FREE(actualargv);
505
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
506
    virCommandFree(cmd);
507
    virObjectUnref(vm);
508
    virObjectUnref(conn);
509
    VIR_FREE(migrateURI);
510 511
    VIR_FREE(xml);
    VIR_FREE(args);
512
    return ret;
513 514 515
}


516
static int
E
Eric Blake 已提交
517
mymain(void)
518 519
{
    int ret = 0;
520
    bool skipLegacyCPUs = false;
521

522 523
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
524
        abs_top_srcdir = abs_srcdir "/..";
525

526 527 528 529 530 531 532 533 534 535
    /* 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;
    }

536
    if (qemuTestDriverInit(&driver) < 0)
537
        return EXIT_FAILURE;
538 539

    driver.privileged = true;
540

541 542 543
    VIR_FREE(driver.config->defaultTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/qemu") < 0)
        return EXIT_FAILURE;
544
    VIR_FREE(driver.config->vncTLSx509certdir);
545
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
546 547
        return EXIT_FAILURE;
    VIR_FREE(driver.config->spiceTLSx509certdir);
548
    if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
549
        return EXIT_FAILURE;
550 551 552
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
553

554
    VIR_FREE(driver.config->stateDir);
555
    if (VIR_STRDUP_QUIET(driver.config->stateDir, "/nowhere") < 0)
556
        return EXIT_FAILURE;
557
    VIR_FREE(driver.config->hugetlbfs);
558
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
559
        return EXIT_FAILURE;
560 561 562
    driver.config->nhugetlbfs = 2;
    if (VIR_STRDUP(driver.config->hugetlbfs[0].mnt_dir, "/dev/hugepages2M") < 0 ||
        VIR_STRDUP(driver.config->hugetlbfs[1].mnt_dir, "/dev/hugepages1G") < 0)
563
        return EXIT_FAILURE;
564 565
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
566
    driver.config->hugetlbfs[1].size = 1048576;
567
    driver.config->spiceTLS = 1;
568
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
569
        return EXIT_FAILURE;
570

571 572 573 574
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags,               \
                      parseFlags, gic, ...)                              \
    do {                                                                 \
        static struct testInfo info = {                                  \
575 576
            name, NULL, migrateFrom, migrateFd, (flags), parseFlags,     \
            false                                                        \
577
        };                                                               \
578 579
        info.skipLegacyCPUs = skipLegacyCPUs;                            \
        if (testInitQEMUCaps(&info, gic) < 0)                            \
580
            return EXIT_FAILURE;                                         \
581
        virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST);  \
582
        if (virTestRun("QEMU XML-2-ARGV " name,                          \
583
                       testCompareXMLToArgv, &info) < 0)                 \
584
            ret = -1;                                                    \
585
        virObjectUnref(info.qemuCaps);                                   \
586 587
    } while (0)

588
# define DO_TEST(name, ...)                                              \
589
    DO_TEST_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__)
590

591
# define DO_TEST_GIC(name, gic, ...)                                     \
592 593
    DO_TEST_FULL(name, NULL, -1, 0, 0, gic, __VA_ARGS__)

594 595
# define DO_TEST_FAILURE(name, ...)                                      \
    DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE,                    \
596
                 0, GIC_NONE, __VA_ARGS__)
597

598 599 600
# define DO_TEST_PARSE_ERROR(name, ...)                                  \
    DO_TEST_FULL(name, NULL, -1,                                         \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE,          \
601
                 0, GIC_NONE, __VA_ARGS__)
602

603 604 605
# define DO_TEST_PARSE_FLAGS_ERROR(name, parseFlags, ...)                \
    DO_TEST_FULL(name, NULL, -1,                                         \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE,          \
606
                 parseFlags, GIC_NONE, __VA_ARGS__)
607

608
# define DO_TEST_LINUX(name, ...)                                        \
609
    DO_TEST_LINUX_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__)
610

611 612 613 614 615 616
# ifdef __linux__
    /* This is a macro that invokes test only on Linux. It's
     * meant to be called in those cases where qemuxml2argvmock
     * cooperation is expected (e.g. we need a fixed time,
     * predictable NUMA topology and so on). On non-Linux
     * platforms the macro just consume its argument. */
617
#  define DO_TEST_LINUX_FULL(name, ...)                                  \
618
    DO_TEST_FULL(name, __VA_ARGS__)
619
# else  /* __linux__ */
620 621 622
#  define DO_TEST_LINUX_FULL(name, ...)                                  \
    do {                                                                 \
        const char *tmp ATTRIBUTE_UNUSED = name;                         \
623 624 625
    } while (0)
# endif /* __linux__ */

626
# define NONE QEMU_CAPS_LAST
627

628 629 630
    /* 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 */
631 632 633 634 635 636 637
    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");
638 639
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
640

641
    DO_TEST("minimal", NONE);
642
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
643
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
644
    DO_TEST("machine-aliases1", NONE);
645
    DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
646 647
    DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
648
    driver.config->dumpGuestCore = true;
649 650
    DO_TEST("machine-core-off", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
651 652 653
    driver.config->dumpGuestCore = false;
    DO_TEST("machine-core-cfg-off", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
654
    DO_TEST_FAILURE("machine-core-on", NONE);
655
    DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT);
M
Michal Privoznik 已提交
656 657 658 659 660 661 662
    DO_TEST("machine-smm-opt",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
L
Li Zhang 已提交
663 664
    DO_TEST("machine-usb-opt", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_USB_OPT);
665 666
    DO_TEST("machine-vmport-opt", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_VMPORT_OPT);
667
    DO_TEST("kvm", QEMU_CAPS_MACHINE_OPT);
668 669
    DO_TEST("default-kvm-host-arch", QEMU_CAPS_MACHINE_OPT);
    DO_TEST("default-qemu-host-arch", QEMU_CAPS_MACHINE_OPT);
670 671 672
    DO_TEST("boot-cdrom", NONE);
    DO_TEST("boot-network", NONE);
    DO_TEST("boot-floppy", NONE);
673
    DO_TEST("boot-floppy-q35",
674
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
675
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
676
            QEMU_CAPS_ICH9_AHCI);
677
    DO_TEST("bootindex-floppy-q35",
678
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
679
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
680
            QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_BOOT_MENU,
681
            QEMU_CAPS_BOOTINDEX);
682 683
    DO_TEST("boot-multi", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-enable",
684
            QEMU_CAPS_BOOT_MENU);
685
    DO_TEST("boot-menu-enable-bootindex",
686
            QEMU_CAPS_BOOT_MENU,
687
            QEMU_CAPS_BOOTINDEX);
688
    DO_TEST("boot-menu-enable-with-timeout",
689
            QEMU_CAPS_BOOT_MENU,
690
            QEMU_CAPS_SPLASH_TIMEOUT);
691
    DO_TEST_FAILURE("boot-menu-enable-with-timeout", QEMU_CAPS_BOOT_MENU);
692
    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE);
693 694
    DO_TEST("boot-menu-disable", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-disable-drive",
695
            QEMU_CAPS_BOOT_MENU);
696
    DO_TEST("boot-menu-disable-drive-bootindex",
697
            QEMU_CAPS_BOOT_MENU,
698
            QEMU_CAPS_BOOTINDEX);
699
    DO_TEST_PARSE_ERROR("boot-dev+order",
700
            QEMU_CAPS_BOOTINDEX,
701
            QEMU_CAPS_VIRTIO_BLK_SCSI);
702
    DO_TEST("boot-order",
703
            QEMU_CAPS_BOOTINDEX,
704
            QEMU_CAPS_VIRTIO_BLK_SCSI);
705
    DO_TEST("boot-complex",
706
            QEMU_CAPS_DRIVE_BOOT,
707
            QEMU_CAPS_VIRTIO_BLK_SCSI);
708
    DO_TEST("boot-complex-bootindex",
709
            QEMU_CAPS_DRIVE_BOOT,
710
            QEMU_CAPS_BOOTINDEX,
711
            QEMU_CAPS_VIRTIO_BLK_SCSI);
712
    DO_TEST("boot-strict",
713
            QEMU_CAPS_DRIVE_BOOT,
714
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT,
715
            QEMU_CAPS_VIRTIO_BLK_SCSI);
716 717 718 719 720

    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);

721
    DO_TEST("bios", QEMU_CAPS_SGA);
J
Ján Tomko 已提交
722
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
723 724 725 726 727 728 729
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
730
    DO_TEST("clock-utc", QEMU_CAPS_NODEFCONFIG);
731
    DO_TEST("clock-localtime", NONE);
732
    DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
733 734
    DO_TEST("clock-variable", QEMU_CAPS_RTC);
    DO_TEST("clock-france", QEMU_CAPS_RTC);
735 736
    DO_TEST("clock-hpet-off", QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET,
            QEMU_CAPS_NO_KVM_PIT);
737
    DO_TEST("clock-catchup", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT);
738
    DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
A
Andrea Bolognani 已提交
739
    DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM);
740
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
741
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
742

743 744
    DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM);
J
Ján Tomko 已提交
745
    DO_TEST("controller-order",
746
            QEMU_CAPS_KVM, QEMU_CAPS_ENABLE_KVM,
747 748 749
            QEMU_CAPS_BOOT_MENU, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DRIVE_AIO,
            QEMU_CAPS_CCID_PASSTHRU, QEMU_CAPS_CHARDEV,
750
            QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_SPICE,
751 752
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
753 754
    DO_TEST("eoi-disabled", NONE);
    DO_TEST("eoi-enabled", NONE);
755 756
    DO_TEST("pv-spinlock-disabled", NONE);
    DO_TEST("pv-spinlock-enabled", NONE);
M
Martin Kletzander 已提交
757
    DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
758

759
    DO_TEST("hyperv", NONE);
760
    DO_TEST("hyperv-off", NONE);
761
    DO_TEST("hyperv-panic", NONE);
762

763 764 765
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

766 767 768
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

769
    DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
770
    DO_TEST("hugepages-numa", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT,
771
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
772
            QEMU_CAPS_VIRTIO_SCSI,
773 774
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
775
            QEMU_CAPS_DEVICE_QXL,
776
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
777
            QEMU_CAPS_DEVICE_PC_DIMM,
778
            QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE);
779 780 781
    DO_TEST_LINUX("hugepages-pages", QEMU_CAPS_MEM_PATH,
                  QEMU_CAPS_OBJECT_MEMORY_RAM,
                  QEMU_CAPS_OBJECT_MEMORY_FILE);
782 783 784 785
    DO_TEST("hugepages-pages2", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
    DO_TEST("hugepages-pages3", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
786 787 788
    DO_TEST_LINUX("hugepages-shared", QEMU_CAPS_MEM_PATH,
                  QEMU_CAPS_OBJECT_MEMORY_RAM,
                  QEMU_CAPS_OBJECT_MEMORY_FILE);
789
    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
790 791
    DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_MEM_PATH,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
792
    DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
793
    DO_TEST("hugepages-pages6", NONE);
794
    DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
795
    DO_TEST("disk-cdrom", NONE);
796
    DO_TEST("disk-iscsi", NONE);
797 798 799 800 801
    DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-ftps", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-tftp", QEMU_CAPS_KVM);
802
    DO_TEST("disk-cdrom-empty", NONE);
803
    DO_TEST("disk-cdrom-tray",
804
            QEMU_CAPS_VIRTIO_TX_ALG);
805 806
    DO_TEST("disk-cdrom-tray-no-device-cap", NONE);
    DO_TEST("disk-floppy", NONE);
807
    DO_TEST_FAILURE("disk-floppy-pseries", NONE);
808
    DO_TEST("disk-floppy-tray-no-device-cap", NONE);
809
    DO_TEST("disk-floppy-tray", NONE);
810
    DO_TEST("disk-virtio-s390",
811
            QEMU_CAPS_VIRTIO_S390);
812
    DO_TEST("disk-many", NONE);
813 814
    DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-virtio-ccw",
815
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
816
    DO_TEST("disk-virtio-ccw-many",
817
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
818
    DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
819
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
820
    DO_TEST("disk-order",
821
            QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
822
    DO_TEST("disk-drive-boot-disk",
823
            QEMU_CAPS_DRIVE_BOOT);
824
    DO_TEST("disk-drive-boot-cdrom",
825
            QEMU_CAPS_DRIVE_BOOT);
826
    DO_TEST("floppy-drive-fat",
827
            QEMU_CAPS_DRIVE_BOOT);
828
    DO_TEST("disk-drive-readonly-disk",
829
            QEMU_CAPS_NODEFCONFIG);
830
    DO_TEST("disk-drive-readonly-no-device",
J
Ján Tomko 已提交
831
            QEMU_CAPS_NODEFCONFIG);
832
    DO_TEST("disk-drive-fmt-qcow",
833
            QEMU_CAPS_DRIVE_BOOT);
834
    DO_TEST("disk-drive-shared",
835
            QEMU_CAPS_DRIVE_SERIAL);
836
    DO_TEST("disk-drive-error-policy-stop",
837
            QEMU_CAPS_MONITOR_JSON);
838
    DO_TEST("disk-drive-error-policy-enospace",
839
            QEMU_CAPS_MONITOR_JSON);
840
    DO_TEST("disk-drive-error-policy-wreport-rignore",
841 842 843 844
            QEMU_CAPS_MONITOR_JSON);
    DO_TEST("disk-drive-cache-v2-wt", NONE);
    DO_TEST("disk-drive-cache-v2-wb", NONE);
    DO_TEST("disk-drive-cache-v2-none", NONE);
845
    DO_TEST("disk-drive-cache-directsync",
846
            QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC);
847
    DO_TEST("disk-drive-cache-unsafe",
848
            QEMU_CAPS_DRIVE_CACHE_UNSAFE);
849
    DO_TEST("disk-drive-copy-on-read",
850 851 852 853 854 855 856 857
            QEMU_CAPS_DRIVE_COPY_ON_READ);
    DO_TEST("disk-drive-network-nbd", NONE);
    DO_TEST("disk-drive-network-nbd-export", NONE);
    DO_TEST("disk-drive-network-nbd-ipv6", NONE);
    DO_TEST("disk-drive-network-nbd-ipv6-export", NONE);
    DO_TEST("disk-drive-network-nbd-unix", NONE);
    DO_TEST("disk-drive-network-iscsi", NONE);
    DO_TEST("disk-drive-network-iscsi-auth", NONE);
858 859
    DO_TEST("disk-drive-network-iscsi-lun",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
860
            QEMU_CAPS_SCSI_BLOCK);
861 862 863 864
    DO_TEST("disk-drive-network-gluster", NONE);
    DO_TEST("disk-drive-network-rbd", NONE);
    DO_TEST("disk-drive-network-sheepdog", NONE);
    DO_TEST("disk-drive-network-rbd-auth", NONE);
865
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
866 867
    DO_TEST("disk-drive-network-rbd-auth-AES",
            QEMU_CAPS_OBJECT_SECRET);
868
# endif
869 870
    DO_TEST("disk-drive-network-rbd-ipv6", NONE);
    DO_TEST_FAILURE("disk-drive-network-rbd-no-colon", NONE);
871
    DO_TEST("disk-drive-no-boot",
872
            QEMU_CAPS_BOOTINDEX);
873
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
874 875
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
876
    DO_TEST("disk-usb-device",
877
            QEMU_CAPS_DEVICE_USB_STORAGE,
878
            QEMU_CAPS_NODEFCONFIG);
879
    DO_TEST("disk-usb-device-removable",
880
            QEMU_CAPS_DEVICE_USB_STORAGE,
881
            QEMU_CAPS_USB_STORAGE_REMOVABLE, QEMU_CAPS_NODEFCONFIG);
882 883
    DO_TEST_FAILURE("disk-usb-pci",
                    QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
884
    DO_TEST("disk-scsi-device",
885
            QEMU_CAPS_NODEFCONFIG,
886
            QEMU_CAPS_SCSI_LSI);
887
    DO_TEST("disk-scsi-device-auto",
888
            QEMU_CAPS_NODEFCONFIG,
889
            QEMU_CAPS_SCSI_LSI);
890
    DO_TEST("disk-scsi-disk-split",
891
            QEMU_CAPS_NODEFCONFIG,
892
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
893
    DO_TEST("disk-scsi-disk-wwn",
894
            QEMU_CAPS_NODEFCONFIG,
895
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
896 897
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST("disk-scsi-disk-vpd",
898
            QEMU_CAPS_NODEFCONFIG,
899
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
900 901
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
902
            QEMU_CAPS_NODEFCONFIG,
903
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
904
            QEMU_CAPS_SCSI_DISK_WWN);
905
    DO_TEST("disk-scsi-vscsi",
906
            QEMU_CAPS_NODEFCONFIG);
907
    DO_TEST("disk-scsi-virtio-scsi",
908
            QEMU_CAPS_NODEFCONFIG,
909
            QEMU_CAPS_VIRTIO_SCSI);
910
    DO_TEST("disk-virtio-scsi-num_queues",
911
            QEMU_CAPS_NODEFCONFIG,
912
            QEMU_CAPS_VIRTIO_SCSI);
913
    DO_TEST("disk-virtio-scsi-cmd_per_lun",
914
            QEMU_CAPS_NODEFCONFIG,
915 916
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("disk-virtio-scsi-max_sectors",
917
            QEMU_CAPS_NODEFCONFIG,
918
            QEMU_CAPS_VIRTIO_SCSI);
919
    DO_TEST("disk-virtio-scsi-ioeventfd",
920
            QEMU_CAPS_NODEFCONFIG,
921
            QEMU_CAPS_VIRTIO_IOEVENTFD, QEMU_CAPS_VIRTIO_SCSI);
922
    DO_TEST("disk-scsi-megasas",
923
            QEMU_CAPS_NODEFCONFIG,
924
            QEMU_CAPS_SCSI_MEGASAS);
925 926 927 928
    DO_TEST("disk-scsi-mptsas1068",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SCSI_MPTSAS1068,
            QEMU_CAPS_SCSI_DISK_WWN);
929
    DO_TEST("disk-sata-device",
J
Jim Fehlig 已提交
930
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI);
931
    DO_TEST("disk-aio",
932
            QEMU_CAPS_DRIVE_AIO);
933
    DO_TEST("disk-source-pool",
934
            QEMU_CAPS_NODEFCONFIG);
935
    DO_TEST("disk-source-pool-mode",
936
            QEMU_CAPS_NODEFCONFIG);
937
    DO_TEST("disk-ioeventfd",
938
            QEMU_CAPS_VIRTIO_IOEVENTFD,
939
            QEMU_CAPS_VIRTIO_TX_ALG,
940
            QEMU_CAPS_VIRTIO_BLK_SCSI);
941
    DO_TEST("disk-copy_on_read",
942
            QEMU_CAPS_DRIVE_COPY_ON_READ,
943
            QEMU_CAPS_VIRTIO_TX_ALG,
944
            QEMU_CAPS_VIRTIO_BLK_SCSI);
O
Osier Yang 已提交
945
    DO_TEST("disk-drive-discard",
946
            QEMU_CAPS_DRIVE_DISCARD);
947 948 949
    DO_TEST("disk-drive-detect-zeroes",
            QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DRIVE_DETECT_ZEROES);
950
    DO_TEST("disk-snapshot", NONE);
951 952 953
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
                        QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
954
    DO_TEST("event_idx",
955 956
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
957
            QEMU_CAPS_VIRTIO_BLK_SCSI);
958
    DO_TEST("virtio-lun",
959
            QEMU_CAPS_VIRTIO_BLK_SCSI);
960
    DO_TEST("disk-scsi-lun-passthrough",
961
            QEMU_CAPS_SCSI_BLOCK,
962
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
963 964 965
    DO_TEST("disk-serial",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DRIVE_SERIAL);
966

967 968 969 970 971 972 973 974 975 976
    DO_TEST("graphics-vnc", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-remove-generated-socket", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
977
    driver.config->vncAutoUnixSocket = true;
978 979
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
980
    driver.config->vncAutoUnixSocket = false;
981 982 983 984
    DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("graphics-vnc-none", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
985

986 987
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
988
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
989
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
990 991
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
992
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
993
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
994 995
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
996

997 998 999
    DO_TEST("graphics-sdl", QEMU_CAPS_SDL, QEMU_CAPS_DEVICE_VGA);
    DO_TEST("graphics-sdl-fullscreen", QEMU_CAPS_SDL,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1000
    DO_TEST("nographics", NONE);
P
Paolo Bonzini 已提交
1001 1002
    DO_TEST("nographics-display",
            QEMU_CAPS_DISPLAY);
1003
    DO_TEST("nographics-vga",
1004
            QEMU_CAPS_VGA_NONE);
1005
    DO_TEST("graphics-spice",
1006
            QEMU_CAPS_SPICE,
1007 1008
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1009
    DO_TEST("graphics-spice-no-args",
1010
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1011 1012 1013
    driver.config->spiceSASL = 1;
    ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
    DO_TEST("graphics-spice-sasl",
1014
            QEMU_CAPS_SPICE,
1015 1016 1017
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
1018
    DO_TEST("graphics-spice-agentmouse",
1019
            QEMU_CAPS_DEVICE_QXL,
1020
            QEMU_CAPS_SPICE,
1021
            QEMU_CAPS_CHARDEV_SPICEVMC,
1022 1023
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1024
    DO_TEST("graphics-spice-compression",
1025
            QEMU_CAPS_SPICE,
1026
            QEMU_CAPS_DEVICE_QXL);
1027
    DO_TEST("graphics-spice-timeout",
1028
            QEMU_CAPS_KVM,
1029
            QEMU_CAPS_SPICE,
1030 1031
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VGA);
1032
    DO_TEST("graphics-spice-qxl-vga",
1033
            QEMU_CAPS_SPICE,
1034
            QEMU_CAPS_DEVICE_QXL);
1035
    DO_TEST("graphics-spice-usb-redir",
1036
            QEMU_CAPS_SPICE,
1037
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1038 1039
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
1040
            QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1041
    DO_TEST("graphics-spice-agent-file-xfer",
1042
            QEMU_CAPS_SPICE,
1043 1044
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1045 1046
    DO_TEST("graphics-spice-socket",
            QEMU_CAPS_SPICE,
1047 1048
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1049 1050
    DO_TEST("graphics-spice-auto-socket",
            QEMU_CAPS_SPICE,
1051 1052
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1053 1054 1055
    driver.config->spiceAutoUnixSocket = true;
    DO_TEST("graphics-spice-auto-socket-cfg",
            QEMU_CAPS_SPICE,
1056 1057
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1058
    driver.config->spiceAutoUnixSocket = false;
1059

1060 1061 1062
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
    DO_TEST("misc-acpi", NONE);
1063 1064 1065
    DO_TEST("misc-disable-s3", QEMU_CAPS_PIIX_DISABLE_S3);
    DO_TEST("misc-disable-suspends", QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
    DO_TEST("misc-enable-s4", QEMU_CAPS_PIIX_DISABLE_S4);
1066
    DO_TEST_FAILURE("misc-enable-s4", NONE);
1067
    DO_TEST("misc-no-reboot", NONE);
1068
    DO_TEST("misc-uuid", NONE);
1069
    DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
1070
    DO_TEST("net-vhostuser", QEMU_CAPS_NETDEV);
1071
    DO_TEST("net-vhostuser-multiq",
1072 1073
            QEMU_CAPS_NETDEV, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
    DO_TEST_FAILURE("net-vhostuser-multiq", QEMU_CAPS_NETDEV);
1074 1075 1076
    DO_TEST_FAILURE("net-vhostuser-fail",
                    QEMU_CAPS_NETDEV,
                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
1077 1078 1079
    DO_TEST("net-user", NONE);
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
1080
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_TX_ALG);
1081
    DO_TEST("net-virtio-disable-offloads",
1082
            QEMU_CAPS_NODEFCONFIG);
1083
    DO_TEST("net-virtio-netdev",
1084
            QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
1085
    DO_TEST("net-virtio-s390",
1086
            QEMU_CAPS_VIRTIO_S390);
1087
    DO_TEST("net-virtio-ccw",
1088
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1089 1090
    DO_TEST("net-virtio-rxqueuesize",
            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE);
1091
    DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
1092 1093
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
1094
    DO_TEST("net-eth-names", NONE);
1095
    DO_TEST("net-eth-hostip", NONE);
1096 1097 1098
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
    DO_TEST("net-mcast", NONE);
1099
    DO_TEST("net-udp", NONE);
1100
    DO_TEST("net-hostdev",
J
Ján Tomko 已提交
1101
            QEMU_CAPS_NODEFCONFIG);
1102
    DO_TEST("net-hostdev-multidomain",
J
Ján Tomko 已提交
1103
            QEMU_CAPS_NODEFCONFIG,
1104 1105 1106
            QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
    DO_TEST_FAILURE("net-hostdev-multidomain",
                    QEMU_CAPS_NODEFCONFIG);
1107
    DO_TEST("net-hostdev-vfio",
J
Ján Tomko 已提交
1108
            QEMU_CAPS_NODEFCONFIG,
1109
            QEMU_CAPS_DEVICE_VFIO_PCI);
1110
    DO_TEST("net-hostdev-vfio-multidomain",
J
Ján Tomko 已提交
1111
            QEMU_CAPS_NODEFCONFIG,
1112 1113 1114
            QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
    DO_TEST_FAILURE("net-hostdev-vfio-multidomain",
                    QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
1115 1116 1117 1118
    DO_TEST_FAILURE("net-hostdev-fail",
                    QEMU_CAPS_NODEFCONFIG,
                    QEMU_CAPS_DEVICE_VFIO_PCI);

1119

1120 1121 1122 1123
    DO_TEST("serial-vc", NONE);
    DO_TEST("serial-pty", NONE);
    DO_TEST("serial-dev", NONE);
    DO_TEST("serial-file", NONE);
1124 1125
    DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV, QEMU_CAPS_CHARDEV_FILE_APPEND,
            QEMU_CAPS_CHARDEV_LOGFILE);
1126 1127 1128 1129 1130
    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);
1131
    DO_TEST("serial-spiceport",
1132
            QEMU_CAPS_CHARDEV,
1133
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1134
            QEMU_CAPS_DEVICE_QXL,
1135
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEPORT);
1136
    DO_TEST("serial-spiceport-nospice", NONE);
1137

1138 1139 1140 1141 1142
    DO_TEST("parallel-tcp", NONE);
    DO_TEST("console-compat", NONE);
    DO_TEST("console-compat-auto", NONE);

    DO_TEST("serial-vc-chardev",
1143
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1144
    DO_TEST("serial-pty-chardev",
1145
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1146
    DO_TEST("serial-dev-chardev",
1147
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1148
    DO_TEST("serial-dev-chardev-iobase",
1149
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1150
    DO_TEST("serial-file-chardev",
1151
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1152
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1153
    DO_TEST("serial-unix-chardev",
1154
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1155
    DO_TEST("serial-tcp-chardev",
1156
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1157
    DO_TEST("serial-udp-chardev",
1158
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1159
    DO_TEST("serial-tcp-telnet-chardev",
1160
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1161 1162 1163 1164 1165 1166
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1167
    DO_TEST("serial-many-chardev",
1168
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1169
    DO_TEST("parallel-tcp-chardev",
1170
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1171
    DO_TEST("parallel-parport-chardev",
1172
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1173
    DO_TEST("console-compat-chardev",
1174
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
M
Michal Privoznik 已提交
1175
    DO_TEST("pci-serial-dev-chardev",
1176
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
M
Michal Privoznik 已提交
1177
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1178

1179
    DO_TEST("channel-guestfwd",
1180
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1181
    DO_TEST("channel-virtio",
1182
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1183
    DO_TEST("channel-virtio-state",
1184
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1185
    DO_TEST("channel-virtio-auto",
1186
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1187
    DO_TEST("channel-virtio-autoassign",
1188
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1189
    DO_TEST("channel-virtio-autoadd",
1190
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1191
    DO_TEST("console-virtio",
1192
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1193
    DO_TEST("console-virtio-many",
1194
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1195
    DO_TEST("console-virtio-s390",
1196
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1197
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
1198
    DO_TEST("console-virtio-ccw",
1199
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1200
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_CCW,
1201
            QEMU_CAPS_VIRTIO_S390);
1202
    DO_TEST("console-sclp",
1203
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1204
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_SCLP_S390);
1205
    DO_TEST("channel-spicevmc",
1206
            QEMU_CAPS_NODEFCONFIG,
1207 1208
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1209
    DO_TEST("channel-spicevmc-old",
1210
            QEMU_CAPS_NODEFCONFIG,
1211 1212
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_SPICEVMC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1213
    DO_TEST("channel-virtio-default",
1214
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1215
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
1216
    DO_TEST("channel-virtio-unix",
1217
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1218

1219
    DO_TEST("smartcard-host",
1220
            QEMU_CAPS_CHARDEV,
1221
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
1222
    DO_TEST("smartcard-host-certificates",
1223
            QEMU_CAPS_CHARDEV,
1224
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);
1225
    DO_TEST("smartcard-passthrough-tcp",
1226
            QEMU_CAPS_CHARDEV,
1227
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_PASSTHRU);
1228
    DO_TEST("smartcard-passthrough-spicevmc",
1229
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1230
            QEMU_CAPS_CCID_PASSTHRU, QEMU_CAPS_CHARDEV_SPICEVMC);
1231
    DO_TEST("smartcard-controller",
1232
            QEMU_CAPS_CHARDEV,
1233 1234
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CCID_EMULATED);

1235
    DO_TEST("usb-controller",
1236
            QEMU_CAPS_CHARDEV,
1237
            QEMU_CAPS_NODEFCONFIG);
1238
    DO_TEST("usb-piix3-controller",
1239
            QEMU_CAPS_CHARDEV, QEMU_CAPS_PIIX3_USB_UHCI,
1240
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_NODEFCONFIG);
1241
    DO_TEST("usb-ich9-ehci-addr",
1242
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1243
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1244
    DO_TEST("input-usbmouse-addr",
1245
            QEMU_CAPS_NODEFCONFIG);
1246
    DO_TEST("usb-ich9-companion",
1247
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1248
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1249
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1250
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1251
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
1252 1253 1254 1255
    DO_TEST("usb-ich9-autoassign",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_HUB);
1256
    DO_TEST("usb-hub",
1257
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
M
Marc-André Lureau 已提交
1258
            QEMU_CAPS_NODEFCONFIG);
1259 1260 1261
    DO_TEST("usb-hub-autoadd",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1262 1263 1264
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
1265 1266 1267
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1268 1269 1270
    DO_TEST("usb-port-missing",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
1271
    DO_TEST("usb-ports",
1272
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
1273
            QEMU_CAPS_NODEFCONFIG);
1274 1275 1276
    DO_TEST("usb-port-autoassign",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
            QEMU_CAPS_NODEFCONFIG);
1277
    DO_TEST("usb-redir",
1278
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1279
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_USB_HUB,
1280 1281
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
1282
    DO_TEST("usb-redir-boot",
1283
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1284 1285 1286 1287
            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);
1288
    DO_TEST("usb-redir-filter",
1289
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1290 1291 1292 1293
            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);
1294
    DO_TEST("usb-redir-filter-version",
1295
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1296 1297 1298
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_USB_REDIR_FILTER);
1299
    DO_TEST("usb1-usb2",
1300
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1301 1302
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB, QEMU_CAPS_ICH9_USB_EHCI1);
1303
    DO_TEST("usb-none",
1304
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1305
    DO_TEST_PARSE_ERROR("usb-none-other",
1306
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1307
    DO_TEST_PARSE_ERROR("usb-none-hub",
1308
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1309 1310
            QEMU_CAPS_USB_HUB);
    DO_TEST_PARSE_ERROR("usb-none-usbtablet",
1311
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1312
    DO_TEST("usb-controller-default-q35",
1313
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1314 1315 1316
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1317
                    QEMU_CAPS_DEVICE_PCI_BRIDGE,
1318 1319 1320
                    QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1321
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1322 1323 1324
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1325
                    QEMU_CAPS_DEVICE_PCI_BRIDGE,
1326 1327
                    QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
                    QEMU_CAPS_PIIX3_USB_UHCI);
1328 1329 1330
    DO_TEST("usb-controller-xhci",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS);
1331 1332 1333 1334
    DO_TEST("usb-xhci-autoassign",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS,
            QEMU_CAPS_USB_HUB);
1335

1336
    DO_TEST("smbios", QEMU_CAPS_SMBIOS_TYPE);
1337
    DO_TEST_PARSE_ERROR("smbios-date", QEMU_CAPS_SMBIOS_TYPE);
1338
    DO_TEST_PARSE_ERROR("smbios-uuid-match", QEMU_CAPS_SMBIOS_TYPE);
1339

1340
    DO_TEST("watchdog", NONE);
1341
    DO_TEST("watchdog-device", QEMU_CAPS_NODEFCONFIG);
1342
    DO_TEST("watchdog-dump", NONE);
1343
    DO_TEST("watchdog-injectnmi", NONE);
1344
    DO_TEST("watchdog-diag288",
1345
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1346
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
1347 1348
    DO_TEST("balloon-device", QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-deflate", QEMU_CAPS_NODEFCONFIG,
1349
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1350
    DO_TEST("balloon-ccw-deflate", QEMU_CAPS_NODEFCONFIG,
1351
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1352
    DO_TEST("balloon-mmio-deflate", QEMU_CAPS_NODEFCONFIG,
1353 1354
            QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1355
    DO_TEST("balloon-device-deflate-off", QEMU_CAPS_NODEFCONFIG,
1356
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1357
    DO_TEST("balloon-device-auto",
1358 1359
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-period", QEMU_CAPS_NODEFCONFIG);
1360 1361
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1362
            QEMU_CAPS_NODEFCONFIG,
1363
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1364 1365
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1366
    DO_TEST("fs9p",
1367
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
1368
            QEMU_CAPS_FSDEV_WRITEOUT);
1369
    DO_TEST("fs9p-ccw",
1370
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
1371
            QEMU_CAPS_FSDEV_WRITEOUT,
1372
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1373

1374 1375
    DO_TEST("hostdev-usb-address", NONE);
    DO_TEST("hostdev-usb-address-device",
1376 1377
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("hostdev-usb-address-device-boot",
1378 1379
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_USB_HOST_BOOTINDEX);
J
Ján Tomko 已提交
1380
    DO_TEST("hostdev-pci-address", NONE);
1381
    DO_TEST("hostdev-pci-address-device",
J
Ján Tomko 已提交
1382
            QEMU_CAPS_NODEFCONFIG);
1383
    DO_TEST("hostdev-vfio",
J
Ján Tomko 已提交
1384
            QEMU_CAPS_NODEFCONFIG,
1385
            QEMU_CAPS_DEVICE_VFIO_PCI);
1386
    DO_TEST("hostdev-vfio-multidomain",
J
Ján Tomko 已提交
1387
            QEMU_CAPS_NODEFCONFIG,
1388 1389 1390
            QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
    DO_TEST_FAILURE("hostdev-vfio-multidomain",
                    QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
1391
    DO_TEST("pci-rom",
J
Ján Tomko 已提交
1392
            QEMU_CAPS_NODEFCONFIG);
1393

1394 1395 1396 1397
    DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0, 0, GIC_NONE, NONE);
1398

1399
    DO_TEST_LINUX_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE,
1400
                       QEMU_CAPS_NUMA,
1401 1402
                       QEMU_CAPS_OBJECT_MEMORY_RAM);

1403
    DO_TEST("qemu-ns", NONE);
1404
    DO_TEST("qemu-ns-no-env", NONE);
1405

1406
    DO_TEST("smp", NONE);
1407

J
John Ferlan 已提交
1408
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1409 1410
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1411
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1412 1413
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1414
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1415 1416 1417 1418 1419 1420
    DO_TEST("iothreads-virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_OBJECT_IOTHREAD,
            QEMU_CAPS_VIRTIO_SCSI_IOTHREAD);
    DO_TEST("iothreads-virtio-scsi-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
J
John Ferlan 已提交
1421

1422 1423
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1424
    DO_TEST("cpu-topology3", NONE);
1425 1426 1427 1428 1429 1430 1431 1432
    DO_TEST("cpu-minimum1", QEMU_CAPS_KVM);
    DO_TEST("cpu-minimum2", QEMU_CAPS_KVM);
    DO_TEST("cpu-exact1", QEMU_CAPS_KVM);
    DO_TEST("cpu-exact2", QEMU_CAPS_KVM);
    DO_TEST("cpu-exact2-nofallback", QEMU_CAPS_KVM);
    DO_TEST("cpu-fallback", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-nofallback", QEMU_CAPS_KVM);
    DO_TEST("cpu-strict1", QEMU_CAPS_KVM);
1433
    DO_TEST("cpu-numa1", NONE);
1434 1435
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1436
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1437 1438
    DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1439 1440
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
    DO_TEST_FAILURE("cpu-numa-memshared", NONE);
1441
    DO_TEST("cpu-host-model", NONE);
1442
    DO_TEST("cpu-host-model-vendor", NONE);
1443
    skipLegacyCPUs = true;
1444
    DO_TEST("cpu-host-model-fallback", NONE);
1445
    DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
1446
    skipLegacyCPUs = false;
A
Andrea Bolognani 已提交
1447
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
1448
    DO_TEST_FAILURE("cpu-host-passthrough", NONE);
A
Andrea Bolognani 已提交
1449
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1450

1451
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1452 1453 1454 1455
    DO_TEST("cpu-Haswell", QEMU_CAPS_KVM);
    DO_TEST("cpu-Haswell2", QEMU_CAPS_KVM);
    DO_TEST("cpu-Haswell3", QEMU_CAPS_KVM);
    DO_TEST("cpu-Haswell-noTSX", QEMU_CAPS_KVM);
1456
    DO_TEST("cpu-host-model-cmt", NONE);
1457
    qemuTestSetHostCPU(driver.caps, NULL);
1458

1459
    DO_TEST("encrypted-disk", NONE);
J
John Ferlan 已提交
1460
    DO_TEST("encrypted-disk-usage", NONE);
1461
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
1462
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1463 1464 1465
# else
    DO_TEST_FAILURE("luks-disks", QEMU_CAPS_OBJECT_SECRET);
# endif
1466

1467 1468 1469 1470 1471 1472 1473 1474
    DO_TEST("memtune", NONE);
    DO_TEST("memtune-unlimited", NONE);
    DO_TEST("blkiotune", NONE);
    DO_TEST("blkiotune-device", NONE);
    DO_TEST("cputune", NONE);
    DO_TEST("cputune-zero-shares", NONE);
    DO_TEST_PARSE_ERROR("cputune-iothreadsched-toomuch", NONE);
    DO_TEST_PARSE_ERROR("cputune-vcpusched-overlap", NONE);
1475
    DO_TEST("cputune-numatune",
1476
            QEMU_CAPS_KVM,
1477
            QEMU_CAPS_OBJECT_IOTHREAD,
1478 1479
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1480

1481
    DO_TEST("numatune-memory", NONE);
1482
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
1483 1484
    DO_TEST_LINUX("numatune-memnode", QEMU_CAPS_NUMA,
                  QEMU_CAPS_OBJECT_MEMORY_RAM);
1485 1486
    DO_TEST_FAILURE("numatune-memnode", NONE);

1487 1488
    DO_TEST_LINUX("numatune-memnode-no-memory", QEMU_CAPS_NUMA,
                  QEMU_CAPS_OBJECT_MEMORY_RAM);
1489 1490
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1491
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1492 1493
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1494 1495
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1496 1497
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1498 1499
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1500
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1501 1502 1503
    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);
1504
    DO_TEST("blkdeviotune",
1505
            QEMU_CAPS_DRIVE_IOTUNE);
1506
    DO_TEST("blkdeviotune-max",
1507
            QEMU_CAPS_DRIVE_IOTUNE,
1508
            QEMU_CAPS_DRIVE_IOTUNE_MAX);
1509

1510
    DO_TEST("multifunction-pci-device",
1511
            QEMU_CAPS_NODEFCONFIG,
1512
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_SCSI_LSI);
1513

1514
    DO_TEST("monitor-json",
1515
            QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG);
1516
    DO_TEST("no-shutdown",
1517 1518
            QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_NO_SHUTDOWN);
1519

1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531
    DO_TEST("seclabel-dynamic", NONE);
    DO_TEST("seclabel-dynamic-baselabel", NONE);
    DO_TEST("seclabel-dynamic-override", NONE);
    DO_TEST("seclabel-dynamic-labelskip", NONE);
    DO_TEST("seclabel-dynamic-relabel", NONE);
    DO_TEST("seclabel-static", NONE);
    DO_TEST("seclabel-static-relabel", NONE);
    DO_TEST("seclabel-static-labelskip", NONE);
    DO_TEST("seclabel-none", NONE);
    DO_TEST("seclabel-dac-none", NONE);
    DO_TEST_PARSE_ERROR("seclabel-multiple", NONE);
    DO_TEST_PARSE_ERROR("seclabel-device-duplicates", NONE);
1532

1533
    DO_TEST("pseries-basic",
1534
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1535
    DO_TEST("pseries-vio",
1536
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1537
    DO_TEST("pseries-usb-default",
1538
            QEMU_CAPS_CHARDEV,
1539 1540
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
1541
    DO_TEST("pseries-usb-multi",
1542
            QEMU_CAPS_CHARDEV,
1543 1544
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
1545
    DO_TEST("pseries-vio-user-assigned",
1546
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1547
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash",
1548
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1549
    DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
1550 1551
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_CHARDEV,
1552 1553
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("pseries-cpu-exact", QEMU_CAPS_CHARDEV,
1554
            QEMU_CAPS_NODEFCONFIG);
1555 1556

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1557
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1558
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
A
Andrea Bolognani 已提交
1559
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1560
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1561 1562
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1563
    DO_TEST("pseries-panic-missing",
1564
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1565
    DO_TEST("pseries-panic-no-address",
1566
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1567
    DO_TEST_FAILURE("pseries-panic-address",
1568
                    QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
1569
    DO_TEST("disk-ide-drive-split",
1570
            QEMU_CAPS_NODEFCONFIG,
1571
            QEMU_CAPS_IDE_CD);
1572
    DO_TEST("disk-ide-wwn",
1573
            QEMU_CAPS_IDE_CD,
1574
            QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_IDE_DRIVE_WWN);
1575

1576
    DO_TEST("disk-geometry", NONE);
V
Viktor Mihajlovski 已提交
1577
    DO_TEST("disk-blockio",
1578
            QEMU_CAPS_NODEFCONFIG,
V
Viktor Mihajlovski 已提交
1579
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1580

1581 1582
    DO_TEST("video-device-pciaddr-default",
            QEMU_CAPS_KVM, QEMU_CAPS_VNC,
1583
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1584
            QEMU_CAPS_DEVICE_QXL,
1585
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
1586
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
1587
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
1588
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1589
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
1590
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
1591
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
1592
    DO_TEST("video-qxl-device",
1593
            QEMU_CAPS_DEVICE_QXL,
1594
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1595
    DO_TEST("video-qxl-device-vgamem",
1596
            QEMU_CAPS_DEVICE_QXL,
1597
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1598 1599
            QEMU_CAPS_QXL_VGAMEM);
    DO_TEST("video-qxl-sec-device",
1600
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1601
    DO_TEST("video-qxl-sec-device-vgamem",
1602 1603
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1604
            QEMU_CAPS_QXL_VGAMEM);
1605 1606 1607
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1608
            QEMU_CAPS_QXL_MAX_OUTPUTS);
1609 1610 1611
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1612
            QEMU_CAPS_QXL_MAX_OUTPUTS);
M
Marc-André Lureau 已提交
1613
    DO_TEST("video-virtio-gpu-device",
1614
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
1615
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1616
    DO_TEST("video-virtio-gpu-virgl",
1617
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1618
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1619
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1620 1621
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1622
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1623 1624 1625
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1626 1627 1628
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1629 1630 1631 1632
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1633
    DO_TEST_PARSE_ERROR("video-invalid", NONE);
1634

1635
    DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG,
1636
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1637
    DO_TEST("virtio-rng-random", QEMU_CAPS_DEVICE_VIRTIO_RNG,
1638
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1639
    DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE_VIRTIO_RNG,
1640
            QEMU_CAPS_OBJECT_RNG_EGD);
1641
    DO_TEST("virtio-rng-multiple", QEMU_CAPS_DEVICE_VIRTIO_RNG,
1642
            QEMU_CAPS_OBJECT_RNG_EGD, QEMU_CAPS_OBJECT_RNG_RANDOM);
1643
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
1644
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_EGD);
1645
    DO_TEST("virtio-rng-ccw",
1646
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1647
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_CCW,
1648 1649
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1650

1651
    DO_TEST("s390-allow-bogus-usb-none",
1652
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1653
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
1654
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1655
    DO_TEST("s390-allow-bogus-usb-controller",
1656
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
1657
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
1658 1659
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);

1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
    DO_TEST("s390-panic-no-address",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("s390-panic-address",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST("s390-panic-missing",
            QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);

O
Olivia Yin 已提交
1670
    DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
1671
    DO_TEST("ppce500-serial", QEMU_CAPS_KVM, QEMU_CAPS_CHARDEV);
O
Olivia Yin 已提交
1672

1673
    DO_TEST("tpm-passthrough",
1674
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
1675
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
1676
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
1677

1678

1679 1680 1681 1682
    DO_TEST_PARSE_ERROR("pci-domain-invalid", NONE);
    DO_TEST_PARSE_ERROR("pci-bus-invalid", NONE);
    DO_TEST_PARSE_ERROR("pci-slot-invalid", NONE);
    DO_TEST_PARSE_ERROR("pci-function-invalid", NONE);
1683

1684 1685 1686 1687 1688
    DO_TEST("pci-autoadd-addr", QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autoadd-idx", QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA);
1689
    DO_TEST("pci-many",
1690 1691
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1692
    DO_TEST("pci-bridge-many-disks",
1693
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
1694
    DO_TEST("pcie-root",
1695
            QEMU_CAPS_ICH9_AHCI,
1696
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1697 1698
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
    DO_TEST("q35",
1699
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1700
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
1701
            QEMU_CAPS_ICH9_AHCI,
1702
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
1703
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1704
            QEMU_CAPS_DEVICE_QXL);
1705 1706 1707 1708 1709 1710 1711 1712
    DO_TEST_PARSE_ERROR("q35-dmi-bad-address1",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420);
    DO_TEST_PARSE_ERROR("q35-dmi-bad-address2",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420);
1713
    DO_TEST("q35-pm-disable",
1714
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1715 1716 1717 1718
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
            QEMU_CAPS_ICH9_DISABLE_S3, QEMU_CAPS_ICH9_DISABLE_S4);
    DO_TEST("q35-pm-disable-fallback",
1719
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1720 1721
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
1722
    DO_TEST("q35-usb2",
1723
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1724 1725 1726 1727
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1728
            QEMU_CAPS_DEVICE_QXL);
1729
    DO_TEST("q35-usb2-multi",
1730
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1731 1732 1733 1734
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1735
            QEMU_CAPS_DEVICE_QXL);
1736
    DO_TEST("q35-usb2-reorder",
1737
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1738 1739 1740 1741
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1742
            QEMU_CAPS_DEVICE_QXL);
1743
    DO_TEST("pcie-root-port",
1744
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1745 1746
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
1747
            QEMU_CAPS_ICH9_AHCI,
1748
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1749
            QEMU_CAPS_DEVICE_QXL);
1750 1751 1752 1753 1754 1755 1756 1757 1758
    DO_TEST("autoindex",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_NEC_USB_XHCI);
1759

1760 1761 1762 1763 1764 1765
    DO_TEST_PARSE_ERROR("q35-wrong-root",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1766
            QEMU_CAPS_DEVICE_QXL);
1767 1768
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);

1769
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
1770
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1771 1772
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
1773
            QEMU_CAPS_ICH9_AHCI,
1774
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1775
            QEMU_CAPS_DEVICE_QXL);
1776

1777
    DO_TEST("pcie-switch-upstream-port",
1778
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1779 1780 1781
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
1782
            QEMU_CAPS_ICH9_AHCI,
1783
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1784
            QEMU_CAPS_DEVICE_QXL);
1785
    DO_TEST("pcie-switch-downstream-port",
1786
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1787 1788 1789 1790
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
1791
            QEMU_CAPS_ICH9_AHCI,
1792
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1793
            QEMU_CAPS_DEVICE_QXL);
1794

1795 1796 1797 1798 1799 1800 1801 1802 1803
    DO_TEST("pci-expander-bus",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PXB);
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-node",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PXB);
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-machine",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PXB);
1804 1805 1806
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PXB);
1807

1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821
    DO_TEST("pcie-expander-bus",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
            QEMU_CAPS_DEVICE_PXB_PCIE);
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-machine",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_X3130_UPSTREAM,
                        QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
1822 1823 1824 1825 1826
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
1827

1828
    DO_TEST("hostdev-scsi-lsi",
1829 1830
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1831
    DO_TEST("hostdev-scsi-virtio-scsi",
1832 1833
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1834
    DO_TEST("hostdev-scsi-readonly",
J
Ján Tomko 已提交
1835
            QEMU_CAPS_VIRTIO_SCSI,
O
Osier Yang 已提交
1836
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
1837
    DO_TEST("hostdev-scsi-virtio-scsi",
1838 1839 1840
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
1841
    DO_TEST("hostdev-scsi-lsi-iscsi",
J
John Ferlan 已提交
1842 1843
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1844
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
J
John Ferlan 已提交
1845 1846
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1847
    DO_TEST("hostdev-scsi-virtio-iscsi",
J
John Ferlan 已提交
1848 1849
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1850
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
J
John Ferlan 已提交
1851 1852
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
1853

1854
    DO_TEST("mlock-on", QEMU_CAPS_REALTIME_MLOCK);
1855
    DO_TEST_FAILURE("mlock-on", NONE);
1856
    DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK);
1857 1858
    DO_TEST("mlock-unsupported", NONE);

1859
    DO_TEST_PARSE_ERROR("pci-bridge-negative-index-invalid",
1860
                        QEMU_CAPS_DEVICE_PCI_BRIDGE);
J
Ján Tomko 已提交
1861
    DO_TEST_PARSE_ERROR("pci-bridge-duplicate-index",
1862
                        QEMU_CAPS_DEVICE_PCI_BRIDGE);
J
Ján Tomko 已提交
1863
    DO_TEST_PARSE_ERROR("pci-root-nonzero-index",
1864
                        QEMU_CAPS_DEVICE_PCI_BRIDGE);
J
Ján Tomko 已提交
1865
    DO_TEST_PARSE_ERROR("pci-root-address",
1866
                        QEMU_CAPS_DEVICE_PCI_BRIDGE);
1867

1868
    DO_TEST("hotplug-base",
1869
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
1870

1871 1872
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
1873
    DO_TEST("pcihole64-q35",
1874
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
1875
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
1876
            QEMU_CAPS_ICH9_AHCI,
1877
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1878
            QEMU_CAPS_DEVICE_QXL,
1879 1880
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

1881
    DO_TEST("arm-vexpressa9-nodevs",
1882
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB);
1883
    DO_TEST("arm-vexpressa9-basic",
1884
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB);
1885
    DO_TEST("arm-vexpressa9-virtio",
1886
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1887
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1888
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1889
    DO_TEST("arm-virt-virtio",
1890
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1891
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1892
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1893

1894
    DO_TEST("aarch64-virt-virtio",
1895
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1896
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1897
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1898 1899 1900 1901 1902 1903

    /* Demonstrates the virtio-pci default... namely that there isn't any!
       q35 style PCI controllers will be added if the binary supports it,
       but virtio-mmio is always used unless PCI addresses are manually
       specified. */
    DO_TEST("aarch64-virtio-pci-default",
1904
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1905 1906 1907 1908 1909 1910
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1911
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1912 1913 1914
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
1915 1916 1917
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
1918
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1919
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1920 1921 1922
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI);
1923 1924 1925 1926 1927
    DO_TEST("aarch64-video-virtio-gpu-pci",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_BOOTINDEX);
1928
    DO_TEST("aarch64-aavmf-virtio-mmio",
1929
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
1930
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1931
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
1932
    DO_TEST("aarch64-virt-default-nic",
1933
            QEMU_CAPS_NODEFCONFIG,
1934
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
1935
    qemuTestSetHostArch(driver.caps, VIR_ARCH_AARCH64);
1936
    DO_TEST("aarch64-cpu-passthrough",
1937
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
1938
            QEMU_CAPS_KVM);
1939 1940 1941
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
A
Andrea Bolognani 已提交
1942
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
1943
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1944 1945 1946 1947
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
A
Andrea Bolognani 已提交
1948
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
1949
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1950 1951 1952 1953
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
A
Andrea Bolognani 已提交
1954
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
1955 1956 1957 1958
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-default", GIC_V2,
A
Andrea Bolognani 已提交
1959
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
1960
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1961 1962 1963 1964 1965 1966 1967
    DO_TEST_GIC("aarch64-gic-default", GIC_V3,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-default", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
A
Andrea Bolognani 已提交
1968
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
1969 1970 1971 1972 1973 1974 1975
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
A
Andrea Bolognani 已提交
1976
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
1977
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1978 1979 1980
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1981
    DO_TEST_FAILURE("aarch64-gic-v3",
A
Andrea Bolognani 已提交
1982
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
A
Andrea Bolognani 已提交
1993
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
1994
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
1995
    DO_TEST_FAILURE("aarch64-gic-host",
A
Andrea Bolognani 已提交
1996
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2009
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
A
Andrea Bolognani 已提交
2010
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2011
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2012
    DO_TEST_FAILURE("aarch64-gic-not-virt",
A
Andrea Bolognani 已提交
2013
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2014
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2015
    DO_TEST_FAILURE("aarch64-gic-not-arm",
A
Andrea Bolognani 已提交
2016
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2017
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2018
    DO_TEST("aarch64-kvm-32-on-64",
2019
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2020
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2021
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2022
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2023
            QEMU_CAPS_KVM);
2024
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2025

2026 2027 2028 2029 2030
    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 已提交
2031
    DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
2032
            QEMU_CAPS_NODEFCONFIG);
D
Dmitry Andreev 已提交
2033
    DO_TEST("panic-double", QEMU_CAPS_DEVICE_PANIC,
2034
            QEMU_CAPS_NODEFCONFIG);
H
Hu Tao 已提交
2035

2036
    DO_TEST("panic-no-address", QEMU_CAPS_DEVICE_PANIC,
2037
            QEMU_CAPS_NODEFCONFIG);
2038

2039 2040
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2041
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2042
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2043
    DO_TEST_FAILURE("shmem-invalid-size",
2044
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2045
    DO_TEST_FAILURE("shmem-invalid-address",
2046
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2047
    DO_TEST_FAILURE("shmem-small-size",
2048
                    QEMU_CAPS_DEVICE_IVSHMEM);
2049
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2050
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2051

2052
    DO_TEST_FAILURE("memory-align-fail", NONE);
2053 2054 2055
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
    DO_TEST_FAILURE("memory-hotplug", NONE);
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2056
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2057
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2058
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2059
            QEMU_CAPS_OBJECT_MEMORY_FILE);
2060
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2061
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2062

2063 2064
    DO_TEST("machine-aeskeywrap-on-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2065
            QEMU_CAPS_DEA_KEY_WRAP,
2066
            QEMU_CAPS_VIRTIO_SCSI,
2067 2068
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", QEMU_CAPS_MACHINE_OPT,
2069
                    QEMU_CAPS_VIRTIO_SCSI,
2070 2071 2072 2073 2074
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2075
            QEMU_CAPS_VIRTIO_SCSI,
2076 2077
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", QEMU_CAPS_MACHINE_OPT,
2078
                    QEMU_CAPS_VIRTIO_SCSI,
2079 2080 2081 2082 2083
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2084
            QEMU_CAPS_VIRTIO_SCSI,
2085 2086
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", QEMU_CAPS_MACHINE_OPT,
2087
                    QEMU_CAPS_VIRTIO_SCSI,
2088 2089 2090 2091
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2092
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2093
            QEMU_CAPS_VIRTIO_SCSI,
2094 2095
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", QEMU_CAPS_MACHINE_OPT,
2096
                    QEMU_CAPS_VIRTIO_SCSI,
2097 2098 2099 2100 2101
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2102
            QEMU_CAPS_VIRTIO_SCSI,
2103
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
2104
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", QEMU_CAPS_MACHINE_OPT,
2105
                    QEMU_CAPS_VIRTIO_SCSI,
2106 2107 2108 2109
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2110
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEA_KEY_WRAP,
2111
            QEMU_CAPS_VIRTIO_SCSI,
2112 2113
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", QEMU_CAPS_MACHINE_OPT,
2114
                    QEMU_CAPS_VIRTIO_SCSI,
2115 2116 2117 2118 2119
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2120
            QEMU_CAPS_VIRTIO_SCSI,
2121 2122
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", QEMU_CAPS_MACHINE_OPT,
2123
                    QEMU_CAPS_VIRTIO_SCSI,
2124 2125 2126 2127
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2128
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEA_KEY_WRAP,
2129
            QEMU_CAPS_VIRTIO_SCSI,
2130 2131
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", QEMU_CAPS_MACHINE_OPT,
2132
                    QEMU_CAPS_VIRTIO_SCSI,
2133 2134 2135 2136 2137
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2138
            QEMU_CAPS_VIRTIO_SCSI,
2139 2140
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST("machine-keywrap-none",
2141
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_VIRTIO_SCSI,
2142
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
2143

J
Jiri Denemark 已提交
2144 2145 2146 2147 2148 2149 2150
    DO_TEST("qemu-ns-domain-ns0", NONE);
    DO_TEST("qemu-ns-domain-commandline", NONE);
    DO_TEST("qemu-ns-domain-commandline-ns0", NONE);
    DO_TEST("qemu-ns-commandline", NONE);
    DO_TEST("qemu-ns-commandline-ns0", NONE);
    DO_TEST("qemu-ns-commandline-ns1", NONE);

2151
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2152
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2153
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2154

2155
    DO_TEST("ppc64-usb-controller",
2156
            QEMU_CAPS_PCI_OHCI);
2157
    DO_TEST("ppc64-usb-controller-legacy",
2158
            QEMU_CAPS_PIIX3_USB_UHCI);
2159

2160 2161 2162 2163
    DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                              VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                              NONE);

2164
    DO_TEST("name-escape", QEMU_CAPS_NAME_DEBUG_THREADS,
2165
            QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_CHARDEV, QEMU_CAPS_VNC,
2166
            QEMU_CAPS_NAME_GUEST, QEMU_CAPS_DEVICE_CIRRUS_VGA);
M
Marc-André Lureau 已提交
2167 2168
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2169
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
J
Ján Tomko 已提交
2170 2171
    DO_TEST("usb-long-port-path", QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_USB_HUB);
2172 2173 2174
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
                        QEMU_CAPS_CHARDEV,
                        QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_USB_HUB);
2175

2176
    DO_TEST("acpi-table", NONE);
2177 2178
    DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
2179 2180
    DO_TEST("intel-iommu-machine", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_MACHINE_IOMMU);
2181

2182 2183
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2184
    qemuTestDriverFree(&driver);
2185

2186
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2187 2188
}

2189 2190
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2argvmock.so",
                       abs_builddir "/.libs/virrandommock.so")
2191

2192 2193
#else

2194 2195 2196 2197
int main(void)
{
    return EXIT_AM_SKIP;
}
2198 2199

#endif /* WITH_QEMU */