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

3
#include <stdio.h>
4 5
#include <stdlib.h>
#include <unistd.h>
6 7 8 9 10
#include <string.h>

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

11 12
#include "testutils.h"

13 14
#ifdef WITH_QEMU

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

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

34
# include "testutilsqemu.h"
35

36 37
# define VIR_FROM_THIS VIR_FROM_QEMU

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

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

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

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

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

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

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

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

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

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

    if (STRNEQ(name, "inactive")) {
        if (virAsprintf(&xmlpath, "%s/%s%s.xml",
                        abs_srcdir,
                        STORAGE_POOL_XML_PATH,
                        name) < 0)
            return NULL;

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

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

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


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

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

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

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

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

    if (!volinfo[1])
        goto fallback;

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

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

166
 fallback:
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    ret = virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
    goto cleanup;
}

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

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

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

    return 0;
}


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

    ignore_value(virAsprintf(&ret, "/some/%s/device/%s", vol->key, vol->name));

    return ret;
}


static char *
fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
                          unsigned int flags_unused ATTRIBUTE_UNUSED)
{
    char *xmlpath = NULL;
    char *xmlbuf = NULL;

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

    if (virAsprintf(&xmlpath, "%s/%s%s.xml",
                    abs_srcdir,
                    STORAGE_POOL_XML_PATH,
                    pool->name) < 0)
        return NULL;

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

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

    return xmlbuf;
}

static int
fakeStoragePoolIsActive(virStoragePoolPtr pool)
{
    if (STREQ(pool->name, "inactive"))
        return 0;

    return 1;
}

/* Test storage pool implementation
 *
 * These functions aid testing of storage pool related stuff when creating a
243
 * qemu command line.
244 245 246
 *
 * There are a few "magic" values to pass to these functions:
 *
247 248
 * 1) "inactive" as a pool name to create an inactive pool. All other names are
 * interpreted as file names in storagepoolxml2xmlout/ and are used as the
249 250 251
 * definition for the pool. If the file doesn't exist the pool doesn't exist.
 *
 * 2) "nonexistent" returns an error while looking up a volume. Otherwise
252
 * pattern VOLUME_TYPE+VOLUME_PATH can be used to simulate a volume in a pool.
253 254 255 256 257 258 259 260 261 262 263 264
 * This creates a fake path for this volume. If the '+' sign is omitted, block
 * type is assumed.
 */
static virStorageDriver fakeStorageDriver = {
    .storagePoolLookupByName = fakeStoragePoolLookupByName,
    .storageVolLookupByName = fakeStorageVolLookupByName,
    .storagePoolGetXMLDesc = fakeStoragePoolGetXMLDesc,
    .storageVolGetPath = fakeStorageVolGetPath,
    .storageVolGetInfo = fakeStorageVolGetInfo,
    .storagePoolIsActive = fakeStoragePoolIsActive,
};

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

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

283 284 285 286

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

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

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

    return 0;
}


static int
356 357
testInitQEMUCaps(struct testInfo *info,
                 int gic)
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
{
    int ret = -1;

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

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

    ret = 0;

 cleanup:
    return ret;
}


374 375
static int
testUpdateQEMUCaps(const struct testInfo *info,
376 377
                   virDomainObjPtr vm,
                   virCapsPtr caps)
378 379 380
{
    int ret = -1;

381 382 383
    if (!caps)
        goto cleanup;

384 385
    virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);

386 387
    virQEMUCapsInitQMPBasicArch(info->qemuCaps);

388 389 390
    if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
        goto cleanup;

391 392 393 394
    virQEMUCapsFreeHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsFreeHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
395

396 397 398 399
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
400

401 402 403 404 405 406 407 408 409
    virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);

    ret = 0;

 cleanup:
    return ret;
}


410
static int
411
testCompareXMLToStartupXML(const void *data)
412
{
413
    const struct testInfo *info = data;
414 415 416 417 418
    unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
    char *xml = NULL;
    char *actual = NULL;
    int ret = -1;

419 420 421
    if (!info->vm)
        return EXIT_AM_SKIP;

422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
    if (virAsprintf(&xml, "%s/qemuxml2startupxmloutdata/%s.xml",
                    abs_srcdir, info->name) < 0)
        goto cleanup;

    if (!virFileExists(xml)) {
        ret = EXIT_AM_SKIP;
        goto cleanup;
    }

    if (!(actual = virDomainDefFormat(info->vm->def, NULL, format_flags)))
        goto cleanup;

    ret = virTestCompareToFile(actual, xml);

 cleanup:
    VIR_FREE(xml);
    VIR_FREE(actual);
    return ret;
}


static int
testCompareXMLToArgv(const void *data)
{
    struct testInfo *info = (void *) data;
447 448 449
    char *xml = NULL;
    char *args = NULL;
    char *migrateURI = NULL;
450
    char *actualargv = NULL;
451
    const char *suffix = info->suffix;
452 453
    unsigned int flags = info->flags;
    unsigned int parseFlags = info->parseFlags;
E
Eric Blake 已提交
454
    int ret = -1;
455
    virDomainObjPtr vm = NULL;
456
    virDomainChrSourceDef monitor_chr;
457
    virConnectPtr conn;
J
Jiri Denemark 已提交
458
    char *log = NULL;
E
Eric Blake 已提交
459
    virCommandPtr cmd = NULL;
460
    size_t i;
461
    qemuDomainObjPrivatePtr priv = NULL;
462

463 464
    memset(&monitor_chr, 0, sizeof(monitor_chr));

465
    if (!(conn = virGetConnect()))
466
        goto cleanup;
467

468 469 470
    if (!suffix)
        suffix = "";

471
    conn->secretDriver = &fakeSecretDriver;
472
    conn->storageDriver = &fakeStorageDriver;
473

474 475 476
    virSetConnectSecret(conn);
    virSetConnectStorage(conn);

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

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

483
    if (virAsprintf(&xml, "%s/qemuxml2argvdata/%s.xml",
484
                    abs_srcdir, info->name) < 0 ||
485 486
        virAsprintf(&args, "%s/qemuxml2argvdata/%s%s.args",
                    abs_srcdir, info->name, suffix) < 0)
487 488 489
        goto cleanup;

    if (info->migrateFrom &&
490 491
        !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                              info->migrateFd)))
492 493
        goto cleanup;

494
    if (!(vm = virDomainObjNew(driver.xmlopt)))
495
        goto cleanup;
496

497
    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
498
    if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
499
                                          NULL, parseFlags))) {
P
Pavel Hrdina 已提交
500
        if (flags & FLAG_EXPECT_PARSE_ERROR)
501
            goto ok;
502
        goto cleanup;
503
    }
504 505 506 507
    if (flags & FLAG_EXPECT_PARSE_ERROR) {
        VIR_TEST_DEBUG("passed instead of expected parse error");
        goto cleanup;
    }
508
    priv = vm->privateData;
509

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

513
    if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
514
        VIR_TEST_DEBUG("ABI stability check failed on %s", xml);
515
        goto cleanup;
516 517
    }

518
    vm->def->id = -1;
519

520
    if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
521
        goto cleanup;
522

523
    if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
524
        goto cleanup;
525

526
    log = virTestLogContentAndReset();
527
    VIR_FREE(log);
528
    virResetLastError();
J
Jiri Denemark 已提交
529

530 531
    for (i = 0; i < vm->def->nhostdevs; i++) {
        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
532 533 534 535 536 537 538 539

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

540 541 542 543 544 545 546 547 548 549 550
    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;
    }

551 552 553
    if (vm->def->tpm) {
        switch (vm->def->tpm->type) {
        case VIR_DOMAIN_TPM_TYPE_EMULATOR:
554
            VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
555 556 557
            if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.path,
                           "/dev/test") < 0)
                goto cleanup;
558
            vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
559 560 561 562 563 564 565
            break;
        case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
        case VIR_DOMAIN_TPM_TYPE_LAST:
            break;
       }
    }

566
    if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI,
P
Pavel Hrdina 已提交
567 568
                                            (flags & FLAG_FIPS), false,
                                            VIR_QEMU_PROCESS_START_COLD))) {
P
Pavel Hrdina 已提交
569 570
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
571
        goto cleanup;
J
Jiri Denemark 已提交
572
    }
573 574 575 576
    if (flags & FLAG_EXPECT_FAILURE) {
        VIR_TEST_DEBUG("passed instead of expected failure");
        goto cleanup;
    }
J
Jiri Denemark 已提交
577

E
Eric Blake 已提交
578
    if (!(actualargv = virCommandToString(cmd)))
579
        goto cleanup;
E
Eric Blake 已提交
580

581
    if (virTestCompareToFile(actualargv, args) < 0)
582
        goto cleanup;
583

P
Pavel Hrdina 已提交
584 585
    ret = 0;

586
 ok:
587
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
588 589
        ret = -1;
        VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
590
        goto cleanup;
P
Pavel Hrdina 已提交
591
    }
592
    if (!virTestOOMActive()) {
593
        if (flags & FLAG_EXPECT_FAILURE) {
594
            if ((log = virTestLogContentAndReset()))
P
Pavel Hrdina 已提交
595 596
                VIR_TEST_DEBUG("Got expected error: \n%s", log);
        }
597
        virResetLastError();
P
Pavel Hrdina 已提交
598
        ret = 0;
599 600
    }

601 602 603
    if (!(flags & FLAG_EXPECT_FAILURE) && ret == 0)
        VIR_STEAL_PTR(info->vm, vm);

604
 cleanup:
605 606
    VIR_FREE(log);
    VIR_FREE(actualargv);
607
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
608
    virCommandFree(cmd);
609
    virObjectUnref(vm);
610 611
    virSetConnectSecret(NULL);
    virSetConnectStorage(NULL);
612
    virObjectUnref(conn);
613
    VIR_FREE(migrateURI);
614 615
    VIR_FREE(xml);
    VIR_FREE(args);
616
    return ret;
617 618
}

A
Andrea Bolognani 已提交
619
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
620

621
static int
E
Eric Blake 已提交
622
mymain(void)
623 624
{
    int ret = 0;
A
Andrea Bolognani 已提交
625
    char *fakerootdir;
626
    bool skipLegacyCPUs = false;
627
    char *capslatest_x86_64 = NULL;
628

A
Andrea Bolognani 已提交
629 630 631 632 633 634 635 636 637 638 639 640
    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
        fprintf(stderr, "Out of memory\n");
        abort();
    }

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

    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);

641 642
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
643
        abs_top_srcdir = abs_srcdir "/..";
644

645 646 647 648 649 650 651 652 653 654
    /* 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;
    }

655
    if (qemuTestDriverInit(&driver) < 0)
656
        return EXIT_FAILURE;
657 658

    driver.privileged = true;
659

660 661 662
    VIR_FREE(driver.config->defaultTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/qemu") < 0)
        return EXIT_FAILURE;
663
    VIR_FREE(driver.config->vncTLSx509certdir);
664
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
665 666
        return EXIT_FAILURE;
    VIR_FREE(driver.config->spiceTLSx509certdir);
667
    if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
668
        return EXIT_FAILURE;
669 670 671
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
672
    VIR_FREE(driver.config->vxhsTLSx509certdir);
673
    if (VIR_STRDUP_QUIET(driver.config->vxhsTLSx509certdir, "/etc/pki/libvirt-vxhs/dummy,path") < 0)
674
        return EXIT_FAILURE;
675 676 677
    VIR_FREE(driver.config->nbdTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->nbdTLSx509certdir, "/etc/pki/libvirt-nbd/dummy,path") < 0)
        return EXIT_FAILURE;
678

679
    VIR_FREE(driver.config->hugetlbfs);
680
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
681
        return EXIT_FAILURE;
682 683 684
    driver.config->nhugetlbfs = 2;
    if (VIR_STRDUP(driver.config->hugetlbfs[0].mnt_dir, "/dev/hugepages2M") < 0 ||
        VIR_STRDUP(driver.config->hugetlbfs[1].mnt_dir, "/dev/hugepages1G") < 0)
685
        return EXIT_FAILURE;
686 687
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
688
    driver.config->hugetlbfs[1].size = 1048576;
689
    driver.config->spiceTLS = 1;
690
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
691
        return EXIT_FAILURE;
692 693 694
    VIR_FREE(driver.config->memoryBackingDir);
    if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
        return EXIT_FAILURE;
695

696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
    if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata",
                                                           "x86_64", "xml")))
        return EXIT_FAILURE;

    VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64);


/**
 * 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.
 */
# define DO_TEST_CAPS_INTERNAL(name, suffix, migrateFrom, flags, parseFlags, \
718
                               arch, capsfile, stripmachinealiases) \
719 720 721 722 723 724 725 726 727
    do { \
        static struct testInfo info = { \
            name, "." suffix, NULL, migrateFrom, migrateFrom ? 7 : -1,\
            (flags), parseFlags, false, NULL \
        }; \
        info.skipLegacyCPUs = skipLegacyCPUs; \
        if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
                                                            capsfile))) \
            return EXIT_FAILURE; \
728 729
        if (stripmachinealiases) \
            virQEMUCapsStripMachineAliases(info.qemuCaps); \
730 731 732 733 734 735 736 737 738
        if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \
                       testCompareXMLToArgv, &info) < 0) \
            ret = -1; \
        virObjectUnref(info.qemuCaps); \
        virObjectUnref(info.vm); \
    } while (0)

# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_"

739 740
# define DO_TEST_CAPS_ARCH_VER_FULL(name, flags, parseFlags, arch, ver) \
    DO_TEST_CAPS_INTERNAL(name, arch "-" ver, NULL, flags, parseFlags, \
741
                          arch, TEST_CAPS_PATH ver "." arch ".xml", false)
742

743 744
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
    DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, arch, ver)
745 746

# define DO_TEST_CAPS_VER(name, ver) \
747
    DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)
748 749

# define DO_TEST_CAPS_LATEST(name) \
750
    DO_TEST_CAPS_INTERNAL(name, "x86_64-latest", NULL, 0, 0, "x86_64", \
751
                          capslatest_x86_64, true)
752 753 754 755 756 757 758 759 760 761 762

/**
 * The following test macros should be used only in cases when the tests require
 * testing of some non-standard combination of capability flags
 */
# define DO_TEST_CAPS_FULL(name, flags, parseFlags, ver) \
    DO_TEST_CAPS_ARCH(name, NULL, flags, parseFlags, GIC_NONE, "x86_64", ver)

# define DO_TEST_CAPS(name, ver) \
    DO_TEST_CAPS_FULL(name, 0, 0, ver)

763 764 765 766
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \
                      parseFlags, gic, ...) \
    do { \
        static struct testInfo info = { \
767
            name, NULL, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
768
            false, NULL \
769 770 771 772 773 774 775 776
        }; \
        info.skipLegacyCPUs = skipLegacyCPUs; \
        if (testInitQEMUCaps(&info, gic) < 0) \
            return EXIT_FAILURE; \
        virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST); \
        if (virTestRun("QEMU XML-2-ARGV " name, \
                       testCompareXMLToArgv, &info) < 0) \
            ret = -1; \
777
        if (virTestRun("QEMU XML-2-startup-XML " name, \
J
Ján Tomko 已提交
778
                       testCompareXMLToStartupXML, &info) < 0) \
779
            ret = -1; \
780
        virObjectUnref(info.qemuCaps); \
781
        virObjectUnref(info.vm); \
782 783
    } while (0)

784
# define DO_TEST(name, ...) \
785
    DO_TEST_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__)
786

787
# define DO_TEST_GIC(name, gic, ...) \
788 789
    DO_TEST_FULL(name, NULL, -1, 0, 0, gic, __VA_ARGS__)

790 791
# define DO_TEST_FAILURE(name, ...) \
    DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, \
792
                 0, GIC_NONE, __VA_ARGS__)
793

794 795 796
# define DO_TEST_PARSE_ERROR(name, ...) \
    DO_TEST_FULL(name, NULL, -1, \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
797
                 0, GIC_NONE, __VA_ARGS__)
798

799 800 801
# define DO_TEST_PARSE_FLAGS_ERROR(name, parseFlags, ...) \
    DO_TEST_FULL(name, NULL, -1, \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
802
                 parseFlags, GIC_NONE, __VA_ARGS__)
803 804

# define NONE QEMU_CAPS_LAST
805

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

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

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

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

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

890
    DO_TEST("bios",
891
            QEMU_CAPS_DEVICE_ISA_SERIAL,
892
            QEMU_CAPS_SGA);
J
Ján Tomko 已提交
893
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
894 895 896
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
897
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
898 899 900
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
901 902 903 904 905 906 907

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

908
    DO_TEST("clock-utc", NONE);
909
    DO_TEST("clock-localtime", NONE);
J
Ján Tomko 已提交
910 911 912 913
    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 已提交
914
    DO_TEST("clock-catchup", QEMU_CAPS_KVM_PIT_TICK_POLICY);
915
    DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
A
Andrea Bolognani 已提交
916
    DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM);
917
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
918
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
919

920 921
    DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM);
J
Ján Tomko 已提交
922
    DO_TEST("controller-order",
923 924 925 926 927 928 929
            QEMU_CAPS_KVM,
            QEMU_CAPS_ENABLE_KVM,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_HDA_DUPLEX,
            QEMU_CAPS_USB_HUB,
930
            QEMU_CAPS_DEVICE_ISA_SERIAL,
931
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
932 933
    DO_TEST("eoi-disabled", NONE);
    DO_TEST("eoi-enabled", NONE);
934 935
    DO_TEST("pv-spinlock-disabled", NONE);
    DO_TEST("pv-spinlock-enabled", NONE);
M
Martin Kletzander 已提交
936
    DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
937

938
    DO_TEST("hyperv", NONE);
939
    DO_TEST("hyperv-off", NONE);
940
    DO_TEST("hyperv-panic", NONE);
941

942 943 944
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

945 946 947
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

J
Ján Tomko 已提交
948
    DO_TEST("hugepages", NONE);
J
Ján Tomko 已提交
949
    DO_TEST("hugepages-numa",
950
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
951
            QEMU_CAPS_VIRTIO_SCSI,
952
            QEMU_CAPS_ICH9_USB_EHCI1,
953
            QEMU_CAPS_SPICE,
954
            QEMU_CAPS_DEVICE_QXL,
955
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
956
            QEMU_CAPS_DEVICE_PC_DIMM,
J
Ján Tomko 已提交
957
            QEMU_CAPS_OBJECT_MEMORY_FILE);
A
Andrea Bolognani 已提交
958 959
    DO_TEST("hugepages-pages",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
960 961
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
J
Ján Tomko 已提交
962
    DO_TEST("hugepages-pages2", QEMU_CAPS_OBJECT_MEMORY_RAM,
963
            QEMU_CAPS_OBJECT_MEMORY_FILE);
J
Ján Tomko 已提交
964
    DO_TEST("hugepages-pages3", QEMU_CAPS_OBJECT_MEMORY_RAM,
965 966
            QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
A
Andrea Bolognani 已提交
967 968 969
    DO_TEST("hugepages-shared",
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
970
    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
J
Ján Tomko 已提交
971
    DO_TEST_FAILURE("hugepages-pages4",
972
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
J
Ján Tomko 已提交
973
    DO_TEST("hugepages-pages5", NONE);
974
    DO_TEST("hugepages-pages6", NONE);
J
Ján Tomko 已提交
975
    DO_TEST("hugepages-pages7",
976 977
            QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
978 979 980
    DO_TEST_FAILURE("hugepages-pages8",
                    QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
                    QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
981 982 983
    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
984 985 986
    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
J
Ján Tomko 已提交
987
    DO_TEST_FAILURE("hugepages-memaccess3",
988 989
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_VIRTIO_SCSI);
990
    DO_TEST("nosharepages", QEMU_CAPS_MEM_MERGE);
991
    DO_TEST("disk-cdrom", NONE);
992
    DO_TEST("disk-iscsi", NONE);
993 994 995 996 997
    DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-ftps", QEMU_CAPS_KVM);
    DO_TEST("disk-cdrom-network-tftp", QEMU_CAPS_KVM);
998
    DO_TEST("disk-cdrom-empty", NONE);
999
    DO_TEST("disk-cdrom-tray",
1000
            QEMU_CAPS_VIRTIO_TX_ALG);
1001 1002
    DO_TEST("disk-cdrom-tray-no-device-cap", NONE);
    DO_TEST("disk-floppy", NONE);
1003 1004
    DO_TEST_FAILURE("disk-floppy-pseries",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1005
    DO_TEST("disk-floppy-tray-no-device-cap", NONE);
1006
    DO_TEST("disk-floppy-tray", NONE);
1007
    DO_TEST("disk-virtio-s390",
1008
            QEMU_CAPS_VIRTIO_S390);
1009
    DO_TEST("disk-many", NONE);
1010 1011
    DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-virtio-ccw",
1012
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1013
    DO_TEST("disk-virtio-ccw-many",
1014
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1015
    DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
1016
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1017
    DO_TEST("disk-order",
1018
            QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
L
Lin Ma 已提交
1019 1020
    DO_TEST("disk-virtio-drive-queues",
            QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
1021
    DO_TEST("disk-drive-boot-disk",
1022
            QEMU_CAPS_DRIVE_BOOT);
1023
    DO_TEST("disk-drive-boot-cdrom",
1024
            QEMU_CAPS_DRIVE_BOOT);
1025
    DO_TEST("floppy-drive-fat",
1026
            QEMU_CAPS_DRIVE_BOOT);
1027 1028
    DO_TEST("disk-drive-readonly-disk", NONE);
    DO_TEST("disk-drive-readonly-no-device", NONE);
1029
    DO_TEST("disk-drive-fmt-qcow",
1030
            QEMU_CAPS_DRIVE_BOOT);
1031
    DO_TEST_PARSE_ERROR("disk-drive-fmt-cow", QEMU_CAPS_DRIVE_BOOT);
1032
    DO_TEST_PARSE_ERROR("disk-drive-fmt-dir", QEMU_CAPS_DRIVE_BOOT);
1033
    DO_TEST_PARSE_ERROR("disk-drive-fmt-iso", QEMU_CAPS_DRIVE_BOOT);
1034
    DO_TEST("disk-drive-shared", NONE);
1035
    DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE);
1036 1037
    DO_TEST("disk-drive-shared-locking",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW);
1038 1039 1040
    DO_TEST("disk-drive-error-policy-stop", NONE);
    DO_TEST("disk-drive-error-policy-enospace", NONE);
    DO_TEST("disk-drive-error-policy-wreport-rignore", NONE);
1041 1042 1043
    DO_TEST("disk-drive-cache-v2-wt", NONE);
    DO_TEST("disk-drive-cache-v2-wb", NONE);
    DO_TEST("disk-drive-cache-v2-none", NONE);
1044
    DO_TEST("disk-drive-cache-directsync", NONE);
1045
    DO_TEST("disk-drive-cache-unsafe", NONE);
1046 1047 1048
    DO_TEST_CAPS_VER("disk-drive-write-cache", "2.6.0");
    DO_TEST_CAPS_VER("disk-drive-write-cache", "2.7.0");
    DO_TEST_CAPS_LATEST("disk-drive-write-cache");
1049 1050 1051 1052 1053 1054 1055
    DO_TEST("disk-drive-network-nbd", NONE);
    DO_TEST("disk-drive-network-nbd-export", NONE);
    DO_TEST("disk-drive-network-nbd-ipv6", NONE);
    DO_TEST("disk-drive-network-nbd-ipv6-export", NONE);
    DO_TEST("disk-drive-network-nbd-unix", NONE);
    DO_TEST("disk-drive-network-iscsi", NONE);
    DO_TEST("disk-drive-network-iscsi-auth", NONE);
1056 1057
    DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-secrettype-invalid", NONE);
    DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-wrong-secrettype", NONE);
1058
    DO_TEST_PARSE_ERROR("disk-drive-network-source-auth-both", NONE);
1059
    DO_TEST("disk-drive-network-iscsi-lun",
1060
            QEMU_CAPS_VIRTIO_SCSI,
1061
            QEMU_CAPS_SCSI_BLOCK);
1062 1063
    DO_TEST("disk-drive-network-gluster",
            QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
1064 1065 1066
    DO_TEST("disk-drive-network-rbd", NONE);
    DO_TEST("disk-drive-network-sheepdog", NONE);
    DO_TEST("disk-drive-network-rbd-auth", NONE);
1067
    DO_TEST("disk-drive-network-source-auth", NONE);
1068
    DO_TEST("disk-drive-network-rbd-auth-AES",
1069
            QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_VIRTIO_SCSI);
1070 1071
    DO_TEST("disk-drive-network-rbd-ipv6", NONE);
    DO_TEST_FAILURE("disk-drive-network-rbd-no-colon", NONE);
1072
    DO_TEST("disk-drive-network-vxhs", QEMU_CAPS_VXHS);
1073
    driver.config->vxhsTLS = 1;
1074
    DO_TEST("disk-drive-network-tlsx509", QEMU_CAPS_VXHS,
1075
            QEMU_CAPS_OBJECT_TLS_CREDS_X509, QEMU_CAPS_NBD_TLS);
1076 1077
    driver.config->vxhsTLS = 0;
    VIR_FREE(driver.config->vxhsTLSx509certdir);
1078
    DO_TEST("disk-drive-no-boot",
1079
            QEMU_CAPS_BOOTINDEX);
1080
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
1081 1082
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
1083
    DO_TEST("disk-usb-device",
1084
            QEMU_CAPS_DEVICE_USB_STORAGE);
1085
    DO_TEST("disk-usb-device-removable",
1086
            QEMU_CAPS_DEVICE_USB_STORAGE,
1087
            QEMU_CAPS_USB_STORAGE_REMOVABLE);
1088
    DO_TEST_FAILURE("disk-usb-pci",
1089
                    QEMU_CAPS_DEVICE_USB_STORAGE);
1090
    DO_TEST("disk-scsi-device",
1091
            QEMU_CAPS_SCSI_LSI);
1092
    DO_TEST("disk-scsi-device-auto",
1093
            QEMU_CAPS_SCSI_LSI);
1094
    DO_TEST("disk-scsi-disk-split",
1095
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1096
    DO_TEST("disk-scsi-disk-wwn",
1097
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1098 1099
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST("disk-scsi-disk-vpd",
1100
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1101 1102
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
1103
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1104
            QEMU_CAPS_SCSI_DISK_WWN);
1105
    DO_TEST("disk-scsi-vscsi", NONE);
1106
    DO_TEST("disk-scsi-virtio-scsi",
1107
            QEMU_CAPS_VIRTIO_SCSI);
1108 1109
    DO_TEST("disk-virtio-scsi-num_queues",
            QEMU_CAPS_VIRTIO_SCSI);
1110 1111 1112 1113
    DO_TEST("disk-virtio-scsi-cmd_per_lun",
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("disk-virtio-scsi-max_sectors",
            QEMU_CAPS_VIRTIO_SCSI);
1114 1115
    DO_TEST("disk-virtio-scsi-ioeventfd",
            QEMU_CAPS_VIRTIO_IOEVENTFD, QEMU_CAPS_VIRTIO_SCSI);
1116 1117
    DO_TEST("disk-scsi-megasas",
            QEMU_CAPS_SCSI_MEGASAS);
1118 1119 1120
    DO_TEST("disk-scsi-mptsas1068",
            QEMU_CAPS_SCSI_MPTSAS1068,
            QEMU_CAPS_SCSI_DISK_WWN);
1121
    DO_TEST("disk-sata-device",
1122
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
1123
    DO_TEST("disk-aio", NONE);
1124 1125
    DO_TEST("disk-source-pool", NONE);
    DO_TEST("disk-source-pool-mode", NONE);
1126
    DO_TEST("disk-ioeventfd",
1127
            QEMU_CAPS_VIRTIO_IOEVENTFD,
1128
            QEMU_CAPS_VIRTIO_TX_ALG,
1129
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1130
    DO_TEST("disk-copy_on_read",
1131
            QEMU_CAPS_VIRTIO_TX_ALG,
1132
            QEMU_CAPS_VIRTIO_BLK_SCSI);
O
Osier Yang 已提交
1133
    DO_TEST("disk-drive-discard",
1134
            QEMU_CAPS_DRIVE_DISCARD);
1135 1136 1137
    DO_TEST("disk-drive-detect-zeroes",
            QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DRIVE_DETECT_ZEROES);
1138
    DO_TEST("disk-snapshot", NONE);
1139 1140
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
1141
                        QEMU_CAPS_DEVICE_USB_STORAGE);
1142 1143 1144 1145 1146 1147 1148 1149
    DO_TEST_PARSE_ERROR("disk-drive-address-conflict",
                        QEMU_CAPS_ICH9_AHCI);
    DO_TEST_PARSE_ERROR("disk-hostdev-scsi-address-conflict",
                        QEMU_CAPS_VIRTIO_SCSI,
                        QEMU_CAPS_DEVICE_SCSI_GENERIC);
    DO_TEST_PARSE_ERROR("hostdevs-drive-address-conflict",
                        QEMU_CAPS_VIRTIO_SCSI,
                        QEMU_CAPS_DEVICE_SCSI_GENERIC);
1150
    DO_TEST("event_idx",
1151 1152
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
1153
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1154
    DO_TEST("virtio-lun",
1155
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1156
    DO_TEST("disk-scsi-lun-passthrough",
1157
            QEMU_CAPS_SCSI_BLOCK,
1158
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1159
    DO_TEST("disk-serial",
1160
            QEMU_CAPS_KVM);
1161 1162 1163 1164 1165 1166 1167 1168
    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);
1169

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

1191 1192
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1193
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
1194
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1195 1196
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1197
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1198
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1199 1200
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1201

J
Ján Tomko 已提交
1202 1203 1204
    DO_TEST("graphics-sdl",
            QEMU_CAPS_DEVICE_VGA);
    DO_TEST("graphics-sdl-fullscreen",
1205
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1206
    DO_TEST("graphics-spice",
1207
            QEMU_CAPS_SPICE,
1208 1209
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1210
    DO_TEST("graphics-spice-no-args",
1211
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1212 1213 1214
    driver.config->spiceSASL = 1;
    ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
    DO_TEST("graphics-spice-sasl",
1215
            QEMU_CAPS_SPICE,
1216 1217 1218
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
1219
    DO_TEST("graphics-spice-agentmouse",
1220
            QEMU_CAPS_DEVICE_QXL,
1221
            QEMU_CAPS_SPICE,
1222
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1223
    DO_TEST("graphics-spice-compression",
1224
            QEMU_CAPS_SPICE,
1225
            QEMU_CAPS_DEVICE_QXL);
1226
    DO_TEST("graphics-spice-timeout",
1227
            QEMU_CAPS_KVM,
1228
            QEMU_CAPS_SPICE,
1229 1230
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VGA);
1231
    DO_TEST("graphics-spice-qxl-vga",
1232
            QEMU_CAPS_SPICE,
1233
            QEMU_CAPS_DEVICE_QXL);
1234
    DO_TEST("graphics-spice-usb-redir",
1235
            QEMU_CAPS_SPICE,
1236 1237 1238 1239
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1240
    DO_TEST("graphics-spice-agent-file-xfer",
1241
            QEMU_CAPS_SPICE,
1242 1243
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1244 1245
    DO_TEST("graphics-spice-socket",
            QEMU_CAPS_SPICE,
1246 1247
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1248 1249
    DO_TEST("graphics-spice-auto-socket",
            QEMU_CAPS_SPICE,
1250 1251
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1252 1253 1254
    driver.config->spiceAutoUnixSocket = true;
    DO_TEST("graphics-spice-auto-socket-cfg",
            QEMU_CAPS_SPICE,
1255 1256
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1257
    driver.config->spiceAutoUnixSocket = false;
1258

1259 1260 1261
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
    DO_TEST("misc-acpi", NONE);
1262 1263 1264
    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);
1265
    DO_TEST_FAILURE("misc-enable-s4", NONE);
1266
    DO_TEST("misc-no-reboot", NONE);
1267
    DO_TEST("misc-uuid", NONE);
1268
    DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
J
Ján Tomko 已提交
1269
    DO_TEST("net-vhostuser", NONE);
1270
    DO_TEST("net-vhostuser-multiq",
J
Ján Tomko 已提交
1271 1272
            QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
    DO_TEST_FAILURE("net-vhostuser-multiq", NONE);
1273 1274
    DO_TEST_FAILURE("net-vhostuser-fail",
                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
1275
    DO_TEST("net-user", NONE);
J
Ján Tomko 已提交
1276
    DO_TEST("net-user-addr", NONE);
1277 1278
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
1279 1280 1281
            QEMU_CAPS_VIRTIO_TX_ALG);
    DO_TEST("net-virtio-disable-offloads", NONE);
    DO_TEST("net-virtio-netdev", NONE);
1282
    DO_TEST("net-virtio-s390",
1283
            QEMU_CAPS_VIRTIO_S390);
1284
    DO_TEST("net-virtio-ccw",
1285
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1286 1287 1288
    DO_TEST("net-virtio-rxtxqueuesize",
            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE,
            QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE);
1289
    DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
1290 1291
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
1292
    DO_TEST("net-eth-names", NONE);
1293
    DO_TEST("net-eth-hostip", NONE);
1294 1295 1296
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
    DO_TEST("net-mcast", NONE);
1297
    DO_TEST("net-udp", NONE);
1298
    DO_TEST("net-hostdev", NONE);
1299
    DO_TEST("net-hostdev-multidomain", NONE);
1300 1301
    DO_TEST("net-hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1302
    DO_TEST("net-hostdev-vfio-multidomain",
1303
            QEMU_CAPS_DEVICE_VFIO_PCI);
1304 1305 1306
    DO_TEST_FAILURE("net-hostdev-fail",
                    QEMU_CAPS_DEVICE_VFIO_PCI);

1307

1308 1309
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1310
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1311
            QEMU_CAPS_CHARDEV_LOGFILE);
1312
    DO_TEST("serial-spiceport",
1313
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1314
            QEMU_CAPS_DEVICE_QXL,
1315
            QEMU_CAPS_SPICE,
1316
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1317
            QEMU_CAPS_CHARDEV_SPICEPORT);
1318
    DO_TEST("serial-spiceport-nospice", NONE);
1319

1320 1321 1322 1323
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1324 1325

    DO_TEST("serial-vc-chardev",
1326
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1327
    DO_TEST("serial-pty-chardev",
1328
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1329
    DO_TEST("serial-dev-chardev",
1330
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1331
    DO_TEST("serial-dev-chardev-iobase",
1332
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1333
    DO_TEST("serial-file-chardev",
1334
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1335
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1336
    DO_TEST("serial-unix-chardev",
1337
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1338
    DO_TEST("serial-tcp-chardev",
1339
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1340
    DO_TEST("serial-udp-chardev",
1341
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1342
    DO_TEST("serial-tcp-telnet-chardev",
1343
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1344 1345
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1346
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1347
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1348 1349
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1350
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1351 1352
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1353
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1354
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1355
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1356 1357 1358 1359 1360 1361 1362 1363
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509secretUUID,
                         "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0)
        return EXIT_FAILURE;
    DO_TEST("serial-tcp-tlsx509-secret-chardev",
            QEMU_CAPS_OBJECT_SECRET,
1364
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1365
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1366 1367
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1368
    DO_TEST("serial-many-chardev",
1369 1370 1371
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
1372
    DO_TEST("console-compat-chardev",
1373
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1374 1375
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1376

1377 1378 1379 1380 1381 1382 1383
    DO_TEST("channel-guestfwd", NONE);
    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);
1384
    DO_TEST("console-virtio-many",
1385
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1386
    DO_TEST("console-virtio-s390",
1387 1388
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390);
1389
    DO_TEST("console-virtio-ccw",
1390
            QEMU_CAPS_BOOTINDEX,
1391
            QEMU_CAPS_CCW,
1392
            QEMU_CAPS_VIRTIO_S390);
1393
    DO_TEST("console-sclp",
1394
            QEMU_CAPS_VIRTIO_S390,
1395
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1396
    DO_TEST("channel-spicevmc",
1397
            QEMU_CAPS_SPICE,
1398
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1399
    DO_TEST("channel-virtio-default",
1400
            QEMU_CAPS_SPICE);
1401
    DO_TEST("channel-virtio-unix", NONE);
1402

1403
    DO_TEST("smartcard-host",
1404
            QEMU_CAPS_CCID_EMULATED);
1405
    DO_TEST("smartcard-host-certificates",
1406
            QEMU_CAPS_CCID_EMULATED);
1407 1408
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1409
    DO_TEST("smartcard-passthrough-tcp",
1410
            QEMU_CAPS_CCID_PASSTHRU);
1411
    DO_TEST("smartcard-passthrough-spicevmc",
1412
            QEMU_CAPS_CCID_PASSTHRU);
1413
    DO_TEST("smartcard-controller",
1414
            QEMU_CAPS_CCID_EMULATED);
1415

1416 1417 1418 1419 1420 1421 1422 1423
    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);
1424 1425
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1426

1427
    DO_TEST("usb-controller", NONE);
1428
    DO_TEST("usb-piix3-controller",
1429
            QEMU_CAPS_PIIX3_USB_UHCI);
1430
    DO_TEST("usb-ich9-ehci-addr",
1431
            QEMU_CAPS_ICH9_USB_EHCI1);
1432
    DO_TEST("input-usbmouse-addr", NONE);
1433
    DO_TEST("usb-ich9-companion",
1434
            QEMU_CAPS_ICH9_USB_EHCI1);
1435
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1436
            QEMU_CAPS_ICH9_USB_EHCI1);
1437
    DO_TEST("usb-ich9-autoassign",
1438
            QEMU_CAPS_ICH9_USB_EHCI1,
1439
            QEMU_CAPS_USB_HUB);
1440
    DO_TEST("usb-hub",
1441
            QEMU_CAPS_USB_HUB);
1442
    DO_TEST("usb-hub-autoadd",
1443
            QEMU_CAPS_USB_HUB);
1444
    DO_TEST("usb-hub-autoadd-deluxe",
1445
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1446
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
1447
            QEMU_CAPS_USB_HUB);
1448
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
1449
            QEMU_CAPS_USB_HUB);
J
Ján Tomko 已提交
1450
    DO_TEST("usb-port-missing",
1451
            QEMU_CAPS_USB_HUB);
1452
    DO_TEST_FAILURE("usb-bus-missing",
1453
                    QEMU_CAPS_USB_HUB);
1454
    DO_TEST("usb-ports",
1455
            QEMU_CAPS_USB_HUB);
1456
    DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
1457
            QEMU_CAPS_USB_HUB);
1458
    DO_TEST("usb-port-autoassign",
1459
            QEMU_CAPS_USB_HUB);
1460
    DO_TEST("usb-redir",
1461 1462 1463
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
1464
            QEMU_CAPS_SPICE);
1465
    DO_TEST("usb-redir-boot",
1466 1467 1468 1469 1470
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_BOOTINDEX,
1471
            QEMU_CAPS_USB_REDIR_BOOTINDEX);
1472
    DO_TEST("usb-redir-filter",
1473 1474 1475 1476
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
1477
            QEMU_CAPS_USB_REDIR_FILTER);
1478 1479
    DO_TEST("usb-redir-filter-version",
            QEMU_CAPS_USB_REDIR,
1480
            QEMU_CAPS_SPICE,
1481
            QEMU_CAPS_USB_REDIR_FILTER);
1482
    DO_TEST("usb1-usb2",
1483 1484 1485
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1);
1486 1487
    DO_TEST("usb-none", NONE);
    DO_TEST_PARSE_ERROR("usb-none-other", NONE);
1488 1489
    DO_TEST_PARSE_ERROR("usb-none-hub",
            QEMU_CAPS_USB_HUB);
1490
    DO_TEST_PARSE_ERROR("usb-none-usbtablet", NONE);
1491
    DO_TEST("usb-controller-default-q35",
1492
            QEMU_CAPS_DEVICE_IOH3420,
1493 1494 1495
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1496
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1497
                    QEMU_CAPS_DEVICE_IOH3420,
1498
                    QEMU_CAPS_PCI_OHCI,
1499 1500
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1501
            QEMU_CAPS_DEVICE_IOH3420,
1502 1503 1504
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1505
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1506
                    QEMU_CAPS_DEVICE_IOH3420,
1507
                    QEMU_CAPS_PCI_OHCI,
1508
                    QEMU_CAPS_PIIX3_USB_UHCI);
1509
    DO_TEST("usb-controller-xhci",
1510 1511 1512
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1513
    DO_TEST("usb-xhci-autoassign",
1514 1515 1516
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS,
1517
            QEMU_CAPS_USB_HUB);
1518
    DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
1519 1520 1521
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1522 1523 1524 1525
    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);
1526

1527 1528 1529
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1530

1531
    DO_TEST("watchdog", NONE);
1532
    DO_TEST("watchdog-device", NONE);
1533
    DO_TEST("watchdog-dump", NONE);
1534
    DO_TEST("watchdog-injectnmi", NONE);
1535
    DO_TEST("watchdog-diag288",
1536
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
1537 1538
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1539
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1540
    DO_TEST("balloon-ccw-deflate",
1541
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1542
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1543
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1544
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1545
    DO_TEST("balloon-device-deflate-off",
1546
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1547 1548
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1549 1550
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1551
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1552
            QEMU_CAPS_HDA_OUTPUT,
1553 1554
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1555
    DO_TEST("fs9p", NONE);
1556
    DO_TEST("fs9p-ccw",
1557
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1558

1559
    DO_TEST("hostdev-usb-address", NONE);
1560
    DO_TEST("hostdev-usb-address-device", NONE);
1561
    DO_TEST("hostdev-usb-address-device-boot",
1562
            QEMU_CAPS_BOOTINDEX,
1563
            QEMU_CAPS_USB_HOST_BOOTINDEX);
J
Ján Tomko 已提交
1564
    DO_TEST("hostdev-pci-address", NONE);
1565
    DO_TEST("hostdev-pci-address-device", NONE);
1566 1567
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1568
    DO_TEST("hostdev-vfio-multidomain",
1569
            QEMU_CAPS_DEVICE_VFIO_PCI);
1570 1571 1572 1573 1574 1575
    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);
1576
    DO_TEST("pci-rom", NONE);
1577
    DO_TEST("pci-rom-disabled", NONE);
1578
    DO_TEST("pci-rom-disabled-invalid", NONE);
1579

1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595
    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
            QEMU_CAPS_CCW,
            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
            QEMU_CAPS_DEVICE_VFIO_CCW);
    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);

1596 1597 1598 1599
    DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE);
    DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0, 0, GIC_NONE, NONE);
1600

A
Andrea Bolognani 已提交
1601 1602 1603
    DO_TEST_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE,
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1604

1605
    DO_TEST("qemu-ns", NONE);
1606
    DO_TEST("qemu-ns-no-env", NONE);
1607
    DO_TEST("qemu-ns-alt", NONE);
1608

1609
    DO_TEST("smp", NONE);
1610

J
John Ferlan 已提交
1611
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1612 1613
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1614
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1615 1616
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1617
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1618 1619 1620 1621 1622
    DO_TEST("iothreads-virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_OBJECT_IOTHREAD,
            QEMU_CAPS_VIRTIO_SCSI_IOTHREAD);
    DO_TEST("iothreads-virtio-scsi-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD,
1623
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
J
John Ferlan 已提交
1624

1625 1626
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1627
    DO_TEST("cpu-topology3", NONE);
1628 1629 1630 1631 1632 1633 1634 1635
    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);
1636
    DO_TEST("cpu-numa1", NONE);
1637 1638
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1639
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1640 1641
    DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1642 1643
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
    DO_TEST_FAILURE("cpu-numa-memshared", NONE);
1644
    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
1645
    DO_TEST("cpu-host-model", NONE);
1646
    DO_TEST("cpu-host-model-vendor", NONE);
1647
    skipLegacyCPUs = true;
1648
    DO_TEST("cpu-host-model-fallback", NONE);
1649
    DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
1650
    skipLegacyCPUs = false;
A
Andrea Bolognani 已提交
1651 1652
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1653

1654
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
1655
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1656 1657
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1658 1659
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1660
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1661 1662 1663 1664
    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);
1665
    DO_TEST("cpu-host-model-cmt", NONE);
1666
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1667
    qemuTestSetHostCPU(driver.caps, NULL);
1668

1669 1670
    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);
1671
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1672
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1673 1674
    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);
1675
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1676
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1677

1678 1679 1680 1681 1682 1683 1684 1685
    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);
1686
    DO_TEST("cputune-numatune",
1687
            QEMU_CAPS_KVM,
1688
            QEMU_CAPS_OBJECT_IOTHREAD,
1689 1690
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1691 1692 1693
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1694

1695
    DO_TEST("numatune-memory", NONE);
1696
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1697 1698 1699
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1700 1701
    DO_TEST_FAILURE("numatune-memnode", NONE);

A
Andrea Bolognani 已提交
1702 1703 1704
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1705 1706
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1707 1708
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1709
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1710 1711
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1712 1713
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1714 1715
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1716 1717
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1718
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1719 1720 1721
    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);
1722
    DO_TEST("blkdeviotune-max",
1723
            QEMU_CAPS_DRIVE_IOTUNE_MAX);
1724 1725 1726
    DO_TEST("blkdeviotune-group-num",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP);
1727 1728 1729
    DO_TEST("blkdeviotune-max-length",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH);
1730

1731
    DO_TEST("multifunction-pci-device",
1732
            QEMU_CAPS_SCSI_LSI);
1733

1734
    DO_TEST("monitor-json", NONE);
1735

1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747
    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);
1748

1749
    DO_TEST("pseries-basic",
1750
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1751
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1752
    DO_TEST("pseries-vio",
1753
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1754
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1755
    DO_TEST("pseries-usb-default",
1756
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1757
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1758
            QEMU_CAPS_PIIX3_USB_UHCI,
1759
            QEMU_CAPS_PCI_OHCI);
1760
    DO_TEST("pseries-usb-multi",
1761
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1762
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1763
            QEMU_CAPS_PIIX3_USB_UHCI,
1764
            QEMU_CAPS_PCI_OHCI);
1765
    DO_TEST("pseries-vio-user-assigned",
1766
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1767 1768
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash", NONE);
1769 1770 1771
    DO_TEST("pseries-nvram",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_DEVICE_NVRAM);
1772
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1773
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1774
            QEMU_CAPS_DEVICE_USB_KBD,
1775
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1776
    DO_TEST("pseries-cpu-exact",
1777
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1778 1779
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE);
1780 1781

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1782
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1783
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1784
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1785 1786 1787
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
1788
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1789
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1790
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1791
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1792 1793 1794
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
1795 1796 1797

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1798
            QEMU_CAPS_KVM,
1799
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1800
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1801 1802
    qemuTestSetHostCPU(driver.caps, NULL);

1803 1804
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1805
    DO_TEST("pseries-panic-missing",
1806
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1807
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1808
    DO_TEST("pseries-panic-no-address",
1809
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1810
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1811
    DO_TEST_FAILURE("pseries-panic-address",
1812
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1813 1814 1815 1816 1817

    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);
1818 1819 1820 1821 1822 1823
    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);
1824 1825 1826
    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);
1827

1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849
    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);

1850
    DO_TEST("pseries-features",
1851
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1852
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1853
    DO_TEST_FAILURE("pseries-features",
1854
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1855
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
1856

1857
    DO_TEST("pseries-serial-native",
1858
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1859 1860
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
1861
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1862 1863
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
1864
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1865
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1866
    DO_TEST("pseries-serial-pci",
1867
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1868 1869
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
1870
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1871 1872
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
1873
    DO_TEST("pseries-console-native",
1874
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1875 1876
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
1877
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1878 1879
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);

1880
    DO_TEST("mach-virt-serial-native",
1881
            QEMU_CAPS_DEVICE_PL011);
1882
    DO_TEST("mach-virt-serial+console-native",
1883
            QEMU_CAPS_DEVICE_PL011);
1884
    DO_TEST("mach-virt-serial-compat",
1885
            QEMU_CAPS_DEVICE_PL011);
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897
    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",
1898 1899
            QEMU_CAPS_DEVICE_PL011);
    DO_TEST("mach-virt-console-virtio", NONE);
1900 1901
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

1902
    DO_TEST("disk-ide-drive-split",
1903
            QEMU_CAPS_IDE_CD);
1904
    DO_TEST("disk-ide-wwn",
1905
            QEMU_CAPS_IDE_CD,
1906
            QEMU_CAPS_IDE_DRIVE_WWN);
1907

1908
    DO_TEST("disk-geometry", NONE);
V
Viktor Mihajlovski 已提交
1909 1910
    DO_TEST("disk-blockio",
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1911

1912
    DO_TEST("video-device-pciaddr-default",
1913 1914
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
1915
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1916
            QEMU_CAPS_DEVICE_QXL);
1917
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
1918
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
1919
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1920
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
1921
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
1922
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
1923
    DO_TEST("video-qxl-device",
1924
            QEMU_CAPS_DEVICE_QXL,
1925
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1926
    DO_TEST("video-qxl-device-vgamem",
1927
            QEMU_CAPS_DEVICE_QXL,
1928
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1929 1930
            QEMU_CAPS_QXL_VGAMEM);
    DO_TEST("video-qxl-sec-device",
1931
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1932
    DO_TEST("video-qxl-sec-device-vgamem",
1933 1934
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1935
            QEMU_CAPS_QXL_VGAMEM);
1936 1937 1938
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1939
            QEMU_CAPS_QXL_MAX_OUTPUTS);
1940 1941 1942
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
1943 1944 1945
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1946
            QEMU_CAPS_QXL_MAX_OUTPUTS);
M
Marc-André Lureau 已提交
1947
    DO_TEST("video-virtio-gpu-device",
1948
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
1949
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1950
    DO_TEST("video-virtio-gpu-virgl",
1951
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1952
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1953
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1954 1955
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1956
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1957 1958
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
1959
            QEMU_CAPS_SPICE_RENDERNODE,
1960
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1961 1962 1963 1964 1965
    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);
1966 1967 1968
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1969 1970 1971
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
1972 1973
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
1974
    DO_TEST_PARSE_ERROR("video-invalid", NONE);
1975

1976 1977
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
1978
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1979 1980
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
1981
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1982 1983
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
1984
            QEMU_CAPS_OBJECT_RNG_EGD);
1985 1986 1987 1988
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1989
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
1990 1991
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
1992
    DO_TEST("virtio-rng-ccw",
1993
            QEMU_CAPS_BOOTINDEX,
1994
            QEMU_CAPS_CCW,
1995 1996
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
1997
            QEMU_CAPS_OBJECT_RNG_RANDOM);
1998

1999
    DO_TEST("s390-allow-bogus-usb-none",
2000 2001 2002 2003
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2004
    DO_TEST("s390-allow-bogus-usb-controller",
2005 2006 2007 2008
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2009

2010
    DO_TEST("s390-panic-no-address",
2011
            QEMU_CAPS_CCW,
2012
            QEMU_CAPS_VIRTIO_S390);
2013
    DO_TEST_FAILURE("s390-panic-address",
2014
            QEMU_CAPS_CCW,
2015
            QEMU_CAPS_VIRTIO_S390);
2016
    DO_TEST("s390-panic-missing",
2017
            QEMU_CAPS_CCW,
2018
            QEMU_CAPS_VIRTIO_S390);
2019
    DO_TEST_PARSE_ERROR("s390-no-parallel",
2020
            QEMU_CAPS_CCW,
2021
            QEMU_CAPS_VIRTIO_S390);
2022
    DO_TEST("s390-serial",
2023
            QEMU_CAPS_CCW,
2024 2025 2026
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
2027
            QEMU_CAPS_CCW,
2028 2029 2030 2031
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
2032
            QEMU_CAPS_CCW,
2033 2034
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2035

2036
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2037
            QEMU_CAPS_KVM);
2038 2039
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2040

2041
    DO_TEST("tpm-passthrough",
2042
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2043 2044
    DO_TEST("tpm-passthrough-crb",
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_CRB);
2045
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2046
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2047
    DO_TEST_CAPS_LATEST("tpm-emulator");
2048
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2049

2050 2051 2052 2053
    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);
2054

2055 2056 2057 2058 2059 2060
    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,
2061
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2062 2063
    DO_TEST("pci-autoadd-idx",
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2064 2065
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
    DO_TEST("pci-autofill-addr", QEMU_CAPS_DEVICE_CIRRUS_VGA);
2066
    DO_TEST("pci-many",
2067
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
2068
    DO_TEST("pci-bridge-many-disks",
2069
            QEMU_CAPS_DEVICE_PCI_BRIDGE);
L
Laine Stump 已提交
2070
    DO_TEST("pcie-root",
2071 2072 2073 2074
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL);
2075
    DO_TEST("q35",
2076
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2077
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2078
            QEMU_CAPS_DEVICE_IOH3420,
2079
            QEMU_CAPS_ICH9_AHCI,
2080
            QEMU_CAPS_ICH9_USB_EHCI1,
2081
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2082
            QEMU_CAPS_DEVICE_QXL);
2083 2084 2085 2086 2087 2088 2089 2090
    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);
2091
    DO_TEST("q35-pm-disable",
2092
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2093
            QEMU_CAPS_DEVICE_IOH3420,
2094 2095 2096 2097
            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",
2098
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2099
            QEMU_CAPS_DEVICE_IOH3420,
2100 2101
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
2102
    DO_TEST("q35-usb2",
2103
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2104
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2105
            QEMU_CAPS_DEVICE_IOH3420,
2106
            QEMU_CAPS_ICH9_AHCI,
2107
            QEMU_CAPS_ICH9_USB_EHCI1,
2108
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2109
            QEMU_CAPS_DEVICE_QXL);
2110
    DO_TEST("q35-usb2-multi",
2111
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2112
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2113
            QEMU_CAPS_DEVICE_IOH3420,
2114
            QEMU_CAPS_ICH9_AHCI,
2115
            QEMU_CAPS_ICH9_USB_EHCI1,
2116
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2117
            QEMU_CAPS_DEVICE_QXL);
2118
    DO_TEST("q35-usb2-reorder",
2119
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
2120
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2121
            QEMU_CAPS_DEVICE_IOH3420,
2122
            QEMU_CAPS_ICH9_AHCI,
2123
            QEMU_CAPS_ICH9_USB_EHCI1,
2124
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2125
            QEMU_CAPS_DEVICE_QXL);
2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143
    /* 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,
2144
            QEMU_CAPS_NEC_USB_XHCI,
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157
            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,
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177
            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,
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191
            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,
2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210
            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,
2211 2212 2213 2214 2215
            QEMU_CAPS_DEVICE_VIRTIO_NET,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE,
2216 2217 2218 2219 2220 2221 2222 2223
            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,
2224
            QEMU_CAPS_NEC_USB_XHCI,
2225
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2226 2227
    DO_TEST("q35-virt-manager-basic",
            QEMU_CAPS_KVM,
2228
            QEMU_CAPS_MACHINE_VMPORT_OPT,
2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252
            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,
2253
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2254
            QEMU_CAPS_USB_REDIR);
2255 2256

    /* Test automatic and manual setting of pcie-root-port attributes */
2257 2258
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2259
            QEMU_CAPS_ICH9_AHCI,
2260
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2261
            QEMU_CAPS_DEVICE_QXL);
2262 2263 2264 2265 2266 2267

    /* 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,
2268
            QEMU_CAPS_DEVICE_IOH3420);
2269
    DO_TEST("pcie-root-port-model-ioh3420",
2270
            QEMU_CAPS_DEVICE_IOH3420);
2271

2272 2273 2274 2275 2276 2277 2278
    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,
2279
            QEMU_CAPS_ICH9_USB_EHCI1,
2280
            QEMU_CAPS_NEC_USB_XHCI);
2281 2282 2283 2284 2285 2286 2287
    /* 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);
2288

2289
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2290
            QEMU_CAPS_DEVICE_IOH3420,
2291
            QEMU_CAPS_ICH9_AHCI,
2292
            QEMU_CAPS_ICH9_USB_EHCI1,
2293
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2294
            QEMU_CAPS_DEVICE_QXL);
2295
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2296
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2297

2298
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2299
            QEMU_CAPS_DEVICE_IOH3420,
2300
            QEMU_CAPS_ICH9_AHCI,
2301
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2302
            QEMU_CAPS_DEVICE_QXL);
2303

2304 2305 2306
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2307
            QEMU_CAPS_ICH9_AHCI,
2308
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2309
            QEMU_CAPS_DEVICE_QXL);
2310 2311 2312 2313
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2314
            QEMU_CAPS_ICH9_AHCI,
2315
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2316
            QEMU_CAPS_DEVICE_QXL);
2317

2318 2319 2320 2321 2322 2323
    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);
2324 2325
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2326

2327 2328 2329 2330 2331 2332 2333 2334 2335 2336
    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);
2337 2338 2339
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2340

2341
    DO_TEST("hostdev-scsi-lsi",
2342 2343
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2344
    DO_TEST("hostdev-scsi-virtio-scsi",
2345 2346
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2347
    DO_TEST("hostdev-scsi-readonly",
J
Ján Tomko 已提交
2348
            QEMU_CAPS_VIRTIO_SCSI,
O
Osier Yang 已提交
2349
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
2350
    DO_TEST("hostdev-scsi-virtio-scsi",
2351 2352 2353
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
2354
    DO_TEST("hostdev-scsi-lsi-iscsi",
J
John Ferlan 已提交
2355 2356
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2357
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
J
John Ferlan 已提交
2358 2359
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2360
    DO_TEST("hostdev-scsi-virtio-iscsi",
J
John Ferlan 已提交
2361 2362
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2363
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
J
John Ferlan 已提交
2364 2365
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2366 2367 2368 2369
    DO_TEST("disk-hostdev-scsi-virtio-iscsi-auth-AES",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_OBJECT_SECRET,
            QEMU_CAPS_ISCSI_PASSWORD_SECRET);
2370 2371
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2372
            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_CCW);
2373 2374 2375
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2376 2377 2378 2379 2380 2381
    DO_TEST("hostdev-scsi-vhost-scsi-pcie",
            QEMU_CAPS_KVM,
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
2382

2383
    DO_TEST("mlock-on", QEMU_CAPS_REALTIME_MLOCK);
2384
    DO_TEST_FAILURE("mlock-on", NONE);
2385
    DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK);
2386 2387
    DO_TEST("mlock-unsupported", NONE);

2388 2389 2390 2391
    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);
2392

2393
    DO_TEST("hotplug-base",
2394
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2395

2396 2397
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
2398
    DO_TEST("pcihole64-q35",
2399
            QEMU_CAPS_DEVICE_IOH3420,
2400
            QEMU_CAPS_ICH9_AHCI,
2401
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2402
            QEMU_CAPS_DEVICE_QXL,
2403 2404
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2405 2406
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2407
    DO_TEST("arm-vexpressa9-virtio",
2408
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2409
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2410
    DO_TEST("arm-virt-virtio",
2411
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2412
            QEMU_CAPS_DEVICE_PL011,
2413
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2414

2415
    DO_TEST("aarch64-virt-virtio",
2416
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2417
            QEMU_CAPS_DEVICE_PL011,
2418
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2419 2420 2421 2422 2423 2424

    /* 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",
2425
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
2426 2427 2428
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2429
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2430
            QEMU_CAPS_DEVICE_IOH3420,
2431
            QEMU_CAPS_DEVICE_PL011,
2432
            QEMU_CAPS_VIRTIO_SCSI);
2433
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
2434
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2435 2436
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2437
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2438
            QEMU_CAPS_DEVICE_PL011,
2439
            QEMU_CAPS_DEVICE_IOH3420);
2440 2441 2442
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
2443
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2444 2445
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2446 2447 2448
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_VIRTIO_SCSI);
2449
    DO_TEST("aarch64-video-virtio-gpu-pci",
2450
            QEMU_CAPS_OBJECT_GPEX,
2451
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2452
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2453
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_BOOTINDEX);
2454
    DO_TEST("aarch64-video-default",
2455
            QEMU_CAPS_OBJECT_GPEX,
2456
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
2457
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2458 2459
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_VNC);
2460
    DO_TEST("aarch64-aavmf-virtio-mmio",
2461
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2462
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2463 2464
    DO_TEST("aarch64-virt-default-nic",
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2465
    qemuTestSetHostArch(driver.caps, VIR_ARCH_AARCH64);
2466
    DO_TEST("aarch64-cpu-passthrough",
2467
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2468
            QEMU_CAPS_KVM);
2469
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
2470
            QEMU_CAPS_KVM,
2471
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2472
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
2473
            QEMU_CAPS_KVM,
2474 2475
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
2476
            QEMU_CAPS_KVM,
2477
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2478
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
2479
            QEMU_CAPS_KVM,
2480
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2481 2482
    DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2483
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
2484
            QEMU_CAPS_KVM,
2485
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2486
    DO_TEST_GIC("aarch64-gic-default-v2", GIC_V2,
2487
            QEMU_CAPS_KVM,
2488
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2489
    DO_TEST_GIC("aarch64-gic-default-v3", GIC_V3,
2490
            QEMU_CAPS_KVM,
2491
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2492
    DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
2493
            QEMU_CAPS_KVM,
2494 2495
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
2496
            QEMU_CAPS_KVM,
2497 2498
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
2499
            QEMU_CAPS_KVM,
2500 2501
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
2502
            QEMU_CAPS_KVM,
2503
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2504
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
2505
            QEMU_CAPS_KVM,
2506
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2507
    DO_TEST_FAILURE("aarch64-gic-v3",
2508
            QEMU_CAPS_KVM, NONE);
2509
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
2510
            QEMU_CAPS_KVM,
2511 2512
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
2513
            QEMU_CAPS_KVM,
2514 2515
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
2516
            QEMU_CAPS_KVM,
2517 2518
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
2519
            QEMU_CAPS_KVM,
2520
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2521
    DO_TEST_FAILURE("aarch64-gic-host",
2522
            QEMU_CAPS_KVM, NONE);
2523
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
2524
            QEMU_CAPS_KVM,
2525 2526
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
2527
            QEMU_CAPS_KVM,
2528 2529
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
2530
            QEMU_CAPS_KVM,
2531 2532
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
2533
            QEMU_CAPS_KVM,
2534
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2535
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
2536
            QEMU_CAPS_KVM,
2537
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2538
    DO_TEST_PARSE_ERROR("aarch64-gic-not-virt",
2539
                        QEMU_CAPS_KVM,
2540 2541
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_PARSE_ERROR("aarch64-gic-not-arm",
2542
                        QEMU_CAPS_KVM,
2543
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2544
    DO_TEST("aarch64-kvm-32-on-64",
2545
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2546
            QEMU_CAPS_DEVICE_PL011,
A
Andrea Bolognani 已提交
2547
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2548
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2549
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2550
            QEMU_CAPS_KVM);
2551 2552 2553 2554 2555 2556 2557
    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);
2558 2559 2560 2561
    DO_TEST("aarch64-traditional-pci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2562
            QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
2563 2564
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
2565 2566 2567 2568 2569 2570 2571

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

2572
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2573

2574
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2575
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2576

2577 2578 2579 2580
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2581

2582 2583
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2584

2585 2586
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2587
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2588 2589 2590
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2591
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2592
    DO_TEST_FAILURE("shmem-invalid-size",
2593
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2594
    DO_TEST_FAILURE("shmem-invalid-address",
2595
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2596
    DO_TEST_FAILURE("shmem-small-size",
2597
                    QEMU_CAPS_DEVICE_IVSHMEM);
2598
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2599
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2600

2601
    DO_TEST_FAILURE("memory-align-fail", NONE);
2602
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2603
    DO_TEST("memory-hotplug", NONE);
2604
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2605
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2606
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2607
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2608
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2609
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2610
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2611
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2612 2613
    DO_TEST("memory-hotplug-nvdimm",
            QEMU_CAPS_DEVICE_NVDIMM,
M
Michal Privoznik 已提交
2614
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2615 2616
    DO_TEST("memory-hotplug-nvdimm-access",
            QEMU_CAPS_DEVICE_NVDIMM,
2617
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2618 2619
    DO_TEST("memory-hotplug-nvdimm-label",
            QEMU_CAPS_DEVICE_NVDIMM,
2620
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2621

2622
    DO_TEST("machine-aeskeywrap-on-caps",
2623
            QEMU_CAPS_AES_KEY_WRAP,
2624
            QEMU_CAPS_DEA_KEY_WRAP,
2625
            QEMU_CAPS_VIRTIO_SCSI,
2626
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2627
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2628
                    QEMU_CAPS_VIRTIO_SCSI,
2629
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2630 2631 2632
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2633
            QEMU_CAPS_AES_KEY_WRAP,
2634
            QEMU_CAPS_VIRTIO_SCSI,
2635
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2636
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2637
                    QEMU_CAPS_VIRTIO_SCSI,
2638
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2639 2640 2641
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2642
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2643
            QEMU_CAPS_VIRTIO_SCSI,
2644
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2645
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2646
                    QEMU_CAPS_VIRTIO_SCSI,
2647
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2648 2649 2650
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2651
            QEMU_CAPS_AES_KEY_WRAP,
2652
            QEMU_CAPS_VIRTIO_SCSI,
2653
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2654
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2655
                    QEMU_CAPS_VIRTIO_SCSI,
2656
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2657 2658 2659
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2660
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2661
            QEMU_CAPS_VIRTIO_SCSI,
2662
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2663
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2664
                    QEMU_CAPS_VIRTIO_SCSI,
2665
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2666 2667 2668
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2669
            QEMU_CAPS_DEA_KEY_WRAP,
2670
            QEMU_CAPS_VIRTIO_SCSI,
2671
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2672
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2673
                    QEMU_CAPS_VIRTIO_SCSI,
2674
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2675 2676 2677
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2678
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2679
            QEMU_CAPS_VIRTIO_SCSI,
2680
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2681
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2682
                    QEMU_CAPS_VIRTIO_SCSI,
2683
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2684 2685 2686
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2687
            QEMU_CAPS_DEA_KEY_WRAP,
2688
            QEMU_CAPS_VIRTIO_SCSI,
2689
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2690
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2691
                    QEMU_CAPS_VIRTIO_SCSI,
2692
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2693 2694 2695
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2696
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2697
            QEMU_CAPS_VIRTIO_SCSI,
2698
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2699
    DO_TEST("machine-keywrap-none",
2700
            QEMU_CAPS_VIRTIO_SCSI,
2701
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2702

2703
    DO_TEST("machine-loadparm-s390",
2704
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2705
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
2706
    DO_TEST("machine-loadparm-net-s390",
2707
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2708 2709
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
2710
            QEMU_CAPS_CCW,
2711 2712 2713
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
2714
                        QEMU_CAPS_CCW,
2715 2716 2717
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
2718
                        QEMU_CAPS_CCW,
2719 2720 2721
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2722 2723 2724 2725 2726 2727 2728
    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);

2729
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2730
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2731
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2732

2733
    DO_TEST("ppc64-usb-controller",
2734
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2735
            QEMU_CAPS_PCI_OHCI);
2736
    DO_TEST("ppc64-usb-controller-legacy",
2737
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2738
            QEMU_CAPS_PIIX3_USB_UHCI);
2739 2740
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", NULL, -1, 0,
                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE,
2741
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2742 2743 2744 2745 2746 2747 2748
                 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);
2749

2750 2751 2752 2753
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2754 2755 2756 2757
    DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                              VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                              NONE);

2758 2759 2760 2761 2762 2763 2764
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
2765
            QEMU_CAPS_SPICE_UNIX,
2766 2767
            QEMU_CAPS_DEVICE_ISA_SERIAL,
            QEMU_CAPS_CHARDEV_FILE_APPEND);
M
Marc-André Lureau 已提交
2768 2769
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2770
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
2771
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
2772
            QEMU_CAPS_USB_HUB);
2773
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
2774
                        QEMU_CAPS_USB_HUB);
2775

2776
    DO_TEST("acpi-table", NONE);
2777
    DO_TEST("intel-iommu",
2778
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2779 2780
    DO_TEST("intel-iommu-machine",
            QEMU_CAPS_MACHINE_IOMMU);
J
Ján Tomko 已提交
2781
    DO_TEST("intel-iommu-caching-mode",
2782 2783
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
2784 2785 2786 2787 2788 2789 2790 2791
            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_DEVICE_INTEL_IOMMU,
            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
            QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
2792 2793 2794 2795 2796 2797
    DO_TEST("intel-iommu-eim",
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
            QEMU_CAPS_INTEL_IOMMU_EIM,
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2798 2799 2800 2801 2802 2803
    DO_TEST("intel-iommu-device-iotlb",
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
            QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB,
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2804

2805
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2806 2807 2808
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2809 2810 2811 2812 2813 2814 2815
    DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
            QEMU_CAPS_VIRTIO_INPUT_HOST,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2816 2817 2818
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2819

J
Ján Tomko 已提交
2820
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2821
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2822
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
2823
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2824
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
2825 2826
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
2827
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2828 2829
            QEMU_CAPS_KVM);

2830 2831 2832 2833 2834 2835 2836 2837
    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);

2838 2839 2840 2841 2842 2843 2844 2845 2846
    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 已提交
2847
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2848

2849 2850 2851
    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,
2852
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2853
            QEMU_CAPS_HDA_DUPLEX,
2854 2855
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
2856
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2857 2858
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
2859
            QEMU_CAPS_ICH9_USB_EHCI1);
2860

2861
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
2862

2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887
    DO_TEST_CAPS_LATEST("tseg-explicit-size");
    DO_TEST_PARSE_ERROR("tseg-i440fx",
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_ICH9_AHCI,
                        QEMU_CAPS_MACHINE_SMM_OPT,
                        QEMU_CAPS_VIRTIO_SCSI,
                        QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES);
    DO_TEST_PARSE_ERROR("tseg-explicit-size",
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_ICH9_AHCI,
                        QEMU_CAPS_MACHINE_SMM_OPT,
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_PARSE_ERROR("tseg-invalid-size",
                        QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_PCI_BRIDGE,
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_ICH9_AHCI,
                        QEMU_CAPS_MACHINE_SMM_OPT,
                        QEMU_CAPS_VIRTIO_SCSI,
                        QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES);

2888
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
2889 2890 2891 2892 2893 2894
            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);

2895
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
2896 2897 2898 2899 2900 2901 2902
            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);

2903 2904 2905
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");

2906 2907 2908 2909
    DO_TEST("launch-security-sev",
            QEMU_CAPS_KVM,
            QEMU_CAPS_SEV_GUEST);

A
Andrea Bolognani 已提交
2910 2911 2912
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

2913
    VIR_FREE(driver.config->nbdTLSx509certdir);
2914
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
2915
    VIR_FREE(fakerootdir);
2916
    VIR_FREE(capslatest_x86_64);
2917

2918
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2919 2920
}

2921
VIR_TEST_MAIN_PRELOAD(mymain,
A
Andrea Bolognani 已提交
2922 2923 2924 2925
                      abs_builddir "/.libs/qemuxml2argvmock.so",
                      abs_builddir "/.libs/virrandommock.so",
                      abs_builddir "/.libs/qemucpumock.so",
                      abs_builddir "/.libs/virpcimock.so")
2926

2927 2928
#else

2929 2930 2931 2932
int main(void)
{
    return EXIT_AM_SKIP;
}
2933 2934

#endif /* WITH_QEMU */