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

#include <unistd.h>
4 5 6 7

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

8 9
#include "testutils.h"

10 11
#ifdef WITH_QEMU

12
# include "internal.h"
13
# include "viralloc.h"
14
# include "qemu/qemu_alias.h"
15 16
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_command.h"
M
Matthias Bolte 已提交
17
# include "qemu/qemu_domain.h"
18
# include "qemu/qemu_migration.h"
19
# include "qemu/qemu_process.h"
20
# include "qemu/qemu_slirp.h"
21
# include "datatypes.h"
22
# include "conf/storage_conf.h"
23
# include "cpu/cpu_map.h"
24
# include "virstring.h"
25
# include "storage/storage_driver.h"
26
# include "virmock.h"
27 28
# include "virfilewrapper.h"
# include "configmake.h"
29

30
# define LIBVIRT_QEMU_CAPSPRIV_H_ALLOW
31 32
# include "qemu/qemu_capspriv.h"

33
# include "testutilsqemu.h"
34

35 36
# define VIR_FROM_THIS VIR_FROM_QEMU

37
static virQEMUDriver driver;
38

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

static virSecretPtr
fakeSecretLookupByUsage(virConnectPtr conn,
54
                        int usageType,
55 56
                        const char *usageID)
{
57
    unsigned char uuid[VIR_UUID_BUFLEN];
58 59 60 61 62 63 64 65 66 67
    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);
68
        return NULL;
69
    }
70

71 72 73
    if (virUUIDGenerate(uuid) < 0)
        return NULL;

74
    return virGetSecret(conn, uuid, usageType, usageID);
75 76
}

77 78 79 80
static virSecretPtr
fakeSecretLookupByUUID(virConnectPtr conn,
                       const unsigned char *uuid)
{
81 82 83
    /* NB: This mocked value could be "tls" or "volume" depending on
     * which test is being run, we'll leave at NONE (or 0) */
    return virGetSecret(conn, uuid, VIR_SECRET_USAGE_TYPE_NONE, "");
84 85
}

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
    virStringListFree(volinfo);
164 165
    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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

/* virNetDevOpenvswitchGetVhostuserIfname mocks a portdev name - handle that */
static virNWFilterBindingPtr
fakeNWFilterBindingLookupByPortDev(virConnectPtr conn,
                                   const char *portdev)
{
    if (STREQ(portdev, "vhost-user0"))
        return virGetNWFilterBinding(conn, "fake_vnet0", "fakeFilterName");

    virReportError(VIR_ERR_NO_NWFILTER_BINDING,
                   "no nwfilter binding for port dev '%s'", portdev);
    return NULL;
}


static int
fakeNWFilterBindingDelete(virNWFilterBindingPtr binding ATTRIBUTE_UNUSED)
{
    return 0;
}


static virNWFilterDriver fakeNWFilterDriver = {
    .nwfilterBindingLookupByPortDev = fakeNWFilterBindingLookupByPortDev,
    .nwfilterBindingDelete = fakeNWFilterBindingDelete,
};

292 293 294 295

static int
testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
{
296 297
    virArch arch = virQEMUCapsGetArch(caps);
    const char *x86Models[] = {
298 299 300 301
        "Opteron_G3", "Opteron_G2", "Opteron_G1",
        "Nehalem", "Penryn", "Conroe",
        "Haswell-noTSX", "Haswell",
    };
302
    const char *x86LegacyModels[] = {
303 304 305 306
        "n270", "athlon", "pentium3", "pentium2", "pentium",
        "486", "coreduo", "kvm32", "qemu32", "kvm64",
        "core2duo", "phenom", "qemu64",
    };
307 308 309 310 311 312
    const char *armModels[] = {
        "cortex-a9", "cortex-a8", "cortex-a57", "cortex-a53",
    };
    const char *ppc64Models[] = {
        "POWER8", "POWER7",
    };
313 314 315
    const char *s390xModels[] = {
        "z990", "zEC12", "z13",
    };
316

317
    if (ARCH_IS_X86(arch)) {
318
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, x86Models,
319 320
                                         ARRAY_CARDINALITY(x86Models),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
321
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, x86Models,
322 323
                                         ARRAY_CARDINALITY(x86Models),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
324 325
            return -1;

326 327 328
        if (!skipLegacy) {
            if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM,
                                             x86LegacyModels,
329 330
                                             ARRAY_CARDINALITY(x86LegacyModels),
                                             VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
331 332
                virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU,
                                             x86LegacyModels,
333 334
                                             ARRAY_CARDINALITY(x86LegacyModels),
                                             VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
335 336
                return -1;
        }
337
    } else if (ARCH_IS_ARM(arch)) {
338
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, armModels,
339 340
                                         ARRAY_CARDINALITY(armModels),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
341
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, armModels,
342 343
                                         ARRAY_CARDINALITY(armModels),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
344 345
            return -1;
    } else if (ARCH_IS_PPC64(arch)) {
346
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, ppc64Models,
347 348
                                         ARRAY_CARDINALITY(ppc64Models),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
349
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, ppc64Models,
350 351
                                         ARRAY_CARDINALITY(ppc64Models),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
352
            return -1;
353 354 355 356 357
    } else if (ARCH_IS_S390(arch)) {
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, s390xModels,
                                         ARRAY_CARDINALITY(s390xModels),
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
            return -1;
358
    }
359 360 361 362 363

    return 0;
}


364
static int
365
testUpdateQEMUCaps(const struct testQemuInfo *info,
366 367
                   virDomainObjPtr vm,
                   virCapsPtr caps)
368 369 370
{
    int ret = -1;

371 372 373
    if (!caps)
        goto cleanup;

374 375
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

376 377
    virQEMUCapsInitQMPBasicArch(info->qemuCaps);

378 379
    if (testAddCPUModels(info->qemuCaps,
                         !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
380 381
        goto cleanup;

382 383 384 385
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
386

387 388 389 390 391 392 393
    ret = 0;

 cleanup:
    return ret;
}


394 395 396 397 398 399
static int
testCheckExclusiveFlags(int flags)
{
    virCheckFlags(FLAG_EXPECT_FAILURE |
                  FLAG_EXPECT_PARSE_ERROR |
                  FLAG_FIPS |
400
                  FLAG_REAL_CAPS |
401
                  FLAG_SKIP_LEGACY_CPUS |
402
                  FLAG_SLIRP_HELPER |
403 404
                  0, -1);

405
    VIR_EXCLUSIVE_FLAGS_RET(FLAG_REAL_CAPS, FLAG_SKIP_LEGACY_CPUS, -1);
406 407 408 409
    return 0;
}


410 411 412
static int
testCompareXMLToArgv(const void *data)
{
413
    struct testQemuInfo *info = (void *) data;
414
    char *migrateURI = NULL;
415
    char *actualargv = NULL;
416 417
    unsigned int flags = info->flags;
    unsigned int parseFlags = info->parseFlags;
E
Eric Blake 已提交
418
    int ret = -1;
419
    virDomainObjPtr vm = NULL;
420
    virDomainChrSourceDef monitor_chr;
421
    virConnectPtr conn;
J
Jiri Denemark 已提交
422
    char *log = NULL;
E
Eric Blake 已提交
423
    virCommandPtr cmd = NULL;
424
    size_t i;
425
    qemuDomainObjPrivatePtr priv = NULL;
426

427 428
    memset(&monitor_chr, 0, sizeof(monitor_chr));

429
    if (!(conn = virGetConnect()))
430
        goto cleanup;
431

432
    conn->secretDriver = &fakeSecretDriver;
433
    conn->storageDriver = &fakeStorageDriver;
434
    conn->nwfilterDriver = &fakeNWFilterDriver;
435

436 437 438 439
    virSetConnectInterface(conn);
    virSetConnectNetwork(conn);
    virSetConnectNWFilter(conn);
    virSetConnectNodeDev(conn);
440 441 442
    virSetConnectSecret(conn);
    virSetConnectStorage(conn);

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

446 447 448
    if (testCheckExclusiveFlags(info->flags) < 0)
        goto cleanup;

449
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
450 451 452
        goto cleanup;

    if (info->migrateFrom &&
453 454
        !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                              info->migrateFd)))
455 456
        goto cleanup;

457
    if (!(vm = virDomainObjNew(driver.xmlopt)))
458
        goto cleanup;
459

460
    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
461 462
    if (!(vm->def = virDomainDefParseFile(info->infile,
                                          driver.caps, driver.xmlopt,
463
                                          NULL, parseFlags))) {
P
Pavel Hrdina 已提交
464
        if (flags & FLAG_EXPECT_PARSE_ERROR)
465
            goto ok;
466
        goto cleanup;
467
    }
468 469 470 471
    if (flags & FLAG_EXPECT_PARSE_ERROR) {
        VIR_TEST_DEBUG("passed instead of expected parse error");
        goto cleanup;
    }
472
    priv = vm->privateData;
473

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

477
    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
478
        VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile);
479
        goto cleanup;
480 481
    }

482
    vm->def->id = -1;
483

484
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
485
        goto cleanup;
486

487 488
    if (!(info->flags & FLAG_REAL_CAPS) &&
        testUpdateQEMUCaps(info, vm, driver.caps) < 0)
489
        goto cleanup;
490

491
    log = virTestLogContentAndReset();
492
    VIR_FREE(log);
493
    virResetLastError();
J
Jiri Denemark 已提交
494

495 496
    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
497 498 499 500

        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) {
501
            hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
502 503 504
        }
    }

505 506 507 508 509 510 511 512 513 514 515
    if (vm->def->vsock) {
        virDomainVsockDefPtr vsock = vm->def->vsock;
        qemuDomainVsockPrivatePtr vsockPriv =
            (qemuDomainVsockPrivatePtr)vsock->privateData;

        if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES)
            vsock->guest_cid = 42;

        vsockPriv->vhostfd = 6789;
    }

516 517 518
    if (vm->def->tpm) {
        switch (vm->def->tpm->type) {
        case VIR_DOMAIN_TPM_TYPE_EMULATOR:
519
            VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
520 521 522
            if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.path,
                           "/dev/test") < 0)
                goto cleanup;
523
            vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
524 525 526 527 528 529 530
            break;
        case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
        case VIR_DOMAIN_TPM_TYPE_LAST:
            break;
       }
    }

531 532 533 534 535 536 537 538 539 540 541 542 543
    if (flags & FLAG_SLIRP_HELPER) {
        for (i = 0; i < vm->def->nnets; i++) {
            virDomainNetDefPtr net = vm->def->nets[i];

            if (net->type == VIR_DOMAIN_NET_TYPE_USER &&
                virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_NET_SOCKET_DGRAM)) {
                qemuSlirpPtr slirp = qemuSlirpNew();
                slirp->fd[0] = 42;
                QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp = slirp;
            }
        }
    }

544
    if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI,
P
Pavel Hrdina 已提交
545 546
                                            (flags & FLAG_FIPS), false,
                                            VIR_QEMU_PROCESS_START_COLD))) {
P
Pavel Hrdina 已提交
547 548
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
549
        goto cleanup;
J
Jiri Denemark 已提交
550
    }
551 552 553 554
    if (flags & FLAG_EXPECT_FAILURE) {
        VIR_TEST_DEBUG("passed instead of expected failure");
        goto cleanup;
    }
J
Jiri Denemark 已提交
555

556
    if (!(actualargv = virCommandToString(cmd, false)))
557
        goto cleanup;
E
Eric Blake 已提交
558

559
    if (virTestCompareToFile(actualargv, info->outfile) < 0)
560
        goto cleanup;
561

P
Pavel Hrdina 已提交
562 563
    ret = 0;

564
 ok:
565
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
566
        ret = -1;
567
        VIR_TEST_DEBUG("Error expected but there wasn't any.");
568
        goto cleanup;
P
Pavel Hrdina 已提交
569
    }
570
    if (!virTestOOMActive()) {
571
        if (flags & FLAG_EXPECT_FAILURE) {
572
            if ((log = virTestLogContentAndReset()))
P
Pavel Hrdina 已提交
573 574
                VIR_TEST_DEBUG("Got expected error: \n%s", log);
        }
575
        virResetLastError();
P
Pavel Hrdina 已提交
576
        ret = 0;
577 578
    }

579
 cleanup:
580 581
    VIR_FREE(log);
    VIR_FREE(actualargv);
582
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
583
    virCommandFree(cmd);
584
    virObjectUnref(vm);
585 586
    virSetConnectSecret(NULL);
    virSetConnectStorage(NULL);
587
    virObjectUnref(conn);
588
    VIR_FREE(migrateURI);
589
    return ret;
590 591
}

592
static int
593
testInfoSetPaths(struct testQemuInfo *info,
594 595 596 597 598 599 600 601 602 603 604 605
                 const char *suffix)
{
    if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
                    abs_srcdir, info->name) < 0 ||
        virAsprintf(&info->outfile, "%s/qemuxml2argvdata/%s%s.args",
                    abs_srcdir, info->name, suffix ? suffix : "") < 0) {
        return -1;
    }

    return 0;
}

A
Andrea Bolognani 已提交
606
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
607

608
static int
E
Eric Blake 已提交
609
mymain(void)
610
{
C
Cole Robinson 已提交
611
    int ret = 0;
A
Andrea Bolognani 已提交
612
    char *fakerootdir;
613
    virHashTablePtr capslatest = NULL;
614

A
Andrea Bolognani 已提交
615 616 617 618 619 620 621 622 623 624 625 626
    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
        fprintf(stderr, "Out of memory\n");
        abort();
    }

    if (!mkdtemp(fakerootdir)) {
        fprintf(stderr, "Cannot create fakerootdir");
        abort();
    }

    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);

627 628 629 630 631 632 633 634 635 636
    /* 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;
    }

637
    if (qemuTestDriverInit(&driver) < 0)
638
        return EXIT_FAILURE;
639 640

    driver.privileged = true;
641

642 643 644
    VIR_FREE(driver.config->defaultTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/qemu") < 0)
        return EXIT_FAILURE;
645
    VIR_FREE(driver.config->vncTLSx509certdir);
646
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
647 648
        return EXIT_FAILURE;
    VIR_FREE(driver.config->spiceTLSx509certdir);
649
    if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
650
        return EXIT_FAILURE;
651 652 653
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
654
    VIR_FREE(driver.config->vxhsTLSx509certdir);
655
    if (VIR_STRDUP_QUIET(driver.config->vxhsTLSx509certdir, "/etc/pki/libvirt-vxhs/dummy,path") < 0)
656
        return EXIT_FAILURE;
657 658 659
    VIR_FREE(driver.config->nbdTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->nbdTLSx509certdir, "/etc/pki/libvirt-nbd/dummy,path") < 0)
        return EXIT_FAILURE;
660

661
    VIR_FREE(driver.config->hugetlbfs);
662
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
663
        return EXIT_FAILURE;
664 665 666
    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)
667
        return EXIT_FAILURE;
668 669
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
670
    driver.config->hugetlbfs[1].size = 1048576;
671
    driver.config->spiceTLS = 1;
672
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
673
        return EXIT_FAILURE;
674 675 676
    VIR_FREE(driver.config->memoryBackingDir);
    if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
        return EXIT_FAILURE;
677 678 679
    VIR_FREE(driver.config->nvramDir);
    if (VIR_STRDUP(driver.config->nvramDir, "/var/lib/libvirt/qemu/nvram") < 0)
        return EXIT_FAILURE;
680

C
Cole Robinson 已提交
681
    capslatest = testQemuGetLatestCaps();
682
    if (!capslatest)
683 684
        return EXIT_FAILURE;

685 686 687 688 689 690 691
    virFileWrapperAddPrefix(SYSCONFDIR "/qemu/firmware",
                            abs_srcdir "/qemufirmwaredata/etc/qemu/firmware");
    virFileWrapperAddPrefix(PREFIX "/share/qemu/firmware",
                            abs_srcdir "/qemufirmwaredata/usr/share/qemu/firmware");
    virFileWrapperAddPrefix("/home/user/.config/qemu/firmware",
                            abs_srcdir "/qemufirmwaredata/home/user/.config/qemu/firmware");

692 693 694 695 696 697 698 699 700 701 702 703 704 705
/**
 * The following set of macros allows testing of XML -> argv conversion with a
 * real set of capabilities gathered from a real qemu copy. It is desired to use
 * these for positive test cases as it provides combinations of flags which
 * can be met in real life.
 *
 * The capabilities are taken from the real capabilities stored in
 * tests/qemucapabilitiesdata.
 *
 * It is suggested to use the DO_TEST_CAPS_LATEST macro which always takes the
 * most recent capability set. In cases when the new code would change behaviour
 * the test cases should be forked using DO_TEST_CAPS_VER with the appropriate
 * version.
 */
706
# define DO_TEST_INTERNAL(_name, _suffix, ...) \
707
    do { \
708
        static struct testQemuInfo info = { \
709
            .name = _name, \
710
        }; \
711 712
        if (testQemuInfoSetArgs(&info, capslatest, \
                                __VA_ARGS__, ARG_END) < 0) \
713
            return EXIT_FAILURE; \
714 715 716 717
        if (testInfoSetPaths(&info, _suffix) < 0) { \
            VIR_TEST_DEBUG("Failed to generate paths for '%s'", _name); \
            return EXIT_FAILURE; \
        } \
718
        if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \
719 720
                       testCompareXMLToArgv, &info) < 0) \
            ret = -1; \
721
        testQemuInfoClear(&info); \
722 723
    } while (0)

724 725 726 727 728 729
# define DO_TEST_CAPS_INTERNAL(name, arch, ver, ...) \
    DO_TEST_INTERNAL(name, "." arch "-" ver, \
                     ARG_CAPS_ARCH, arch, \
                     ARG_CAPS_VER, ver, \
                     __VA_ARGS__)

730
# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \
731
    DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__)
732

733 734 735
# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \
    DO_TEST_CAPS_INTERNAL(name, arch, ver, __VA_ARGS__)

736
# define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
737
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)
738

739
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
740
    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END)
741

742
# define DO_TEST_CAPS_LATEST(name) \
743
    DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
744

745 746 747
# define DO_TEST_CAPS_VER(name, ver) \
    DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)

748 749
# define DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, arch) \
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \
750
                                  ARG_FLAGS, FLAG_EXPECT_FAILURE)
751

752 753 754 755 756 757 758 759 760 761 762 763
# define DO_TEST_CAPS_ARCH_VER_FAILURE(name, arch, ver) \
    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, \
                               ARG_FLAGS, FLAG_EXPECT_FAILURE)

# define DO_TEST_CAPS_LATEST_FAILURE(name) \
    DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, "x86_64")

# define DO_TEST_CAPS_VER_FAILURE(name, ver) \
    DO_TEST_CAPS_ARCH_VER_FAILURE(name, "x86_64", ver)

# define DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR(name, arch) \
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \
764
                                  ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
765

766 767 768 769 770 771 772 773 774 775
# define DO_TEST_CAPS_ARCH_VER_PARSE_ERROR(name, arch, ver) \
    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, \
                               ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)

# define DO_TEST_CAPS_LATEST_PARSE_ERROR(name) \
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR(name, "x86_64")

# define DO_TEST_CAPS_VER_PARSE_ERROR(name, ver) \
    DO_TEST_CAPS_ARCH_VER_PARSE_ERROR(name, "x86_64", ver)

776 777 778
# define DO_TEST_FULL(name, ...) \
    DO_TEST_INTERNAL(name, "", \
                     __VA_ARGS__, QEMU_CAPS_LAST)
779

780 781 782
/* All the following macros require an explicit QEMU_CAPS_* list
 * at the end of the argument list, or the NONE placeholder.
 * */
783
# define DO_TEST(name, ...) \
784
    DO_TEST_FULL(name, \
785
                 ARG_QEMU_CAPS, __VA_ARGS__)
786

787
# define DO_TEST_GIC(name, gic, ...) \
788
    DO_TEST_FULL(name, \
789
                 ARG_GIC, gic, \
790
                 ARG_QEMU_CAPS, __VA_ARGS__)
791

792
# define DO_TEST_FAILURE(name, ...) \
793 794
    DO_TEST_FULL(name, \
                 ARG_FLAGS, FLAG_EXPECT_FAILURE, \
795
                 ARG_QEMU_CAPS, __VA_ARGS__)
796

797
# define DO_TEST_PARSE_ERROR(name, ...) \
798
    DO_TEST_FULL(name, \
799
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
800
                 ARG_QEMU_CAPS, __VA_ARGS__)
801

802
# define NONE QEMU_CAPS_LAST
803

804 805 806
    /* 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 */
807 808 809 810 811 812 813
    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");
814 815
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
816

817
    DO_TEST("minimal", NONE);
818 819
    DO_TEST("minimal-sandbox",
            QEMU_CAPS_SECCOMP_BLACKLIST);
820
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
821
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
822 823 824 825

    DO_TEST_CAPS_LATEST("genid");
    DO_TEST_CAPS_LATEST("genid-auto");

826
    DO_TEST("machine-aliases1", NONE);
827
    DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
828
    DO_TEST("machine-core-on", NONE);
829
    driver.config->dumpGuestCore = true;
830
    DO_TEST("machine-core-off", NONE);
831
    driver.config->dumpGuestCore = false;
M
Michal Privoznik 已提交
832 833 834
    DO_TEST("machine-smm-opt",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
835
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
836 837 838
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
839
    DO_TEST("machine-vmport-opt",
840
            QEMU_CAPS_MACHINE_VMPORT_OPT);
841 842 843
    DO_TEST("default-kvm-host-arch", NONE);
    DO_TEST("default-qemu-host-arch", NONE);
    DO_TEST("x86-kvm-32-on-64", NONE);
844 845 846
    DO_TEST("boot-cdrom", NONE);
    DO_TEST("boot-network", NONE);
    DO_TEST("boot-floppy", NONE);
847
    DO_TEST("boot-floppy-q35",
848
            QEMU_CAPS_DEVICE_IOH3420,
849
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
850 851
    DO_TEST("boot-multi", NONE);
    DO_TEST("boot-menu-enable", NONE);
852
    DO_TEST("boot-menu-enable-with-timeout",
853
            QEMU_CAPS_SPLASH_TIMEOUT);
J
Ján Tomko 已提交
854
    DO_TEST_FAILURE("boot-menu-enable-with-timeout", NONE);
855
    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE);
J
Ján Tomko 已提交
856 857
    DO_TEST("boot-menu-disable", NONE);
    DO_TEST("boot-menu-disable-drive", NONE);
858
    DO_TEST_PARSE_ERROR("boot-dev+order",
859
            QEMU_CAPS_VIRTIO_BLK_SCSI);
860
    DO_TEST("boot-order",
861
            QEMU_CAPS_VIRTIO_BLK_SCSI);
862
    DO_TEST("boot-complex",
863
            QEMU_CAPS_VIRTIO_BLK_SCSI);
864
    DO_TEST("boot-strict",
865
            QEMU_CAPS_BOOT_STRICT,
866
            QEMU_CAPS_VIRTIO_BLK_SCSI);
867 868 869 870 871

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

872
    DO_TEST("bios",
873
            QEMU_CAPS_DEVICE_ISA_SERIAL,
874
            QEMU_CAPS_SGA);
J
Ján Tomko 已提交
875
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
876 877 878
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
879
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
880 881 882
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
883 884 885 886 887 888 889

    /* Make sure all combinations of ACPI and UEFI behave as expected */
    DO_TEST("q35-acpi-uefi", NONE);
    DO_TEST_PARSE_ERROR("q35-noacpi-uefi", NONE);
    DO_TEST("q35-noacpi-nouefi", NONE);
    DO_TEST("q35-acpi-nouefi", NONE);

890
    DO_TEST("clock-utc", NONE);
891
    DO_TEST("clock-localtime", NONE);
J
Ján Tomko 已提交
892 893 894 895
    DO_TEST("clock-localtime-basis-localtime", NONE);
    DO_TEST("clock-variable", NONE);
    DO_TEST("clock-france", NONE);
    DO_TEST("clock-hpet-off", NONE);
J
Ján Tomko 已提交
896
    DO_TEST("clock-catchup", QEMU_CAPS_KVM_PIT_TICK_POLICY);
897 898
    DO_TEST("cpu-kvmclock", NONE);
    DO_TEST("cpu-host-kvmclock", NONE);
899
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
900
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
901

902 903
    DO_TEST("cpu-eoi-disabled", NONE);
    DO_TEST("cpu-eoi-enabled", NONE);
J
Ján Tomko 已提交
904
    DO_TEST("controller-order",
905 906 907 908 909 910
            QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_HDA_DUPLEX,
            QEMU_CAPS_USB_HUB,
911
            QEMU_CAPS_DEVICE_ISA_SERIAL,
912
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
913
    DO_TEST_CAPS_VER("eoi-disabled", "2.7.0");
914
    DO_TEST_CAPS_VER("eoi-disabled", "4.0.0");
915 916
    DO_TEST_CAPS_LATEST("eoi-disabled");
    DO_TEST_CAPS_VER("eoi-enabled", "2.7.0");
917
    DO_TEST_CAPS_VER("eoi-enabled", "4.0.0");
918 919
    DO_TEST_CAPS_LATEST("eoi-enabled");
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "2.7.0");
920
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "4.0.0");
921 922
    DO_TEST_CAPS_LATEST("pv-spinlock-disabled");
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "2.7.0");
923
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "4.0.0");
924 925
    DO_TEST_CAPS_LATEST("pv-spinlock-enabled");
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "2.7.0");
926
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "4.0.0");
927
    DO_TEST_CAPS_LATEST("kvmclock+eoi-disabled");
928

929 930 931 932 933 934
    DO_TEST_CAPS_VER("hyperv", "4.0.0");
    DO_TEST_CAPS_LATEST("hyperv");
    DO_TEST_CAPS_VER("hyperv-off", "4.0.0");
    DO_TEST_CAPS_LATEST("hyperv-off");
    DO_TEST_CAPS_VER("hyperv-panic", "4.0.0");
    DO_TEST_CAPS_LATEST("hyperv-panic");
935
    DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
936

937 938 939
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

940 941 942
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

943 944 945
    DO_TEST("pages-discard",
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
946 947 948 949
    DO_TEST("pages-discard-hugepages",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
950 951 952 953
    DO_TEST("pages-dimm-discard",
            QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
954
    DO_TEST("hugepages-default", NONE);
955
    DO_TEST("hugepages-default-2M", NONE);
956
    DO_TEST("hugepages-default-system-size", NONE);
957
    DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
958
    DO_TEST("hugepages-nodeset", NONE);
959 960 961 962
    DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
                        QEMU_CAPS_DEVICE_PC_DIMM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE,
                        QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
963
    DO_TEST("hugepages-numa-default",
964
            QEMU_CAPS_OBJECT_MEMORY_FILE);
965 966 967
    DO_TEST("hugepages-numa-default-2M",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
968
    DO_TEST("hugepages-numa-default-dimm",
969
            QEMU_CAPS_DEVICE_PC_DIMM,
J
Ján Tomko 已提交
970
            QEMU_CAPS_OBJECT_MEMORY_FILE);
971
    DO_TEST("hugepages-numa-nodeset",
A
Andrea Bolognani 已提交
972
            QEMU_CAPS_OBJECT_MEMORY_RAM,
973
            QEMU_CAPS_OBJECT_MEMORY_FILE);
974 975
    DO_TEST("hugepages-numa-nodeset-part",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
976
            QEMU_CAPS_OBJECT_MEMORY_FILE);
977 978 979
    DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist",
                        QEMU_CAPS_OBJECT_MEMORY_RAM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE);
A
Andrea Bolognani 已提交
980 981 982
    DO_TEST("hugepages-shared",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
983
    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
984 985 986
    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
987 988 989
    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
990 991 992
    DO_TEST_PARSE_ERROR("hugepages-memaccess3",
                        QEMU_CAPS_OBJECT_MEMORY_RAM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE);
993
    DO_TEST_CAPS_LATEST("hugepages-nvdimm");
994
    DO_TEST("nosharepages", QEMU_CAPS_MEM_MERGE);
995
    DO_TEST("disk-cdrom", NONE);
996
    DO_TEST_CAPS_VER("disk-cdrom", "2.12.0");
997
    DO_TEST_CAPS_LATEST("disk-cdrom");
998
    DO_TEST_CAPS_LATEST("disk-cdrom-bus-other");
999
    DO_TEST("disk-iscsi", NONE);
1000
    DO_TEST("disk-cdrom-network", QEMU_CAPS_KVM);
1001
    DO_TEST_CAPS_VER("disk-cdrom-network", "2.12.0");
1002
    DO_TEST_CAPS_LATEST("disk-cdrom-network");
1003
    DO_TEST("disk-cdrom-tray",
1004
            QEMU_CAPS_VIRTIO_TX_ALG);
1005
    DO_TEST_CAPS_VER("disk-cdrom-tray", "2.12.0");
1006
    DO_TEST_CAPS_LATEST("disk-cdrom-tray");
1007
    DO_TEST("disk-floppy", NONE);
1008
    DO_TEST_CAPS_VER("disk-floppy", "2.12.0");
1009
    DO_TEST_CAPS_LATEST("disk-floppy");
1010
    DO_TEST_CAPS_VER("disk-floppy-q35-2_9", "2.12.0");
1011
    DO_TEST_CAPS_LATEST("disk-floppy-q35-2_9");
1012
    DO_TEST_CAPS_VER("disk-floppy-q35-2_11", "2.12.0");
1013
    DO_TEST_CAPS_LATEST("disk-floppy-q35-2_11");
1014 1015
    DO_TEST_FAILURE("disk-floppy-pseries",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1016
    DO_TEST("disk-floppy-tray", NONE);
1017
    DO_TEST("disk-virtio-s390",
1018
            QEMU_CAPS_VIRTIO_S390);
1019
    DO_TEST("disk-virtio", NONE);
1020
    DO_TEST("disk-virtio-ccw",
1021
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1022
    DO_TEST("disk-virtio-ccw-many",
1023
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1024 1025 1026 1027
    DO_TEST("disk-virtio-s390-zpci",
            QEMU_CAPS_DEVICE_ZPCI,
            QEMU_CAPS_CCW,
            QEMU_CAPS_VIRTIO_S390);
1028
    DO_TEST("disk-order", QEMU_CAPS_VIRTIO_BLK_SCSI);
1029
    DO_TEST("disk-virtio-queues",
L
Lin Ma 已提交
1030
            QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
1031 1032 1033
    DO_TEST("disk-boot-disk", NONE);
    DO_TEST("disk-boot-cdrom", NONE);
    DO_TEST("floppy-drive-fat", NONE);
1034
    DO_TEST_CAPS_VER("floppy-drive-fat", "2.12.0");
1035
    DO_TEST_CAPS_LATEST("floppy-drive-fat");
1036
    DO_TEST("disk-readonly-disk", NONE);
1037
    DO_TEST_CAPS_VER("disk-readonly-disk", "2.12.0");
1038
    DO_TEST_CAPS_LATEST("disk-readonly-disk");
1039 1040 1041 1042
    DO_TEST("disk-fmt-qcow", NONE);
    DO_TEST_PARSE_ERROR("disk-fmt-cow", NONE);
    DO_TEST_PARSE_ERROR("disk-fmt-dir", NONE);
    DO_TEST_PARSE_ERROR("disk-fmt-iso", NONE);
1043
    DO_TEST_CAPS_VER("disk-shared", "2.12.0");
1044
    DO_TEST_CAPS_LATEST("disk-shared");
1045 1046
    DO_TEST_PARSE_ERROR("disk-shared-qcow", NONE);
    DO_TEST("disk-error-policy", NONE);
1047
    DO_TEST_CAPS_VER("disk-error-policy", "2.12.0");
1048
    DO_TEST_CAPS_LATEST("disk-error-policy");
1049
    DO_TEST_CAPS_VER("disk-cache", "1.5.3");
1050 1051
    DO_TEST_CAPS_VER("disk-cache", "2.6.0");
    DO_TEST_CAPS_VER("disk-cache", "2.7.0");
1052
    DO_TEST_CAPS_VER("disk-cache", "2.12.0");
1053
    DO_TEST_CAPS_LATEST("disk-cache");
1054
    DO_TEST("disk-network-nbd", NONE);
1055
    DO_TEST_CAPS_VER("disk-network-nbd", "2.12.0");
1056
    DO_TEST_CAPS_LATEST("disk-network-nbd");
1057
    DO_TEST("disk-network-iscsi", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_BLOCK);
1058 1059 1060 1061
    DO_TEST("disk-network-iscsi-modern",
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_BLOCK,
            QEMU_CAPS_ISCSI_PASSWORD_SECRET);
1062
    DO_TEST_CAPS_VER("disk-network-iscsi", "2.12.0");
1063
    DO_TEST_CAPS_LATEST("disk-network-iscsi");
1064 1065 1066 1067
    DO_TEST_PARSE_ERROR("disk-network-iscsi-auth-secrettype-invalid", NONE);
    DO_TEST_PARSE_ERROR("disk-network-iscsi-auth-wrong-secrettype", NONE);
    DO_TEST_PARSE_ERROR("disk-network-source-auth-both", NONE);
    DO_TEST("disk-network-gluster",
1068
            QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
1069
    DO_TEST_CAPS_VER("disk-network-gluster", "2.12.0");
1070
    DO_TEST_CAPS_LATEST("disk-network-gluster");
1071
    DO_TEST_CAPS_VER("disk-network-rbd", "2.5.0");
1072
    DO_TEST_CAPS_VER("disk-network-rbd", "2.12.0");
1073 1074
    DO_TEST_CAPS_LATEST("disk-network-rbd");
    DO_TEST_FAILURE("disk-network-rbd-no-colon", NONE);
1075
    DO_TEST("disk-network-sheepdog", NONE);
1076
    DO_TEST_CAPS_VER("disk-network-sheepdog", "2.12.0");
1077
    DO_TEST_CAPS_LATEST("disk-network-sheepdog");
1078
    DO_TEST("disk-network-source-auth", NONE);
1079
    DO_TEST_CAPS_VER("disk-network-source-auth", "2.12.0");
1080
    DO_TEST_CAPS_LATEST("disk-network-source-auth");
1081
    DO_TEST("disk-network-vxhs", QEMU_CAPS_VXHS);
1082
    driver.config->vxhsTLS = 1;
1083
    DO_TEST("disk-network-tlsx509", QEMU_CAPS_VXHS,
1084
            QEMU_CAPS_OBJECT_TLS_CREDS_X509, QEMU_CAPS_NBD_TLS);
1085
    DO_TEST_CAPS_VER("disk-network-tlsx509", "2.12.0");
1086
    DO_TEST_CAPS_LATEST("disk-network-tlsx509");
1087 1088
    driver.config->vxhsTLS = 0;
    VIR_FREE(driver.config->vxhsTLSx509certdir);
1089
    DO_TEST("disk-no-boot", NONE);
1090
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
1091 1092
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
1093
    DO_TEST("disk-usb-device",
1094
            QEMU_CAPS_DEVICE_USB_STORAGE);
1095
    DO_TEST("disk-usb-device-removable",
1096
            QEMU_CAPS_DEVICE_USB_STORAGE,
1097
            QEMU_CAPS_USB_STORAGE_REMOVABLE);
1098
    DO_TEST_FAILURE("disk-usb-pci",
1099
                    QEMU_CAPS_DEVICE_USB_STORAGE);
1100
    DO_TEST_CAPS_LATEST("disk-scsi");
1101 1102
    DO_TEST_CAPS_VER("disk-scsi-device-auto", "1.5.3");
    DO_TEST_CAPS_LATEST("disk-scsi-device-auto");
1103
    DO_TEST("disk-scsi-disk-split",
1104
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1105
    DO_TEST("disk-scsi-disk-wwn",
1106
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1107
    DO_TEST("disk-scsi-disk-vpd",
1108
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1109
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
1110
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1111
    DO_TEST_CAPS_LATEST("controller-virtio-scsi");
1112
    DO_TEST("disk-sata-device",
1113
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
1114
    DO_TEST("disk-aio", NONE);
1115
    DO_TEST_CAPS_VER("disk-aio", "2.12.0");
1116
    DO_TEST_CAPS_LATEST("disk-aio");
1117 1118
    DO_TEST("disk-source-pool", NONE);
    DO_TEST("disk-source-pool-mode", NONE);
1119
    DO_TEST("disk-ioeventfd",
1120
            QEMU_CAPS_VIRTIO_IOEVENTFD,
1121
            QEMU_CAPS_VIRTIO_TX_ALG,
1122
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1123
    DO_TEST("disk-copy_on_read",
1124
            QEMU_CAPS_VIRTIO_TX_ALG,
1125
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1126
    DO_TEST_CAPS_VER("disk-copy_on_read", "2.12.0");
1127
    DO_TEST_CAPS_LATEST("disk-copy_on_read");
1128
    DO_TEST("disk-discard",
1129
            QEMU_CAPS_DRIVE_DISCARD);
1130
    DO_TEST("disk-detect-zeroes",
1131 1132
            QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DRIVE_DETECT_ZEROES);
1133
    DO_TEST_CAPS_VER("disk-detect-zeroes", "2.12.0");
1134
    DO_TEST_CAPS_LATEST("disk-detect-zeroes");
1135
    DO_TEST("disk-snapshot", NONE);
1136 1137
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
1138
                        QEMU_CAPS_DEVICE_USB_STORAGE);
1139
    DO_TEST_PARSE_ERROR("disk-address-conflict",
1140 1141
                        QEMU_CAPS_ICH9_AHCI);
    DO_TEST_PARSE_ERROR("disk-hostdev-scsi-address-conflict",
1142
                        QEMU_CAPS_VIRTIO_SCSI);
1143
    DO_TEST_PARSE_ERROR("hostdevs-drive-address-conflict",
1144
                        QEMU_CAPS_VIRTIO_SCSI);
1145
    DO_TEST("event_idx",
1146 1147
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
1148
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1149
    DO_TEST("virtio-lun",
1150
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1151
    DO_TEST("disk-scsi-lun-passthrough",
1152
            QEMU_CAPS_SCSI_BLOCK,
1153
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1154
    DO_TEST("disk-serial",
1155
            QEMU_CAPS_KVM);
1156 1157 1158 1159 1160 1161 1162 1163
    DO_TEST_PARSE_ERROR("disk-fdc-incompatible-address",
                        NONE);
    DO_TEST_PARSE_ERROR("disk-ide-incompatible-address",
                        NONE);
    DO_TEST_PARSE_ERROR("disk-sata-incompatible-address",
                        QEMU_CAPS_ICH9_AHCI);
    DO_TEST_PARSE_ERROR("disk-scsi-incompatible-address",
                        QEMU_CAPS_VIRTIO_SCSI);
1164 1165 1166 1167
    DO_TEST_CAPS_VER("disk-backing-chains-index", "2.12.0");
    DO_TEST_CAPS_LATEST("disk-backing-chains-index");
    DO_TEST_CAPS_VER("disk-backing-chains-noindex", "2.12.0");
    DO_TEST_CAPS_LATEST("disk-backing-chains-noindex");
1168

1169 1170 1171
    DO_TEST("graphics-egl-headless",
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1172 1173
    DO_TEST_CAPS_LATEST("graphics-egl-headless");
    DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
1174

1175 1176
    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);
1177 1178
    DO_TEST("graphics-vnc-websocket",
            QEMU_CAPS_VNC,
1179
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1180
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
1181 1182 1183 1184 1185
            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);
1186
    driver.config->vncAutoUnixSocket = true;
1187 1188
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1189
    driver.config->vncAutoUnixSocket = false;
1190 1191 1192 1193
    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);
1194 1195
    DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
1196

1197 1198
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1199
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
1200
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1201 1202
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1203
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1204 1205
    DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
    DO_TEST_CAPS_LATEST("graphics-vnc-tls");
1206 1207 1208 1209 1210
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509secretUUID,
                         "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0)
        return EXIT_FAILURE;
    DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret");
    VIR_FREE(driver.config->vncTLSx509secretUUID);
1211
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1212 1213
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1214 1215 1216 1217
    DO_TEST("graphics-vnc-egl-headless",
            QEMU_CAPS_VNC,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1218

J
Ján Tomko 已提交
1219 1220
    DO_TEST("graphics-sdl",
            QEMU_CAPS_DEVICE_VGA);
1221
    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-sdl-egl-headless");
J
Ján Tomko 已提交
1222
    DO_TEST("graphics-sdl-fullscreen",
1223
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1224
    DO_TEST("graphics-spice",
1225
            QEMU_CAPS_SPICE,
1226 1227
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1228
    DO_TEST("graphics-spice-no-args",
1229
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1230 1231 1232
    driver.config->spiceSASL = 1;
    ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
    DO_TEST("graphics-spice-sasl",
1233
            QEMU_CAPS_SPICE,
1234 1235 1236
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
1237
    DO_TEST("graphics-spice-agentmouse",
1238
            QEMU_CAPS_DEVICE_QXL,
1239
            QEMU_CAPS_SPICE,
1240
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1241
    DO_TEST("graphics-spice-compression",
1242
            QEMU_CAPS_SPICE,
1243
            QEMU_CAPS_DEVICE_QXL);
1244
    DO_TEST("graphics-spice-timeout",
1245
            QEMU_CAPS_KVM,
1246
            QEMU_CAPS_SPICE,
1247 1248
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VGA);
1249
    DO_TEST("graphics-spice-qxl-vga",
1250
            QEMU_CAPS_SPICE,
1251
            QEMU_CAPS_DEVICE_QXL);
1252
    DO_TEST("graphics-spice-usb-redir",
1253
            QEMU_CAPS_SPICE,
1254 1255 1256 1257
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1258
    DO_TEST("graphics-spice-agent-file-xfer",
1259
            QEMU_CAPS_SPICE,
1260 1261
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1262 1263
    DO_TEST("graphics-spice-socket",
            QEMU_CAPS_SPICE,
1264 1265
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1266 1267
    DO_TEST("graphics-spice-auto-socket",
            QEMU_CAPS_SPICE,
1268 1269
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1270 1271 1272
    driver.config->spiceAutoUnixSocket = true;
    DO_TEST("graphics-spice-auto-socket-cfg",
            QEMU_CAPS_SPICE,
1273 1274
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1275
    driver.config->spiceAutoUnixSocket = false;
1276 1277 1278 1279
    DO_TEST("graphics-spice-egl-headless",
            QEMU_CAPS_SPICE,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_QXL);
1280
    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-spice-invalid-egl-headless");
1281
    DO_TEST_CAPS_LATEST("graphics-spice-gl-auto-rendernode");
1282

1283 1284 1285
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
    DO_TEST("misc-acpi", NONE);
1286 1287 1288
    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);
1289
    DO_TEST_FAILURE("misc-enable-s4", NONE);
1290
    DO_TEST("misc-no-reboot", NONE);
1291
    DO_TEST("misc-uuid", NONE);
1292
    DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
1293
    DO_TEST("net-vhostuser", QEMU_CAPS_CHARDEV_FD_PASS);
1294 1295
    DO_TEST_CAPS_VER("net-vhostuser", "2.5.0");
    DO_TEST_CAPS_LATEST("net-vhostuser");
1296
    DO_TEST("net-vhostuser-multiq",
J
Ján Tomko 已提交
1297 1298
            QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
    DO_TEST_FAILURE("net-vhostuser-multiq", NONE);
1299 1300
    DO_TEST_FAILURE("net-vhostuser-fail",
                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
1301
    DO_TEST("net-user", NONE);
1302
    DO_TEST_CAPS_ARCH_VER_FULL("net-user", "x86_64", "4.0.0", ARG_FLAGS, FLAG_SLIRP_HELPER);
J
Ján Tomko 已提交
1303
    DO_TEST("net-user-addr", NONE);
1304 1305
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
1306 1307 1308
            QEMU_CAPS_VIRTIO_TX_ALG);
    DO_TEST("net-virtio-disable-offloads", NONE);
    DO_TEST("net-virtio-netdev", NONE);
1309
    DO_TEST("net-virtio-s390",
1310
            QEMU_CAPS_VIRTIO_S390);
1311
    DO_TEST("net-virtio-ccw",
1312
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1313 1314 1315
    DO_TEST("net-virtio-rxtxqueuesize",
            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE,
            QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE);
1316
    DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
1317 1318
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
1319
    DO_TEST("net-eth-names", NONE);
1320
    DO_TEST("net-eth-hostip", NONE);
1321 1322
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
1323
    DO_TEST("net-many-models", NONE);
1324
    DO_TEST("net-mcast", NONE);
1325
    DO_TEST("net-udp", NONE);
1326 1327 1328
    DO_TEST("net-hostdev", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("net-hostdev-bootorder", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("net-hostdev-multidomain", QEMU_CAPS_DEVICE_VFIO_PCI);
1329 1330
    DO_TEST("net-hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1331
    DO_TEST("net-hostdev-vfio-multidomain",
1332
            QEMU_CAPS_DEVICE_VFIO_PCI);
1333 1334 1335
    DO_TEST_FAILURE("net-hostdev-fail",
                    QEMU_CAPS_DEVICE_VFIO_PCI);

1336

1337 1338
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1339
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1340
            QEMU_CAPS_CHARDEV_LOGFILE);
1341
    DO_TEST("serial-spiceport",
1342
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1343
            QEMU_CAPS_DEVICE_QXL,
1344
            QEMU_CAPS_SPICE,
1345
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1346
    DO_TEST("serial-spiceport-nospice", NONE);
1347

1348 1349 1350 1351
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1352 1353

    DO_TEST("serial-vc-chardev",
1354
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1355
    DO_TEST("serial-pty-chardev",
1356
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1357
    DO_TEST("serial-dev-chardev",
1358
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1359
    DO_TEST("serial-dev-chardev-iobase",
1360
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1361
    DO_TEST("serial-file-chardev",
1362
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1363
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1364
    DO_TEST("serial-unix-chardev",
1365
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1366
    DO_TEST_CAPS_LATEST("serial-unix-chardev");
1367
    DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE);
1368
    DO_TEST("serial-tcp-chardev",
1369
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1370
    DO_TEST("serial-udp-chardev",
1371
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1372
    DO_TEST("serial-tcp-telnet-chardev",
1373
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1374 1375
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1376
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1377
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1378 1379
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1380
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1381 1382
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1383
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1384
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1385
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1386 1387 1388 1389 1390 1391 1392 1393
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509secretUUID,
                         "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0)
        return EXIT_FAILURE;
    DO_TEST("serial-tcp-tlsx509-secret-chardev",
            QEMU_CAPS_OBJECT_SECRET,
1394
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1395
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1396 1397
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1398
    DO_TEST("serial-many-chardev",
1399 1400 1401
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
J
Ján Tomko 已提交
1402 1403
    DO_TEST_CAPS_VER("parallel-unix-chardev", "2.5.0");
    DO_TEST_CAPS_LATEST("parallel-unix-chardev");
1404
    DO_TEST("console-compat-chardev",
1405
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1406 1407
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1408

1409
    DO_TEST("channel-guestfwd", NONE);
J
Ján Tomko 已提交
1410 1411
    DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0");
    DO_TEST_CAPS_LATEST("channel-unix-guestfwd");
1412 1413 1414 1415 1416 1417
    DO_TEST("channel-virtio", NONE);
    DO_TEST("channel-virtio-state", NONE);
    DO_TEST("channel-virtio-auto", NONE);
    DO_TEST("channel-virtio-autoassign", NONE);
    DO_TEST("channel-virtio-autoadd", NONE);
    DO_TEST("console-virtio", NONE);
1418
    DO_TEST("console-virtio-many",
1419
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1420
    DO_TEST("console-virtio-s390",
1421
            QEMU_CAPS_VIRTIO_S390);
1422
    DO_TEST("console-virtio-ccw",
1423
            QEMU_CAPS_CCW,
1424
            QEMU_CAPS_VIRTIO_S390);
J
Ján Tomko 已提交
1425 1426
    DO_TEST_CAPS_VER("console-virtio-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("console-virtio-unix");
1427
    DO_TEST("console-sclp",
1428
            QEMU_CAPS_VIRTIO_S390,
1429
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1430
    DO_TEST("channel-spicevmc",
1431
            QEMU_CAPS_SPICE,
1432
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1433
    DO_TEST("channel-virtio-default",
1434
            QEMU_CAPS_SPICE);
1435
    DO_TEST("channel-virtio-unix", NONE);
1436

1437
    DO_TEST("smartcard-host",
1438
            QEMU_CAPS_CCID_EMULATED);
1439
    DO_TEST("smartcard-host-certificates",
1440
            QEMU_CAPS_CCID_EMULATED);
1441 1442
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1443
    DO_TEST("smartcard-passthrough-tcp",
1444
            QEMU_CAPS_CCID_PASSTHRU);
1445
    DO_TEST("smartcard-passthrough-spicevmc",
1446
            QEMU_CAPS_CCID_PASSTHRU);
1447
    DO_TEST("smartcard-controller",
1448
            QEMU_CAPS_CCID_EMULATED);
J
Ján Tomko 已提交
1449 1450
    DO_TEST_CAPS_VER("smartcard-passthrough-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("smartcard-passthrough-unix");
1451

1452 1453 1454 1455 1456 1457 1458 1459
    DO_TEST("chardev-reconnect",
            QEMU_CAPS_CHARDEV_RECONNECT,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_CCID_PASSTHRU);
    DO_TEST_PARSE_ERROR("chardev-reconnect-invalid-timeout",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1460 1461
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1462

1463
    DO_TEST("usb-controller", NONE);
1464
    DO_TEST("usb-piix3-controller",
1465
            QEMU_CAPS_PIIX3_USB_UHCI);
1466
    DO_TEST("usb-ich9-ehci-addr",
1467
            QEMU_CAPS_ICH9_USB_EHCI1);
1468
    DO_TEST("input-usbmouse-addr", NONE);
1469
    DO_TEST("usb-ich9-companion",
1470
            QEMU_CAPS_ICH9_USB_EHCI1);
1471
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1472
            QEMU_CAPS_ICH9_USB_EHCI1);
1473
    DO_TEST("usb-ich9-autoassign",
1474
            QEMU_CAPS_ICH9_USB_EHCI1,
1475
            QEMU_CAPS_USB_HUB);
1476
    DO_TEST("usb-hub",
1477
            QEMU_CAPS_USB_HUB);
1478
    DO_TEST("usb-hub-autoadd",
1479
            QEMU_CAPS_USB_HUB);
1480
    DO_TEST("usb-hub-autoadd-deluxe",
1481
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1482
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
1483
            QEMU_CAPS_USB_HUB);
1484
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
1485
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1486
    DO_TEST("usb-port-missing",
1487
            QEMU_CAPS_USB_HUB);
1488
    DO_TEST_FAILURE("usb-bus-missing",
1489
                    QEMU_CAPS_USB_HUB);
1490
    DO_TEST("usb-ports",
1491
            QEMU_CAPS_USB_HUB);
1492
    DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
1493
            QEMU_CAPS_USB_HUB);
1494
    DO_TEST("usb-port-autoassign",
1495
            QEMU_CAPS_USB_HUB);
1496
    DO_TEST("usb-redir",
1497 1498 1499
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1500
            QEMU_CAPS_SPICE);
1501
    DO_TEST("usb-redir-boot",
1502 1503 1504
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1505
            QEMU_CAPS_SPICE);
1506
    DO_TEST("usb-redir-filter",
1507 1508 1509 1510
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
1511
            QEMU_CAPS_USB_REDIR_FILTER);
1512 1513
    DO_TEST("usb-redir-filter-version",
            QEMU_CAPS_USB_REDIR,
1514
            QEMU_CAPS_SPICE,
1515
            QEMU_CAPS_USB_REDIR_FILTER);
J
Ján Tomko 已提交
1516 1517
    DO_TEST_CAPS_VER("usb-redir-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("usb-redir-unix");
1518
    DO_TEST("usb1-usb2",
1519 1520 1521
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1);
1522 1523
    DO_TEST("usb-none", NONE);
    DO_TEST_PARSE_ERROR("usb-none-other", NONE);
1524 1525
    DO_TEST_PARSE_ERROR("usb-none-hub",
            QEMU_CAPS_USB_HUB);
1526
    DO_TEST_PARSE_ERROR("usb-none-usbtablet", NONE);
1527
    DO_TEST("usb-controller-default-q35",
1528
            QEMU_CAPS_DEVICE_IOH3420,
1529 1530 1531
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1532
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1533
                    QEMU_CAPS_DEVICE_IOH3420,
1534
                    QEMU_CAPS_PCI_OHCI,
1535 1536
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1537
            QEMU_CAPS_DEVICE_IOH3420,
1538 1539 1540
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1541
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1542
                    QEMU_CAPS_DEVICE_IOH3420,
1543
                    QEMU_CAPS_PCI_OHCI,
1544
                    QEMU_CAPS_PIIX3_USB_UHCI);
1545
    DO_TEST("usb-controller-xhci",
1546 1547 1548
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1549
    DO_TEST("usb-xhci-autoassign",
1550 1551 1552
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS,
1553
            QEMU_CAPS_USB_HUB);
1554
    DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
1555 1556 1557
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1558 1559 1560 1561
    DO_TEST("usb-controller-qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI);
    DO_TEST_FAILURE("usb-controller-qemu-xhci-unavailable", NONE);
    DO_TEST_PARSE_ERROR("usb-controller-qemu-xhci-limit",
                        QEMU_CAPS_DEVICE_QEMU_XHCI);
1562

1563 1564 1565
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1566

1567
    DO_TEST("watchdog", NONE);
1568
    DO_TEST("watchdog-device", NONE);
1569
    DO_TEST("watchdog-dump", NONE);
1570
    DO_TEST("watchdog-injectnmi", NONE);
1571
    DO_TEST("watchdog-diag288", QEMU_CAPS_VIRTIO_S390);
1572 1573
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1574
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1575
    DO_TEST("balloon-ccw-deflate",
1576
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1577
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1578
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1579
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1580
    DO_TEST("balloon-device-deflate-off",
1581
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1582 1583
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1584 1585
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1586
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1587
            QEMU_CAPS_HDA_OUTPUT,
1588 1589
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1590
    DO_TEST("fs9p", NONE);
1591
    DO_TEST_CAPS_LATEST("fs9p");
1592
    DO_TEST("fs9p-ccw",
1593
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1594
    DO_TEST_CAPS_ARCH_LATEST("fs9p-ccw", "s390x");
1595

1596
    DO_TEST("hostdev-usb-address", NONE);
1597
    DO_TEST("hostdev-usb-address-device", NONE);
1598
    DO_TEST("hostdev-usb-address-device-boot", NONE);
1599 1600
    DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI);
1601 1602
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1603
    DO_TEST("hostdev-vfio-multidomain",
1604
            QEMU_CAPS_DEVICE_VFIO_PCI);
1605 1606 1607 1608 1609 1610
    DO_TEST("hostdev-mdev-precreated",
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST_PARSE_ERROR("hostdev-mdev-src-address-invalid",
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1611 1612 1613 1614 1615 1616 1617
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-opengl");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-egl-headless");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-vnc");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-vnc-egl-headless");
    DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_VFIO_PCI_DISPLAY);
1618 1619
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1620 1621 1622
    DO_TEST("hostdev-vfio-zpci",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635
    DO_TEST("hostdev-vfio-zpci-multidomain-many",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST("hostdev-vfio-zpci-autogenerate",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST("hostdev-vfio-zpci-boundaries",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1636
    DO_TEST("pci-rom", QEMU_CAPS_DEVICE_VFIO_PCI);
1637
    DO_TEST("pci-rom-disabled", NONE);
1638
    DO_TEST("pci-rom-disabled-invalid", NONE);
1639

1640 1641 1642 1643
    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
1644 1645
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
                             "s390x");
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657
    DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-duplicate-address",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-invalid-address",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);

B
Boris Fiuczynski 已提交
1658 1659
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ap",
                             "s390x");
1660 1661
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ap-boot-fail",
                                         "s390x");
B
Boris Fiuczynski 已提交
1662

1663
    DO_TEST_FULL("restore-v2",
1664 1665
                 ARG_MIGRATE_FROM, "exec:cat",
                 ARG_MIGRATE_FD, 7,
1666
                 ARG_QEMU_CAPS, NONE);
1667
    DO_TEST_FULL("restore-v2-fd",
1668 1669
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1670
                 ARG_QEMU_CAPS, NONE);
1671
    DO_TEST_FULL("restore-v2-fd",
1672 1673
                 ARG_MIGRATE_FROM, "fd:7",
                 ARG_MIGRATE_FD, 7,
1674
                 ARG_QEMU_CAPS, NONE);
1675
    DO_TEST_FULL("migrate",
1676
                 ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000",
1677
                 ARG_QEMU_CAPS, NONE);
1678

1679
    DO_TEST_FULL("migrate-numa-unaligned",
1680 1681
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1682
                 ARG_QEMU_CAPS,
A
Andrea Bolognani 已提交
1683 1684
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1685

1686 1687
    DO_TEST_CAPS_VER("qemu-ns", "4.0.0");
    DO_TEST_CAPS_LATEST("qemu-ns");
1688
    DO_TEST("qemu-ns-no-env", NONE);
1689
    DO_TEST("qemu-ns-alt", NONE);
1690

1691
    DO_TEST("smp", NONE);
1692

J
John Ferlan 已提交
1693
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1694 1695
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1696
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1697 1698
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1699
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1700 1701
    DO_TEST_CAPS_LATEST("iothreads-virtio-scsi-pci");
    DO_TEST_CAPS_ARCH_LATEST("iothreads-virtio-scsi-ccw", "s390x");
J
John Ferlan 已提交
1702

1703 1704
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1705
    DO_TEST("cpu-topology3", NONE);
1706 1707 1708 1709 1710 1711 1712 1713
    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);
1714
    DO_TEST("cpu-no-removed-features", QEMU_CAPS_KVM);
1715
    DO_TEST("cpu-numa1", NONE);
1716 1717
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1718
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1719 1720
    DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1721 1722
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
    DO_TEST_FAILURE("cpu-numa-memshared", NONE);
1723
    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
1724
    DO_TEST("cpu-host-model", NONE);
1725
    DO_TEST("cpu-host-model-vendor", NONE);
1726
    DO_TEST_FULL("cpu-host-model-fallback",
1727
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS,
1728
                 ARG_QEMU_CAPS, NONE);
1729
    DO_TEST_FULL("cpu-host-model-nofallback",
1730
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS | FLAG_EXPECT_FAILURE,
1731
                 ARG_QEMU_CAPS, NONE);
A
Andrea Bolognani 已提交
1732 1733
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1734

1735
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
1736
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1737 1738
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1739 1740
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1741
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1742 1743 1744 1745
    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);
1746
    DO_TEST("cpu-host-model-cmt", NONE);
1747
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1748 1749
    DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
    DO_TEST_CAPS_LATEST("cpu-translation");
1750
    qemuTestSetHostCPU(driver.caps, NULL);
1751

1752 1753
    DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
    DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
1754
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1755
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1756 1757
    DO_TEST_PARSE_ERROR("luks-disks-source-qcow2", QEMU_CAPS_OBJECT_SECRET);
    DO_TEST("luks-disks-source-qcow2", QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_QCOW2_LUKS);
1758
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1759
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1760

1761 1762 1763 1764 1765 1766 1767 1768
    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);
1769
    DO_TEST("cputune-numatune",
1770
            QEMU_CAPS_KVM,
1771
            QEMU_CAPS_OBJECT_IOTHREAD,
1772 1773
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1774 1775 1776
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1777

1778
    DO_TEST("numatune-memory", NONE);
1779
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1780 1781 1782
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1783 1784
    DO_TEST_FAILURE("numatune-memnode", NONE);

A
Andrea Bolognani 已提交
1785 1786 1787
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1788 1789
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1790 1791
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1792
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1793 1794
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1795 1796
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1797 1798
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1799 1800
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1801
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1802 1803 1804
    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);
1805
    DO_TEST("blkdeviotune-max",
1806
            QEMU_CAPS_DRIVE_IOTUNE_MAX);
1807 1808 1809
    DO_TEST("blkdeviotune-group-num",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP);
1810 1811 1812
    DO_TEST("blkdeviotune-max-length",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH);
1813

1814
    DO_TEST("multifunction-pci-device",
1815
            QEMU_CAPS_SCSI_LSI);
1816

1817
    DO_TEST("monitor-json", NONE);
1818

1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830
    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);
1831

1832
    DO_TEST("pseries-basic",
1833
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1834
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1835
    DO_TEST("pseries-vio",
1836
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1837
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1838
    DO_TEST("pseries-usb-default",
1839
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1840
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1841
            QEMU_CAPS_PIIX3_USB_UHCI,
1842
            QEMU_CAPS_PCI_OHCI);
1843
    DO_TEST("pseries-usb-multi",
1844
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1845
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1846
            QEMU_CAPS_PIIX3_USB_UHCI,
1847
            QEMU_CAPS_PCI_OHCI);
1848
    DO_TEST("pseries-vio-user-assigned",
1849
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1850 1851
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash", NONE);
1852 1853 1854
    DO_TEST("pseries-nvram",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_DEVICE_NVRAM);
1855
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1856
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1857
            QEMU_CAPS_DEVICE_USB_KBD,
1858
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1859
    DO_TEST("pseries-cpu-exact",
1860
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1861 1862
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE);
1863 1864

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1865
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1866
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1867
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1868 1869 1870
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
1871
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1872
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1873
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1874
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1875 1876 1877
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
1878 1879 1880

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1881
            QEMU_CAPS_KVM,
1882
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1883
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1884 1885
    qemuTestSetHostCPU(driver.caps, NULL);

1886 1887
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1888
    DO_TEST("pseries-panic-missing",
1889
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1890
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1891
    DO_TEST("pseries-panic-no-address",
1892
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1893
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1894
    DO_TEST_FAILURE("pseries-panic-address",
1895
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1896 1897 1898 1899 1900

    DO_TEST("pseries-phb-simple",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
    DO_TEST("pseries-phb-default-missing",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1901 1902 1903 1904 1905 1906
    DO_TEST("pseries-phb-numa-node",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE);
    DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", NONE);
1907 1908 1909
    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-1", NONE);
    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-2", NONE);
    DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-3", NONE);
1910

1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932
    DO_TEST("pseries-many-devices",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-many-buses-1",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-many-buses-2",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-hostdevs-1",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("pseries-hostdevs-2",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("pseries-hostdevs-3",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);

1933
    DO_TEST("pseries-features",
1934
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1935
            QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
1936
            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
1937
            QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
1938
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1939
    DO_TEST_FAILURE("pseries-features",
1940
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1941
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
1942

1943
    DO_TEST("pseries-serial-native",
1944
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1945 1946
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
1947
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1948 1949
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
1950
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1951
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1952
    DO_TEST("pseries-serial-pci",
1953
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1954 1955
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
1956
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1957 1958
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
1959
    DO_TEST("pseries-console-native",
1960
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1961 1962
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
1963
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1964
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
1965
    DO_TEST_PARSE_ERROR("pseries-spaprvio-invalid", "ppc64");
1966

1967
    DO_TEST("mach-virt-serial-native",
1968
            QEMU_CAPS_DEVICE_PL011);
1969
    DO_TEST("mach-virt-serial+console-native",
1970
            QEMU_CAPS_DEVICE_PL011);
1971
    DO_TEST("mach-virt-serial-compat",
1972
            QEMU_CAPS_DEVICE_PL011);
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984
    DO_TEST("mach-virt-serial-pci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("mach-virt-serial-usb",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
    DO_TEST("mach-virt-console-native",
1985
            QEMU_CAPS_DEVICE_PL011);
1986 1987
    DO_TEST("mach-virt-console-virtio",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
1988 1989
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

1990 1991
    DO_TEST("disk-ide-split", NONE);
    DO_TEST("disk-ide-wwn", QEMU_CAPS_IDE_DRIVE_WWN);
1992

1993
    DO_TEST("disk-geometry", NONE);
1994
    DO_TEST("disk-blockio", QEMU_CAPS_BLOCKIO);
1995

1996
    DO_TEST("video-device-pciaddr-default",
1997 1998
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
1999
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2000
            QEMU_CAPS_DEVICE_QXL);
2001
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
2002
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
2003
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2004
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
2005
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
2006
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
2007
    DO_TEST("video-qxl-device",
2008
            QEMU_CAPS_DEVICE_QXL,
2009
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2010
    DO_TEST("video-qxl-device-vgamem",
2011
            QEMU_CAPS_DEVICE_QXL,
2012
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2013
            QEMU_CAPS_QXL_VGAMEM);
2014
    DO_TEST_CAPS_LATEST("video-qxl-device-vram64");
2015
    DO_TEST("video-qxl-sec-device",
2016
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2017
    DO_TEST("video-qxl-sec-device-vgamem",
2018 2019
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2020
            QEMU_CAPS_QXL_VGAMEM);
2021
    DO_TEST_CAPS_LATEST("video-qxl-sec-device-vram64");
2022 2023 2024
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2025
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2026 2027 2028
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2029 2030 2031
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2032
            QEMU_CAPS_QXL_MAX_OUTPUTS);
M
Marc-André Lureau 已提交
2033
    DO_TEST("video-virtio-gpu-device",
2034
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
2035
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2036
    DO_TEST("video-virtio-gpu-virgl",
2037
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2038
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2039
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2040 2041
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2042
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2043 2044
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
2045
            QEMU_CAPS_SPICE_RENDERNODE,
2046
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2047 2048 2049 2050 2051
    DO_TEST("video-virtio-gpu-sdl-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SDL_GL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2052 2053 2054
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2055 2056 2057
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
2058 2059
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
2060
    DO_TEST_CAPS_LATEST("video-bochs-display-device");
2061 2062 2063
    DO_TEST("video-none-device",
            QEMU_CAPS_VNC);
    DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
2064

2065 2066
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2067
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2068 2069
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2070
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2071 2072
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2073
            QEMU_CAPS_OBJECT_RNG_EGD);
J
Ján Tomko 已提交
2074 2075
    DO_TEST_CAPS_VER("virtio-rng-egd-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("virtio-rng-egd-unix");
2076 2077 2078 2079
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2080
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
2081 2082
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
2083
    DO_TEST("virtio-rng-ccw",
2084
            QEMU_CAPS_CCW,
2085 2086
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2087
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2088

2089
    DO_TEST("s390-allow-bogus-usb-none",
2090 2091 2092
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2093
    DO_TEST("s390-allow-bogus-usb-controller",
2094 2095 2096
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2097

2098
    DO_TEST("s390-panic-no-address",
2099
            QEMU_CAPS_CCW,
2100
            QEMU_CAPS_VIRTIO_S390);
2101
    DO_TEST_FAILURE("s390-panic-address",
2102
            QEMU_CAPS_CCW,
2103
            QEMU_CAPS_VIRTIO_S390);
2104
    DO_TEST("s390-panic-missing",
2105
            QEMU_CAPS_CCW,
2106
            QEMU_CAPS_VIRTIO_S390);
2107
    DO_TEST_PARSE_ERROR("s390-no-parallel",
2108
            QEMU_CAPS_CCW,
2109
            QEMU_CAPS_VIRTIO_S390);
2110
    DO_TEST("s390-serial",
2111
            QEMU_CAPS_CCW,
2112 2113 2114
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
2115
            QEMU_CAPS_CCW,
2116 2117 2118 2119
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
2120
            QEMU_CAPS_CCW,
2121 2122
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2123

2124
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2125
            QEMU_CAPS_KVM);
2126 2127
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2128

2129
    DO_TEST("tpm-passthrough",
2130
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2131 2132
    DO_TEST("tpm-passthrough-crb",
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_CRB);
2133
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2134
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2135
    DO_TEST_CAPS_LATEST("tpm-emulator");
2136
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2137
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2-enc");
2138

2139 2140 2141 2142
    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);
2143

2144 2145 2146 2147 2148 2149
    DO_TEST("pci-bridge",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autoadd-addr",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2150
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2151 2152
    DO_TEST("pci-autoadd-idx",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2153 2154
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA);
2155
    DO_TEST("pci-many",
2156
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2157
    DO_TEST("pci-bridge-many-disks",
2158
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
2159
    DO_TEST("pcie-root",
2160 2161 2162 2163
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL);
2164
    DO_TEST("q35",
2165
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2166
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2167
            QEMU_CAPS_DEVICE_IOH3420,
2168
            QEMU_CAPS_ICH9_AHCI,
2169
            QEMU_CAPS_ICH9_USB_EHCI1,
2170
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2171
            QEMU_CAPS_DEVICE_QXL);
2172 2173 2174 2175 2176 2177 2178 2179
    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);
2180
    DO_TEST("q35-pm-disable",
2181
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2182
            QEMU_CAPS_DEVICE_IOH3420,
2183 2184 2185 2186
            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",
2187
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2188
            QEMU_CAPS_DEVICE_IOH3420,
2189 2190
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
2191
    DO_TEST("q35-usb2",
2192
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2193
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2194
            QEMU_CAPS_DEVICE_IOH3420,
2195
            QEMU_CAPS_ICH9_AHCI,
2196
            QEMU_CAPS_ICH9_USB_EHCI1,
2197
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2198
            QEMU_CAPS_DEVICE_QXL);
2199
    DO_TEST("q35-usb2-multi",
2200
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2201
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2202
            QEMU_CAPS_DEVICE_IOH3420,
2203
            QEMU_CAPS_ICH9_AHCI,
2204
            QEMU_CAPS_ICH9_USB_EHCI1,
2205
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2206
            QEMU_CAPS_DEVICE_QXL);
2207
    DO_TEST("q35-usb2-reorder",
2208
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2209
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2210
            QEMU_CAPS_DEVICE_IOH3420,
2211
            QEMU_CAPS_ICH9_AHCI,
2212
            QEMU_CAPS_ICH9_USB_EHCI1,
2213
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2214
            QEMU_CAPS_DEVICE_QXL);
2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232
    /* verify that devices with pcie capability are assigned to a pcie slot */
    DO_TEST("q35-pcie",
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
2233
            QEMU_CAPS_NEC_USB_XHCI,
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
    /* same XML as q35-pcie, but don't set
     * QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, so virtio devices should
     * be assigned to legacy pci slots
     */
    DO_TEST("q35-virtio-pci",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
    /* same as q35-pcie, but all PCI controllers are added automatically */
    DO_TEST("q35-pcie-autoadd",
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
    DO_TEST("q35-default-devices-only",
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
    DO_TEST("q35-multifunction",
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2300 2301 2302 2303 2304
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2305 2306 2307 2308 2309 2310 2311 2312
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
2313
            QEMU_CAPS_NEC_USB_XHCI,
2314
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2315 2316
    DO_TEST("q35-virt-manager-basic",
            QEMU_CAPS_KVM,
2317
            QEMU_CAPS_MACHINE_VMPORT_OPT,
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
            QEMU_CAPS_ICH9_DISABLE_S3,
            QEMU_CAPS_ICH9_DISABLE_S4,
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_HDA_DUPLEX,
2342
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2343
            QEMU_CAPS_USB_REDIR);
2344 2345

    /* Test automatic and manual setting of pcie-root-port attributes */
2346 2347
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2348
            QEMU_CAPS_ICH9_AHCI,
2349
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2350
            QEMU_CAPS_DEVICE_QXL);
2351 2352 2353 2354 2355 2356

    /* Make sure the default model for PCIe Root Ports is picked correctly
     * based on QEMU binary capabilities. We use x86/q35 for the test, but
     * any PCIe machine type (such as aarch64/virt) will behave the same */
    DO_TEST("pcie-root-port-model-generic",
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
2357
            QEMU_CAPS_DEVICE_IOH3420);
2358
    DO_TEST("pcie-root-port-model-ioh3420",
2359
            QEMU_CAPS_DEVICE_IOH3420);
2360

2361 2362 2363 2364 2365 2366 2367
    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,
2368
            QEMU_CAPS_ICH9_USB_EHCI1,
2369
            QEMU_CAPS_NEC_USB_XHCI);
2370 2371 2372 2373 2374 2375 2376
    /* Make sure the user can always override libvirt's default device
     * placement policy by providing an explicit PCI address */
    DO_TEST("q35-pci-force-address",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_HDA_DUPLEX);
2377

2378
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2379
            QEMU_CAPS_DEVICE_IOH3420,
2380
            QEMU_CAPS_ICH9_AHCI,
2381
            QEMU_CAPS_ICH9_USB_EHCI1,
2382
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2383
            QEMU_CAPS_DEVICE_QXL);
2384
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2385
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2386

2387
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2388
            QEMU_CAPS_DEVICE_IOH3420,
2389
            QEMU_CAPS_ICH9_AHCI,
2390
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2391
            QEMU_CAPS_DEVICE_QXL);
2392

2393 2394 2395
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2396
            QEMU_CAPS_ICH9_AHCI,
2397
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2398
            QEMU_CAPS_DEVICE_QXL);
2399 2400 2401 2402
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2403
            QEMU_CAPS_ICH9_AHCI,
2404
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2405
            QEMU_CAPS_DEVICE_QXL);
2406

2407 2408 2409 2410 2411 2412
    DO_TEST("pci-expander-bus",
            QEMU_CAPS_DEVICE_PXB);
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-node",
                        QEMU_CAPS_DEVICE_PXB);
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-machine",
                        QEMU_CAPS_DEVICE_PXB);
2413 2414
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2415

2416 2417 2418 2419 2420 2421 2422 2423 2424 2425
    DO_TEST("pcie-expander-bus",
            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_IOH3420,
                        QEMU_CAPS_DEVICE_X3130_UPSTREAM,
                        QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2426 2427 2428
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2429

2430
    DO_TEST("hostdev-scsi-lsi",
2431 2432
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2433
    DO_TEST("hostdev-scsi-virtio-scsi",
2434 2435
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2436
    DO_TEST("hostdev-scsi-readonly",
2437 2438
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2439
    DO_TEST("hostdev-scsi-virtio-scsi",
2440 2441
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2442
    DO_TEST("hostdev-scsi-lsi-iscsi",
2443 2444
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2445
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
2446 2447
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2448
    DO_TEST("hostdev-scsi-virtio-iscsi",
2449 2450
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2451
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
2452 2453
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2454
    DO_TEST("disk-hostdev-scsi-virtio-iscsi-auth-AES",
2455 2456 2457
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_OBJECT_SECRET,
2458
            QEMU_CAPS_ISCSI_PASSWORD_SECRET);
2459 2460
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2461
            QEMU_CAPS_CCW);
2462
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
2463 2464
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VHOST_SCSI);
2465
    DO_TEST_CAPS_LATEST_PARSE_ERROR("hostdev-scsi-vhost-scsi-pci-boot-fail");
2466 2467 2468 2469 2470
    DO_TEST("hostdev-scsi-vhost-scsi-pcie",
            QEMU_CAPS_KVM,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
2471

2472 2473
    DO_TEST_CAPS_VER("mlock-on", "3.0.0");
    DO_TEST_CAPS_VER("mlock-off", "3.0.0");
2474 2475
    DO_TEST_CAPS_LATEST("mlock-on");
    DO_TEST_CAPS_LATEST("mlock-off");
2476

2477 2478 2479 2480
    DO_TEST_PARSE_ERROR("pci-bridge-negative-index-invalid", NONE);
    DO_TEST_PARSE_ERROR("pci-bridge-duplicate-index", NONE);
    DO_TEST_PARSE_ERROR("pci-root-nonzero-index", NONE);
    DO_TEST_PARSE_ERROR("pci-root-address", NONE);
2481

2482
    DO_TEST("hotplug-base",
2483
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2484

2485 2486
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
2487
    DO_TEST("pcihole64-q35",
2488
            QEMU_CAPS_DEVICE_IOH3420,
2489
            QEMU_CAPS_ICH9_AHCI,
2490
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2491
            QEMU_CAPS_DEVICE_QXL,
2492 2493
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2494 2495
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2496
    DO_TEST("arm-vexpressa9-virtio",
2497
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2498
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2499
    DO_TEST("arm-virt-virtio",
2500
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2501
            QEMU_CAPS_DEVICE_PL011,
2502
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2503

2504
    DO_TEST("aarch64-virt-virtio",
2505
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2506
            QEMU_CAPS_DEVICE_PL011,
2507
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2508 2509 2510 2511 2512 2513

    /* 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",
2514
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
2515 2516 2517
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2518
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2519
            QEMU_CAPS_DEVICE_IOH3420,
2520
            QEMU_CAPS_DEVICE_PL011,
2521
            QEMU_CAPS_VIRTIO_SCSI);
2522
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
2523
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2524 2525
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2526
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2527
            QEMU_CAPS_DEVICE_PL011,
2528
            QEMU_CAPS_DEVICE_IOH3420);
2529 2530 2531
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
2532
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2533 2534
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2535 2536 2537
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_VIRTIO_SCSI);
2538
    DO_TEST("aarch64-video-virtio-gpu-pci",
2539
            QEMU_CAPS_OBJECT_GPEX,
2540
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2541
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2542
            QEMU_CAPS_DEVICE_VIRTIO_GPU);
2543
    DO_TEST("aarch64-video-default",
2544
            QEMU_CAPS_OBJECT_GPEX,
2545
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2546
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2547 2548
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_VNC);
2549
    DO_TEST("aarch64-aavmf-virtio-mmio",
2550
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2551
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2552 2553
    DO_TEST("aarch64-virt-default-nic",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2554
    qemuTestSetHostArch(driver.caps, VIR_ARCH_AARCH64);
2555
    DO_TEST("aarch64-cpu-passthrough",
2556
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2557
            QEMU_CAPS_KVM);
2558
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
2559
            QEMU_CAPS_KVM,
2560
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2561
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
2562
            QEMU_CAPS_KVM,
2563 2564
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
2565
            QEMU_CAPS_KVM,
2566
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2567
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
2568
            QEMU_CAPS_KVM,
2569
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2570 2571
    DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2572
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
2573
            QEMU_CAPS_KVM,
2574
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2575
    DO_TEST_GIC("aarch64-gic-default-v2", GIC_V2,
2576
            QEMU_CAPS_KVM,
2577
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2578
    DO_TEST_GIC("aarch64-gic-default-v3", GIC_V3,
2579
            QEMU_CAPS_KVM,
2580
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2581
    DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
2582
            QEMU_CAPS_KVM,
2583 2584
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
2585
            QEMU_CAPS_KVM,
2586 2587
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
2588
            QEMU_CAPS_KVM,
2589 2590
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
2591
            QEMU_CAPS_KVM,
2592
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2593
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
2594
            QEMU_CAPS_KVM,
2595
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2596
    DO_TEST_FAILURE("aarch64-gic-v3",
2597
            QEMU_CAPS_KVM, NONE);
2598
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
2599
            QEMU_CAPS_KVM,
2600 2601
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
2602
            QEMU_CAPS_KVM,
2603 2604
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
2605
            QEMU_CAPS_KVM,
2606 2607
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
2608
            QEMU_CAPS_KVM,
2609
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2610
    DO_TEST_FAILURE("aarch64-gic-host",
2611
            QEMU_CAPS_KVM, NONE);
2612
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
2613
            QEMU_CAPS_KVM,
2614 2615
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
2616
            QEMU_CAPS_KVM,
2617 2618
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
2619
            QEMU_CAPS_KVM,
2620 2621
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
2622
            QEMU_CAPS_KVM,
2623
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2624
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
2625
            QEMU_CAPS_KVM,
2626
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2627
    DO_TEST_PARSE_ERROR("aarch64-gic-not-virt",
2628
                        QEMU_CAPS_KVM,
2629 2630
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_PARSE_ERROR("aarch64-gic-not-arm",
2631
                        QEMU_CAPS_KVM,
2632
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2633
    DO_TEST("aarch64-kvm-32-on-64",
2634
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2635
            QEMU_CAPS_DEVICE_PL011,
A
Andrea Bolognani 已提交
2636
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2637
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2638
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2639
            QEMU_CAPS_KVM);
2640 2641 2642 2643 2644 2645 2646
    DO_TEST("aarch64-pci-serial",
            QEMU_CAPS_DEVICE_PCI_SERIAL,
            QEMU_CAPS_CHARDEV_LOGFILE,
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT);
2647 2648 2649 2650
    DO_TEST("aarch64-traditional-pci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2651
            QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
2652 2653
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
2654 2655 2656 2657 2658 2659 2660

    /* Make sure all combinations of ACPI and UEFI behave as expected */
    DO_TEST("aarch64-acpi-uefi", NONE);
    DO_TEST("aarch64-noacpi-uefi", NONE);
    DO_TEST("aarch64-noacpi-nouefi", NONE);
    DO_TEST_PARSE_ERROR("aarch64-acpi-nouefi", NONE);

2661
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2662

2663
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2664
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2665

2666 2667 2668 2669
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2670

2671 2672
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2673

2674 2675
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2676
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2677 2678 2679
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2680
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2681
    DO_TEST_FAILURE("shmem-invalid-size",
2682
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2683
    DO_TEST_FAILURE("shmem-invalid-address",
2684
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2685
    DO_TEST_FAILURE("shmem-small-size",
2686
                    QEMU_CAPS_DEVICE_IVSHMEM);
2687
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2688
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2689

2690
    DO_TEST_FAILURE("memory-align-fail", NONE);
2691
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2692
    DO_TEST("memory-hotplug", NONE);
2693
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2694
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2695
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2696
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2697
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2698
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2699
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2700
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2701 2702 2703
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-access");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-label");
2704
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-align");
2705
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-pmem");
2706
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly");
2707

2708
    DO_TEST("machine-aeskeywrap-on-caps",
2709
            QEMU_CAPS_AES_KEY_WRAP,
2710
            QEMU_CAPS_DEA_KEY_WRAP,
2711
            QEMU_CAPS_VIRTIO_SCSI,
2712
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2713
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2714
                    QEMU_CAPS_VIRTIO_SCSI,
2715
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2716 2717 2718
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2719
            QEMU_CAPS_AES_KEY_WRAP,
2720
            QEMU_CAPS_VIRTIO_SCSI,
2721
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2722
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2723
                    QEMU_CAPS_VIRTIO_SCSI,
2724
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2725 2726 2727
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2728
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2729
            QEMU_CAPS_VIRTIO_SCSI,
2730
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2731
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2732
                    QEMU_CAPS_VIRTIO_SCSI,
2733
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2734 2735 2736
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2737
            QEMU_CAPS_AES_KEY_WRAP,
2738
            QEMU_CAPS_VIRTIO_SCSI,
2739
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2740
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2741
                    QEMU_CAPS_VIRTIO_SCSI,
2742
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2743 2744 2745
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2746
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2747
            QEMU_CAPS_VIRTIO_SCSI,
2748
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2749
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2750
                    QEMU_CAPS_VIRTIO_SCSI,
2751
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2752 2753 2754
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2755
            QEMU_CAPS_DEA_KEY_WRAP,
2756
            QEMU_CAPS_VIRTIO_SCSI,
2757
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2758
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2759
                    QEMU_CAPS_VIRTIO_SCSI,
2760
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2761 2762 2763
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2764
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2765
            QEMU_CAPS_VIRTIO_SCSI,
2766
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2767
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2768
                    QEMU_CAPS_VIRTIO_SCSI,
2769
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2770 2771 2772
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2773
            QEMU_CAPS_DEA_KEY_WRAP,
2774
            QEMU_CAPS_VIRTIO_SCSI,
2775
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2776
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2777
                    QEMU_CAPS_VIRTIO_SCSI,
2778
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2779 2780 2781
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2782
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2783
            QEMU_CAPS_VIRTIO_SCSI,
2784
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2785
    DO_TEST("machine-keywrap-none",
2786
            QEMU_CAPS_VIRTIO_SCSI,
2787
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2788

2789
    DO_TEST("machine-loadparm-s390",
2790
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2791
            QEMU_CAPS_LOADPARM);
2792
    DO_TEST("machine-loadparm-net-s390",
2793
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2794
            QEMU_CAPS_LOADPARM);
2795
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
2796
            QEMU_CAPS_CCW,
2797
            QEMU_CAPS_VIRTIO_S390,
2798 2799
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
2800
                        QEMU_CAPS_CCW,
2801
                        QEMU_CAPS_VIRTIO_S390,
2802 2803
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
2804
                        QEMU_CAPS_CCW,
2805
                        QEMU_CAPS_VIRTIO_S390,
2806 2807
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2808 2809 2810 2811 2812 2813 2814
    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);

2815
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2816
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2817
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2818

2819
    DO_TEST("ppc64-usb-controller",
2820
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2821
            QEMU_CAPS_PCI_OHCI);
2822
    DO_TEST("ppc64-usb-controller-legacy",
2823
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2824
            QEMU_CAPS_PIIX3_USB_UHCI);
2825
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci",
2826
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
2827
                 ARG_QEMU_CAPS,
2828
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2829 2830 2831 2832 2833 2834 2835
                 QEMU_CAPS_NEC_USB_XHCI,
                 QEMU_CAPS_DEVICE_QEMU_XHCI);

    DO_TEST("aarch64-usb-controller-qemu-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_QEMU_XHCI);
2836

2837 2838 2839 2840
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2841 2842 2843
    /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag
     * will avoid the error. Still, we expect qemu driver to complain about
     * missing machine error, and not crash */
2844 2845 2846 2847
    DO_TEST_FULL("missing-machine",
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE,
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE,
                 ARG_QEMU_CAPS, NONE);
2848

2849 2850 2851
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
2852 2853
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP,
2854 2855 2856 2857
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
2858
            QEMU_CAPS_SPICE_UNIX,
2859 2860 2861 2862 2863
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_SPICE_RENDERNODE,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2864
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2865
            QEMU_CAPS_CHARDEV_FILE_APPEND,
2866
            QEMU_CAPS_CCID_EMULATED,
2867
            QEMU_CAPS_VIRTIO_SCSI);
M
Marc-André Lureau 已提交
2868 2869
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2870
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
2871
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
2872
            QEMU_CAPS_USB_HUB);
2873
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
2874
                        QEMU_CAPS_USB_HUB);
2875

2876
    DO_TEST("acpi-table", NONE);
2877 2878 2879 2880 2881 2882

    DO_TEST_CAPS_LATEST("intel-iommu");
    DO_TEST_CAPS_VER("intel-iommu", "2.6.0");
    DO_TEST_CAPS_LATEST("intel-iommu-caching-mode");
    DO_TEST_CAPS_LATEST("intel-iommu-eim");
    DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb");
2883
    DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
2884
    DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
2885

2886
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2887 2888 2889
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2890 2891 2892 2893 2894 2895 2896
    DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2897 2898 2899
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2900

J
Ján Tomko 已提交
2901
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2902
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2903
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
2904
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2905
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
2906 2907
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
2908
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2909 2910
            QEMU_CAPS_KVM);

M
Marc-André Lureau 已提交
2911
    DO_TEST_CAPS_LATEST("memfd-memory-numa");
2912
    DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
M
Marc-André Lureau 已提交
2913

2914 2915 2916 2917 2918 2919 2920 2921
    DO_TEST("cpu-check-none", QEMU_CAPS_KVM);
    DO_TEST("cpu-check-partial", QEMU_CAPS_KVM);
    DO_TEST("cpu-check-full", QEMU_CAPS_KVM);
    DO_TEST("cpu-check-default-none", QEMU_CAPS_KVM);
    DO_TEST("cpu-check-default-none2", NONE);
    DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM);
    DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM);

2922 2923 2924 2925 2926 2927 2928 2929 2930
    DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
    DO_TEST("cpu-cache-disable2", QEMU_CAPS_KVM);
    DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
    DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
    DO_TEST("cpu-cache-passthrough2", QEMU_CAPS_KVM);
    DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
    DO_TEST_PARSE_ERROR("cpu-cache-emulate-l2", QEMU_CAPS_KVM);
    DO_TEST_PARSE_ERROR("cpu-cache-passthrough3", QEMU_CAPS_KVM);
    DO_TEST_PARSE_ERROR("cpu-cache-passthrough-l3", QEMU_CAPS_KVM);
M
Marc-André Lureau 已提交
2931
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2932

2933 2934 2935
    DO_TEST("user-aliases", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3,
            QEMU_CAPS_PIIX_DISABLE_S4, QEMU_CAPS_VNC,
2936
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2937
            QEMU_CAPS_HDA_DUPLEX,
2938 2939
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
2940
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2941 2942
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
2943
            QEMU_CAPS_ICH9_USB_EHCI1);
2944

2945
    DO_TEST_CAPS_VER("disk-virtio-scsi-reservations", "2.12.0");
2946
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
2947

2948
    DO_TEST_CAPS_LATEST("tseg-explicit-size");
2949 2950 2951
    DO_TEST_CAPS_LATEST_PARSE_ERROR("tseg-i440fx");
    DO_TEST_CAPS_VER_PARSE_ERROR("tseg-explicit-size", "2.10.0");
    DO_TEST_CAPS_LATEST_PARSE_ERROR("tseg-invalid-size");
2952

2953
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
2954 2955 2956 2957 2958 2959
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS,
            QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW);

2960
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
2961 2962 2963 2964 2965 2966 2967
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
            QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW,
            QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW,
            QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW);

2968 2969
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");
2970 2971
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
2972

2973
    DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
2974

L
Lubomir Rintel 已提交
2975 2976
    DO_TEST("riscv64-virt",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2977 2978
    DO_TEST("riscv64-virt-pci",
            QEMU_CAPS_OBJECT_GPEX);
L
Lubomir Rintel 已提交
2979

2980 2981 2982 2983 2984
    /* Older version checks disable-legacy usage */
    DO_TEST_CAPS_VER("virtio-transitional", "3.1.0");
    DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0");
    DO_TEST_CAPS_LATEST("virtio-transitional");
    DO_TEST_CAPS_LATEST("virtio-non-transitional");
2985
    DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-transitional-not-supported");
2986

2987 2988 2989 2990 2991 2992 2993 2994
    /* Simple headless guests for various architectures */
    DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-pseries-headless", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-headless", "riscv64");
    DO_TEST_CAPS_ARCH_LATEST("s390x-ccw-headless", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-headless", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-headless", "x86_64");

2995 2996 2997
    /* Simple guests with graphics for various architectures */
    DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-graphics", "aarch64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-pseries-graphics", "ppc64");
2998
    DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-graphics", "riscv64");
2999
    DO_TEST_CAPS_ARCH_LATEST("s390x-ccw-graphics", "s390x");
3000 3001 3002
    DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-graphics", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-graphics", "x86_64");

3003 3004 3005 3006 3007
    DO_TEST_CAPS_LATEST("os-firmware-bios");
    DO_TEST_CAPS_LATEST("os-firmware-efi");
    DO_TEST_CAPS_LATEST("os-firmware-efi-secboot");
    DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64");

A
Andrea Bolognani 已提交
3008 3009 3010
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

3011
    VIR_FREE(driver.config->nbdTLSx509certdir);
3012
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
3013
    VIR_FREE(fakerootdir);
3014
    virHashFree(capslatest);
3015
    virFileWrapperClearPrefixes();
3016

3017
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
3018 3019
}

3020
VIR_TEST_MAIN_PRELOAD(mymain,
3021 3022 3023 3024
                      VIR_TEST_MOCK("qemuxml2argv"),
                      VIR_TEST_MOCK("virrandom"),
                      VIR_TEST_MOCK("qemucpu"),
                      VIR_TEST_MOCK("virpci"))
3025

3026 3027
#else

3028 3029 3030 3031
int main(void)
{
    return EXIT_AM_SKIP;
}
3032 3033

#endif /* WITH_QEMU */