qemuxml2argvtest.c 132.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 "qemu/qemu_qapi.h"
22
# include "datatypes.h"
23
# include "conf/storage_conf.h"
24
# include "cpu/cpu_map.h"
25
# include "virstring.h"
26
# include "storage/storage_driver.h"
27
# include "virmock.h"
28 29
# include "virfilewrapper.h"
# include "configmake.h"
30 31
# include "testutilsqemuschema.h"
# include "qemu/qemu_monitor_json.h"
32

33
# define LIBVIRT_QEMU_CAPSPRIV_H_ALLOW
34 35
# include "qemu/qemu_capspriv.h"

36
# include "testutilsqemu.h"
37

38 39
# define VIR_FROM_THIS VIR_FROM_QEMU

40
static virQEMUDriver driver;
41

42
static unsigned char *
J
Ján Tomko 已提交
43
fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED,
44
                   size_t *value_size,
J
Ján Tomko 已提交
45 46
                   unsigned int fakeflags G_GNUC_UNUSED,
                   unsigned int internalFlags G_GNUC_UNUSED)
47
{
48
    char *secret;
49
    secret = g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A");
50 51 52 53 54 55
    *value_size = strlen(secret);
    return (unsigned char *) secret;
}

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

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

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

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

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

100 101 102 103 104 105 106 107 108 109 110 111

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

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

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

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

161
 cleanup:
162
    virStringListFree(volinfo);
163 164
    return ret;

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


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

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

207 208
    xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir, STORAGE_POOL_XML_PATH,
                              pool->name);
209

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

217
 cleanup:
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
    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
235
 * qemu command line.
236 237 238
 *
 * There are a few "magic" values to pass to these functions:
 *
239 240
 * 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
241 242 243
 * 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
244
 * pattern VOLUME_TYPE+VOLUME_PATH can be used to simulate a volume in a pool.
245 246 247 248 249 250 251 252 253 254 255 256
 * 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,
};

257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272

/* 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 已提交
273
fakeNWFilterBindingDelete(virNWFilterBindingPtr binding G_GNUC_UNUSED)
274 275 276 277 278 279 280 281 282 283
{
    return 0;
}


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

284 285 286 287

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

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

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

    return 0;
}


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

364 365
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

366 367
    virQEMUCapsInitQMPBasicArch(info->qemuCaps);

368 369
    if (testAddCPUModels(info->qemuCaps,
                         !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
370
        return -1;
371

372 373 374 375
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
376

377
    return 0;
378 379 380
}


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

392
    VIR_EXCLUSIVE_FLAGS_RET(FLAG_REAL_CAPS, FLAG_SKIP_LEGACY_CPUS, -1);
393 394 395 396
    return 0;
}


397 398 399 400 401
static virCommandPtr
testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
                               virDomainObjPtr vm,
                               const char *migrateURI,
                               struct testQemuInfo *info,
402 403
                               unsigned int flags,
                               bool jsonPropsValidation)
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
{
    size_t i;

    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];

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

    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 ||
            QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
            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;
    }

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

440 441 442 443 444 445 446
    for (i = 0; i < vm->def->ntpms; i++) {
        if (vm->def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
            continue;

        VIR_FREE(vm->def->tpms[i]->data.emulator.source.data.file.path);
        vm->def->tpms[i]->data.emulator.source.data.file.path = g_strdup("/dev/test");
        vm->def->tpms[i]->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
    }

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

    if (flags & FLAG_SLIRP_HELPER) {
        for (i = 0; i < vm->def->nnets; i++) {
            virDomainNetDefPtr net = vm->def->nets[i];

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

    return qemuProcessCreatePretendCmd(drv, vm, migrateURI,
                                       (flags & FLAG_FIPS), false,
474
                                       jsonPropsValidation,
475 476 477 478
                                       VIR_QEMU_PROCESS_START_COLD);
}


479 480 481 482 483 484 485
static int
testCompareXMLToArgvValidateSchema(virQEMUDriverPtr drv,
                                   const char *migrateURI,
                                   struct testQemuInfo *info,
                                   unsigned int flags)
{
    VIR_AUTOSTRINGLIST args = NULL;
486
    g_autoptr(virDomainObj) vm = NULL;
487 488 489 490
    size_t nargs = 0;
    size_t i;
    g_autoptr(virHashTable) schema = NULL;
    g_autoptr(virCommand) cmd = NULL;
491
    unsigned int parseFlags = info->parseFlags;
492 493 494 495 496 497 498 499 500 501 502 503

    if (info->schemafile)
        schema = testQEMUSchemaLoad(info->schemafile);

    /* comment out with line comment to enable schema checking for non _CAPS tests
    if (!schema)
        schema = testQEMUSchemaLoadLatest(virArchToString(info->arch));
    // */

    if (!schema)
        return 0;

504 505 506 507 508 509 510 511 512
    if (!(vm = virDomainObjNew(driver.xmlopt)))
        return -1;

    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
    if (!(vm->def = virDomainDefParseFile(info->infile,
                                          driver.xmlopt,
                                          NULL, parseFlags)))
        return -1;

513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
    if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags,
                                               true)))
        return -1;

    if (virCommandGetArgList(cmd, &args, &nargs) < 0)
        return -1;

    for (i = 0; i < nargs; i++) {
        g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
        g_autoptr(virJSONValue) jsonargs = NULL;

        if (STREQ(args[i], "-blockdev")) {
            if (!(jsonargs = virJSONValueFromString(args[i + 1])))
                return -1;

            if (testQEMUSchemaValidateCommand("blockdev-add", jsonargs,
                                              schema, false, false, &debug) < 0) {
                VIR_TEST_VERBOSE("failed to validate -blockdev '%s' against QAPI schema: %s",
                                 args[i + 1], virBufferCurrentContent(&debug));
                return -1;
            }

            i++;
        } else if (STREQ(args[i], "-netdev")) {
            if (!(jsonargs = virJSONValueFromString(args[i + 1])))
                return -1;

            /* skip the validation for pre-QAPIfication cases */
            if (virQEMUQAPISchemaPathExists("netdev_add/arg-type/type/!string", schema))
                continue;

            if (testQEMUSchemaValidateCommand("netdev_add", jsonargs,
                                              schema, false, false, &debug) < 0) {
                VIR_TEST_VERBOSE("failed to validate -netdev '%s' against QAPI schema: %s",
                                 args[i + 1], virBufferCurrentContent(&debug));
                return -1;
            }

            i++;
        }
    }

    return 0;
}


559 560 561
static int
testCompareXMLToArgv(const void *data)
{
562
    struct testQemuInfo *info = (void *) data;
563
    char *migrateURI = NULL;
564
    char *actualargv = NULL;
565 566
    unsigned int flags = info->flags;
    unsigned int parseFlags = info->parseFlags;
E
Eric Blake 已提交
567
    int ret = -1;
568
    virDomainObjPtr vm = NULL;
569
    virDomainChrSourceDef monitor_chr;
570
    virConnectPtr conn;
J
Jiri Denemark 已提交
571
    char *log = NULL;
E
Eric Blake 已提交
572
    virCommandPtr cmd = NULL;
573
    qemuDomainObjPrivatePtr priv = NULL;
574

575
    if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
576
        qemuTestSetHostArch(&driver, info->arch);
577

578 579
    memset(&monitor_chr, 0, sizeof(monitor_chr));

580
    if (!(conn = virGetConnect()))
581
        goto cleanup;
582

583
    conn->secretDriver = &fakeSecretDriver;
584
    conn->storageDriver = &fakeStorageDriver;
585
    conn->nwfilterDriver = &fakeNWFilterDriver;
586

587 588 589 590
    virSetConnectInterface(conn);
    virSetConnectNetwork(conn);
    virSetConnectNWFilter(conn);
    virSetConnectNodeDev(conn);
591 592 593
    virSetConnectSecret(conn);
    virSetConnectStorage(conn);

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

597 598 599
    if (testCheckExclusiveFlags(info->flags) < 0)
        goto cleanup;

600
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
601 602 603
        goto cleanup;

    if (info->migrateFrom &&
604 605
        !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                              info->migrateFd)))
606 607
        goto cleanup;

608
    if (!(vm = virDomainObjNew(driver.xmlopt)))
609
        goto cleanup;
610

611 612 613 614 615 616
    if (!virFileExists(info->infile)) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "Input file '%s' not found", info->infile);
        goto cleanup;
    }

617
    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
618
    if (!(vm->def = virDomainDefParseFile(info->infile,
619
                                          driver.xmlopt,
620
                                          NULL, parseFlags))) {
P
Pavel Hrdina 已提交
621
        if (flags & FLAG_EXPECT_PARSE_ERROR)
622
            goto ok;
623
        goto cleanup;
624
    }
625 626 627 628
    if (flags & FLAG_EXPECT_PARSE_ERROR) {
        VIR_TEST_DEBUG("passed instead of expected parse error");
        goto cleanup;
    }
629
    priv = vm->privateData;
630

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

634
    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
635
        VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile);
636
        goto cleanup;
637 638
    }

639
    vm->def->id = -1;
640

641
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
642
        goto cleanup;
643

644 645 646 647 648 649
    if (!(info->flags & FLAG_REAL_CAPS)) {
        if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
            goto cleanup;
        if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
            goto cleanup;
    }
650

651
    log = virTestLogContentAndReset();
652
    VIR_FREE(log);
653
    virResetLastError();
J
Jiri Denemark 已提交
654

655
    if (!(cmd = testCompareXMLToArgvCreateArgs(&driver, vm, migrateURI, info,
656
                                               flags, false))) {
P
Pavel Hrdina 已提交
657 658
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
659
        goto cleanup;
J
Jiri Denemark 已提交
660
    }
661 662 663 664
    if (flags & FLAG_EXPECT_FAILURE) {
        VIR_TEST_DEBUG("passed instead of expected failure");
        goto cleanup;
    }
J
Jiri Denemark 已提交
665

666
    if (testCompareXMLToArgvValidateSchema(&driver, migrateURI, info, flags) < 0)
667 668
        goto cleanup;

669
    if (!(actualargv = virCommandToString(cmd, false)))
670
        goto cleanup;
E
Eric Blake 已提交
671

672
    if (virTestCompareToFile(actualargv, info->outfile) < 0)
673
        goto cleanup;
674

P
Pavel Hrdina 已提交
675 676
    ret = 0;

677
 ok:
678
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
679
        ret = -1;
680
        VIR_TEST_DEBUG("Error expected but there wasn't any.");
681
        goto cleanup;
P
Pavel Hrdina 已提交
682
    }
683 684 685
    if (flags & FLAG_EXPECT_FAILURE) {
        if ((log = virTestLogContentAndReset()))
            VIR_TEST_DEBUG("Got expected error: \n%s", log);
686
    }
687 688
    virResetLastError();
    ret = 0;
689

690
 cleanup:
691 692
    VIR_FREE(log);
    VIR_FREE(actualargv);
693
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
694
    virCommandFree(cmd);
695
    virObjectUnref(vm);
696 697
    virSetConnectSecret(NULL);
    virSetConnectStorage(NULL);
698
    virObjectUnref(conn);
699
    VIR_FREE(migrateURI);
700
    if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
701
        qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
702

703
    return ret;
704 705
}

706
static void
707
testInfoSetPaths(struct testQemuInfo *info,
708 709
                 const char *suffix)
{
710 711 712 713
    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 : "");
714 715
}

716 717
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"

718
static int
E
Eric Blake 已提交
719
mymain(void)
720
{
C
Cole Robinson 已提交
721
    int ret = 0;
722
    char *fakerootdir;
723
    virHashTablePtr capslatest = NULL;
724

725 726 727 728 729 730 731 732 733
    fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);

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

    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);

734 735 736 737 738
    /* 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. */
739 740
    if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
        perror("g_setenv");
741 742 743
        return EXIT_FAILURE;
    }

744
    if (qemuTestDriverInit(&driver) < 0)
745
        return EXIT_FAILURE;
746 747

    driver.privileged = true;
748

749
    VIR_FREE(driver.config->defaultTLSx509certdir);
750
    driver.config->defaultTLSx509certdir = g_strdup("/etc/pki/qemu");
751
    VIR_FREE(driver.config->vncTLSx509certdir);
752
    driver.config->vncTLSx509certdir = g_strdup("/etc/pki/libvirt-vnc");
753
    VIR_FREE(driver.config->spiceTLSx509certdir);
754
    driver.config->spiceTLSx509certdir = g_strdup("/etc/pki/libvirt-spice");
755
    VIR_FREE(driver.config->chardevTLSx509certdir);
756
    driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
757
    VIR_FREE(driver.config->vxhsTLSx509certdir);
758
    driver.config->vxhsTLSx509certdir = g_strdup("/etc/pki/libvirt-vxhs/dummy,path");
759
    VIR_FREE(driver.config->nbdTLSx509certdir);
760
    driver.config->nbdTLSx509certdir = g_strdup("/etc/pki/libvirt-nbd/dummy,path");
761

762
    VIR_FREE(driver.config->hugetlbfs);
763
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
764
        return EXIT_FAILURE;
765
    driver.config->nhugetlbfs = 2;
766 767
    driver.config->hugetlbfs[0].mnt_dir = g_strdup("/dev/hugepages2M");
    driver.config->hugetlbfs[1].mnt_dir = g_strdup("/dev/hugepages1G");
768 769
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
770
    driver.config->hugetlbfs[1].size = 1048576;
771
    driver.config->spiceTLS = 1;
772
    driver.config->spicePassword = g_strdup("123456");
773
    VIR_FREE(driver.config->memoryBackingDir);
774
    driver.config->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
775
    VIR_FREE(driver.config->nvramDir);
776
    driver.config->nvramDir = g_strdup("/var/lib/libvirt/qemu/nvram");
777

C
Cole Robinson 已提交
778
    capslatest = testQemuGetLatestCaps();
779
    if (!capslatest)
780 781
        return EXIT_FAILURE;

782 783 784 785 786 787 788
    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");

789 790 791 792 793 794 795 796 797 798
    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");

799 800 801 802 803 804 805 806 807 808 809 810 811 812
/**
 * 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.
 */
813
# define DO_TEST_INTERNAL(_name, _suffix, ...) \
814
    do { \
815
        static struct testQemuInfo info = { \
816
            .name = _name, \
817
        }; \
818 819
        if (testQemuInfoSetArgs(&info, capslatest, \
                                __VA_ARGS__, ARG_END) < 0) \
820
            return EXIT_FAILURE; \
821
        testInfoSetPaths(&info, _suffix); \
822
        if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \
823 824
                       testCompareXMLToArgv, &info) < 0) \
            ret = -1; \
825
        testQemuInfoClear(&info); \
826 827
    } while (0)

828 829 830 831 832 833
# define DO_TEST_CAPS_INTERNAL(name, arch, ver, ...) \
    DO_TEST_INTERNAL(name, "." arch "-" ver, \
                     ARG_CAPS_ARCH, arch, \
                     ARG_CAPS_VER, ver, \
                     __VA_ARGS__)

834
# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \
835
    DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__)
836

837 838 839
# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \
    DO_TEST_CAPS_INTERNAL(name, arch, ver, __VA_ARGS__)

840
# define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
841
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)
842

843
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
844
    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END)
845

846
# define DO_TEST_CAPS_LATEST(name) \
847
    DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
848

849 850 851
# define DO_TEST_CAPS_VER(name, ver) \
    DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)

852 853 854
# define DO_TEST_CAPS_LATEST_PPC64(name) \
    DO_TEST_CAPS_ARCH_LATEST(name, "ppc64")

855 856
# define DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, arch) \
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \
857
                                  ARG_FLAGS, FLAG_EXPECT_FAILURE)
858

859 860 861 862 863 864 865 866 867 868 869 870
# 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, \
871
                                  ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
872

873 874 875 876 877 878 879 880 881 882
# 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)

883 884 885
# define DO_TEST_FULL(name, ...) \
    DO_TEST_INTERNAL(name, "", \
                     __VA_ARGS__, QEMU_CAPS_LAST)
886

887 888 889
/* All the following macros require an explicit QEMU_CAPS_* list
 * at the end of the argument list, or the NONE placeholder.
 * */
890
# define DO_TEST(name, ...) \
891
    DO_TEST_FULL(name, \
892
                 ARG_QEMU_CAPS, __VA_ARGS__)
893

894
# define DO_TEST_GIC(name, gic, ...) \
895
    DO_TEST_FULL(name, \
896
                 ARG_GIC, gic, \
897
                 ARG_QEMU_CAPS, __VA_ARGS__)
898

899
# define DO_TEST_FAILURE(name, ...) \
900 901
    DO_TEST_FULL(name, \
                 ARG_FLAGS, FLAG_EXPECT_FAILURE, \
902
                 ARG_QEMU_CAPS, __VA_ARGS__)
903

904
# define DO_TEST_PARSE_ERROR(name, ...) \
905
    DO_TEST_FULL(name, \
906
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
907
                 ARG_QEMU_CAPS, __VA_ARGS__)
908

909
# define NONE QEMU_CAPS_LAST
910

911 912 913
    /* 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 */
914 915 916 917 918 919 920 921 922
    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");
923

924
    DO_TEST("minimal", NONE);
925 926
    DO_TEST("minimal-sandbox",
            QEMU_CAPS_SECCOMP_BLACKLIST);
927
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
928
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
929 930 931 932

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

933
    DO_TEST("machine-aliases1", NONE);
934
    DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
935
    DO_TEST("machine-core-on", NONE);
936
    driver.config->dumpGuestCore = true;
937
    DO_TEST("machine-core-off", NONE);
938
    driver.config->dumpGuestCore = false;
M
Michal Privoznik 已提交
939 940 941
    DO_TEST("machine-smm-opt",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
942
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
943 944 945
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
946
    DO_TEST("machine-vmport-opt",
947
            QEMU_CAPS_MACHINE_VMPORT_OPT);
948 949 950
    DO_TEST("default-kvm-host-arch", NONE);
    DO_TEST("default-qemu-host-arch", NONE);
    DO_TEST("x86-kvm-32-on-64", NONE);
951 952 953
    DO_TEST("boot-cdrom", NONE);
    DO_TEST("boot-network", NONE);
    DO_TEST("boot-floppy", NONE);
954
    DO_TEST("boot-floppy-q35",
955
            QEMU_CAPS_DEVICE_IOH3420,
956
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
957 958
    DO_TEST("boot-multi", NONE);
    DO_TEST("boot-menu-enable", NONE);
959
    DO_TEST("boot-menu-enable-with-timeout",
960
            QEMU_CAPS_SPLASH_TIMEOUT);
961
    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout", NONE);
962
    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE);
J
Ján Tomko 已提交
963 964
    DO_TEST("boot-menu-disable", NONE);
    DO_TEST("boot-menu-disable-drive", NONE);
965
    DO_TEST_PARSE_ERROR("boot-dev+order",
966
            QEMU_CAPS_VIRTIO_BLK_SCSI);
967
    DO_TEST("boot-order",
968
            QEMU_CAPS_VIRTIO_BLK_SCSI);
969
    DO_TEST("boot-complex",
970
            QEMU_CAPS_VIRTIO_BLK_SCSI);
971
    DO_TEST("boot-strict",
972
            QEMU_CAPS_BOOT_STRICT,
973
            QEMU_CAPS_VIRTIO_BLK_SCSI);
974 975 976

    DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
    DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
977
    DO_TEST_PARSE_ERROR("reboot-timeout-enabled", NONE);
978

979
    DO_TEST("bios",
980
            QEMU_CAPS_DEVICE_ISA_SERIAL,
981
            QEMU_CAPS_SGA);
J
Ján Tomko 已提交
982
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
983 984 985
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
986
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
987 988 989
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
990 991 992 993 994 995 996

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

997
    DO_TEST("clock-utc", NONE);
998
    DO_TEST("clock-localtime", NONE);
J
Ján Tomko 已提交
999 1000 1001 1002
    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 已提交
1003
    DO_TEST("clock-catchup", QEMU_CAPS_KVM_PIT_TICK_POLICY);
1004 1005
    DO_TEST("cpu-kvmclock", NONE);
    DO_TEST("cpu-host-kvmclock", NONE);
1006
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
1007
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
1008

1009 1010
    DO_TEST("cpu-eoi-disabled", NONE);
    DO_TEST("cpu-eoi-enabled", NONE);
J
Ján Tomko 已提交
1011
    DO_TEST("controller-order",
1012 1013 1014 1015 1016 1017
            QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_HDA_DUPLEX,
            QEMU_CAPS_USB_HUB,
1018
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1019
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1020
    DO_TEST_CAPS_VER("eoi-disabled", "2.7.0");
1021
    DO_TEST_CAPS_VER("eoi-disabled", "4.0.0");
1022 1023
    DO_TEST_CAPS_LATEST("eoi-disabled");
    DO_TEST_CAPS_VER("eoi-enabled", "2.7.0");
1024
    DO_TEST_CAPS_VER("eoi-enabled", "4.0.0");
1025 1026
    DO_TEST_CAPS_LATEST("eoi-enabled");
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "2.7.0");
1027
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "4.0.0");
1028 1029
    DO_TEST_CAPS_LATEST("pv-spinlock-disabled");
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "2.7.0");
1030
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "4.0.0");
1031 1032
    DO_TEST_CAPS_LATEST("pv-spinlock-enabled");
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "2.7.0");
1033
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "4.0.0");
1034
    DO_TEST_CAPS_LATEST("kvmclock+eoi-disabled");
1035

1036 1037 1038 1039 1040 1041
    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");
1042
    DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
1043

1044 1045 1046
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

1047 1048 1049
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

1050 1051 1052
    DO_TEST("pages-discard",
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
1053 1054 1055 1056
    DO_TEST("pages-discard-hugepages",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
1057 1058 1059 1060
    DO_TEST("pages-dimm-discard",
            QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
1061 1062
    DO_TEST("hugepages-default", QEMU_CAPS_OBJECT_MEMORY_FILE);
    DO_TEST("hugepages-default-2M", QEMU_CAPS_OBJECT_MEMORY_FILE);
1063
    DO_TEST("hugepages-default-system-size", QEMU_CAPS_OBJECT_MEMORY_FILE);
1064
    DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
1065
    DO_TEST("hugepages-nodeset", QEMU_CAPS_OBJECT_MEMORY_FILE);
1066 1067 1068 1069
    DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
                        QEMU_CAPS_DEVICE_PC_DIMM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE,
                        QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
1070
    DO_TEST("hugepages-numa-default",
1071
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1072 1073 1074
    DO_TEST("hugepages-numa-default-2M",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1075
    DO_TEST("hugepages-numa-default-dimm",
1076
            QEMU_CAPS_DEVICE_PC_DIMM,
J
Ján Tomko 已提交
1077
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1078
    DO_TEST("hugepages-numa-nodeset",
A
Andrea Bolognani 已提交
1079
            QEMU_CAPS_OBJECT_MEMORY_RAM,
1080
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1081 1082
    DO_TEST("hugepages-numa-nodeset-part",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
1083
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1084 1085 1086
    DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist",
                        QEMU_CAPS_OBJECT_MEMORY_RAM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE);
A
Andrea Bolognani 已提交
1087 1088 1089
    DO_TEST("hugepages-shared",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1090
    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
1091 1092 1093
    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
1094 1095 1096
    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
1097 1098 1099
    DO_TEST_PARSE_ERROR("hugepages-memaccess3",
                        QEMU_CAPS_OBJECT_MEMORY_RAM,
                        QEMU_CAPS_OBJECT_MEMORY_FILE);
1100
    DO_TEST_CAPS_LATEST("hugepages-nvdimm");
1101
    DO_TEST("nosharepages", QEMU_CAPS_MEM_MERGE);
1102
    DO_TEST("disk-cdrom", NONE);
1103
    DO_TEST_CAPS_VER("disk-cdrom", "2.12.0");
1104
    DO_TEST_CAPS_LATEST("disk-cdrom");
1105
    DO_TEST_CAPS_LATEST("disk-cdrom-empty-network-invalid");
1106
    DO_TEST_CAPS_LATEST("disk-cdrom-bus-other");
1107
    DO_TEST("disk-iscsi", NONE);
1108
    DO_TEST("disk-cdrom-network", QEMU_CAPS_KVM);
1109
    DO_TEST_CAPS_VER("disk-cdrom-network", "2.12.0");
1110
    DO_TEST_CAPS_LATEST("disk-cdrom-network");
1111
    DO_TEST("disk-cdrom-tray",
1112
            QEMU_CAPS_VIRTIO_TX_ALG);
1113
    DO_TEST_CAPS_VER("disk-cdrom-tray", "2.12.0");
1114
    DO_TEST_CAPS_LATEST("disk-cdrom-tray");
1115
    DO_TEST("disk-floppy", NONE);
1116
    DO_TEST_CAPS_VER("disk-floppy", "2.12.0");
1117
    DO_TEST_CAPS_LATEST("disk-floppy");
1118
    DO_TEST_CAPS_VER("disk-floppy-q35-2_9", "2.12.0");
1119
    DO_TEST_CAPS_LATEST("disk-floppy-q35-2_9");
1120
    DO_TEST_CAPS_VER("disk-floppy-q35-2_11", "2.12.0");
1121
    DO_TEST_CAPS_LATEST("disk-floppy-q35-2_11");
1122 1123
    DO_TEST_FAILURE("disk-floppy-pseries",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1124
    DO_TEST("disk-floppy-tray", NONE);
1125
    DO_TEST("disk-virtio-s390",
1126
            QEMU_CAPS_VIRTIO_S390);
1127
    DO_TEST("disk-virtio", NONE);
1128
    DO_TEST("disk-virtio-ccw",
1129
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1130
    DO_TEST("disk-virtio-ccw-many",
1131
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1132 1133 1134 1135
    DO_TEST("disk-virtio-s390-zpci",
            QEMU_CAPS_DEVICE_ZPCI,
            QEMU_CAPS_CCW,
            QEMU_CAPS_VIRTIO_S390);
1136
    DO_TEST("disk-order", QEMU_CAPS_VIRTIO_BLK_SCSI);
1137
    DO_TEST("disk-virtio-queues",
L
Lin Ma 已提交
1138
            QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
1139 1140 1141
    DO_TEST("disk-boot-disk", NONE);
    DO_TEST("disk-boot-cdrom", NONE);
    DO_TEST("floppy-drive-fat", NONE);
1142
    DO_TEST_CAPS_VER("floppy-drive-fat", "2.12.0");
1143
    DO_TEST_CAPS_LATEST("floppy-drive-fat");
1144
    DO_TEST("disk-readonly-disk", NONE);
1145
    DO_TEST_CAPS_VER("disk-readonly-disk", "2.12.0");
1146
    DO_TEST_CAPS_LATEST("disk-readonly-disk");
1147 1148 1149 1150
    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);
1151
    DO_TEST_CAPS_VER("disk-shared", "2.12.0");
1152
    DO_TEST_CAPS_LATEST("disk-shared");
1153 1154
    DO_TEST_PARSE_ERROR("disk-shared-qcow", NONE);
    DO_TEST("disk-error-policy", NONE);
1155
    DO_TEST_CAPS_VER("disk-error-policy", "2.12.0");
1156
    DO_TEST_CAPS_LATEST("disk-error-policy");
1157 1158
    DO_TEST_CAPS_ARCH_VER("disk-error-policy-s390x", "s390x", "2.12.0");
    DO_TEST_CAPS_ARCH_LATEST("disk-error-policy-s390x", "s390x");
1159
    DO_TEST_CAPS_VER("disk-cache", "1.5.3");
1160 1161
    DO_TEST_CAPS_VER("disk-cache", "2.6.0");
    DO_TEST_CAPS_VER("disk-cache", "2.7.0");
1162
    DO_TEST_CAPS_VER("disk-cache", "2.12.0");
1163
    DO_TEST_CAPS_LATEST("disk-cache");
1164
    DO_TEST("disk-network-nbd", NONE);
1165
    DO_TEST_CAPS_VER("disk-network-nbd", "2.12.0");
1166
    DO_TEST_CAPS_LATEST("disk-network-nbd");
1167
    DO_TEST("disk-network-iscsi", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_BLOCK);
1168 1169 1170 1171
    DO_TEST("disk-network-iscsi-modern",
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_SCSI_BLOCK,
            QEMU_CAPS_ISCSI_PASSWORD_SECRET);
1172
    DO_TEST_CAPS_VER("disk-network-iscsi", "2.12.0");
1173
    DO_TEST_CAPS_LATEST("disk-network-iscsi");
1174 1175 1176 1177
    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",
1178
            QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
1179
    DO_TEST_CAPS_VER("disk-network-gluster", "2.12.0");
1180
    DO_TEST_CAPS_LATEST("disk-network-gluster");
1181
    DO_TEST_CAPS_VER("disk-network-rbd", "2.5.0");
1182
    DO_TEST_CAPS_VER("disk-network-rbd", "2.12.0");
1183 1184
    DO_TEST_CAPS_LATEST("disk-network-rbd");
    DO_TEST_FAILURE("disk-network-rbd-no-colon", NONE);
1185
    DO_TEST("disk-network-sheepdog", NONE);
1186
    DO_TEST_CAPS_VER("disk-network-sheepdog", "2.12.0");
1187
    DO_TEST_CAPS_LATEST("disk-network-sheepdog");
1188
    DO_TEST("disk-network-source-auth", NONE);
1189
    DO_TEST_CAPS_VER("disk-network-source-auth", "2.12.0");
1190
    DO_TEST_CAPS_LATEST("disk-network-source-auth");
1191
    DO_TEST("disk-network-vxhs", QEMU_CAPS_VXHS);
1192
    driver.config->vxhsTLS = 1;
1193
    DO_TEST("disk-network-tlsx509", QEMU_CAPS_VXHS,
1194
            QEMU_CAPS_OBJECT_TLS_CREDS_X509, QEMU_CAPS_NBD_TLS);
1195
    DO_TEST_CAPS_VER("disk-network-tlsx509", "2.12.0");
1196
    DO_TEST_CAPS_LATEST("disk-network-tlsx509");
1197
    DO_TEST_CAPS_LATEST("disk-network-http");
1198 1199
    driver.config->vxhsTLS = 0;
    VIR_FREE(driver.config->vxhsTLSx509certdir);
1200
    DO_TEST("disk-no-boot", NONE);
1201
    DO_TEST_CAPS_LATEST("disk-nvme");
1202
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
1203
                        QEMU_CAPS_VIRTIO_SCSI);
1204
    DO_TEST_CAPS_LATEST_PARSE_ERROR("disk-attaching-partition-nosupport");
1205
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
1206
    DO_TEST("disk-usb-device",
1207
            QEMU_CAPS_DEVICE_USB_STORAGE);
1208
    DO_TEST("disk-usb-device-removable",
1209
            QEMU_CAPS_DEVICE_USB_STORAGE,
1210
            QEMU_CAPS_USB_STORAGE_REMOVABLE);
1211
    DO_TEST_FAILURE("disk-usb-pci",
1212
                    QEMU_CAPS_DEVICE_USB_STORAGE);
1213
    DO_TEST_CAPS_LATEST("disk-scsi");
1214 1215
    DO_TEST_CAPS_VER("disk-scsi-device-auto", "1.5.3");
    DO_TEST_CAPS_LATEST("disk-scsi-device-auto");
1216
    DO_TEST("disk-scsi-disk-split",
1217
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1218
    DO_TEST("disk-scsi-disk-wwn",
1219
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1220
    DO_TEST("disk-scsi-disk-vpd",
1221
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1222
    DO_TEST_PARSE_ERROR("disk-scsi-disk-vpd-build-error",
1223
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN);
1224
    DO_TEST_CAPS_LATEST("controller-virtio-scsi");
1225
    DO_TEST("disk-sata-device",
1226
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
1227
    DO_TEST("disk-aio", NONE);
1228
    DO_TEST_CAPS_VER("disk-aio", "2.12.0");
1229
    DO_TEST_CAPS_LATEST("disk-aio");
H
Han Han 已提交
1230
    DO_TEST_CAPS_LATEST("disk-aio-io_uring");
1231 1232
    DO_TEST("disk-source-pool", NONE);
    DO_TEST("disk-source-pool-mode", NONE);
1233
    DO_TEST("disk-ioeventfd",
1234
            QEMU_CAPS_VIRTIO_IOEVENTFD,
1235
            QEMU_CAPS_VIRTIO_TX_ALG,
1236
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1237
    DO_TEST("disk-copy_on_read",
1238
            QEMU_CAPS_VIRTIO_TX_ALG,
1239
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1240
    DO_TEST_CAPS_VER("disk-copy_on_read", "2.12.0");
1241
    DO_TEST_CAPS_LATEST("disk-copy_on_read");
1242 1243
    DO_TEST_CAPS_VER("disk-discard", "4.1.0");
    DO_TEST_CAPS_LATEST("disk-discard");
1244
    DO_TEST_CAPS_VER("disk-detect-zeroes", "2.12.0");
1245
    DO_TEST_CAPS_LATEST("disk-detect-zeroes");
1246
    DO_TEST("disk-snapshot", NONE);
1247 1248
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
1249
                        QEMU_CAPS_DEVICE_USB_STORAGE);
1250
    DO_TEST_PARSE_ERROR("disk-address-conflict",
1251 1252
                        QEMU_CAPS_ICH9_AHCI);
    DO_TEST_PARSE_ERROR("disk-hostdev-scsi-address-conflict",
1253
                        QEMU_CAPS_VIRTIO_SCSI);
1254
    DO_TEST_PARSE_ERROR("hostdevs-drive-address-conflict",
1255
                        QEMU_CAPS_VIRTIO_SCSI);
1256
    DO_TEST("event_idx",
1257 1258
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
1259
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1260
    DO_TEST("virtio-lun",
1261
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1262
    DO_TEST("disk-scsi-lun-passthrough",
1263
            QEMU_CAPS_SCSI_BLOCK,
1264
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1265
    DO_TEST("disk-serial",
1266
            QEMU_CAPS_KVM);
1267 1268 1269 1270 1271 1272 1273 1274
    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);
1275 1276 1277 1278
    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");
1279

1280 1281
    DO_TEST_CAPS_LATEST("disk-slices");

1282 1283 1284
    DO_TEST_CAPS_ARCH_VER("disk-arm-virtio-sd", "aarch64", "4.0.0");
    DO_TEST_CAPS_ARCH_LATEST("disk-arm-virtio-sd", "aarch64");

1285 1286 1287
    DO_TEST("graphics-egl-headless",
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1288 1289
    DO_TEST_CAPS_LATEST("graphics-egl-headless");
    DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
1290

1291 1292
    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);
1293 1294
    DO_TEST("graphics-vnc-websocket",
            QEMU_CAPS_VNC,
1295
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1296
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
1297 1298 1299 1300 1301
            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);
1302
    driver.config->vncAutoUnixSocket = true;
1303 1304
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1305
    driver.config->vncAutoUnixSocket = false;
1306 1307 1308 1309
    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);
1310 1311
    DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
1312

1313 1314
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1315
    driver.config->vncSASLdir = g_strdup("/root/.sasl2");
1316
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1317 1318
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1319
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1320 1321
    DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
    DO_TEST_CAPS_LATEST("graphics-vnc-tls");
1322
    driver.config->vncTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
1323 1324
    DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret");
    VIR_FREE(driver.config->vncTLSx509secretUUID);
1325
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1326 1327
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1328 1329 1330 1331
    DO_TEST("graphics-vnc-egl-headless",
            QEMU_CAPS_VNC,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1332

J
Ján Tomko 已提交
1333 1334
    DO_TEST("graphics-sdl",
            QEMU_CAPS_DEVICE_VGA);
1335
    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-sdl-egl-headless");
J
Ján Tomko 已提交
1336
    DO_TEST("graphics-sdl-fullscreen",
1337
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1338
    DO_TEST("graphics-spice",
1339
            QEMU_CAPS_SPICE,
1340 1341
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1342
    DO_TEST("graphics-spice-no-args",
1343
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1344
    driver.config->spiceSASL = 1;
1345
    driver.config->spiceSASLdir = g_strdup("/root/.sasl2");
1346
    DO_TEST("graphics-spice-sasl",
1347
            QEMU_CAPS_SPICE,
1348 1349 1350
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
1351
    DO_TEST("graphics-spice-agentmouse",
1352
            QEMU_CAPS_DEVICE_QXL,
1353
            QEMU_CAPS_SPICE,
1354
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1355
    DO_TEST("graphics-spice-compression",
1356
            QEMU_CAPS_SPICE,
1357
            QEMU_CAPS_DEVICE_QXL);
1358
    DO_TEST("graphics-spice-timeout",
1359
            QEMU_CAPS_KVM,
1360
            QEMU_CAPS_SPICE,
1361 1362
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VGA);
1363
    DO_TEST("graphics-spice-qxl-vga",
1364
            QEMU_CAPS_SPICE,
1365
            QEMU_CAPS_DEVICE_QXL);
1366
    DO_TEST("graphics-spice-usb-redir",
1367
            QEMU_CAPS_SPICE,
1368 1369 1370 1371
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1372
    DO_TEST("graphics-spice-agent-file-xfer",
1373
            QEMU_CAPS_SPICE,
1374 1375
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1376 1377
    DO_TEST("graphics-spice-socket",
            QEMU_CAPS_SPICE,
1378 1379
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1380 1381
    DO_TEST("graphics-spice-auto-socket",
            QEMU_CAPS_SPICE,
1382 1383
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1384 1385 1386
    driver.config->spiceAutoUnixSocket = true;
    DO_TEST("graphics-spice-auto-socket-cfg",
            QEMU_CAPS_SPICE,
1387 1388
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1389
    driver.config->spiceAutoUnixSocket = false;
1390 1391 1392 1393
    DO_TEST("graphics-spice-egl-headless",
            QEMU_CAPS_SPICE,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_QXL);
1394
    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-spice-invalid-egl-headless");
1395
    DO_TEST_CAPS_LATEST("graphics-spice-gl-auto-rendernode");
1396

1397 1398 1399
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
    DO_TEST("misc-acpi", NONE);
1400 1401 1402
    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);
1403
    DO_TEST_PARSE_ERROR("misc-enable-s4", NONE);
1404
    DO_TEST("misc-no-reboot", NONE);
1405
    DO_TEST("misc-uuid", NONE);
1406
    DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
1407
    DO_TEST("net-vhostuser", QEMU_CAPS_CHARDEV_FD_PASS);
1408 1409
    DO_TEST_CAPS_VER("net-vhostuser", "2.5.0");
    DO_TEST_CAPS_LATEST("net-vhostuser");
1410
    DO_TEST("net-vhostuser-multiq",
J
Ján Tomko 已提交
1411 1412
            QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
    DO_TEST_FAILURE("net-vhostuser-multiq", NONE);
1413 1414
    DO_TEST_FAILURE("net-vhostuser-fail",
                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
1415
    DO_TEST("net-user", NONE);
1416
    DO_TEST_CAPS_ARCH_VER_FULL("net-user", "x86_64", "4.0.0", ARG_FLAGS, FLAG_SLIRP_HELPER);
J
Ján Tomko 已提交
1417
    DO_TEST("net-user-addr", NONE);
1418 1419
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
1420 1421 1422
            QEMU_CAPS_VIRTIO_TX_ALG);
    DO_TEST("net-virtio-disable-offloads", NONE);
    DO_TEST("net-virtio-netdev", NONE);
1423
    DO_TEST("net-virtio-s390",
1424
            QEMU_CAPS_VIRTIO_S390);
1425
    DO_TEST("net-virtio-ccw",
1426
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1427 1428 1429
    DO_TEST("net-virtio-rxtxqueuesize",
            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE,
            QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE);
1430
    DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
1431 1432 1433 1434
    DO_TEST("net-virtio-teaming",
            QEMU_CAPS_VIRTIO_NET_FAILOVER,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST_PARSE_ERROR("net-virtio-teaming", NONE);
1435 1436
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
1437
    DO_TEST("net-eth-names", NONE);
1438
    DO_TEST("net-eth-hostip", NONE);
1439
    DO_TEST("net-eth-unmanaged-tap", NONE);
1440 1441
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
1442
    DO_TEST("net-many-models", NONE);
1443
    DO_TEST("net-mcast", NONE);
1444
    DO_TEST("net-udp", NONE);
1445 1446 1447
    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);
1448 1449
    DO_TEST("net-hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1450
    DO_TEST("net-hostdev-vfio-multidomain",
1451
            QEMU_CAPS_DEVICE_VFIO_PCI);
1452 1453 1454
    DO_TEST_FAILURE("net-hostdev-fail",
                    QEMU_CAPS_DEVICE_VFIO_PCI);

1455 1456 1457
    DO_TEST("hostdev-pci-multifunction",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DEVICE_VFIO_PCI);
1458

1459 1460 1461 1462
    DO_TEST("hostdev-pci-address-unassigned",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DEVICE_VFIO_PCI);

1463 1464
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1465
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1466
            QEMU_CAPS_CHARDEV_LOGFILE);
1467
    DO_TEST("serial-spiceport",
1468
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1469
            QEMU_CAPS_DEVICE_QXL,
1470
            QEMU_CAPS_SPICE,
1471
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1472
    DO_TEST("serial-spiceport-nospice", NONE);
1473

1474 1475 1476 1477
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1478 1479

    DO_TEST("serial-vc-chardev",
1480
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1481
    DO_TEST("serial-pty-chardev",
1482
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1483
    DO_TEST("serial-dev-chardev",
1484
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1485
    DO_TEST("serial-dev-chardev-iobase",
1486
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1487
    DO_TEST("serial-file-chardev",
1488
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1489
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1490
    DO_TEST("serial-unix-chardev",
1491
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1492
    DO_TEST_CAPS_LATEST("serial-unix-chardev");
1493
    DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE);
1494
    DO_TEST("serial-tcp-chardev",
1495
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1496
    DO_TEST("serial-udp-chardev",
1497
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1498
    DO_TEST("serial-tcp-telnet-chardev",
1499
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1500 1501
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1502
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1503
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1504 1505
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1506
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1507 1508
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1509
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1510
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1511
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1512
    VIR_FREE(driver.config->chardevTLSx509certdir);
1513 1514
    driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
    driver.config->chardevTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
1515 1516
    DO_TEST("serial-tcp-tlsx509-secret-chardev",
            QEMU_CAPS_OBJECT_SECRET,
1517
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1518
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1519 1520
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1521
    DO_TEST("serial-many-chardev",
1522 1523 1524
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
J
Ján Tomko 已提交
1525 1526
    DO_TEST_CAPS_VER("parallel-unix-chardev", "2.5.0");
    DO_TEST_CAPS_LATEST("parallel-unix-chardev");
1527
    DO_TEST("console-compat-chardev",
1528
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1529 1530
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1531

1532
    DO_TEST("channel-guestfwd", NONE);
J
Ján Tomko 已提交
1533 1534
    DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0");
    DO_TEST_CAPS_LATEST("channel-unix-guestfwd");
1535 1536 1537 1538 1539 1540
    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);
1541
    DO_TEST("console-virtio-many",
1542
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1543
    DO_TEST("console-virtio-s390",
1544
            QEMU_CAPS_VIRTIO_S390);
1545
    DO_TEST("console-virtio-ccw",
1546
            QEMU_CAPS_CCW,
1547
            QEMU_CAPS_VIRTIO_S390);
J
Ján Tomko 已提交
1548 1549
    DO_TEST_CAPS_VER("console-virtio-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("console-virtio-unix");
1550
    DO_TEST("console-sclp",
1551
            QEMU_CAPS_VIRTIO_S390,
1552
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1553
    DO_TEST("channel-spicevmc",
1554
            QEMU_CAPS_SPICE,
1555
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1556
    DO_TEST("channel-virtio-default",
1557
            QEMU_CAPS_SPICE);
1558
    DO_TEST("channel-virtio-unix", NONE);
1559

1560
    DO_TEST("smartcard-host",
1561
            QEMU_CAPS_CCID_EMULATED);
1562
    DO_TEST("smartcard-host-certificates",
1563
            QEMU_CAPS_CCID_EMULATED);
1564 1565
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1566
    DO_TEST("smartcard-passthrough-tcp",
1567
            QEMU_CAPS_CCID_PASSTHRU);
1568
    DO_TEST("smartcard-passthrough-spicevmc",
1569
            QEMU_CAPS_CCID_PASSTHRU);
1570
    DO_TEST("smartcard-controller",
1571
            QEMU_CAPS_CCID_EMULATED);
J
Ján Tomko 已提交
1572 1573
    DO_TEST_CAPS_VER("smartcard-passthrough-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("smartcard-passthrough-unix");
1574

1575 1576 1577 1578 1579 1580 1581 1582
    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);
1583 1584
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1585

1586
    DO_TEST("usb-controller", NONE);
1587
    DO_TEST("usb-piix3-controller",
1588
            QEMU_CAPS_PIIX3_USB_UHCI);
1589
    DO_TEST("usb-ich9-ehci-addr",
1590
            QEMU_CAPS_ICH9_USB_EHCI1);
1591
    DO_TEST("input-usbmouse-addr", NONE);
1592
    DO_TEST("usb-ich9-companion",
1593
            QEMU_CAPS_ICH9_USB_EHCI1);
1594
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1595
            QEMU_CAPS_ICH9_USB_EHCI1);
1596
    DO_TEST("usb-ich9-autoassign",
1597
            QEMU_CAPS_ICH9_USB_EHCI1,
1598
            QEMU_CAPS_USB_HUB);
1599
    DO_TEST("usb-hub",
1600
            QEMU_CAPS_USB_HUB);
1601
    DO_TEST("usb-hub-autoadd",
1602
            QEMU_CAPS_USB_HUB);
1603
    DO_TEST("usb-hub-autoadd-deluxe",
1604
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1605
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
1606
            QEMU_CAPS_USB_HUB);
1607
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
1608
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1609
    DO_TEST("usb-port-missing",
1610
            QEMU_CAPS_USB_HUB);
1611
    DO_TEST_FAILURE("usb-bus-missing",
1612
                    QEMU_CAPS_USB_HUB);
1613
    DO_TEST("usb-ports",
1614
            QEMU_CAPS_USB_HUB);
1615
    DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
1616
            QEMU_CAPS_USB_HUB);
1617
    DO_TEST("usb-port-autoassign",
1618
            QEMU_CAPS_USB_HUB);
1619
    DO_TEST("usb-redir",
1620 1621 1622
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1623
            QEMU_CAPS_SPICE);
1624
    DO_TEST("usb-redir-boot",
1625 1626 1627
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1628
            QEMU_CAPS_SPICE);
1629
    DO_TEST("usb-redir-filter",
1630 1631 1632 1633
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
1634
            QEMU_CAPS_USB_REDIR_FILTER);
1635 1636
    DO_TEST("usb-redir-filter-version",
            QEMU_CAPS_USB_REDIR,
1637
            QEMU_CAPS_SPICE,
1638
            QEMU_CAPS_USB_REDIR_FILTER);
J
Ján Tomko 已提交
1639 1640
    DO_TEST_CAPS_VER("usb-redir-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("usb-redir-unix");
1641
    DO_TEST("usb1-usb2",
1642 1643 1644
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1);
1645 1646
    DO_TEST("usb-none", NONE);
    DO_TEST_PARSE_ERROR("usb-none-other", NONE);
1647 1648
    DO_TEST_PARSE_ERROR("usb-none-hub",
            QEMU_CAPS_USB_HUB);
1649
    DO_TEST_PARSE_ERROR("usb-none-usbtablet", NONE);
1650
    DO_TEST("usb-controller-default-q35",
1651
            QEMU_CAPS_DEVICE_IOH3420,
1652 1653 1654
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1655
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1656
                    QEMU_CAPS_DEVICE_IOH3420,
1657
                    QEMU_CAPS_PCI_OHCI,
1658 1659
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1660
            QEMU_CAPS_DEVICE_IOH3420,
1661 1662 1663
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1664
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1665
                    QEMU_CAPS_DEVICE_IOH3420,
1666
                    QEMU_CAPS_PCI_OHCI,
1667
                    QEMU_CAPS_PIIX3_USB_UHCI);
1668
    DO_TEST("usb-controller-xhci",
1669 1670 1671
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1672
    DO_TEST("usb-xhci-autoassign",
1673 1674 1675
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS,
1676
            QEMU_CAPS_USB_HUB);
1677
    DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
1678 1679 1680
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1681 1682 1683 1684
    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);
1685

1686 1687 1688
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1689
    DO_TEST("smbios-type-fwcfg", QEMU_CAPS_FW_CFG);
1690

1691
    DO_TEST("watchdog", NONE);
1692
    DO_TEST("watchdog-device", NONE);
1693
    DO_TEST("watchdog-dump", NONE);
1694
    DO_TEST("watchdog-injectnmi", NONE);
1695
    DO_TEST("watchdog-diag288", QEMU_CAPS_VIRTIO_S390);
1696 1697
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1698
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1699
    DO_TEST("balloon-ccw-deflate",
1700
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1701
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1702
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1703
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1704
    DO_TEST("balloon-device-deflate-off",
1705
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1706 1707
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1708 1709
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1710
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1711
            QEMU_CAPS_HDA_OUTPUT,
1712 1713
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1714
    DO_TEST("fs9p", NONE);
1715
    DO_TEST_CAPS_LATEST("fs9p");
1716
    DO_TEST("fs9p-ccw",
1717
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1718
    DO_TEST_CAPS_ARCH_LATEST("fs9p-ccw", "s390x");
1719

1720
    DO_TEST("hostdev-usb-address", NONE);
1721
    DO_TEST("hostdev-usb-address-device", NONE);
1722
    DO_TEST("hostdev-usb-address-device-boot", NONE);
1723 1724
    DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI);
1725 1726
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1727
    DO_TEST("hostdev-vfio-multidomain",
1728
            QEMU_CAPS_DEVICE_VFIO_PCI);
1729 1730 1731 1732 1733 1734
    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);
1735 1736 1737 1738 1739 1740 1741
    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);
1742
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb");
1743 1744
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1745 1746 1747
    DO_TEST("hostdev-vfio-zpci",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
1748 1749 1750 1751 1752 1753 1754
    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);
1755 1756 1757
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-uid-set-zero",
                        QEMU_CAPS_DEVICE_VFIO_PCI,
                        QEMU_CAPS_DEVICE_ZPCI);
1758 1759 1760 1761 1762 1763
    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);
1764
    DO_TEST("pci-rom", QEMU_CAPS_DEVICE_VFIO_PCI);
1765
    DO_TEST("pci-rom-disabled", NONE);
1766
    DO_TEST("pci-rom-disabled-invalid", NONE);
1767

1768 1769 1770 1771
    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
1772 1773
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
                             "s390x");
1774 1775 1776
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw",
                        QEMU_CAPS_CCW,
                        QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
1777 1778 1779 1780 1781 1782 1783 1784 1785
    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 已提交
1786 1787
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ap",
                             "s390x");
1788 1789
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ap-boot-fail",
                                         "s390x");
B
Boris Fiuczynski 已提交
1790

1791
    DO_TEST_FULL("restore-v2",
1792 1793
                 ARG_MIGRATE_FROM, "exec:cat",
                 ARG_MIGRATE_FD, 7,
1794
                 ARG_QEMU_CAPS, NONE);
1795
    DO_TEST_FULL("restore-v2-fd",
1796 1797
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1798
                 ARG_QEMU_CAPS, NONE);
1799
    DO_TEST_FULL("restore-v2-fd",
1800 1801
                 ARG_MIGRATE_FROM, "fd:7",
                 ARG_MIGRATE_FD, 7,
1802
                 ARG_QEMU_CAPS, NONE);
1803
    DO_TEST_FULL("migrate",
1804
                 ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000",
1805
                 ARG_QEMU_CAPS, NONE);
1806

1807
    DO_TEST_FULL("migrate-numa-unaligned",
1808 1809
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1810
                 ARG_QEMU_CAPS,
A
Andrea Bolognani 已提交
1811 1812
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1813

1814 1815
    DO_TEST_CAPS_VER("qemu-ns", "4.0.0");
    DO_TEST_CAPS_LATEST("qemu-ns");
1816
    DO_TEST("qemu-ns-no-env", NONE);
1817
    DO_TEST("qemu-ns-alt", NONE);
1818

1819
    DO_TEST("smp", NONE);
1820
    DO_TEST("smp-dies", QEMU_CAPS_SMP_DIES);
1821

J
John Ferlan 已提交
1822
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1823 1824
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1825
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1826 1827
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1828
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1829 1830
    DO_TEST_CAPS_LATEST("iothreads-virtio-scsi-pci");
    DO_TEST_CAPS_ARCH_LATEST("iothreads-virtio-scsi-ccw", "s390x");
J
John Ferlan 已提交
1831

1832 1833
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1834
    DO_TEST("cpu-topology3", NONE);
1835 1836 1837 1838 1839 1840 1841 1842
    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);
1843
    DO_TEST("cpu-no-removed-features", QEMU_CAPS_KVM);
1844
    DO_TEST("cpu-numa1", NONE);
1845 1846
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1847
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1848
    DO_TEST_PARSE_ERROR("cpu-numa-disjoint", NONE);
1849
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1850
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
1851
    DO_TEST_PARSE_ERROR("cpu-numa-memshared", NONE);
1852
    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
1853
    DO_TEST("cpu-host-model", NONE);
1854
    DO_TEST("cpu-host-model-vendor", NONE);
1855
    DO_TEST_FULL("cpu-host-model-fallback",
1856
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS,
1857
                 ARG_QEMU_CAPS, NONE);
1858
    DO_TEST_FULL("cpu-host-model-nofallback",
1859
                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS | FLAG_EXPECT_FAILURE,
1860
                 ARG_QEMU_CAPS, NONE);
A
Andrea Bolognani 已提交
1861 1862
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1863

1864
    qemuTestSetHostArch(&driver, VIR_ARCH_S390X);
1865
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1866 1867
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1868
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
1869

1870
    qemuTestSetHostCPU(&driver, driver.hostarch, cpuHaswell);
1871 1872 1873 1874
    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);
1875
    DO_TEST("cpu-host-model-cmt", NONE);
1876
    DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
1877
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1878
    DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
1879 1880
    DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
    DO_TEST_CAPS_LATEST("cpu-translation");
1881
    qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
1882

1883 1884
    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);
1885
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1886
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1887 1888
    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);
1889
    DO_TEST_CAPS_LATEST("luks-disks-source-qcow2");
1890
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1891
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1892

1893 1894 1895 1896 1897 1898 1899 1900
    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);
1901
    DO_TEST("cputune-numatune",
1902
            QEMU_CAPS_KVM,
1903
            QEMU_CAPS_OBJECT_IOTHREAD,
1904 1905
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1906 1907 1908
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1909
    DO_TEST_CAPS_LATEST("cputune-cpuset-big-id");
1910

1911
    DO_TEST("numatune-memory", NONE);
1912
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1913 1914 1915
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1916
    DO_TEST_PARSE_ERROR("numatune-memnode", NONE);
1917

A
Andrea Bolognani 已提交
1918 1919 1920
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1921
    DO_TEST_PARSE_ERROR("numatune-memnode-no-memory", NONE);
1922

1923 1924
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1925
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1926 1927
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1928 1929
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1930 1931
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1932 1933
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1934
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1935 1936 1937
    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);
1938 1939 1940 1941 1942 1943
    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");
1944

1945
    DO_TEST("multifunction-pci-device",
1946
            QEMU_CAPS_SCSI_LSI);
1947

1948
    DO_TEST("monitor-json", NONE);
1949

1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961
    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);
1962

1963
    DO_TEST("pseries-basic",
1964
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1965
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1966
    DO_TEST("pseries-vio",
1967
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1968
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1969
    DO_TEST("pseries-usb-default",
1970
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1971
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1972
            QEMU_CAPS_PIIX3_USB_UHCI,
1973
            QEMU_CAPS_PCI_OHCI);
1974
    DO_TEST("pseries-usb-multi",
1975
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1976
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1977
            QEMU_CAPS_PIIX3_USB_UHCI,
1978
            QEMU_CAPS_PCI_OHCI);
1979
    DO_TEST("pseries-vio-user-assigned",
1980
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1981 1982
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash", NONE);
1983 1984 1985
    DO_TEST("pseries-nvram",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_DEVICE_NVRAM);
1986
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1987
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1988
            QEMU_CAPS_DEVICE_USB_KBD,
1989
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1990
    DO_TEST("pseries-cpu-exact",
1991
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1992 1993
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE);
1994

1995
    qemuTestSetHostArch(&driver, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1996
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1997
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1998
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1999 2000 2001
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
2002
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
2003
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
2004
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2005
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2006 2007 2008
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
2009

2010
    qemuTestSetHostCPU(&driver, driver.hostarch, cpuPower9);
2011
    DO_TEST("pseries-cpu-compat-power9",
2012
            QEMU_CAPS_KVM,
2013
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2014
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2015
    qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
2016

2017
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
2018

2019
    DO_TEST("pseries-panic-missing",
2020
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2021
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2022
    DO_TEST("pseries-panic-no-address",
2023
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2024
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2025
    DO_TEST_FAILURE("pseries-panic-address",
2026
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
2027 2028 2029 2030 2031

    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);
2032 2033 2034 2035 2036 2037
    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);
2038 2039 2040
    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);
2041

2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063
    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);

2064
    DO_TEST("pseries-features",
2065
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2066
            QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
2067
            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
2068
            QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
2069
            QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2070
            QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2071
            QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2072
            QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2073
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
2074 2075 2076 2077 2078 2079 2080

    /* 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,
2081
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2082
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2083 2084
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
2085 2086 2087 2088 2089 2090 2091

    /* 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,
2092
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2093
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2094
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2095 2096 2097 2098 2099 2100 2101 2102
                        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,
2103
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2104
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2105
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2106 2107 2108 2109 2110 2111 2112 2113
                        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,
2114
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2115
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2116
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2117 2118 2119 2120 2121 2122 2123 2124
                        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,
2125
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC,
2126
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
2127
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS,
2128 2129
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

2130 2131 2132 2133 2134 2135 2136
    /* 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,
2137
                        QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
2138 2139
                        QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
                        QEMU_CAPS_MACHINE_PSERIES_CAP_IBS);
2140 2141 2142 2143 2144 2145 2146 2147 2148

    /* 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,
2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161
                        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);
2162

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

2165
    DO_TEST("pseries-serial-native",
2166
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2167 2168
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
2169
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2170 2171
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
2172
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2173
            QEMU_CAPS_DEVICE_SPAPR_VTY);
2174
    DO_TEST("pseries-serial-pci",
2175
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2176 2177
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
2178
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2179 2180
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
2181
    DO_TEST("pseries-console-native",
2182
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2183 2184
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
2185
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
2186
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
2187
    DO_TEST_PARSE_ERROR("pseries-spaprvio-invalid", "ppc64");
2188

2189
    DO_TEST("mach-virt-serial-native",
2190
            QEMU_CAPS_DEVICE_PL011);
2191
    DO_TEST("mach-virt-serial+console-native",
2192
            QEMU_CAPS_DEVICE_PL011);
2193
    DO_TEST("mach-virt-serial-compat",
2194
            QEMU_CAPS_DEVICE_PL011);
2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206
    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",
2207
            QEMU_CAPS_DEVICE_PL011);
2208 2209
    DO_TEST("mach-virt-console-virtio",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2210 2211
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

2212 2213
    DO_TEST("disk-ide-split", NONE);
    DO_TEST("disk-ide-wwn", QEMU_CAPS_IDE_DRIVE_WWN);
2214

2215
    DO_TEST("disk-geometry", NONE);
2216
    DO_TEST("disk-blockio", QEMU_CAPS_BLOCKIO);
2217

2218
    DO_TEST("video-device-pciaddr-default",
2219 2220
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
2221
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2222
            QEMU_CAPS_DEVICE_QXL);
2223
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
2224
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
2225
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2226
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
2227
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
2228
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
2229
    DO_TEST("video-qxl-device",
2230
            QEMU_CAPS_DEVICE_QXL,
2231
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2232
    DO_TEST("video-qxl-device-vgamem",
2233
            QEMU_CAPS_DEVICE_QXL,
2234
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2235
            QEMU_CAPS_QXL_VGAMEM);
2236
    DO_TEST_CAPS_LATEST("video-qxl-device-vram64");
2237
    DO_TEST("video-qxl-sec-device",
2238
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2239
    DO_TEST("video-qxl-sec-device-vgamem",
2240 2241
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2242
            QEMU_CAPS_QXL_VGAMEM);
2243
    DO_TEST_CAPS_LATEST("video-qxl-sec-device-vram64");
2244 2245 2246
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2247
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2248 2249 2250
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2251 2252 2253
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2254
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2255 2256 2257 2258
    DO_TEST("video-qxl-resolution",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_VGAMEM);
M
Marc-André Lureau 已提交
2259
    DO_TEST("video-virtio-gpu-device",
2260
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
2261
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2262
    DO_TEST("video-virtio-gpu-virgl",
2263
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2264
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2265
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2266 2267
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2268
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2269 2270
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
2271
            QEMU_CAPS_SPICE_RENDERNODE,
2272
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2273 2274 2275 2276 2277
    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);
2278 2279 2280
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2281 2282 2283
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
2284 2285
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
2286
    DO_TEST_CAPS_LATEST("video-bochs-display-device");
2287
    DO_TEST_CAPS_LATEST("video-ramfb-display-device");
2288
    DO_TEST_CAPS_LATEST_PARSE_ERROR("video-ramfb-display-device-pci-address");
2289 2290 2291
    DO_TEST("video-none-device",
            QEMU_CAPS_VNC);
    DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
2292
    DO_TEST_PARSE_ERROR("default-video-type-x86_64-caps-test-0", NONE);
2293

2294 2295 2296 2297 2298
    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");

2299 2300
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2301
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2302 2303
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2304
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2305 2306
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2307
            QEMU_CAPS_OBJECT_RNG_EGD);
H
Han Han 已提交
2308
    DO_TEST_CAPS_LATEST("virtio-rng-builtin");
J
Ján Tomko 已提交
2309 2310
    DO_TEST_CAPS_VER("virtio-rng-egd-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("virtio-rng-egd-unix");
2311 2312 2313 2314
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2315
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
2316 2317
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
2318
    DO_TEST("virtio-rng-ccw",
2319
            QEMU_CAPS_CCW,
2320 2321
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2322
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2323

2324
    DO_TEST("s390-allow-bogus-usb-none",
2325 2326 2327
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2328
    DO_TEST("s390-allow-bogus-usb-controller",
2329 2330 2331
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2332

2333
    DO_TEST("s390-panic-no-address",
2334
            QEMU_CAPS_CCW,
2335
            QEMU_CAPS_VIRTIO_S390);
2336
    DO_TEST_FAILURE("s390-panic-address",
2337
            QEMU_CAPS_CCW,
2338
            QEMU_CAPS_VIRTIO_S390);
2339
    DO_TEST("s390-panic-missing",
2340
            QEMU_CAPS_CCW,
2341
            QEMU_CAPS_VIRTIO_S390);
2342
    DO_TEST_PARSE_ERROR("s390-no-parallel",
2343
            QEMU_CAPS_CCW,
2344
            QEMU_CAPS_VIRTIO_S390);
2345
    DO_TEST("s390-serial",
2346
            QEMU_CAPS_CCW,
2347 2348 2349
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
2350
            QEMU_CAPS_CCW,
2351 2352 2353 2354
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
2355
            QEMU_CAPS_CCW,
2356 2357
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2358

2359
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2360
            QEMU_CAPS_KVM);
2361 2362
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2363

2364 2365
    DO_TEST_CAPS_LATEST("tpm-passthrough");
    DO_TEST_CAPS_LATEST("tpm-passthrough-crb");
2366
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2367
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2368
    DO_TEST_CAPS_LATEST("tpm-emulator");
2369
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2370
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2-enc");
2371
    DO_TEST_CAPS_LATEST_PPC64("tpm-emulator-spapr");
2372

2373 2374 2375 2376
    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);
2377

2378 2379 2380 2381 2382 2383
    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,
2384
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2385 2386
    DO_TEST("pci-autoadd-idx",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2387 2388
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA);
2389
    DO_TEST("pci-many",
2390
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2391
    DO_TEST("pci-bridge-many-disks",
2392
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
2393
    DO_TEST("pcie-root",
2394 2395 2396 2397
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL);
2398
    DO_TEST("q35",
2399
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2400
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2401
            QEMU_CAPS_DEVICE_IOH3420,
2402
            QEMU_CAPS_ICH9_AHCI,
2403
            QEMU_CAPS_ICH9_USB_EHCI1,
2404
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2405
            QEMU_CAPS_DEVICE_QXL);
2406 2407 2408 2409 2410 2411 2412 2413
    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);
2414
    DO_TEST("q35-pm-disable",
2415
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2416
            QEMU_CAPS_DEVICE_IOH3420,
2417 2418 2419 2420
            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",
2421
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2422
            QEMU_CAPS_DEVICE_IOH3420,
2423 2424
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
2425
    DO_TEST("q35-usb2",
2426
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2427
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2428
            QEMU_CAPS_DEVICE_IOH3420,
2429
            QEMU_CAPS_ICH9_AHCI,
2430
            QEMU_CAPS_ICH9_USB_EHCI1,
2431
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2432
            QEMU_CAPS_DEVICE_QXL);
2433
    DO_TEST("q35-usb2-multi",
2434
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2435
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2436
            QEMU_CAPS_DEVICE_IOH3420,
2437
            QEMU_CAPS_ICH9_AHCI,
2438
            QEMU_CAPS_ICH9_USB_EHCI1,
2439
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2440
            QEMU_CAPS_DEVICE_QXL);
2441
    DO_TEST("q35-usb2-reorder",
2442
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2443
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2444
            QEMU_CAPS_DEVICE_IOH3420,
2445
            QEMU_CAPS_ICH9_AHCI,
2446
            QEMU_CAPS_ICH9_USB_EHCI1,
2447
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2448
            QEMU_CAPS_DEVICE_QXL);
2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466
    /* 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,
2467
            QEMU_CAPS_NEC_USB_XHCI,
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480
            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,
2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500
            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,
2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514
            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,
2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533
            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,
2534 2535 2536 2537 2538
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2539 2540 2541 2542 2543 2544 2545 2546
            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,
2547
            QEMU_CAPS_NEC_USB_XHCI,
2548
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2549 2550
    DO_TEST("q35-virt-manager-basic",
            QEMU_CAPS_KVM,
2551
            QEMU_CAPS_MACHINE_VMPORT_OPT,
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575
            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,
2576
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2577
            QEMU_CAPS_USB_REDIR);
2578 2579

    /* Test automatic and manual setting of pcie-root-port attributes */
2580 2581
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2582
            QEMU_CAPS_ICH9_AHCI,
2583
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2584
            QEMU_CAPS_DEVICE_QXL);
2585 2586 2587 2588 2589 2590

    /* 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,
2591
            QEMU_CAPS_DEVICE_IOH3420);
2592
    DO_TEST("pcie-root-port-model-ioh3420",
2593
            QEMU_CAPS_DEVICE_IOH3420);
2594
    DO_TEST_CAPS_LATEST("pcie-root-port-nohotplug");
2595

2596 2597 2598 2599 2600 2601 2602
    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,
2603
            QEMU_CAPS_ICH9_USB_EHCI1,
2604
            QEMU_CAPS_NEC_USB_XHCI);
2605 2606 2607 2608 2609 2610 2611
    /* 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);
2612

2613
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2614
            QEMU_CAPS_DEVICE_IOH3420,
2615
            QEMU_CAPS_ICH9_AHCI,
2616
            QEMU_CAPS_ICH9_USB_EHCI1,
2617
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2618
            QEMU_CAPS_DEVICE_QXL);
2619
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2620
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2621

2622
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2623
            QEMU_CAPS_DEVICE_IOH3420,
2624
            QEMU_CAPS_ICH9_AHCI,
2625
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2626
            QEMU_CAPS_DEVICE_QXL);
2627

2628 2629 2630
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2631
            QEMU_CAPS_ICH9_AHCI,
2632
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2633
            QEMU_CAPS_DEVICE_QXL);
2634 2635 2636 2637
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2638
            QEMU_CAPS_ICH9_AHCI,
2639
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2640
            QEMU_CAPS_DEVICE_QXL);
2641

2642 2643 2644 2645 2646 2647
    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);
2648 2649
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2650

2651 2652 2653 2654 2655 2656 2657 2658 2659 2660
    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);
2661 2662 2663
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2664

2665
    DO_TEST_CAPS_VER("hostdev-scsi-lsi", "2.8.0");
2666
    DO_TEST_CAPS_VER("hostdev-scsi-lsi", "4.1.0");
2667
    DO_TEST_CAPS_LATEST("hostdev-scsi-lsi");
2668
    DO_TEST_CAPS_VER("hostdev-scsi-virtio-scsi", "2.8.0");
2669
    DO_TEST_CAPS_VER("hostdev-scsi-virtio-scsi", "4.1.0");
2670
    DO_TEST_CAPS_LATEST("hostdev-scsi-virtio-scsi");
2671

2672 2673
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2674
            QEMU_CAPS_CCW);
2675
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
2676 2677
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VHOST_SCSI);
2678
    DO_TEST_CAPS_LATEST_PARSE_ERROR("hostdev-scsi-vhost-scsi-pci-boot-fail");
2679 2680 2681 2682 2683
    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);
2684

2685 2686
    DO_TEST_CAPS_VER("mlock-on", "3.0.0");
    DO_TEST_CAPS_VER("mlock-off", "3.0.0");
2687 2688
    DO_TEST_CAPS_LATEST("mlock-on");
    DO_TEST_CAPS_LATEST("mlock-off");
2689

2690 2691 2692 2693
    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);
2694

2695
    DO_TEST("hotplug-base",
2696
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2697

2698
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
2699
    DO_TEST_PARSE_ERROR("pcihole64-none", NONE);
2700
    DO_TEST("pcihole64-q35",
2701
            QEMU_CAPS_DEVICE_IOH3420,
2702
            QEMU_CAPS_ICH9_AHCI,
2703
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2704
            QEMU_CAPS_DEVICE_QXL,
2705 2706
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2707 2708
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2709
    DO_TEST("arm-vexpressa9-virtio",
2710
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2711
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2712
    DO_TEST("arm-virt-virtio",
2713
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2714
            QEMU_CAPS_DEVICE_PL011,
2715
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2716

2717
    DO_TEST("aarch64-virt-virtio",
2718
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2719
            QEMU_CAPS_DEVICE_PL011,
2720
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2721 2722 2723 2724 2725 2726

    /* 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",
2727
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
2728 2729 2730
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2731
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2732
            QEMU_CAPS_DEVICE_IOH3420,
2733
            QEMU_CAPS_DEVICE_PL011,
2734
            QEMU_CAPS_VIRTIO_SCSI);
2735
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
2736
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2737 2738
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2739
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2740
            QEMU_CAPS_DEVICE_PL011,
2741
            QEMU_CAPS_DEVICE_IOH3420);
2742 2743 2744
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
2745
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2746 2747
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2748 2749 2750
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_VIRTIO_SCSI);
2751
    DO_TEST("aarch64-video-virtio-gpu-pci",
2752
            QEMU_CAPS_OBJECT_GPEX,
2753
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2754
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2755
            QEMU_CAPS_DEVICE_VIRTIO_GPU);
2756
    DO_TEST("aarch64-video-default",
2757
            QEMU_CAPS_OBJECT_GPEX,
2758
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2759
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2760 2761
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_VNC);
2762
    DO_TEST("aarch64-aavmf-virtio-mmio",
2763
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2764
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2765 2766
    DO_TEST("aarch64-virt-default-nic",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2767
    qemuTestSetHostArch(&driver, VIR_ARCH_AARCH64);
2768
    DO_TEST("aarch64-cpu-passthrough",
2769
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2770
            QEMU_CAPS_KVM);
2771
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
2772
            QEMU_CAPS_KVM,
2773
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2774
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
2775
            QEMU_CAPS_KVM,
2776 2777
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
2778
            QEMU_CAPS_KVM,
2779
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2780
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
2781
            QEMU_CAPS_KVM,
2782
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2783 2784
    DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2785
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
2786
            QEMU_CAPS_KVM,
2787
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2788
    DO_TEST_GIC("aarch64-gic-default-v2", GIC_V2,
2789
            QEMU_CAPS_KVM,
2790
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2791
    DO_TEST_GIC("aarch64-gic-default-v3", GIC_V3,
2792
            QEMU_CAPS_KVM,
2793
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2794
    DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
2795
            QEMU_CAPS_KVM,
2796 2797
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
2798
            QEMU_CAPS_KVM,
2799 2800
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
2801
            QEMU_CAPS_KVM,
2802 2803
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
2804
            QEMU_CAPS_KVM,
2805
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2806
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
2807
            QEMU_CAPS_KVM,
2808
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2809
    DO_TEST_FAILURE("aarch64-gic-v3",
2810
            QEMU_CAPS_KVM, NONE);
2811
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
2812
            QEMU_CAPS_KVM,
2813 2814
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
2815
            QEMU_CAPS_KVM,
2816 2817
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
2818
            QEMU_CAPS_KVM,
2819 2820
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
2821
            QEMU_CAPS_KVM,
2822
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2823
    DO_TEST_FAILURE("aarch64-gic-host",
2824
            QEMU_CAPS_KVM, NONE);
2825
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
2826
            QEMU_CAPS_KVM,
2827 2828
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
2829
            QEMU_CAPS_KVM,
2830 2831
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
2832
            QEMU_CAPS_KVM,
2833 2834
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
2835
            QEMU_CAPS_KVM,
2836
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2837
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
2838
            QEMU_CAPS_KVM,
2839
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2840
    DO_TEST_PARSE_ERROR("aarch64-gic-not-virt",
2841
                        QEMU_CAPS_KVM,
2842 2843
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_PARSE_ERROR("aarch64-gic-not-arm",
2844
                        QEMU_CAPS_KVM,
2845
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2846
    DO_TEST("aarch64-kvm-32-on-64",
2847
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2848
            QEMU_CAPS_DEVICE_PL011,
A
Andrea Bolognani 已提交
2849
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2850
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2851
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2852
            QEMU_CAPS_KVM);
2853 2854 2855 2856 2857 2858 2859
    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);
2860 2861 2862 2863
    DO_TEST("aarch64-traditional-pci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2864
            QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
2865 2866
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
2867 2868 2869 2870 2871 2872 2873

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

2874 2875 2876 2877 2878 2879 2880 2881 2882
    /* 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");

2883 2884
    DO_TEST_CAPS_ARCH_LATEST("clock-timer-armvtimer", "aarch64");

2885
    qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
2886

2887
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2888
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2889

2890 2891 2892 2893
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2894

2895 2896
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2897

2898 2899
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2900
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2901 2902 2903
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2904
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2905
    DO_TEST_FAILURE("shmem-invalid-size",
2906
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2907
    DO_TEST_FAILURE("shmem-invalid-address",
2908
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2909
    DO_TEST_FAILURE("shmem-small-size",
2910
                    QEMU_CAPS_DEVICE_IVSHMEM);
2911
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2912
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2913

2914
    DO_TEST_FAILURE("memory-align-fail", NONE);
2915
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2916
    DO_TEST("memory-hotplug", NONE);
2917
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2918
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2919
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2920
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2921
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2922
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2923
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2924
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2925 2926 2927
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-access");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-label");
2928
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-align");
2929
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-pmem");
2930
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly");
2931
    DO_TEST_CAPS_ARCH_LATEST("memory-hotplug-nvdimm-ppc64", "ppc64");
2932

2933
    DO_TEST("machine-aeskeywrap-on-caps",
2934
            QEMU_CAPS_AES_KEY_WRAP,
2935
            QEMU_CAPS_DEA_KEY_WRAP,
2936
            QEMU_CAPS_VIRTIO_SCSI,
2937
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2938
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2939
                    QEMU_CAPS_VIRTIO_SCSI,
2940
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2941 2942 2943
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2944
            QEMU_CAPS_AES_KEY_WRAP,
2945
            QEMU_CAPS_VIRTIO_SCSI,
2946
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2947
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2948
                    QEMU_CAPS_VIRTIO_SCSI,
2949
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2950 2951 2952
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2953
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2954
            QEMU_CAPS_VIRTIO_SCSI,
2955
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2956
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2957
                    QEMU_CAPS_VIRTIO_SCSI,
2958
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2959 2960 2961
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2962
            QEMU_CAPS_AES_KEY_WRAP,
2963
            QEMU_CAPS_VIRTIO_SCSI,
2964
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2965
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2966
                    QEMU_CAPS_VIRTIO_SCSI,
2967
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2968 2969 2970
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2971
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2972
            QEMU_CAPS_VIRTIO_SCSI,
2973
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2974
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2975
                    QEMU_CAPS_VIRTIO_SCSI,
2976
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2977 2978 2979
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2980
            QEMU_CAPS_DEA_KEY_WRAP,
2981
            QEMU_CAPS_VIRTIO_SCSI,
2982
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2983
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2984
                    QEMU_CAPS_VIRTIO_SCSI,
2985
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2986 2987 2988
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2989
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2990
            QEMU_CAPS_VIRTIO_SCSI,
2991
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2992
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2993
                    QEMU_CAPS_VIRTIO_SCSI,
2994
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2995 2996 2997
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2998
            QEMU_CAPS_DEA_KEY_WRAP,
2999
            QEMU_CAPS_VIRTIO_SCSI,
3000
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
3001
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
3002
                    QEMU_CAPS_VIRTIO_SCSI,
3003
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
3004 3005 3006
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
3007
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
3008
            QEMU_CAPS_VIRTIO_SCSI,
3009
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
3010
    DO_TEST("machine-keywrap-none",
3011
            QEMU_CAPS_VIRTIO_SCSI,
3012
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
3013

3014
    DO_TEST("machine-loadparm-s390",
3015
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
3016
            QEMU_CAPS_LOADPARM);
3017
    DO_TEST("machine-loadparm-net-s390",
3018
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
3019
            QEMU_CAPS_LOADPARM);
3020
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
3021
            QEMU_CAPS_CCW,
3022
            QEMU_CAPS_VIRTIO_S390,
3023 3024
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
3025
                        QEMU_CAPS_CCW,
3026
                        QEMU_CAPS_VIRTIO_S390,
3027 3028
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
3029
                        QEMU_CAPS_CCW,
3030
                        QEMU_CAPS_VIRTIO_S390,
3031 3032
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
3033 3034 3035 3036 3037 3038 3039
    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);

3040
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
3041
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
3042
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
3043

3044
    DO_TEST("ppc64-usb-controller",
3045
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
3046
            QEMU_CAPS_PCI_OHCI);
3047
    DO_TEST("ppc64-usb-controller-legacy",
3048
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
3049
            QEMU_CAPS_PIIX3_USB_UHCI);
3050
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci",
3051
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
3052
                 ARG_QEMU_CAPS,
3053
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
3054 3055 3056
                 QEMU_CAPS_NEC_USB_XHCI,
                 QEMU_CAPS_DEVICE_QEMU_XHCI);

3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068
    DO_TEST_PARSE_ERROR("ppc64-tpmproxy-double",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_PCI_OHCI,
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
                        QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY);

    DO_TEST_PARSE_ERROR("ppc64-tpm-double",
                        QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                        QEMU_CAPS_PCI_OHCI,
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
                        QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY);

3069 3070 3071
    DO_TEST_CAPS_LATEST_PPC64("ppc64-tpmproxy-single");
    DO_TEST_CAPS_LATEST_PPC64("ppc64-tpmproxy-with-tpm");

3072 3073 3074 3075
    DO_TEST("aarch64-usb-controller-qemu-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_DEVICE_QEMU_XHCI);
3076

3077 3078 3079 3080
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

3081
    /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag
3082 3083 3084 3085 3086
     * 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.
     */
3087
    DO_TEST_FULL("missing-machine",
3088
                 ARG_FLAGS, FLAG_EXPECT_FAILURE,
3089 3090
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE,
                 ARG_QEMU_CAPS, NONE);
3091

3092 3093 3094
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
3095 3096
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP,
3097 3098 3099 3100
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
3101
            QEMU_CAPS_SPICE_UNIX,
3102 3103 3104 3105 3106
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_SPICE_RENDERNODE,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
3107
            QEMU_CAPS_DEVICE_ISA_SERIAL,
3108
            QEMU_CAPS_CHARDEV_FILE_APPEND,
3109
            QEMU_CAPS_CCID_EMULATED,
3110
            QEMU_CAPS_VIRTIO_SCSI);
M
Marc-André Lureau 已提交
3111 3112
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

3113
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
3114
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
3115
            QEMU_CAPS_USB_HUB);
3116
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
3117
                        QEMU_CAPS_USB_HUB);
3118

3119
    DO_TEST("acpi-table", NONE);
3120 3121 3122 3123 3124 3125

    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");
3126
    DO_TEST_CAPS_LATEST("intel-iommu-aw-bits");
3127
    DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
3128
    DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
3129

3130
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
3131 3132 3133
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

3134
    DO_TEST_CAPS_LATEST("virtio-options");
3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158
    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");
3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200
    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);
3201

J
Ján Tomko 已提交
3202
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
3203
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
3204
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
3205
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
3206
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
3207 3208
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
3209
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
3210 3211
            QEMU_CAPS_KVM);

M
Marc-André Lureau 已提交
3212
    DO_TEST_CAPS_LATEST("memfd-memory-numa");
3213
    DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
M
Marc-André Lureau 已提交
3214

3215 3216 3217 3218 3219 3220 3221 3222
    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);

3223 3224 3225 3226 3227 3228 3229 3230 3231
    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 已提交
3232
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
3233

3234 3235 3236
    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,
3237
            QEMU_CAPS_DEVICE_ISA_SERIAL,
3238
            QEMU_CAPS_HDA_DUPLEX,
3239 3240
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
3241
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
3242 3243
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
3244
            QEMU_CAPS_ICH9_USB_EHCI1);
3245

3246
    DO_TEST_CAPS_VER("disk-virtio-scsi-reservations", "2.12.0");
3247
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
3248

3249
    DO_TEST_CAPS_LATEST("tseg-explicit-size");
3250 3251 3252
    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");
3253

3254
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
3255 3256 3257 3258 3259 3260
            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);

3261
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
3262 3263 3264 3265 3266 3267 3268
            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);

3269 3270
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");
3271 3272
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
3273

3274
    DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
3275

3276 3277
    DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
    DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
3278
    DO_TEST_CAPS_LATEST_PARSE_ERROR("vhost-user-fs-readonly");
3279

L
Lubomir Rintel 已提交
3280 3281
    DO_TEST("riscv64-virt",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
3282 3283
    DO_TEST("riscv64-virt-pci",
            QEMU_CAPS_OBJECT_GPEX);
L
Lubomir Rintel 已提交
3284

3285 3286 3287 3288 3289
    /* 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");
3290
    DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-transitional-not-supported");
3291

3292 3293 3294 3295 3296 3297 3298 3299
    /* 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");

3300 3301 3302
    /* 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");
3303
    DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-graphics", "riscv64");
3304
    DO_TEST_CAPS_ARCH_LATEST("s390x-ccw-graphics", "s390x");
3305 3306 3307
    DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-graphics", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-graphics", "x86_64");

3308 3309 3310 3311 3312
    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");

3313 3314 3315
    DO_TEST_CAPS_LATEST("vhost-user-vga");
    DO_TEST_CAPS_LATEST("vhost-user-gpu-secondary");

3316 3317 3318
    DO_TEST_CAPS_VER("cpu-Icelake-Server-pconfig", "3.1.0");
    DO_TEST_CAPS_LATEST("cpu-Icelake-Server-pconfig");

3319 3320
    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");
3321 3322 3323 3324 3325 3326
    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");
3327 3328
    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");
3329 3330
    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");
3331 3332 3333 3334
    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");
3335

3336 3337
    DO_TEST_CAPS_LATEST("virtio-9p-multidevs");

3338 3339 3340
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

3341
    VIR_FREE(driver.config->nbdTLSx509certdir);
3342
    qemuTestDriverFree(&driver);
3343
    VIR_FREE(fakerootdir);
3344
    virHashFree(capslatest);
3345
    virFileWrapperClearPrefixes();
3346

3347
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
3348 3349
}

3350
VIR_TEST_MAIN_PRELOAD(mymain,
3351
                      VIR_TEST_MOCK("qemuxml2argv"),
M
Michal Privoznik 已提交
3352
                      VIR_TEST_MOCK("domaincaps"),
3353 3354 3355
                      VIR_TEST_MOCK("virrandom"),
                      VIR_TEST_MOCK("qemucpu"),
                      VIR_TEST_MOCK("virpci"))
3356

3357 3358
#else

3359 3360 3361 3362
int main(void)
{
    return EXIT_AM_SKIP;
}
3363 3364

#endif /* WITH_QEMU */