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

#include <unistd.h>
4 5 6 7

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

8 9
#include "testutils.h"

10 11
#ifdef WITH_QEMU

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

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

33
# include "testutilsqemu.h"
34

35 36
# define VIR_FROM_THIS VIR_FROM_QEMU

37
static virQEMUDriver driver;
38

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

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

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

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

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

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

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

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

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

    if (STRNEQ(name, "inactive")) {
109 110
        xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir,
                                  STORAGE_POOL_XML_PATH, name);
111 112 113 114 115 116 117 118 119 120

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

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

121
 cleanup:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    VIR_FREE(xmlpath);
    return ret;
}


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

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

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

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

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

    if (!volinfo[1])
        goto fallback;

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

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

162
 fallback:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    ret = virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
    goto cleanup;
}

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

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

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

    return 0;
}


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

190
    ret = g_strdup_printf("/some/%s/device/%s", vol->key, vol->name);
191 192 193 194 195 196 197

    return ret;
}


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

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

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

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

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

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

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


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

285 286 287 288

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

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

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

    return 0;
}


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

364 365 366
    if (!caps)
        goto cleanup;

367 368
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

369 370
    virQEMUCapsInitQMPBasicArch(info->qemuCaps);

371 372
    if (testAddCPUModels(info->qemuCaps,
                         !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
373 374
        goto cleanup;

375 376 377 378
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
379

380 381 382 383 384 385 386
    ret = 0;

 cleanup:
    return ret;
}


387 388 389 390 391 392
static int
testCheckExclusiveFlags(int flags)
{
    virCheckFlags(FLAG_EXPECT_FAILURE |
                  FLAG_EXPECT_PARSE_ERROR |
                  FLAG_FIPS |
393
                  FLAG_REAL_CAPS |
394
                  FLAG_SKIP_LEGACY_CPUS |
395
                  FLAG_SLIRP_HELPER |
396 397
                  0, -1);

398
    VIR_EXCLUSIVE_FLAGS_RET(FLAG_REAL_CAPS, FLAG_SKIP_LEGACY_CPUS, -1);
399 400 401 402
    return 0;
}


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

420 421
    memset(&monitor_chr, 0, sizeof(monitor_chr));

422
    if (!(conn = virGetConnect()))
423
        goto cleanup;
424

425
    conn->secretDriver = &fakeSecretDriver;
426
    conn->storageDriver = &fakeStorageDriver;
427
    conn->nwfilterDriver = &fakeNWFilterDriver;
428

429 430 431 432
    virSetConnectInterface(conn);
    virSetConnectNetwork(conn);
    virSetConnectNWFilter(conn);
    virSetConnectNodeDev(conn);
433 434 435
    virSetConnectSecret(conn);
    virSetConnectStorage(conn);

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

439 440 441
    if (testCheckExclusiveFlags(info->flags) < 0)
        goto cleanup;

442
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
443 444 445
        goto cleanup;

    if (info->migrateFrom &&
446 447
        !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                              info->migrateFd)))
448 449
        goto cleanup;

450
    if (!(vm = virDomainObjNew(driver.xmlopt)))
451
        goto cleanup;
452

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

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

470
    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
471
        VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile);
472
        goto cleanup;
473 474
    }

475
    vm->def->id = -1;
476

477
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
478
        goto cleanup;
479

480 481
    if (!(info->flags & FLAG_REAL_CAPS) &&
        testUpdateQEMUCaps(info, vm, driver.caps) < 0)
482
        goto cleanup;
483

484
    log = virTestLogContentAndReset();
485
    VIR_FREE(log);
486
    virResetLastError();
J
Jiri Denemark 已提交
487

488 489
    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
490 491 492 493

        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) {
494
            hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
495 496 497
        }
    }

498 499 500 501 502 503 504 505 506 507 508
    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;
    }

509 510 511
    if (vm->def->tpm) {
        switch (vm->def->tpm->type) {
        case VIR_DOMAIN_TPM_TYPE_EMULATOR:
512
            VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
513
            vm->def->tpm->data.emulator.source.data.file.path = g_strdup("/dev/test");
514
            vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
515 516 517 518 519 520 521
            break;
        case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
        case VIR_DOMAIN_TPM_TYPE_LAST:
            break;
       }
    }

522 523 524 525 526 527 528 529 530 531
    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;
        }
    }

532 533 534 535 536
    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 &&
537
                virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
538 539 540 541 542 543 544
                qemuSlirpPtr slirp = qemuSlirpNew();
                slirp->fd[0] = 42;
                QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp = slirp;
            }
        }
    }

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

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

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

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

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

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

591
static void
592
testInfoSetPaths(struct testQemuInfo *info,
593 594
                 const char *suffix)
{
595 596 597 598
    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 : "");
599 600
}

A
Andrea Bolognani 已提交
601
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
602

603
static int
E
Eric Blake 已提交
604
mymain(void)
605
{
C
Cole Robinson 已提交
606
    int ret = 0;
A
Andrea Bolognani 已提交
607
    char *fakerootdir;
608
    virHashTablePtr capslatest = NULL;
609

610
    fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
A
Andrea Bolognani 已提交
611

J
Ján Tomko 已提交
612
    if (!g_mkdtemp(fakerootdir)) {
A
Andrea Bolognani 已提交
613 614 615 616 617 618
        fprintf(stderr, "Cannot create fakerootdir");
        abort();
    }

    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);

619 620 621 622 623 624 625 626 627 628
    /* Set the timezone because we are mocking the time() function.
     * If we don't do that, then localtime() may return unpredictable
     * results. In order to detect things that just work by a blind
     * chance, we need to set an virtual timezone that no libvirt
     * developer resides in. */
    if (setenv("TZ", "VIR00:30", 1) < 0) {
        perror("setenv");
        return EXIT_FAILURE;
    }

629
    if (qemuTestDriverInit(&driver) < 0)
630
        return EXIT_FAILURE;
631 632

    driver.privileged = true;
633

634
    VIR_FREE(driver.config->defaultTLSx509certdir);
635
    driver.config->defaultTLSx509certdir = g_strdup("/etc/pki/qemu");
636
    VIR_FREE(driver.config->vncTLSx509certdir);
637
    driver.config->vncTLSx509certdir = g_strdup("/etc/pki/libvirt-vnc");
638
    VIR_FREE(driver.config->spiceTLSx509certdir);
639
    driver.config->spiceTLSx509certdir = g_strdup("/etc/pki/libvirt-spice");
640
    VIR_FREE(driver.config->chardevTLSx509certdir);
641
    driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
642
    VIR_FREE(driver.config->vxhsTLSx509certdir);
643
    driver.config->vxhsTLSx509certdir = g_strdup("/etc/pki/libvirt-vxhs/dummy,path");
644
    VIR_FREE(driver.config->nbdTLSx509certdir);
645
    driver.config->nbdTLSx509certdir = g_strdup("/etc/pki/libvirt-nbd/dummy,path");
646

647
    VIR_FREE(driver.config->hugetlbfs);
648
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
649
        return EXIT_FAILURE;
650
    driver.config->nhugetlbfs = 2;
651 652
    driver.config->hugetlbfs[0].mnt_dir = g_strdup("/dev/hugepages2M");
    driver.config->hugetlbfs[1].mnt_dir = g_strdup("/dev/hugepages1G");
653 654
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
655
    driver.config->hugetlbfs[1].size = 1048576;
656
    driver.config->spiceTLS = 1;
657
    driver.config->spicePassword = g_strdup("123456");
658
    VIR_FREE(driver.config->memoryBackingDir);
659
    driver.config->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
660
    VIR_FREE(driver.config->nvramDir);
661
    driver.config->nvramDir = g_strdup("/var/lib/libvirt/qemu/nvram");
662

C
Cole Robinson 已提交
663
    capslatest = testQemuGetLatestCaps();
664
    if (!capslatest)
665 666
        return EXIT_FAILURE;

667 668 669 670 671 672 673
    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");

674 675 676 677 678 679 680 681 682 683
    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");

684 685 686 687 688 689 690 691 692 693 694 695 696 697
/**
 * 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.
 */
698
# define DO_TEST_INTERNAL(_name, _suffix, ...) \
699
    do { \
700
        static struct testQemuInfo info = { \
701
            .name = _name, \
702
        }; \
703 704
        if (testQemuInfoSetArgs(&info, capslatest, \
                                __VA_ARGS__, ARG_END) < 0) \
705
            return EXIT_FAILURE; \
706
        testInfoSetPaths(&info, _suffix); \
707
        if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \
708 709
                       testCompareXMLToArgv, &info) < 0) \
            ret = -1; \
710
        testQemuInfoClear(&info); \
711 712
    } while (0)

713 714 715 716 717 718
# define DO_TEST_CAPS_INTERNAL(name, arch, ver, ...) \
    DO_TEST_INTERNAL(name, "." arch "-" ver, \
                     ARG_CAPS_ARCH, arch, \
                     ARG_CAPS_VER, ver, \
                     __VA_ARGS__)

719
# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \
720
    DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__)
721

722 723 724
# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \
    DO_TEST_CAPS_INTERNAL(name, arch, ver, __VA_ARGS__)

725
# define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
726
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)
727

728
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
729
    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END)
730

731
# define DO_TEST_CAPS_LATEST(name) \
732
    DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
733

734 735 736
# define DO_TEST_CAPS_VER(name, ver) \
    DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)

737 738
# define DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, arch) \
    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \
739
                                  ARG_FLAGS, FLAG_EXPECT_FAILURE)
740

741 742 743 744 745 746 747 748 749 750 751 752
# 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, \
753
                                  ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
754

755 756 757 758 759 760 761 762 763 764
# 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)

765 766 767
# define DO_TEST_FULL(name, ...) \
    DO_TEST_INTERNAL(name, "", \
                     __VA_ARGS__, QEMU_CAPS_LAST)
768

769 770 771
/* All the following macros require an explicit QEMU_CAPS_* list
 * at the end of the argument list, or the NONE placeholder.
 * */
772
# define DO_TEST(name, ...) \
773
    DO_TEST_FULL(name, \
774
                 ARG_QEMU_CAPS, __VA_ARGS__)
775

776
# define DO_TEST_GIC(name, gic, ...) \
777
    DO_TEST_FULL(name, \
778
                 ARG_GIC, gic, \
779
                 ARG_QEMU_CAPS, __VA_ARGS__)
780

781
# define DO_TEST_FAILURE(name, ...) \
782 783
    DO_TEST_FULL(name, \
                 ARG_FLAGS, FLAG_EXPECT_FAILURE, \
784
                 ARG_QEMU_CAPS, __VA_ARGS__)
785

786
# define DO_TEST_PARSE_ERROR(name, ...) \
787
    DO_TEST_FULL(name, \
788
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
789
                 ARG_QEMU_CAPS, __VA_ARGS__)
790

791
# define NONE QEMU_CAPS_LAST
792

793 794 795
    /* 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 */
796 797 798 799 800 801 802
    setenv("PATH", "/bin", 1);
    setenv("USER", "test", 1);
    setenv("LOGNAME", "test", 1);
    setenv("HOME", "/home/test", 1);
    unsetenv("TMPDIR");
    unsetenv("LD_PRELOAD");
    unsetenv("LD_LIBRARY_PATH");
803 804
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
805

806
    DO_TEST("minimal", NONE);
807 808
    DO_TEST("minimal-sandbox",
            QEMU_CAPS_SECCOMP_BLACKLIST);
809
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
810
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
811 812 813 814

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

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

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

861
    DO_TEST("bios",
862
            QEMU_CAPS_DEVICE_ISA_SERIAL,
863
            QEMU_CAPS_SGA);
J
Ján Tomko 已提交
864
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
865 866 867
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
868
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
869 870 871
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
872 873 874 875 876 877 878

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

879
    DO_TEST("clock-utc", NONE);
880
    DO_TEST("clock-localtime", NONE);
J
Ján Tomko 已提交
881 882 883 884
    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 已提交
885
    DO_TEST("clock-catchup", QEMU_CAPS_KVM_PIT_TICK_POLICY);
886 887
    DO_TEST("cpu-kvmclock", NONE);
    DO_TEST("cpu-host-kvmclock", NONE);
888
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
889
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
890

891 892
    DO_TEST("cpu-eoi-disabled", NONE);
    DO_TEST("cpu-eoi-enabled", NONE);
J
Ján Tomko 已提交
893
    DO_TEST("controller-order",
894 895 896 897 898 899
            QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_HDA_DUPLEX,
            QEMU_CAPS_USB_HUB,
900
            QEMU_CAPS_DEVICE_ISA_SERIAL,
901
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
902
    DO_TEST_CAPS_VER("eoi-disabled", "2.7.0");
903
    DO_TEST_CAPS_VER("eoi-disabled", "4.0.0");
904 905
    DO_TEST_CAPS_LATEST("eoi-disabled");
    DO_TEST_CAPS_VER("eoi-enabled", "2.7.0");
906
    DO_TEST_CAPS_VER("eoi-enabled", "4.0.0");
907 908
    DO_TEST_CAPS_LATEST("eoi-enabled");
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "2.7.0");
909
    DO_TEST_CAPS_VER("pv-spinlock-disabled", "4.0.0");
910 911
    DO_TEST_CAPS_LATEST("pv-spinlock-disabled");
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "2.7.0");
912
    DO_TEST_CAPS_VER("pv-spinlock-enabled", "4.0.0");
913 914
    DO_TEST_CAPS_LATEST("pv-spinlock-enabled");
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "2.7.0");
915
    DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "4.0.0");
916
    DO_TEST_CAPS_LATEST("kvmclock+eoi-disabled");
917

918 919 920 921 922 923
    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");
924
    DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
925

926 927 928
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

929 930 931
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

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

1160 1161 1162
    DO_TEST("graphics-egl-headless",
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1163 1164
    DO_TEST_CAPS_LATEST("graphics-egl-headless");
    DO_TEST_CAPS_LATEST("graphics-egl-headless-rendernode");
1165

1166 1167
    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);
1168 1169
    DO_TEST("graphics-vnc-websocket",
            QEMU_CAPS_VNC,
1170
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1171
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
1172 1173 1174 1175 1176
            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);
1177
    driver.config->vncAutoUnixSocket = true;
1178 1179
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1180
    driver.config->vncAutoUnixSocket = false;
1181 1182 1183 1184
    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);
1185 1186
    DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
1187

1188 1189
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1190
    driver.config->vncSASLdir = g_strdup("/root/.sasl2");
1191
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1192 1193
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1194
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1195 1196
    DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
    DO_TEST_CAPS_LATEST("graphics-vnc-tls");
1197
    driver.config->vncTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
1198 1199
    DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret");
    VIR_FREE(driver.config->vncTLSx509secretUUID);
1200
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1201 1202
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1203 1204 1205 1206
    DO_TEST("graphics-vnc-egl-headless",
            QEMU_CAPS_VNC,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1207

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

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

1326 1327 1328
    DO_TEST("hostdev-pci-multifunction",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DEVICE_VFIO_PCI);
1329

1330 1331
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1332
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1333
            QEMU_CAPS_CHARDEV_LOGFILE);
1334
    DO_TEST("serial-spiceport",
1335
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1336
            QEMU_CAPS_DEVICE_QXL,
1337
            QEMU_CAPS_SPICE,
1338
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1339
    DO_TEST("serial-spiceport-nospice", NONE);
1340

1341 1342 1343 1344
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1345 1346

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

1399
    DO_TEST("channel-guestfwd", NONE);
J
Ján Tomko 已提交
1400 1401
    DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0");
    DO_TEST_CAPS_LATEST("channel-unix-guestfwd");
1402 1403 1404 1405 1406 1407
    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);
1408
    DO_TEST("console-virtio-many",
1409
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1410
    DO_TEST("console-virtio-s390",
1411
            QEMU_CAPS_VIRTIO_S390);
1412
    DO_TEST("console-virtio-ccw",
1413
            QEMU_CAPS_CCW,
1414
            QEMU_CAPS_VIRTIO_S390);
J
Ján Tomko 已提交
1415 1416
    DO_TEST_CAPS_VER("console-virtio-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("console-virtio-unix");
1417
    DO_TEST("console-sclp",
1418
            QEMU_CAPS_VIRTIO_S390,
1419
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1420
    DO_TEST("channel-spicevmc",
1421
            QEMU_CAPS_SPICE,
1422
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1423
    DO_TEST("channel-virtio-default",
1424
            QEMU_CAPS_SPICE);
1425
    DO_TEST("channel-virtio-unix", NONE);
1426

1427
    DO_TEST("smartcard-host",
1428
            QEMU_CAPS_CCID_EMULATED);
1429
    DO_TEST("smartcard-host-certificates",
1430
            QEMU_CAPS_CCID_EMULATED);
1431 1432
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1433
    DO_TEST("smartcard-passthrough-tcp",
1434
            QEMU_CAPS_CCID_PASSTHRU);
1435
    DO_TEST("smartcard-passthrough-spicevmc",
1436
            QEMU_CAPS_CCID_PASSTHRU);
1437
    DO_TEST("smartcard-controller",
1438
            QEMU_CAPS_CCID_EMULATED);
J
Ján Tomko 已提交
1439 1440
    DO_TEST_CAPS_VER("smartcard-passthrough-unix", "2.5.0");
    DO_TEST_CAPS_LATEST("smartcard-passthrough-unix");
1441

1442 1443 1444 1445 1446 1447 1448 1449
    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);
1450 1451
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1452

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

1553 1554 1555
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1556

1557
    DO_TEST("watchdog", NONE);
1558
    DO_TEST("watchdog-device", NONE);
1559
    DO_TEST("watchdog-dump", NONE);
1560
    DO_TEST("watchdog-injectnmi", NONE);
1561
    DO_TEST("watchdog-diag288", QEMU_CAPS_VIRTIO_S390);
1562 1563
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1564
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1565
    DO_TEST("balloon-ccw-deflate",
1566
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1567
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1568
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1569
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1570
    DO_TEST("balloon-device-deflate-off",
1571
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1572 1573
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1574 1575
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1576
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1577
            QEMU_CAPS_HDA_OUTPUT,
1578 1579
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1580
    DO_TEST("fs9p", NONE);
1581
    DO_TEST_CAPS_LATEST("fs9p");
1582
    DO_TEST("fs9p-ccw",
1583
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1584
    DO_TEST_CAPS_ARCH_LATEST("fs9p-ccw", "s390x");
1585

1586
    DO_TEST("hostdev-usb-address", NONE);
1587
    DO_TEST("hostdev-usb-address-device", NONE);
1588
    DO_TEST("hostdev-usb-address-device-boot", NONE);
1589 1590
    DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI);
1591 1592
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1593
    DO_TEST("hostdev-vfio-multidomain",
1594
            QEMU_CAPS_DEVICE_VFIO_PCI);
1595 1596 1597 1598 1599 1600
    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);
1601 1602 1603 1604 1605 1606 1607
    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);
1608
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb");
1609 1610
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1611 1612 1613
    DO_TEST("hostdev-vfio-zpci",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626
    DO_TEST("hostdev-vfio-zpci-multidomain-many",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST("hostdev-vfio-zpci-autogenerate",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST("hostdev-vfio-zpci-boundaries",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_ZPCI);
    DO_TEST_PARSE_ERROR("hostdev-vfio-zpci",
                        QEMU_CAPS_DEVICE_VFIO_PCI);
1627
    DO_TEST("pci-rom", QEMU_CAPS_DEVICE_VFIO_PCI);
1628
    DO_TEST("pci-rom-disabled", NONE);
1629
    DO_TEST("pci-rom-disabled-invalid", NONE);
1630

1631 1632 1633 1634
    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
1635 1636
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
                             "s390x");
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648
    DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-duplicate-address",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
    DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-invalid-address",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);

B
Boris Fiuczynski 已提交
1649 1650
    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ap",
                             "s390x");
1651 1652
    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ap-boot-fail",
                                         "s390x");
B
Boris Fiuczynski 已提交
1653

1654
    DO_TEST_FULL("restore-v2",
1655 1656
                 ARG_MIGRATE_FROM, "exec:cat",
                 ARG_MIGRATE_FD, 7,
1657
                 ARG_QEMU_CAPS, NONE);
1658
    DO_TEST_FULL("restore-v2-fd",
1659 1660
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1661
                 ARG_QEMU_CAPS, NONE);
1662
    DO_TEST_FULL("restore-v2-fd",
1663 1664
                 ARG_MIGRATE_FROM, "fd:7",
                 ARG_MIGRATE_FD, 7,
1665
                 ARG_QEMU_CAPS, NONE);
1666
    DO_TEST_FULL("migrate",
1667
                 ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000",
1668
                 ARG_QEMU_CAPS, NONE);
1669

1670
    DO_TEST_FULL("migrate-numa-unaligned",
1671 1672
                 ARG_MIGRATE_FROM, "stdio",
                 ARG_MIGRATE_FD, 7,
1673
                 ARG_QEMU_CAPS,
A
Andrea Bolognani 已提交
1674 1675
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1676

1677 1678
    DO_TEST_CAPS_VER("qemu-ns", "4.0.0");
    DO_TEST_CAPS_LATEST("qemu-ns");
1679
    DO_TEST("qemu-ns-no-env", NONE);
1680
    DO_TEST("qemu-ns-alt", NONE);
1681

1682
    DO_TEST("smp", NONE);
1683

J
John Ferlan 已提交
1684
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1685 1686
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1687
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1688 1689
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1690
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1691 1692
    DO_TEST_CAPS_LATEST("iothreads-virtio-scsi-pci");
    DO_TEST_CAPS_ARCH_LATEST("iothreads-virtio-scsi-ccw", "s390x");
J
John Ferlan 已提交
1693

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

1726
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
1727
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1728 1729
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1730 1731
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1732
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1733 1734 1735 1736
    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);
1737
    DO_TEST("cpu-host-model-cmt", NONE);
1738
    DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
1739
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1740
    DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
1741 1742
    DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
    DO_TEST_CAPS_LATEST("cpu-translation");
1743
    qemuTestSetHostCPU(driver.caps, NULL);
1744

1745 1746
    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);
1747
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1748
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1749 1750
    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);
1751
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1752
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1753

1754 1755 1756 1757 1758 1759 1760 1761
    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);
1762
    DO_TEST("cputune-numatune",
1763
            QEMU_CAPS_KVM,
1764
            QEMU_CAPS_OBJECT_IOTHREAD,
1765 1766
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1767 1768 1769
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1770

1771
    DO_TEST("numatune-memory", NONE);
1772
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1773 1774 1775
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1776 1777
    DO_TEST_FAILURE("numatune-memnode", NONE);

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

1783 1784
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

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

1807
    DO_TEST("multifunction-pci-device",
1808
            QEMU_CAPS_SCSI_LSI);
1809

1810
    DO_TEST("monitor-json", NONE);
1811

1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823
    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);
1824

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

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1858
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1859
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1860
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1861 1862 1863
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
1864
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1865
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1866
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1867
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1868 1869 1870
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
1871 1872 1873

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1874
            QEMU_CAPS_KVM,
1875
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1876
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1877 1878
    qemuTestSetHostCPU(driver.caps, NULL);

1879 1880
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1881
    DO_TEST("pseries-panic-missing",
1882
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1883
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1884
    DO_TEST("pseries-panic-no-address",
1885
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1886
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1887
    DO_TEST_FAILURE("pseries-panic-address",
1888
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1889 1890 1891 1892 1893

    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);
1894 1895 1896 1897 1898 1899
    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);
1900 1901 1902
    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);
1903

1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925
    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);

1926
    DO_TEST("pseries-features",
1927
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1928
            QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
1929
            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
1930
            QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV,
1931
            QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST,
1932
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1933
    DO_TEST_FAILURE("pseries-features",
1934
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1935
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
1936

1937
    DO_TEST("pseries-serial-native",
1938
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1939 1940
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
1941
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1942 1943
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
1944
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1945
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1946
    DO_TEST("pseries-serial-pci",
1947
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1948 1949
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
1950
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1951 1952
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
1953
    DO_TEST("pseries-console-native",
1954
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1955 1956
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
1957
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1958
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
1959
    DO_TEST_PARSE_ERROR("pseries-spaprvio-invalid", "ppc64");
1960

1961
    DO_TEST("mach-virt-serial-native",
1962
            QEMU_CAPS_DEVICE_PL011);
1963
    DO_TEST("mach-virt-serial+console-native",
1964
            QEMU_CAPS_DEVICE_PL011);
1965
    DO_TEST("mach-virt-serial-compat",
1966
            QEMU_CAPS_DEVICE_PL011);
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
    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",
1979
            QEMU_CAPS_DEVICE_PL011);
1980 1981
    DO_TEST("mach-virt-console-virtio",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
1982 1983
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

1984 1985
    DO_TEST("disk-ide-split", NONE);
    DO_TEST("disk-ide-wwn", QEMU_CAPS_IDE_DRIVE_WWN);
1986

1987
    DO_TEST("disk-geometry", NONE);
1988
    DO_TEST("disk-blockio", QEMU_CAPS_BLOCKIO);
1989

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

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

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

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

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

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

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

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

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

    /* 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,
2356
            QEMU_CAPS_DEVICE_IOH3420);
2357
    DO_TEST("pcie-root-port-model-ioh3420",
2358
            QEMU_CAPS_DEVICE_IOH3420);
2359

2360 2361 2362 2363 2364 2365 2366
    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,
2367
            QEMU_CAPS_ICH9_USB_EHCI1,
2368
            QEMU_CAPS_NEC_USB_XHCI);
2369 2370 2371 2372 2373 2374 2375
    /* 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);
2376

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

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

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

2406 2407 2408 2409 2410 2411
    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);
2412 2413
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2414

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

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

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

2476 2477 2478 2479
    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);
2480

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

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

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

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

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

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

2660 2661 2662 2663 2664 2665 2666 2667 2668
    /* 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");

2669
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2670

2671
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2672
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2673

2674 2675 2676 2677
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2678

2679 2680
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2681

2682 2683
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2684
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2685 2686 2687
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2688
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2689
    DO_TEST_FAILURE("shmem-invalid-size",
2690
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2691
    DO_TEST_FAILURE("shmem-invalid-address",
2692
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2693
    DO_TEST_FAILURE("shmem-small-size",
2694
                    QEMU_CAPS_DEVICE_IVSHMEM);
2695
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2696
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2697

2698
    DO_TEST_FAILURE("memory-align-fail", NONE);
2699
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2700
    DO_TEST("memory-hotplug", NONE);
2701
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2702
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2703
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2704
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2705
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2706
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2707
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2708
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2709 2710 2711
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-access");
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-label");
2712
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-align");
2713
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-pmem");
2714
    DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly");
2715

2716
    DO_TEST("machine-aeskeywrap-on-caps",
2717
            QEMU_CAPS_AES_KEY_WRAP,
2718
            QEMU_CAPS_DEA_KEY_WRAP,
2719
            QEMU_CAPS_VIRTIO_SCSI,
2720
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2721
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2722
                    QEMU_CAPS_VIRTIO_SCSI,
2723
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2724 2725 2726
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2727
            QEMU_CAPS_AES_KEY_WRAP,
2728
            QEMU_CAPS_VIRTIO_SCSI,
2729
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2730
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2731
                    QEMU_CAPS_VIRTIO_SCSI,
2732
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2733 2734 2735
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

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

    DO_TEST("machine-aeskeywrap-off-cap",
2745
            QEMU_CAPS_AES_KEY_WRAP,
2746
            QEMU_CAPS_VIRTIO_SCSI,
2747
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2748
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2749
                    QEMU_CAPS_VIRTIO_SCSI,
2750
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2751 2752 2753
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

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

    DO_TEST("machine-deakeywrap-on-cap",
2763
            QEMU_CAPS_DEA_KEY_WRAP,
2764
            QEMU_CAPS_VIRTIO_SCSI,
2765
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2766
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2767
                    QEMU_CAPS_VIRTIO_SCSI,
2768
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2769 2770 2771
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

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

    DO_TEST("machine-deakeywrap-off-cap",
2781
            QEMU_CAPS_DEA_KEY_WRAP,
2782
            QEMU_CAPS_VIRTIO_SCSI,
2783
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2784
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2785
                    QEMU_CAPS_VIRTIO_SCSI,
2786
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2787 2788 2789
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2790
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2791
            QEMU_CAPS_VIRTIO_SCSI,
2792
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2793
    DO_TEST("machine-keywrap-none",
2794
            QEMU_CAPS_VIRTIO_SCSI,
2795
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2796

2797
    DO_TEST("machine-loadparm-s390",
2798
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2799
            QEMU_CAPS_LOADPARM);
2800
    DO_TEST("machine-loadparm-net-s390",
2801
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2802
            QEMU_CAPS_LOADPARM);
2803
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
2804
            QEMU_CAPS_CCW,
2805
            QEMU_CAPS_VIRTIO_S390,
2806 2807
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
2808
                        QEMU_CAPS_CCW,
2809
                        QEMU_CAPS_VIRTIO_S390,
2810 2811
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
2812
                        QEMU_CAPS_CCW,
2813
                        QEMU_CAPS_VIRTIO_S390,
2814 2815
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2816 2817 2818 2819 2820 2821 2822
    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);

2823
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2824
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2825
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2826

2827
    DO_TEST("ppc64-usb-controller",
2828
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2829
            QEMU_CAPS_PCI_OHCI);
2830
    DO_TEST("ppc64-usb-controller-legacy",
2831
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2832
            QEMU_CAPS_PIIX3_USB_UHCI);
2833
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci",
2834
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
2835
                 ARG_QEMU_CAPS,
2836
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2837 2838 2839 2840 2841 2842 2843
                 QEMU_CAPS_NEC_USB_XHCI,
                 QEMU_CAPS_DEVICE_QEMU_XHCI);

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

2845 2846 2847 2848
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2849 2850 2851
    /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag
     * will avoid the error. Still, we expect qemu driver to complain about
     * missing machine error, and not crash */
2852 2853 2854 2855
    DO_TEST_FULL("missing-machine",
                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE,
                 ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE,
                 ARG_QEMU_CAPS, NONE);
2856

2857 2858 2859
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
2860 2861
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP,
2862 2863 2864 2865
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
2866
            QEMU_CAPS_SPICE_UNIX,
2867 2868 2869 2870 2871
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_SPICE_RENDERNODE,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2872
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2873
            QEMU_CAPS_CHARDEV_FILE_APPEND,
2874
            QEMU_CAPS_CCID_EMULATED,
2875
            QEMU_CAPS_VIRTIO_SCSI);
M
Marc-André Lureau 已提交
2876 2877
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2878
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
2879
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
2880
            QEMU_CAPS_USB_HUB);
2881
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
2882
                        QEMU_CAPS_USB_HUB);
2883

2884
    DO_TEST("acpi-table", NONE);
2885 2886 2887 2888 2889 2890

    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");
2891
    DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
2892
    DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
2893

2894
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2895 2896 2897
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2898 2899 2900
    DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
2901
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2902
            QEMU_CAPS_DEVICE_VHOST_USER_GPU,
2903 2904
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2905 2906 2907
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2908

J
Ján Tomko 已提交
2909
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2910
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2911
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
2912
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2913
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
2914 2915
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
2916
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2917 2918
            QEMU_CAPS_KVM);

M
Marc-André Lureau 已提交
2919
    DO_TEST_CAPS_LATEST("memfd-memory-numa");
2920
    DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
M
Marc-André Lureau 已提交
2921

2922 2923 2924 2925 2926 2927 2928 2929
    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);

2930 2931 2932 2933 2934 2935 2936 2937 2938
    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 已提交
2939
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2940

2941 2942 2943
    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,
2944
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2945
            QEMU_CAPS_HDA_DUPLEX,
2946 2947
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
2948
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2949 2950
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
2951
            QEMU_CAPS_ICH9_USB_EHCI1);
2952

2953
    DO_TEST_CAPS_VER("disk-virtio-scsi-reservations", "2.12.0");
2954
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
2955

2956
    DO_TEST_CAPS_LATEST("tseg-explicit-size");
2957 2958 2959
    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");
2960

2961
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
2962 2963 2964 2965 2966 2967
            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);

2968
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
2969 2970 2971 2972 2973 2974 2975
            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);

2976 2977
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");
2978 2979
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
    DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
2980

2981
    DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
2982

L
Lubomir Rintel 已提交
2983 2984
    DO_TEST("riscv64-virt",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2985 2986
    DO_TEST("riscv64-virt-pci",
            QEMU_CAPS_OBJECT_GPEX);
L
Lubomir Rintel 已提交
2987

2988 2989 2990 2991 2992
    /* 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");
2993
    DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-transitional-not-supported");
2994

2995 2996 2997 2998 2999 3000 3001 3002
    /* 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");

3003 3004 3005
    /* 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");
3006
    DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-graphics", "riscv64");
3007
    DO_TEST_CAPS_ARCH_LATEST("s390x-ccw-graphics", "s390x");
3008 3009 3010
    DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-graphics", "x86_64");
    DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-graphics", "x86_64");

3011 3012 3013 3014 3015
    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");

3016 3017 3018
    DO_TEST_CAPS_LATEST("vhost-user-vga");
    DO_TEST_CAPS_LATEST("vhost-user-gpu-secondary");

3019 3020 3021
    DO_TEST_CAPS_VER("cpu-Icelake-Server-pconfig", "3.1.0");
    DO_TEST_CAPS_LATEST("cpu-Icelake-Server-pconfig");

A
Andrea Bolognani 已提交
3022 3023 3024
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

3025
    VIR_FREE(driver.config->nbdTLSx509certdir);
3026
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
3027
    VIR_FREE(fakerootdir);
3028
    virHashFree(capslatest);
3029
    virFileWrapperClearPrefixes();
3030

3031
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
3032 3033
}

3034
VIR_TEST_MAIN_PRELOAD(mymain,
3035 3036 3037 3038
                      VIR_TEST_MOCK("qemuxml2argv"),
                      VIR_TEST_MOCK("virrandom"),
                      VIR_TEST_MOCK("qemucpu"),
                      VIR_TEST_MOCK("virpci"))
3039

3040 3041
#else

3042 3043 3044 3045
int main(void)
{
    return EXIT_AM_SKIP;
}
3046 3047

#endif /* WITH_QEMU */