qemuxml2argvtest.c 128.2 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
static unsigned char *
J
Ján Tomko 已提交
40
fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED,
41
                   size_t *value_size,
J
Ján Tomko 已提交
42 43
                   unsigned int fakeflags G_GNUC_UNUSED,
                   unsigned int internalFlags G_GNUC_UNUSED)
44
{
45
    char *secret;
46
    secret = g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A");
47 48 49 50 51 52
    *value_size = strlen(secret);
    return (unsigned char *) secret;
}

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

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

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

76 77 78 79
static virSecretPtr
fakeSecretLookupByUUID(virConnectPtr conn,
                       const unsigned char *uuid)
{
80 81 82
    /* 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, "");
83 84
}

85
static virSecretDriver fakeSecretDriver = {
86 87
    .connectNumOfSecrets = NULL,
    .connectListSecrets = NULL,
88
    .secretLookupByUUID = fakeSecretLookupByUUID,
89 90 91 92 93 94
    .secretLookupByUsage = fakeSecretLookupByUsage,
    .secretDefineXML = NULL,
    .secretGetXMLDesc = NULL,
    .secretSetValue = NULL,
    .secretGetValue = fakeSecretGetValue,
    .secretUndefine = NULL,
95 96
};

97 98 99 100 101 102 103 104 105 106 107 108

# 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")) {
109 110
        xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir,
                                  STORAGE_POOL_XML_PATH, name);
111 112 113 114 115 116 117 118 119 120

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

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

121
 cleanup:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    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);

158
 cleanup:
159
    virStringListFree(volinfo);
160 161
    return ret;

162
 fallback:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
    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)
{
M
Michal Privoznik 已提交
188
    return g_strdup_printf("/some/%s/device/%s", vol->key, vol->name);
189 190 191 192 193
}


static char *
fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
J
Ján Tomko 已提交
194
                          unsigned int flags_unused G_GNUC_UNUSED)
195 196 197 198 199 200 201 202 203
{
    char *xmlpath = NULL;
    char *xmlbuf = NULL;

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

204 205
    xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir, STORAGE_POOL_XML_PATH,
                              pool->name);
206

207
    if (virTestLoadFile(xmlpath, &xmlbuf) < 0) {
208 209 210 211 212 213
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "failed to load XML file '%s'",
                       xmlpath);
        goto cleanup;
    }

214
 cleanup:
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    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
232
 * qemu command line.
233 234 235
 *
 * There are a few "magic" values to pass to these functions:
 *
236 237
 * 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
238 239 240
 * 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
241
 * pattern VOLUME_TYPE+VOLUME_PATH can be used to simulate a volume in a pool.
242 243 244 245 246 247 248 249 250 251 252 253
 * This creates a fake path for this volume. If the '+' sign is omitted, block
 * type is assumed.
 */
static virStorageDriver fakeStorageDriver = {
    .storagePoolLookupByName = fakeStoragePoolLookupByName,
    .storageVolLookupByName = fakeStorageVolLookupByName,
    .storagePoolGetXMLDesc = fakeStoragePoolGetXMLDesc,
    .storageVolGetPath = fakeStorageVolGetPath,
    .storageVolGetInfo = fakeStorageVolGetInfo,
    .storagePoolIsActive = fakeStoragePoolIsActive,
};

254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269

/* 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
J
Ján Tomko 已提交
270
fakeNWFilterBindingDelete(virNWFilterBindingPtr binding G_GNUC_UNUSED)
271 272 273 274 275 276 277 278 279 280
{
    return 0;
}


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

281 282 283 284

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

306
    if (ARCH_IS_X86(arch)) {
307
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, x86Models,
308
                                         G_N_ELEMENTS(x86Models),
309
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
310
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, x86Models,
311
                                         G_N_ELEMENTS(x86Models),
312
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
313 314
            return -1;

315 316 317
        if (!skipLegacy) {
            if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM,
                                             x86LegacyModels,
318
                                             G_N_ELEMENTS(x86LegacyModels),
319
                                             VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
320 321
                virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU,
                                             x86LegacyModels,
322
                                             G_N_ELEMENTS(x86LegacyModels),
323
                                             VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
324 325
                return -1;
        }
326
    } else if (ARCH_IS_ARM(arch)) {
327
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, armModels,
328
                                         G_N_ELEMENTS(armModels),
329
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
330
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, armModels,
331
                                         G_N_ELEMENTS(armModels),
332
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
333 334
            return -1;
    } else if (ARCH_IS_PPC64(arch)) {
335
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, ppc64Models,
336
                                         G_N_ELEMENTS(ppc64Models),
337
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 ||
338
            virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_QEMU, ppc64Models,
339
                                         G_N_ELEMENTS(ppc64Models),
340
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
341
            return -1;
342 343
    } else if (ARCH_IS_S390(arch)) {
        if (virQEMUCapsAddCPUDefinitions(caps, VIR_DOMAIN_VIRT_KVM, s390xModels,
344
                                         G_N_ELEMENTS(s390xModels),
345 346
                                         VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0)
            return -1;
347
    }
348 349 350 351 352

    return 0;
}


353
static int
354
testUpdateQEMUCaps(const struct testQemuInfo *info,
355 356
                   virDomainObjPtr vm,
                   virCapsPtr caps)
357
{
358
    if (!caps)
359
        return -1;
360

361 362
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

363 364
    virQEMUCapsInitQMPBasicArch(info->qemuCaps);

365 366
    if (testAddCPUModels(info->qemuCaps,
                         !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
367
        return -1;
368

369 370 371 372
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
373

374
    return 0;
375 376 377
}


378 379 380 381 382 383
static int
testCheckExclusiveFlags(int flags)
{
    virCheckFlags(FLAG_EXPECT_FAILURE |
                  FLAG_EXPECT_PARSE_ERROR |
                  FLAG_FIPS |
384
                  FLAG_REAL_CAPS |
385
                  FLAG_SKIP_LEGACY_CPUS |
386
                  FLAG_SLIRP_HELPER |
387 388
                  0, -1);

389
    VIR_EXCLUSIVE_FLAGS_RET(FLAG_REAL_CAPS, FLAG_SKIP_LEGACY_CPUS, -1);
390 391 392 393
    return 0;
}


394 395 396
static int
testCompareXMLToArgv(const void *data)
{
397
    struct testQemuInfo *info = (void *) data;
398
    char *migrateURI = NULL;
399
    char *actualargv = NULL;
400 401
    unsigned int flags = info->flags;
    unsigned int parseFlags = info->parseFlags;
E
Eric Blake 已提交
402
    int ret = -1;
403
    virDomainObjPtr vm = NULL;
404
    virDomainChrSourceDef monitor_chr;
405
    virConnectPtr conn;
J
Jiri Denemark 已提交
406
    char *log = NULL;
E
Eric Blake 已提交
407
    virCommandPtr cmd = NULL;
408
    size_t i;
409
    qemuDomainObjPrivatePtr priv = NULL;
410

411
    if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
412
        qemuTestSetHostArch(&driver, info->arch);
413

414 415
    memset(&monitor_chr, 0, sizeof(monitor_chr));

416
    if (!(conn = virGetConnect()))
417
        goto cleanup;
418

419
    conn->secretDriver = &fakeSecretDriver;
420
    conn->storageDriver = &fakeStorageDriver;
421
    conn->nwfilterDriver = &fakeNWFilterDriver;
422

423 424 425 426
    virSetConnectInterface(conn);
    virSetConnectNetwork(conn);
    virSetConnectNWFilter(conn);
    virSetConnectNodeDev(conn);
427 428 429
    virSetConnectSecret(conn);
    virSetConnectStorage(conn);

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

433 434 435
    if (testCheckExclusiveFlags(info->flags) < 0)
        goto cleanup;

436
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
437 438 439
        goto cleanup;

    if (info->migrateFrom &&
440 441
        !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                              info->migrateFd)))
442 443
        goto cleanup;

444
    if (!(vm = virDomainObjNew(driver.xmlopt)))
445
        goto cleanup;
446

447
    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
448
    if (!(vm->def = virDomainDefParseFile(info->infile,
449
                                          driver.xmlopt,
450
                                          NULL, parseFlags))) {
P
Pavel Hrdina 已提交
451
        if (flags & FLAG_EXPECT_PARSE_ERROR)
452
            goto ok;
453
        goto cleanup;
454
    }
455 456 457 458
    if (flags & FLAG_EXPECT_PARSE_ERROR) {
        VIR_TEST_DEBUG("passed instead of expected parse error");
        goto cleanup;
    }
459
    priv = vm->privateData;
460

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

464
    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
465
        VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile);
466
        goto cleanup;
467 468
    }

469
    vm->def->id = -1;
470

471
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
472
        goto cleanup;
473

474 475 476 477 478 479
    if (!(info->flags & FLAG_REAL_CAPS)) {
        if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
            goto cleanup;
        if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
            goto cleanup;
    }
480

481
    log = virTestLogContentAndReset();
482
    VIR_FREE(log);
483
    virResetLastError();
J
Jiri Denemark 已提交
484

485 486
    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
487 488 489 490

        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) {
491
            hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
492 493 494
        }
    }

495 496 497 498 499 500 501 502 503 504 505
    for (i = 0; i < vm->def->nfss; i++) {
        virDomainFSDefPtr fs = vm->def->fss[i];
        char *s;

        if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
            continue;

        s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu.vhost-fs.sock", i);
        QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s;
    }

506 507 508 509 510 511 512 513 514 515 516
    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;
    }

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

530 531 532 533 534 535 536 537 538 539
    for (i = 0; i < vm->def->nvideos; i++) {
        virDomainVideoDefPtr video = vm->def->videos[i];

        if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
            qemuDomainVideoPrivatePtr vpriv = QEMU_DOMAIN_VIDEO_PRIVATE(video);

            vpriv->vhost_user_fd = 1729;
        }
    }

540 541 542 543 544
    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 &&
545
                virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
546 547 548 549 550 551 552
                qemuSlirpPtr slirp = qemuSlirpNew();
                slirp->fd[0] = 42;
                QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp = slirp;
            }
        }
    }

553
    if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI,
P
Pavel Hrdina 已提交
554 555
                                            (flags & FLAG_FIPS), false,
                                            VIR_QEMU_PROCESS_START_COLD))) {
P
Pavel Hrdina 已提交
556 557
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
558
        goto cleanup;
J
Jiri Denemark 已提交
559
    }
560 561 562 563
    if (flags & FLAG_EXPECT_FAILURE) {
        VIR_TEST_DEBUG("passed instead of expected failure");
        goto cleanup;
    }
J
Jiri Denemark 已提交
564

565
    if (!(actualargv = virCommandToString(cmd, false)))
566
        goto cleanup;
E
Eric Blake 已提交
567

568
    if (virTestCompareToFile(actualargv, info->outfile) < 0)
569
        goto cleanup;
570

P
Pavel Hrdina 已提交
571 572
    ret = 0;

573
 ok:
574
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
575
        ret = -1;
576
        VIR_TEST_DEBUG("Error expected but there wasn't any.");
577
        goto cleanup;
P
Pavel Hrdina 已提交
578
    }
579 580 581
    if (flags & FLAG_EXPECT_FAILURE) {
        if ((log = virTestLogContentAndReset()))
            VIR_TEST_DEBUG("Got expected error: \n%s", log);
582
    }
583 584
    virResetLastError();
    ret = 0;
585

586
 cleanup:
587 588
    VIR_FREE(log);
    VIR_FREE(actualargv);
589
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
590
    virCommandFree(cmd);
591
    virObjectUnref(vm);
592 593
    virSetConnectSecret(NULL);
    virSetConnectStorage(NULL);
594
    virObjectUnref(conn);
595
    VIR_FREE(migrateURI);
596
    if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
597
        qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
598

599
    return ret;
600 601
}

602
static void
603
testInfoSetPaths(struct testQemuInfo *info,
604 605
                 const char *suffix)
{
606 607 608 609
    info->infile = g_strdup_printf("%s/qemuxml2argvdata/%s.xml",
                                   abs_srcdir, info->name);
    info->outfile = g_strdup_printf("%s/qemuxml2argvdata/%s%s.args",
                                    abs_srcdir, info->name, suffix ? suffix : "");
610 611
}

612 613
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"

614
static int
E
Eric Blake 已提交
615
mymain(void)
616
{
C
Cole Robinson 已提交
617
    int ret = 0;
618
    char *fakerootdir;
619
    virHashTablePtr capslatest = NULL;
620

621 622 623 624 625 626 627 628 629
    fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);

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

    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);

630 631 632 633 634
    /* 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. */
635 636
    if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
        perror("g_setenv");
637 638 639
        return EXIT_FAILURE;
    }

640
    if (qemuTestDriverInit(&driver) < 0)
641
        return EXIT_FAILURE;
642 643

    driver.privileged = true;
644

645
    VIR_FREE(driver.config->defaultTLSx509certdir);
646
    driver.config->defaultTLSx509certdir = g_strdup("/etc/pki/qemu");
647
    VIR_FREE(driver.config->vncTLSx509certdir);
648
    driver.config->vncTLSx509certdir = g_strdup("/etc/pki/libvirt-vnc");
649
    VIR_FREE(driver.config->spiceTLSx509certdir);
650
    driver.config->spiceTLSx509certdir = g_strdup("/etc/pki/libvirt-spice");
651
    VIR_FREE(driver.config->chardevTLSx509certdir);
652
    driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
653
    VIR_FREE(driver.config->vxhsTLSx509certdir);
654
    driver.config->vxhsTLSx509certdir = g_strdup("/etc/pki/libvirt-vxhs/dummy,path");
655
    VIR_FREE(driver.config->nbdTLSx509certdir);
656
    driver.config->nbdTLSx509certdir = g_strdup("/etc/pki/libvirt-nbd/dummy,path");
657

658
    VIR_FREE(driver.config->hugetlbfs);
659
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
660
        return EXIT_FAILURE;
661
    driver.config->nhugetlbfs = 2;
662 663
    driver.config->hugetlbfs[0].mnt_dir = g_strdup("/dev/hugepages2M");
    driver.config->hugetlbfs[1].mnt_dir = g_strdup("/dev/hugepages1G");
664 665
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
666
    driver.config->hugetlbfs[1].size = 1048576;
667
    driver.config->spiceTLS = 1;
668
    driver.config->spicePassword = g_strdup("123456");
669
    VIR_FREE(driver.config->memoryBackingDir);
670
    driver.config->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
671
    VIR_FREE(driver.config->nvramDir);
672
    driver.config->nvramDir = g_strdup("/var/lib/libvirt/qemu/nvram");
673

C
Cole Robinson 已提交
674
    capslatest = testQemuGetLatestCaps();
675
    if (!capslatest)
676 677
        return EXIT_FAILURE;

678 679 680 681 682 683 684
    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");

685 686 687 688 689 690 691 692 693 694
    virFileWrapperAddPrefix(SYSCONFDIR "/qemu/vhost-user",
                            abs_srcdir "/qemuvhostuserdata/etc/qemu/vhost-user");
    virFileWrapperAddPrefix(PREFIX "/share/qemu/vhost-user",
                            abs_srcdir "/qemuvhostuserdata/usr/share/qemu/vhost-user");
    virFileWrapperAddPrefix("/home/user/.config/qemu/vhost-user",
                            abs_srcdir "/qemuvhostuserdata/home/user/.config/qemu/vhost-user");

    virFileWrapperAddPrefix("/usr/libexec/qemu/vhost-user",
                            abs_srcdir "/qemuvhostuserdata/usr/libexec/qemu/vhost-user");

695 696 697 698 699 700 701 702 703 704 705 706 707 708
/**
 * 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.
 */
709
# define DO_TEST_INTERNAL(_name, _suffix, ...) \
710
    do { \
711
        static struct testQemuInfo info = { \
712
            .name = _name, \
713
        }; \
714 715
        if (testQemuInfoSetArgs(&info, capslatest, \
                                __VA_ARGS__, ARG_END) < 0) \
716
            return EXIT_FAILURE; \
717
        testInfoSetPaths(&info, _suffix); \
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 750
# define DO_TEST_CAPS_LATEST_PPC64(name) \
    DO_TEST_CAPS_ARCH_LATEST(name, "ppc64")

751 752
# define DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, arch) \
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \
753
                                  ARG_FLAGS, FLAG_EXPECT_FAILURE)
754

755 756 757 758 759 760 761 762 763 764 765 766
# 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, \
767
                                  ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
768

769 770 771 772 773 774 775 776 777 778
# 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)

779 780 781
# define DO_TEST_FULL(name, ...) \
    DO_TEST_INTERNAL(name, "", \
                     __VA_ARGS__, QEMU_CAPS_LAST)
782

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

790
# define DO_TEST_GIC(name, gic, ...) \
791
    DO_TEST_FULL(name, \
792
                 ARG_GIC, gic, \
793
                 ARG_QEMU_CAPS, __VA_ARGS__)
794

795
# define DO_TEST_FAILURE(name, ...) \
796 797
    DO_TEST_FULL(name, \
                 ARG_FLAGS, FLAG_EXPECT_FAILURE, \
798
                 ARG_QEMU_CAPS, __VA_ARGS__)
799

800
# define DO_TEST_PARSE_ERROR(name, ...) \
801
    DO_TEST_FULL(name, \
802
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
803
                 ARG_QEMU_CAPS, __VA_ARGS__)
804

805
# define NONE QEMU_CAPS_LAST
806

807 808 809
    /* 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 */
810 811 812 813 814 815 816 817 818
    g_setenv("PATH", "/bin", TRUE);
    g_setenv("USER", "test", TRUE);
    g_setenv("LOGNAME", "test", TRUE);
    g_setenv("HOME", "/home/test", TRUE);
    g_unsetenv("TMPDIR");
    g_unsetenv("LD_PRELOAD");
    g_unsetenv("LD_LIBRARY_PATH");
    g_unsetenv("QEMU_AUDIO_DRV");
    g_unsetenv("SDL_AUDIODRIVER");
819

820
    DO_TEST("minimal", NONE);
821 822
    DO_TEST("minimal-sandbox",
            QEMU_CAPS_SECCOMP_BLACKLIST);
823
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
824
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
825 826 827 828

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

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

    DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
    DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
873
    DO_TEST_PARSE_ERROR("reboot-timeout-enabled", NONE);
874

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

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

893
    DO_TEST("clock-utc", NONE);
894
    DO_TEST("clock-localtime", NONE);
J
Ján Tomko 已提交
895 896 897 898
    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 已提交
899
    DO_TEST("clock-catchup", QEMU_CAPS_KVM_PIT_TICK_POLICY);
900 901
    DO_TEST("cpu-kvmclock", NONE);
    DO_TEST("cpu-host-kvmclock", NONE);
902
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
903
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
904

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

932 933 934 935 936 937
    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");
938
    DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
939

940 941 942
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

943 944 945
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

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

1176 1177
    DO_TEST_CAPS_LATEST("disk-slices");

1178 1179 1180
    DO_TEST("graphics-egl-headless",
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1181 1182
    DO_TEST_CAPS_LATEST("graphics-egl-headless");
    DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
1183

1184 1185
    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);
1186 1187
    DO_TEST("graphics-vnc-websocket",
            QEMU_CAPS_VNC,
1188
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1189
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
1190 1191 1192 1193 1194
            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);
1195
    driver.config->vncAutoUnixSocket = true;
1196 1197
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1198
    driver.config->vncAutoUnixSocket = false;
1199 1200 1201 1202
    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);
1203 1204
    DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
1205

1206 1207
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1208
    driver.config->vncSASLdir = g_strdup("/root/.sasl2");
1209
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1210 1211
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1212
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1213 1214
    DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
    DO_TEST_CAPS_LATEST("graphics-vnc-tls");
1215
    driver.config->vncTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
1216 1217
    DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret");
    VIR_FREE(driver.config->vncTLSx509secretUUID);
1218
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1219 1220
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1221 1222 1223 1224
    DO_TEST("graphics-vnc-egl-headless",
            QEMU_CAPS_VNC,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1225

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

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

1348 1349 1350
    DO_TEST("hostdev-pci-multifunction",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DEVICE_VFIO_PCI);
1351

1352 1353 1354 1355
    DO_TEST("hostdev-pci-address-unassigned",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DEVICE_VFIO_PCI);

1356 1357
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1358
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1359
            QEMU_CAPS_CHARDEV_LOGFILE);
1360
    DO_TEST("serial-spiceport",
1361
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1362
            QEMU_CAPS_DEVICE_QXL,
1363
            QEMU_CAPS_SPICE,
1364
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1365
    DO_TEST("serial-spiceport-nospice", NONE);
1366

1367 1368 1369 1370
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1371 1372

    DO_TEST("serial-vc-chardev",
1373
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1374
    DO_TEST("serial-pty-chardev",
1375
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1376
    DO_TEST("serial-dev-chardev",
1377
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1378
    DO_TEST("serial-dev-chardev-iobase",
1379
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1380
    DO_TEST("serial-file-chardev",
1381
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1382
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1383
    DO_TEST("serial-unix-chardev",
1384
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1385
    DO_TEST_CAPS_LATEST("serial-unix-chardev");
1386
    DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE);
1387
    DO_TEST("serial-tcp-chardev",
1388
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1389
    DO_TEST("serial-udp-chardev",
1390
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1391
    DO_TEST("serial-tcp-telnet-chardev",
1392
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1393 1394
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1395
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1396
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1397 1398
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1399
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1400 1401
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1402
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1403
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1404
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1405
    VIR_FREE(driver.config->chardevTLSx509certdir);
1406 1407
    driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
    driver.config->chardevTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
1408 1409
    DO_TEST("serial-tcp-tlsx509-secret-chardev",
            QEMU_CAPS_OBJECT_SECRET,
1410
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1411
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1412 1413
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1414
    DO_TEST("serial-many-chardev",
1415 1416 1417
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
J
Ján Tomko 已提交
1418 1419
    DO_TEST_CAPS_VER("parallel-unix-chardev", "2.5.0");
    DO_TEST_CAPS_LATEST("parallel-unix-chardev");
1420
    DO_TEST("console-compat-chardev",
1421
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1422 1423
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1424

1425
    DO_TEST("channel-guestfwd", NONE);
J
Ján Tomko 已提交
1426 1427
    DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0");
    DO_TEST_CAPS_LATEST("channel-unix-guestfwd");
1428 1429 1430 1431 1432 1433
    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);
1434
    DO_TEST("console-virtio-many",
1435
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1436
    DO_TEST("console-virtio-s390",
1437
            QEMU_CAPS_VIRTIO_S390);
1438
    DO_TEST("console-virtio-ccw",
1439
            QEMU_CAPS_CCW,
1440
            QEMU_CAPS_VIRTIO_S390);
J
Ján Tomko 已提交
1441 1442
    DO_TEST_CAPS_VER("console-virtio-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("console-virtio-unix");
1443
    DO_TEST("console-sclp",
1444
            QEMU_CAPS_VIRTIO_S390,
1445
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1446
    DO_TEST("channel-spicevmc",
1447
            QEMU_CAPS_SPICE,
1448
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1449
    DO_TEST("channel-virtio-default",
1450
            QEMU_CAPS_SPICE);
1451
    DO_TEST("channel-virtio-unix", NONE);
1452

1453
    DO_TEST("smartcard-host",
1454
            QEMU_CAPS_CCID_EMULATED);
1455
    DO_TEST("smartcard-host-certificates",
1456
            QEMU_CAPS_CCID_EMULATED);
1457 1458
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1459
    DO_TEST("smartcard-passthrough-tcp",
1460
            QEMU_CAPS_CCID_PASSTHRU);
1461
    DO_TEST("smartcard-passthrough-spicevmc",
1462
            QEMU_CAPS_CCID_PASSTHRU);
1463
    DO_TEST("smartcard-controller",
1464
            QEMU_CAPS_CCID_EMULATED);
J
Ján Tomko 已提交
1465 1466
    DO_TEST_CAPS_VER("smartcard-passthrough-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("smartcard-passthrough-unix");
1467

1468 1469 1470 1471 1472 1473 1474 1475
    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);
1476 1477
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1478

1479
    DO_TEST("usb-controller", NONE);
1480
    DO_TEST("usb-piix3-controller",
1481
            QEMU_CAPS_PIIX3_USB_UHCI);
1482
    DO_TEST("usb-ich9-ehci-addr",
1483
            QEMU_CAPS_ICH9_USB_EHCI1);
1484
    DO_TEST("input-usbmouse-addr", NONE);
1485
    DO_TEST("usb-ich9-companion",
1486
            QEMU_CAPS_ICH9_USB_EHCI1);
1487
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1488
            QEMU_CAPS_ICH9_USB_EHCI1);
1489
    DO_TEST("usb-ich9-autoassign",
1490
            QEMU_CAPS_ICH9_USB_EHCI1,
1491
            QEMU_CAPS_USB_HUB);
1492
    DO_TEST("usb-hub",
1493
            QEMU_CAPS_USB_HUB);
1494
    DO_TEST("usb-hub-autoadd",
1495
            QEMU_CAPS_USB_HUB);
1496
    DO_TEST("usb-hub-autoadd-deluxe",
1497
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1498
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
1499
            QEMU_CAPS_USB_HUB);
1500
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
1501
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1502
    DO_TEST("usb-port-missing",
1503
            QEMU_CAPS_USB_HUB);
1504
    DO_TEST_FAILURE("usb-bus-missing",
1505
                    QEMU_CAPS_USB_HUB);
1506
    DO_TEST("usb-ports",
1507
            QEMU_CAPS_USB_HUB);
1508
    DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
1509
            QEMU_CAPS_USB_HUB);
1510
    DO_TEST("usb-port-autoassign",
1511
            QEMU_CAPS_USB_HUB);
1512
    DO_TEST("usb-redir",
1513 1514 1515
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1516
            QEMU_CAPS_SPICE);
1517
    DO_TEST("usb-redir-boot",
1518 1519 1520
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1521
            QEMU_CAPS_SPICE);
1522
    DO_TEST("usb-redir-filter",
1523 1524 1525 1526
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
1527
            QEMU_CAPS_USB_REDIR_FILTER);
1528 1529
    DO_TEST("usb-redir-filter-version",
            QEMU_CAPS_USB_REDIR,
1530
            QEMU_CAPS_SPICE,
1531
            QEMU_CAPS_USB_REDIR_FILTER);
J
Ján Tomko 已提交
1532 1533
    DO_TEST_CAPS_VER("usb-redir-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("usb-redir-unix");
1534
    DO_TEST("usb1-usb2",
1535 1536 1537
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1);
1538 1539
    DO_TEST("usb-none", NONE);
    DO_TEST_PARSE_ERROR("usb-none-other", NONE);
1540 1541
    DO_TEST_PARSE_ERROR("usb-none-hub",
            QEMU_CAPS_USB_HUB);
1542
    DO_TEST_PARSE_ERROR("usb-none-usbtablet", NONE);
1543
    DO_TEST("usb-controller-default-q35",
1544
            QEMU_CAPS_DEVICE_IOH3420,
1545 1546 1547
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1548
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1549
                    QEMU_CAPS_DEVICE_IOH3420,
1550
                    QEMU_CAPS_PCI_OHCI,
1551 1552
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1553
            QEMU_CAPS_DEVICE_IOH3420,
1554 1555 1556
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1557
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1558
                    QEMU_CAPS_DEVICE_IOH3420,
1559
                    QEMU_CAPS_PCI_OHCI,
1560
                    QEMU_CAPS_PIIX3_USB_UHCI);
1561
    DO_TEST("usb-controller-xhci",
1562 1563 1564
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1565
    DO_TEST("usb-xhci-autoassign",
1566 1567 1568
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS,
1569
            QEMU_CAPS_USB_HUB);
1570
    DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
1571 1572 1573
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1574 1575 1576 1577
    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);
1578

1579 1580 1581
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1582

1583
    DO_TEST("watchdog", NONE);
1584
    DO_TEST("watchdog-device", NONE);
1585
    DO_TEST("watchdog-dump", NONE);
1586
    DO_TEST("watchdog-injectnmi", NONE);
1587
    DO_TEST("watchdog-diag288", QEMU_CAPS_VIRTIO_S390);
1588 1589
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1590
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1591
    DO_TEST("balloon-ccw-deflate",
1592
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1593
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1594
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1595
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1596
    DO_TEST("balloon-device-deflate-off",
1597
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1598 1599
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1600 1601
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1602
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1603
            QEMU_CAPS_HDA_OUTPUT,
1604 1605
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1606
    DO_TEST("fs9p", NONE);
1607
    DO_TEST_CAPS_LATEST("fs9p");
1608
    DO_TEST("fs9p-ccw",
1609
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1610
    DO_TEST_CAPS_ARCH_LATEST("fs9p-ccw", "s390x");
1611

1612
    DO_TEST("hostdev-usb-address", NONE);
1613
    DO_TEST("hostdev-usb-address-device", NONE);
1614
    DO_TEST("hostdev-usb-address-device-boot", NONE);
1615 1616
    DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI);
1617 1618
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1619
    DO_TEST("hostdev-vfio-multidomain",
1620
            QEMU_CAPS_DEVICE_VFIO_PCI);
1621 1622 1623 1624 1625 1626
    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);
1627 1628 1629 1630 1631 1632 1633
    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);
1634
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb");
1635 1636
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1637 1638 1639
    DO_TEST("hostdev-vfio-zpci",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
    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);
1653
    DO_TEST("pci-rom", QEMU_CAPS_DEVICE_VFIO_PCI);
1654
    DO_TEST("pci-rom-disabled", NONE);
1655
    DO_TEST("pci-rom-disabled-invalid", NONE);
1656

1657 1658 1659 1660
    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
1661 1662
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
                             "s390x");
1663 1664 1665
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw",
                        QEMU_CAPS_CCW,
                        QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
1666 1667 1668 1669 1670 1671 1672 1673 1674
    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 已提交
1675 1676
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ap",
                             "s390x");
1677 1678
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ap-boot-fail",
                                         "s390x");
B
Boris Fiuczynski 已提交
1679

1680
    DO_TEST_FULL("restore-v2",
1681 1682
                 ARG_MIGRATE_FROM, "exec:cat",
                 ARG_MIGRATE_FD, 7,
1683
                 ARG_QEMU_CAPS, NONE);
1684
    DO_TEST_FULL("restore-v2-fd",
1685 1686
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1687
                 ARG_QEMU_CAPS, NONE);
1688
    DO_TEST_FULL("restore-v2-fd",
1689 1690
                 ARG_MIGRATE_FROM, "fd:7",
                 ARG_MIGRATE_FD, 7,
1691
                 ARG_QEMU_CAPS, NONE);
1692
    DO_TEST_FULL("migrate",
1693
                 ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000",
1694
                 ARG_QEMU_CAPS, NONE);
1695

1696
    DO_TEST_FULL("migrate-numa-unaligned",
1697 1698
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1699
                 ARG_QEMU_CAPS,
A
Andrea Bolognani 已提交
1700 1701
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1702

1703 1704
    DO_TEST_CAPS_VER("qemu-ns", "4.0.0");
    DO_TEST_CAPS_LATEST("qemu-ns");
1705
    DO_TEST("qemu-ns-no-env", NONE);
1706
    DO_TEST("qemu-ns-alt", NONE);
1707

1708
    DO_TEST("smp", NONE);
1709
    DO_TEST("smp-dies", QEMU_CAPS_SMP_DIES);
1710

J
John Ferlan 已提交
1711
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1712 1713
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1714
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1715 1716
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1717
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1718 1719
    DO_TEST_CAPS_LATEST("iothreads-virtio-scsi-pci");
    DO_TEST_CAPS_ARCH_LATEST("iothreads-virtio-scsi-ccw", "s390x");
J
John Ferlan 已提交
1720

1721 1722
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1723
    DO_TEST("cpu-topology3", NONE);
1724 1725 1726 1727 1728 1729 1730 1731
    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);
1732
    DO_TEST("cpu-no-removed-features", QEMU_CAPS_KVM);
1733
    DO_TEST("cpu-numa1", NONE);
1734 1735
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1736
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1737
    DO_TEST_PARSE_ERROR("cpu-numa-disjoint", NONE);
1738
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1739
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
1740
    DO_TEST_PARSE_ERROR("cpu-numa-memshared", NONE);
1741
    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
1742
    DO_TEST("cpu-host-model", NONE);
1743
    DO_TEST("cpu-host-model-vendor", NONE);
1744
    DO_TEST_FULL("cpu-host-model-fallback",
1745
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS,
1746
                 ARG_QEMU_CAPS, NONE);
1747
    DO_TEST_FULL("cpu-host-model-nofallback",
1748
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS | FLAG_EXPECT_FAILURE,
1749
                 ARG_QEMU_CAPS, NONE);
A
Andrea Bolognani 已提交
1750 1751
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1752

1753
    qemuTestSetHostArch(&driver, VIR_ARCH_S390X);
1754
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1755 1756
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1757
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
1758

1759
    qemuTestSetHostCPU(&driver, driver.hostarch, cpuHaswell);
1760 1761 1762 1763
    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);
1764
    DO_TEST("cpu-host-model-cmt", NONE);
1765
    DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
1766
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1767
    DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
1768 1769
    DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
    DO_TEST_CAPS_LATEST("cpu-translation");
1770
    qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
1771

1772 1773
    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);
1774
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1775
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1776 1777
    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);
1778
    DO_TEST_CAPS_LATEST("luks-disks-source-qcow2");
1779
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1780
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1781

1782 1783 1784 1785 1786 1787 1788 1789
    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);
1790
    DO_TEST("cputune-numatune",
1791
            QEMU_CAPS_KVM,
1792
            QEMU_CAPS_OBJECT_IOTHREAD,
1793 1794
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1795 1796 1797
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1798

1799
    DO_TEST("numatune-memory", NONE);
1800
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1801 1802 1803
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1804
    DO_TEST_PARSE_ERROR("numatune-memnode", NONE);
1805

A
Andrea Bolognani 已提交
1806 1807 1808
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1809
    DO_TEST_PARSE_ERROR("numatune-memnode-no-memory", NONE);
1810

1811 1812
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1813
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1814 1815
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1816 1817
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1818 1819
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1820 1821
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1822
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1823 1824 1825
    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);
1826 1827 1828 1829 1830 1831
    DO_TEST_CAPS_VER("blkdeviotune-max", "4.1.0");
    DO_TEST_CAPS_LATEST("blkdeviotune-max");
    DO_TEST_CAPS_VER("blkdeviotune-group-num", "4.1.0");
    DO_TEST_CAPS_LATEST("blkdeviotune-group-num");
    DO_TEST_CAPS_VER("blkdeviotune-max-length", "4.1.0");
    DO_TEST_CAPS_LATEST("blkdeviotune-max-length");
1832

1833
    DO_TEST("multifunction-pci-device",
1834
            QEMU_CAPS_SCSI_LSI);
1835

1836
    DO_TEST("monitor-json", NONE);
1837

1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849
    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);
1850

1851
    DO_TEST("pseries-basic",
1852
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1853
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1854
    DO_TEST("pseries-vio",
1855
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1856
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1857
    DO_TEST("pseries-usb-default",
1858
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1859
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1860
            QEMU_CAPS_PIIX3_USB_UHCI,
1861
            QEMU_CAPS_PCI_OHCI);
1862
    DO_TEST("pseries-usb-multi",
1863
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1864
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1865
            QEMU_CAPS_PIIX3_USB_UHCI,
1866
            QEMU_CAPS_PCI_OHCI);
1867
    DO_TEST("pseries-vio-user-assigned",
1868
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1869 1870
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash", NONE);
1871 1872 1873
    DO_TEST("pseries-nvram",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_DEVICE_NVRAM);
1874
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1875
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1876
            QEMU_CAPS_DEVICE_USB_KBD,
1877
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1878
    DO_TEST("pseries-cpu-exact",
1879
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1880 1881
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE);
1882

1883
    qemuTestSetHostArch(&driver, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1884
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1885
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1886
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1887 1888 1889
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
1890
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1891
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1892
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1893
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1894 1895 1896
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
1897

1898
    qemuTestSetHostCPU(&driver, driver.hostarch, cpuPower9);
1899
    DO_TEST("pseries-cpu-compat-power9",
1900
            QEMU_CAPS_KVM,
1901
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1902
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1903
    qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
1904

1905
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
1906

1907
    DO_TEST("pseries-panic-missing",
1908
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1909
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1910
    DO_TEST("pseries-panic-no-address",
1911
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1912
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1913
    DO_TEST_FAILURE("pseries-panic-address",
1914
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1915 1916 1917 1918 1919

    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);
1920 1921 1922 1923 1924 1925
    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);
1926 1927 1928
    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);
1929

1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
    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);

1952
    DO_TEST("pseries-features",
1953
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1954
            QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
1955
            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
1956
            QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
1957
            QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
1958
            QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
1959
            QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
1960
            QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
1961
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1962 1963 1964 1965 1966 1967 1968

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
1969
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
1970
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
1971 1972
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
1973 1974 1975 1976 1977 1978 1979

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
1980
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
1981
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
1982
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
1983 1984 1985 1986 1987 1988 1989 1990
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_HTM */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
1991
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
1992
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
1993
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
1994 1995 1996 1997 1998 1999 2000 2001
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2002
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2003
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2004
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2005 2006 2007 2008 2009 2010 2011 2012
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
2013
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2014
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2015
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2016 2017
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

2018 2019 2020 2021 2022 2023 2024
    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_CFPC */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
2025
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2026 2027
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
2028 2029 2030 2031 2032 2033 2034 2035 2036

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_SBBC */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);

    /* parse error: no QEMU_CAPS_MACHINE_PSERIES_IBS */
    DO_TEST_PARSE_ERROR("pseries-features",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC);
2050

A
Andrea Bolognani 已提交
2051
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
2052

2053
    DO_TEST("pseries-serial-native",
2054
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2055 2056
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
2057
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2058 2059
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
2060
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2061
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2062
    DO_TEST("pseries-serial-pci",
2063
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2064 2065
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
2066
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2067 2068
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
2069
    DO_TEST("pseries-console-native",
2070
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2071 2072
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
2073
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
2074
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
2075
    DO_TEST_PARSE_ERROR("pseries-spaprvio-invalid", "ppc64");
2076

2077
    DO_TEST("mach-virt-serial-native",
2078
            QEMU_CAPS_DEVICE_PL011);
2079
    DO_TEST("mach-virt-serial+console-native",
2080
            QEMU_CAPS_DEVICE_PL011);
2081
    DO_TEST("mach-virt-serial-compat",
2082
            QEMU_CAPS_DEVICE_PL011);
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094
    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",
2095
            QEMU_CAPS_DEVICE_PL011);
2096 2097
    DO_TEST("mach-virt-console-virtio",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2098 2099
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

2100 2101
    DO_TEST("disk-ide-split", NONE);
    DO_TEST("disk-ide-wwn", QEMU_CAPS_IDE_DRIVE_WWN);
2102

2103
    DO_TEST("disk-geometry", NONE);
2104
    DO_TEST("disk-blockio", QEMU_CAPS_BLOCKIO);
2105

2106
    DO_TEST("video-device-pciaddr-default",
2107 2108
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
2109
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2110
            QEMU_CAPS_DEVICE_QXL);
2111
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
2112
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
2113
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2114
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
2115
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
2116
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
2117
    DO_TEST("video-qxl-device",
2118
            QEMU_CAPS_DEVICE_QXL,
2119
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2120
    DO_TEST("video-qxl-device-vgamem",
2121
            QEMU_CAPS_DEVICE_QXL,
2122
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2123
            QEMU_CAPS_QXL_VGAMEM);
2124
    DO_TEST_CAPS_LATEST("video-qxl-device-vram64");
2125
    DO_TEST("video-qxl-sec-device",
2126
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2127
    DO_TEST("video-qxl-sec-device-vgamem",
2128 2129
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2130
            QEMU_CAPS_QXL_VGAMEM);
2131
    DO_TEST_CAPS_LATEST("video-qxl-sec-device-vram64");
2132 2133 2134
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2135
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2136 2137 2138
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2139 2140 2141
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2142
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2143 2144 2145 2146
    DO_TEST("video-qxl-resolution",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_VGAMEM);
M
Marc-André Lureau 已提交
2147
    DO_TEST("video-virtio-gpu-device",
2148
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
2149
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2150
    DO_TEST("video-virtio-gpu-virgl",
2151
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2152
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2153
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2154 2155
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2156
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2157 2158
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
2159
            QEMU_CAPS_SPICE_RENDERNODE,
2160
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2161 2162 2163 2164 2165
    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);
2166 2167 2168
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2169 2170 2171
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
2172 2173
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
2174
    DO_TEST_CAPS_LATEST("video-bochs-display-device");
2175
    DO_TEST_CAPS_LATEST("video-ramfb-display-device");
2176 2177 2178
    DO_TEST("video-none-device",
            QEMU_CAPS_VNC);
    DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
2179
    DO_TEST_PARSE_ERROR("default-video-type-x86_64-caps-test-0", NONE);
2180

2181 2182 2183 2184 2185
    DO_TEST_CAPS_ARCH_LATEST("default-video-type-aarch64", "aarch64");
    DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("default-video-type-riscv64", "riscv64");
    DO_TEST_CAPS_ARCH_LATEST("default-video-type-s390x", "s390x");

2186 2187
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2188
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2189 2190
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2191
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2192 2193
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2194
            QEMU_CAPS_OBJECT_RNG_EGD);
H
Han Han 已提交
2195
    DO_TEST_CAPS_LATEST("virtio-rng-builtin");
J
Ján Tomko 已提交
2196 2197
    DO_TEST_CAPS_VER("virtio-rng-egd-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("virtio-rng-egd-unix");
2198 2199 2200 2201
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2202
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
2203 2204
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
2205
    DO_TEST("virtio-rng-ccw",
2206
            QEMU_CAPS_CCW,
2207 2208
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2209
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2210

2211
    DO_TEST("s390-allow-bogus-usb-none",
2212 2213 2214
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2215
    DO_TEST("s390-allow-bogus-usb-controller",
2216 2217 2218
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2219

2220
    DO_TEST("s390-panic-no-address",
2221
            QEMU_CAPS_CCW,
2222
            QEMU_CAPS_VIRTIO_S390);
2223
    DO_TEST_FAILURE("s390-panic-address",
2224
            QEMU_CAPS_CCW,
2225
            QEMU_CAPS_VIRTIO_S390);
2226
    DO_TEST("s390-panic-missing",
2227
            QEMU_CAPS_CCW,
2228
            QEMU_CAPS_VIRTIO_S390);
2229
    DO_TEST_PARSE_ERROR("s390-no-parallel",
2230
            QEMU_CAPS_CCW,
2231
            QEMU_CAPS_VIRTIO_S390);
2232
    DO_TEST("s390-serial",
2233
            QEMU_CAPS_CCW,
2234 2235 2236
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
2237
            QEMU_CAPS_CCW,
2238 2239 2240 2241
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
2242
            QEMU_CAPS_CCW,
2243 2244
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2245

2246
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2247
            QEMU_CAPS_KVM);
2248 2249
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2250

2251 2252
    DO_TEST_CAPS_LATEST("tpm-passthrough");
    DO_TEST_CAPS_LATEST("tpm-passthrough-crb");
2253
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2254
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2255
    DO_TEST_CAPS_LATEST("tpm-emulator");
2256
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2257
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2-enc");
2258
    DO_TEST_CAPS_LATEST_PPC64("tpm-emulator-spapr");
2259

2260 2261 2262 2263
    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);
2264

2265 2266 2267 2268 2269 2270
    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,
2271
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2272 2273
    DO_TEST("pci-autoadd-idx",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2274 2275
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA);
2276
    DO_TEST("pci-many",
2277
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2278
    DO_TEST("pci-bridge-many-disks",
2279
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
2280
    DO_TEST("pcie-root",
2281 2282 2283 2284
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL);
2285
    DO_TEST("q35",
2286
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2287
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2288
            QEMU_CAPS_DEVICE_IOH3420,
2289
            QEMU_CAPS_ICH9_AHCI,
2290
            QEMU_CAPS_ICH9_USB_EHCI1,
2291
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2292
            QEMU_CAPS_DEVICE_QXL);
2293 2294 2295 2296 2297 2298 2299 2300
    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);
2301
    DO_TEST("q35-pm-disable",
2302
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2303
            QEMU_CAPS_DEVICE_IOH3420,
2304 2305 2306 2307
            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",
2308
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2309
            QEMU_CAPS_DEVICE_IOH3420,
2310 2311
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
2312
    DO_TEST("q35-usb2",
2313
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2314
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2315
            QEMU_CAPS_DEVICE_IOH3420,
2316
            QEMU_CAPS_ICH9_AHCI,
2317
            QEMU_CAPS_ICH9_USB_EHCI1,
2318
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2319
            QEMU_CAPS_DEVICE_QXL);
2320
    DO_TEST("q35-usb2-multi",
2321
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2322
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2323
            QEMU_CAPS_DEVICE_IOH3420,
2324
            QEMU_CAPS_ICH9_AHCI,
2325
            QEMU_CAPS_ICH9_USB_EHCI1,
2326
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2327
            QEMU_CAPS_DEVICE_QXL);
2328
    DO_TEST("q35-usb2-reorder",
2329
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2330
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2331
            QEMU_CAPS_DEVICE_IOH3420,
2332
            QEMU_CAPS_ICH9_AHCI,
2333
            QEMU_CAPS_ICH9_USB_EHCI1,
2334
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2335
            QEMU_CAPS_DEVICE_QXL);
2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353
    /* 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,
2354
            QEMU_CAPS_NEC_USB_XHCI,
2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367
            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,
2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387
            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,
2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401
            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,
2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420
            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,
2421 2422 2423 2424 2425
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2426 2427 2428 2429 2430 2431 2432 2433
            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,
2434
            QEMU_CAPS_NEC_USB_XHCI,
2435
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2436 2437
    DO_TEST("q35-virt-manager-basic",
            QEMU_CAPS_KVM,
2438
            QEMU_CAPS_MACHINE_VMPORT_OPT,
2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462
            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,
2463
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2464
            QEMU_CAPS_USB_REDIR);
2465 2466

    /* Test automatic and manual setting of pcie-root-port attributes */
2467 2468
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2469
            QEMU_CAPS_ICH9_AHCI,
2470
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2471
            QEMU_CAPS_DEVICE_QXL);
2472 2473 2474 2475 2476 2477

    /* 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,
2478
            QEMU_CAPS_DEVICE_IOH3420);
2479
    DO_TEST("pcie-root-port-model-ioh3420",
2480
            QEMU_CAPS_DEVICE_IOH3420);
2481
    DO_TEST_CAPS_LATEST("pcie-root-port-nohotplug");
2482

2483 2484 2485 2486 2487 2488 2489
    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,
2490
            QEMU_CAPS_ICH9_USB_EHCI1,
2491
            QEMU_CAPS_NEC_USB_XHCI);
2492 2493 2494 2495 2496 2497 2498
    /* 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);
2499

2500
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2501
            QEMU_CAPS_DEVICE_IOH3420,
2502
            QEMU_CAPS_ICH9_AHCI,
2503
            QEMU_CAPS_ICH9_USB_EHCI1,
2504
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2505
            QEMU_CAPS_DEVICE_QXL);
2506
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2507
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2508

2509
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2510
            QEMU_CAPS_DEVICE_IOH3420,
2511
            QEMU_CAPS_ICH9_AHCI,
2512
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2513
            QEMU_CAPS_DEVICE_QXL);
2514

2515 2516 2517
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2518
            QEMU_CAPS_ICH9_AHCI,
2519
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2520
            QEMU_CAPS_DEVICE_QXL);
2521 2522 2523 2524
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2525
            QEMU_CAPS_ICH9_AHCI,
2526
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2527
            QEMU_CAPS_DEVICE_QXL);
2528

2529 2530 2531 2532 2533 2534
    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);
2535 2536
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2537

2538 2539 2540 2541 2542 2543 2544 2545 2546 2547
    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);
2548 2549 2550
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2551

2552
    DO_TEST("hostdev-scsi-lsi",
2553 2554
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2555
    DO_TEST("hostdev-scsi-virtio-scsi",
2556 2557
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2558
    DO_TEST("hostdev-scsi-readonly",
2559 2560
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2561
    DO_TEST("hostdev-scsi-virtio-scsi",
2562 2563
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2564
    DO_TEST("hostdev-scsi-lsi-iscsi",
2565 2566
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2567
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
2568 2569
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2570
    DO_TEST("hostdev-scsi-virtio-iscsi",
2571 2572
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2573
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
2574 2575
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI);
2576
    DO_TEST("disk-hostdev-scsi-virtio-iscsi-auth-AES",
2577 2578 2579
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_OBJECT_SECRET,
2580
            QEMU_CAPS_ISCSI_PASSWORD_SECRET);
2581 2582
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2583
            QEMU_CAPS_CCW);
2584
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
2585 2586
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VHOST_SCSI);
2587
    DO_TEST_CAPS_LATEST_PARSE_ERROR("hostdev-scsi-vhost-scsi-pci-boot-fail");
2588 2589 2590 2591 2592
    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);
2593

2594 2595
    DO_TEST_CAPS_VER("mlock-on", "3.0.0");
    DO_TEST_CAPS_VER("mlock-off", "3.0.0");
2596 2597
    DO_TEST_CAPS_LATEST("mlock-on");
    DO_TEST_CAPS_LATEST("mlock-off");
2598

2599 2600 2601 2602
    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);
2603

2604
    DO_TEST("hotplug-base",
2605
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2606

2607
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
2608
    DO_TEST_PARSE_ERROR("pcihole64-none", NONE);
2609
    DO_TEST("pcihole64-q35",
2610
            QEMU_CAPS_DEVICE_IOH3420,
2611
            QEMU_CAPS_ICH9_AHCI,
2612
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2613
            QEMU_CAPS_DEVICE_QXL,
2614 2615
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2616 2617
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2618
    DO_TEST("arm-vexpressa9-virtio",
2619
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2620
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2621
    DO_TEST("arm-virt-virtio",
2622
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2623
            QEMU_CAPS_DEVICE_PL011,
2624
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2625

2626
    DO_TEST("aarch64-virt-virtio",
2627
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2628
            QEMU_CAPS_DEVICE_PL011,
2629
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2630 2631 2632 2633 2634 2635

    /* 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",
2636
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
2637 2638 2639
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2640
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2641
            QEMU_CAPS_DEVICE_IOH3420,
2642
            QEMU_CAPS_DEVICE_PL011,
2643
            QEMU_CAPS_VIRTIO_SCSI);
2644
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
2645
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2646 2647
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2648
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2649
            QEMU_CAPS_DEVICE_PL011,
2650
            QEMU_CAPS_DEVICE_IOH3420);
2651 2652 2653
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
2654
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2655 2656
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2657 2658 2659
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_VIRTIO_SCSI);
2660
    DO_TEST("aarch64-video-virtio-gpu-pci",
2661
            QEMU_CAPS_OBJECT_GPEX,
2662
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2663
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2664
            QEMU_CAPS_DEVICE_VIRTIO_GPU);
2665
    DO_TEST("aarch64-video-default",
2666
            QEMU_CAPS_OBJECT_GPEX,
2667
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2668
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2669 2670
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_VNC);
2671
    DO_TEST("aarch64-aavmf-virtio-mmio",
2672
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2673
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2674 2675
    DO_TEST("aarch64-virt-default-nic",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2676
    qemuTestSetHostArch(&driver, VIR_ARCH_AARCH64);
2677
    DO_TEST("aarch64-cpu-passthrough",
2678
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2679
            QEMU_CAPS_KVM);
2680
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
2681
            QEMU_CAPS_KVM,
2682
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2683
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
2684
            QEMU_CAPS_KVM,
2685 2686
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
2687
            QEMU_CAPS_KVM,
2688
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2689
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
2690
            QEMU_CAPS_KVM,
2691
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2692 2693
    DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2694
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
2695
            QEMU_CAPS_KVM,
2696
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2697
    DO_TEST_GIC("aarch64-gic-default-v2", GIC_V2,
2698
            QEMU_CAPS_KVM,
2699
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2700
    DO_TEST_GIC("aarch64-gic-default-v3", GIC_V3,
2701
            QEMU_CAPS_KVM,
2702
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2703
    DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
2704
            QEMU_CAPS_KVM,
2705 2706
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
2707
            QEMU_CAPS_KVM,
2708 2709
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
2710
            QEMU_CAPS_KVM,
2711 2712
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
2713
            QEMU_CAPS_KVM,
2714
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2715
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
2716
            QEMU_CAPS_KVM,
2717
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2718
    DO_TEST_FAILURE("aarch64-gic-v3",
2719
            QEMU_CAPS_KVM, NONE);
2720
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
2721
            QEMU_CAPS_KVM,
2722 2723
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
2724
            QEMU_CAPS_KVM,
2725 2726
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
2727
            QEMU_CAPS_KVM,
2728 2729
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
2730
            QEMU_CAPS_KVM,
2731
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2732
    DO_TEST_FAILURE("aarch64-gic-host",
2733
            QEMU_CAPS_KVM, NONE);
2734
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
2735
            QEMU_CAPS_KVM,
2736 2737
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
2738
            QEMU_CAPS_KVM,
2739 2740
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
2741
            QEMU_CAPS_KVM,
2742 2743
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
2744
            QEMU_CAPS_KVM,
2745
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2746
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
2747
            QEMU_CAPS_KVM,
2748
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2749
    DO_TEST_PARSE_ERROR("aarch64-gic-not-virt",
2750
                        QEMU_CAPS_KVM,
2751 2752
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_PARSE_ERROR("aarch64-gic-not-arm",
2753
                        QEMU_CAPS_KVM,
2754
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2755
    DO_TEST("aarch64-kvm-32-on-64",
2756
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2757
            QEMU_CAPS_DEVICE_PL011,
A
Andrea Bolognani 已提交
2758
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2759
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2760
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2761
            QEMU_CAPS_KVM);
2762 2763 2764 2765 2766 2767 2768
    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);
2769 2770 2771 2772
    DO_TEST("aarch64-traditional-pci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2773
            QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
2774 2775
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
2776 2777 2778 2779 2780 2781 2782

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

2783 2784 2785 2786 2787 2788 2789 2790 2791
    /* QEMU 4.0.0 didn't have support for aarch64 CPU features */
    DO_TEST_CAPS_ARCH_VER_FAILURE("aarch64-features-sve", "aarch64", "4.0.0");
    /* aarch64 doesn't support the same CPU features as x86 */
    DO_TEST_CAPS_ARCH_LATEST_FAILURE("aarch64-features-wrong", "aarch64");
    /* Can't enable vector lengths when SVE is overall disabled */
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("aarch64-features-sve-disabled", "aarch64");
    /* SVE aarch64 CPU features work on modern QEMU */
    DO_TEST_CAPS_ARCH_LATEST("aarch64-features-sve", "aarch64");

2792 2793
    DO_TEST_CAPS_ARCH_LATEST("clock-timer-armvtimer", "aarch64");

2794
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
2795

2796
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2797
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2798

2799 2800 2801 2802
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2803

2804 2805
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2806

2807 2808
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2809
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2810 2811 2812
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2813
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2814
    DO_TEST_FAILURE("shmem-invalid-size",
2815
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2816
    DO_TEST_FAILURE("shmem-invalid-address",
2817
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2818
    DO_TEST_FAILURE("shmem-small-size",
2819
                    QEMU_CAPS_DEVICE_IVSHMEM);
2820
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2821
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2822

2823
    DO_TEST_FAILURE("memory-align-fail", NONE);
2824
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2825
    DO_TEST("memory-hotplug", NONE);
2826
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2827
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2828
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2829
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2830
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2831
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2832
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2833
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2834 2835 2836
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-access");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-label");
2837
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-align");
2838
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-pmem");
2839
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly");
2840
    DO_TEST_CAPS_ARCH_LATEST("memory-hotplug-nvdimm-ppc64", "ppc64");
2841

2842
    DO_TEST("machine-aeskeywrap-on-caps",
2843
            QEMU_CAPS_AES_KEY_WRAP,
2844
            QEMU_CAPS_DEA_KEY_WRAP,
2845
            QEMU_CAPS_VIRTIO_SCSI,
2846
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2847
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2848
                    QEMU_CAPS_VIRTIO_SCSI,
2849
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2850 2851 2852
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2853
            QEMU_CAPS_AES_KEY_WRAP,
2854
            QEMU_CAPS_VIRTIO_SCSI,
2855
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2856
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2857
                    QEMU_CAPS_VIRTIO_SCSI,
2858
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2859 2860 2861
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2862
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2863
            QEMU_CAPS_VIRTIO_SCSI,
2864
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2865
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2866
                    QEMU_CAPS_VIRTIO_SCSI,
2867
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2868 2869 2870
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2871
            QEMU_CAPS_AES_KEY_WRAP,
2872
            QEMU_CAPS_VIRTIO_SCSI,
2873
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2874
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2875
                    QEMU_CAPS_VIRTIO_SCSI,
2876
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2877 2878 2879
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2880
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2881
            QEMU_CAPS_VIRTIO_SCSI,
2882
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2883
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2884
                    QEMU_CAPS_VIRTIO_SCSI,
2885
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2886 2887 2888
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2889
            QEMU_CAPS_DEA_KEY_WRAP,
2890
            QEMU_CAPS_VIRTIO_SCSI,
2891
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2892
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2893
                    QEMU_CAPS_VIRTIO_SCSI,
2894
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2895 2896 2897
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2898
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2899
            QEMU_CAPS_VIRTIO_SCSI,
2900
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2901
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2902
                    QEMU_CAPS_VIRTIO_SCSI,
2903
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2904 2905 2906
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2907
            QEMU_CAPS_DEA_KEY_WRAP,
2908
            QEMU_CAPS_VIRTIO_SCSI,
2909
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2910
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2911
                    QEMU_CAPS_VIRTIO_SCSI,
2912
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2913 2914 2915
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2916
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2917
            QEMU_CAPS_VIRTIO_SCSI,
2918
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2919
    DO_TEST("machine-keywrap-none",
2920
            QEMU_CAPS_VIRTIO_SCSI,
2921
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2922

2923
    DO_TEST("machine-loadparm-s390",
2924
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2925
            QEMU_CAPS_LOADPARM);
2926
    DO_TEST("machine-loadparm-net-s390",
2927
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2928
            QEMU_CAPS_LOADPARM);
2929
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
2930
            QEMU_CAPS_CCW,
2931
            QEMU_CAPS_VIRTIO_S390,
2932 2933
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
2934
                        QEMU_CAPS_CCW,
2935
                        QEMU_CAPS_VIRTIO_S390,
2936 2937
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
2938
                        QEMU_CAPS_CCW,
2939
                        QEMU_CAPS_VIRTIO_S390,
2940 2941
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2942 2943 2944 2945 2946 2947 2948
    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);

2949
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2950
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2951
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2952

2953
    DO_TEST("ppc64-usb-controller",
2954
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2955
            QEMU_CAPS_PCI_OHCI);
2956
    DO_TEST("ppc64-usb-controller-legacy",
2957
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2958
            QEMU_CAPS_PIIX3_USB_UHCI);
2959
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci",
2960
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
2961
                 ARG_QEMU_CAPS,
2962
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2963 2964 2965 2966 2967 2968 2969
                 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);
2970

2971 2972 2973 2974
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2975
    /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag
2976 2977 2978 2979 2980
     * will avoid the error during parse. This will cause us to fill in
     * the missing machine type using the i386 binary, despite it being
     * the wrong binary for the arch. We expect to get a failure about
     * bad arch later when creating the pretend command.
     */
2981
    DO_TEST_FULL("missing-machine",
2982
                 ARG_FLAGS, FLAG_EXPECT_FAILURE,
2983 2984
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE,
                 ARG_QEMU_CAPS, NONE);
2985

2986 2987 2988
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
2989 2990
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP,
2991 2992 2993 2994
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
2995
            QEMU_CAPS_SPICE_UNIX,
2996 2997 2998 2999 3000
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_SPICE_RENDERNODE,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
3001
            QEMU_CAPS_DEVICE_ISA_SERIAL,
3002
            QEMU_CAPS_CHARDEV_FILE_APPEND,
3003
            QEMU_CAPS_CCID_EMULATED,
3004
            QEMU_CAPS_VIRTIO_SCSI);
M
Marc-André Lureau 已提交
3005 3006
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

3007
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
3008
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
3009
            QEMU_CAPS_USB_HUB);
3010
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
3011
                        QEMU_CAPS_USB_HUB);
3012

3013
    DO_TEST("acpi-table", NONE);
3014 3015 3016 3017 3018 3019

    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");
3020
    DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
3021
    DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
3022

3023
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
3024 3025 3026
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

3027
    DO_TEST_CAPS_LATEST("virtio-options");
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051
    DO_TEST_CAPS_LATEST("virtio-options-controller-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-disk-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-fs-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-input-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-memballoon-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-net-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-rng-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-video-iommu");
    DO_TEST_CAPS_LATEST("virtio-options-controller-ats");
    DO_TEST_CAPS_LATEST("virtio-options-disk-ats");
    DO_TEST_CAPS_LATEST("virtio-options-fs-ats");
    DO_TEST_CAPS_LATEST("virtio-options-input-ats");
    DO_TEST_CAPS_LATEST("virtio-options-memballoon-ats");
    DO_TEST_CAPS_LATEST("virtio-options-net-ats");
    DO_TEST_CAPS_LATEST("virtio-options-rng-ats");
    DO_TEST_CAPS_LATEST("virtio-options-video-ats");
    DO_TEST_CAPS_LATEST("virtio-options-controller-packed");
    DO_TEST_CAPS_LATEST("virtio-options-disk-packed");
    DO_TEST_CAPS_LATEST("virtio-options-fs-packed");
    DO_TEST_CAPS_LATEST("virtio-options-input-packed");
    DO_TEST_CAPS_LATEST("virtio-options-memballoon-packed");
    DO_TEST_CAPS_LATEST("virtio-options-net-packed");
    DO_TEST_CAPS_LATEST("virtio-options-rng-packed");
    DO_TEST_CAPS_LATEST("virtio-options-video-packed");
3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093
    DO_TEST_PARSE_ERROR("virtio-options-controller-iommu", QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_PARSE_ERROR("virtio-options-disk-iommu", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-fs-iommu", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-input-iommu", QEMU_CAPS_VIRTIO_MOUSE,
                        QEMU_CAPS_VIRTIO_KEYBOARD);
    DO_TEST_PARSE_ERROR("virtio-options-net-iommu", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-memballoon-iommu", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-rng-iommu", QEMU_CAPS_DEVICE_VIRTIO_RNG,
                        QEMU_CAPS_OBJECT_RNG_RANDOM);
    DO_TEST_PARSE_ERROR("virtio-options-video-iommu", QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_VIRTIO_GPU_VIRGL,
                        QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
                        QEMU_CAPS_DEVICE_VHOST_USER_GPU);
    DO_TEST_PARSE_ERROR("virtio-options-controller-ats", QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_PARSE_ERROR("virtio-options-disk-ats", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-fs-ats", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-input-ats", QEMU_CAPS_VIRTIO_MOUSE,
                        QEMU_CAPS_VIRTIO_KEYBOARD);
    DO_TEST_PARSE_ERROR("virtio-options-memballoon-ats", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-net-ats", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-rng-ats", QEMU_CAPS_DEVICE_VIRTIO_RNG,
                        QEMU_CAPS_OBJECT_RNG_RANDOM);
    DO_TEST_PARSE_ERROR("virtio-options-video-ats", QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_VIRTIO_GPU_VIRGL,
                        QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
                        QEMU_CAPS_DEVICE_VHOST_USER_GPU);
    DO_TEST_PARSE_ERROR("virtio-options-controller-packed", QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_PARSE_ERROR("virtio-options-disk-packed", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-fs-packed", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-input-packed", QEMU_CAPS_VIRTIO_MOUSE,
                        QEMU_CAPS_VIRTIO_KEYBOARD);
    DO_TEST_PARSE_ERROR("virtio-options-memballoon-packed", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-net-packed", NONE);
    DO_TEST_PARSE_ERROR("virtio-options-rng-packed", QEMU_CAPS_DEVICE_VIRTIO_RNG,
                        QEMU_CAPS_OBJECT_RNG_RANDOM);
    DO_TEST_PARSE_ERROR("virtio-options-video-packed", QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_DEVICE_VIRTIO_GPU,
                        QEMU_CAPS_VIRTIO_GPU_VIRGL,
                        QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
                        QEMU_CAPS_DEVICE_VHOST_USER_GPU);
3094

J
Ján Tomko 已提交
3095
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
3096
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
3097
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
3098
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
3099
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
3100 3101
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
3102
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
3103 3104
            QEMU_CAPS_KVM);

M
Marc-André Lureau 已提交
3105
    DO_TEST_CAPS_LATEST("memfd-memory-numa");
3106
    DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
M
Marc-André Lureau 已提交
3107

3108 3109 3110 3111 3112 3113 3114 3115
    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);

3116 3117 3118 3119 3120 3121 3122 3123 3124
    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 已提交
3125
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
3126

3127 3128 3129
    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,
3130
            QEMU_CAPS_DEVICE_ISA_SERIAL,
3131
            QEMU_CAPS_HDA_DUPLEX,
3132 3133
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
3134
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
3135 3136
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
3137
            QEMU_CAPS_ICH9_USB_EHCI1);
3138

3139
    DO_TEST_CAPS_VER("disk-virtio-scsi-reservations", "2.12.0");
3140
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
3141

3142
    DO_TEST_CAPS_LATEST("tseg-explicit-size");
3143 3144 3145
    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");
3146

3147
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
3148 3149 3150 3151 3152 3153
            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);

3154
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
3155 3156 3157 3158 3159 3160 3161
            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);

3162 3163
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");
3164 3165
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
3166

3167
    DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
3168

3169 3170 3171
    DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
    DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");

L
Lubomir Rintel 已提交
3172 3173
    DO_TEST("riscv64-virt",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
3174 3175
    DO_TEST("riscv64-virt-pci",
            QEMU_CAPS_OBJECT_GPEX);
L
Lubomir Rintel 已提交
3176

3177 3178 3179 3180 3181
    /* 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");
3182
    DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-transitional-not-supported");
3183

3184 3185 3186 3187 3188 3189 3190 3191
    /* 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");

3192 3193 3194
    /* 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");
3195
    DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-graphics", "riscv64");
3196
    DO_TEST_CAPS_ARCH_LATEST("s390x-ccw-graphics", "s390x");
3197 3198 3199
    DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-graphics", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-graphics", "x86_64");

3200 3201 3202 3203 3204
    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");

3205 3206 3207
    DO_TEST_CAPS_LATEST("vhost-user-vga");
    DO_TEST_CAPS_LATEST("vhost-user-gpu-secondary");

3208 3209 3210
    DO_TEST_CAPS_VER("cpu-Icelake-Server-pconfig", "3.1.0");
    DO_TEST_CAPS_LATEST("cpu-Icelake-Server-pconfig");

3211 3212
    DO_TEST_CAPS_ARCH_LATEST("aarch64-default-cpu-kvm-virt-4.2", "aarch64");
    DO_TEST_CAPS_ARCH_LATEST("aarch64-default-cpu-tcg-virt-4.2", "aarch64");
3213 3214 3215 3216 3217 3218
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-kvm-pseries-2.7", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-2.7", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-kvm-pseries-3.1", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-3.1", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-kvm-pseries-4.2", "ppc64");
    DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-4.2", "ppc64");
3219 3220
    DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-kvm-ccw-virtio-2.7", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-tcg-ccw-virtio-2.7", "s390x");
3221 3222
    DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-kvm-ccw-virtio-4.2", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-tcg-ccw-virtio-4.2", "s390x");
3223 3224 3225 3226
    DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-pc-4.2", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-pc-4.2", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-q35-4.2", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64");
3227

3228 3229
    DO_TEST_CAPS_LATEST("virtio-9p-multidevs");

3230 3231 3232
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

3233
    VIR_FREE(driver.config->nbdTLSx509certdir);
3234
    qemuTestDriverFree(&driver);
3235
    VIR_FREE(fakerootdir);
3236
    virHashFree(capslatest);
3237
    virFileWrapperClearPrefixes();
3238

3239
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
3240 3241
}

3242
VIR_TEST_MAIN_PRELOAD(mymain,
3243
                      VIR_TEST_MOCK("qemuxml2argv"),
M
Michal Privoznik 已提交
3244
                      VIR_TEST_MOCK("domaincaps"),
3245 3246 3247
                      VIR_TEST_MOCK("virrandom"),
                      VIR_TEST_MOCK("qemucpu"),
                      VIR_TEST_MOCK("virpci"))
3248

3249 3250
#else

3251 3252 3253 3254
int main(void)
{
    return EXIT_AM_SKIP;
}
3255 3256

#endif /* WITH_QEMU */