qemuxml2argvtest.c 111.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_CAPS_LATEST("disk-cdrom");
993
    DO_TEST("disk-iscsi", NONE);
994
    DO_TEST("disk-cdrom-network", QEMU_CAPS_KVM);
995
    DO_TEST_CAPS_LATEST("disk-cdrom-network");
996
    DO_TEST("disk-cdrom-tray",
997
            QEMU_CAPS_VIRTIO_TX_ALG);
998
    DO_TEST_CAPS_LATEST("disk-cdrom-tray");
999
    DO_TEST("disk-floppy", NONE);
1000 1001
    DO_TEST_FAILURE("disk-floppy-pseries",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1002
    DO_TEST("disk-floppy-tray", NONE);
1003
    DO_TEST("disk-virtio-s390",
1004
            QEMU_CAPS_VIRTIO_S390);
1005
    DO_TEST("disk-many", NONE);
1006 1007
    DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-virtio-ccw",
1008
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1009
    DO_TEST("disk-virtio-ccw-many",
1010
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1011
    DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
1012
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1013
    DO_TEST("disk-order",
1014
            QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
1015
    DO_TEST("disk-virtio-queues",
L
Lin Ma 已提交
1016
            QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
1017
    DO_TEST("disk-boot-disk",
1018
            QEMU_CAPS_DRIVE_BOOT);
1019
    DO_TEST("disk-boot-cdrom",
1020
            QEMU_CAPS_DRIVE_BOOT);
1021
    DO_TEST("floppy-drive-fat",
1022
            QEMU_CAPS_DRIVE_BOOT);
1023 1024
    DO_TEST("disk-readonly-disk", NONE);
    DO_TEST("disk-fmt-qcow",
1025
            QEMU_CAPS_DRIVE_BOOT);
1026 1027 1028 1029 1030 1031
    DO_TEST_PARSE_ERROR("disk-fmt-cow", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST_PARSE_ERROR("disk-fmt-dir", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST_PARSE_ERROR("disk-fmt-iso", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-shared", NONE);
    DO_TEST_PARSE_ERROR("disk-shared-qcow", NONE);
    DO_TEST("disk-shared-locking",
1032
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW);
1033 1034
    DO_TEST("disk-error-policy", NONE);
    DO_TEST_CAPS_LATEST("disk-error-policy");
1035
    DO_TEST("disk-cache", QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_USB_STORAGE);
1036 1037 1038
    DO_TEST_CAPS_VER("disk-cache", "2.6.0");
    DO_TEST_CAPS_VER("disk-cache", "2.7.0");
    DO_TEST_CAPS_LATEST("disk-cache");
1039 1040 1041 1042 1043
    DO_TEST("disk-network-nbd", NONE);
    DO_TEST("disk-network-nbd-export", NONE);
    DO_TEST("disk-network-nbd-ipv6", NONE);
    DO_TEST("disk-network-nbd-ipv6-export", NONE);
    DO_TEST("disk-network-nbd-unix", NONE);
1044
    DO_TEST("disk-network-iscsi", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_BLOCK);
1045
    DO_TEST_CAPS_LATEST("disk-network-iscsi");
1046 1047 1048 1049
    DO_TEST_PARSE_ERROR("disk-network-iscsi-auth-secrettype-invalid", NONE);
    DO_TEST_PARSE_ERROR("disk-network-iscsi-auth-wrong-secrettype", NONE);
    DO_TEST_PARSE_ERROR("disk-network-source-auth-both", NONE);
    DO_TEST("disk-network-gluster",
1050
            QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
1051 1052 1053 1054 1055
    DO_TEST("disk-network-rbd", NONE);
    DO_TEST("disk-network-sheepdog", NONE);
    DO_TEST("disk-network-rbd-auth", NONE);
    DO_TEST("disk-network-source-auth", NONE);
    DO_TEST("disk-network-rbd-auth-AES",
1056
            QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_VIRTIO_SCSI);
1057 1058 1059
    DO_TEST("disk-network-rbd-ipv6", NONE);
    DO_TEST_FAILURE("disk-network-rbd-no-colon", NONE);
    DO_TEST("disk-network-vxhs", QEMU_CAPS_VXHS);
1060
    driver.config->vxhsTLS = 1;
1061
    DO_TEST("disk-network-tlsx509", QEMU_CAPS_VXHS,
1062
            QEMU_CAPS_OBJECT_TLS_CREDS_X509, QEMU_CAPS_NBD_TLS);
1063 1064
    driver.config->vxhsTLS = 0;
    VIR_FREE(driver.config->vxhsTLSx509certdir);
1065
    DO_TEST("disk-no-boot",
1066
            QEMU_CAPS_BOOTINDEX);
1067
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
1068 1069
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
1070
    DO_TEST("disk-usb-device",
1071
            QEMU_CAPS_DEVICE_USB_STORAGE);
1072
    DO_TEST("disk-usb-device-removable",
1073
            QEMU_CAPS_DEVICE_USB_STORAGE,
1074
            QEMU_CAPS_USB_STORAGE_REMOVABLE);
1075
    DO_TEST_FAILURE("disk-usb-pci",
1076
                    QEMU_CAPS_DEVICE_USB_STORAGE);
1077
    DO_TEST("disk-scsi-device",
1078
            QEMU_CAPS_SCSI_LSI);
1079
    DO_TEST("disk-scsi-device-auto",
1080
            QEMU_CAPS_SCSI_LSI);
1081
    DO_TEST("disk-scsi-disk-split",
1082
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1083
    DO_TEST("disk-scsi-disk-wwn",
1084
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1085 1086
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST("disk-scsi-disk-vpd",
1087
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1088 1089
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
1090
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
1091
            QEMU_CAPS_SCSI_DISK_WWN);
1092
    DO_TEST("disk-scsi-vscsi", NONE);
1093
    DO_TEST("disk-scsi-virtio-scsi",
1094
            QEMU_CAPS_VIRTIO_SCSI);
1095 1096
    DO_TEST("disk-virtio-scsi-num_queues",
            QEMU_CAPS_VIRTIO_SCSI);
1097 1098 1099 1100
    DO_TEST("disk-virtio-scsi-cmd_per_lun",
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("disk-virtio-scsi-max_sectors",
            QEMU_CAPS_VIRTIO_SCSI);
1101 1102
    DO_TEST("disk-virtio-scsi-ioeventfd",
            QEMU_CAPS_VIRTIO_IOEVENTFD, QEMU_CAPS_VIRTIO_SCSI);
1103 1104
    DO_TEST("disk-scsi-megasas",
            QEMU_CAPS_SCSI_MEGASAS);
1105 1106 1107
    DO_TEST("disk-scsi-mptsas1068",
            QEMU_CAPS_SCSI_MPTSAS1068,
            QEMU_CAPS_SCSI_DISK_WWN);
1108
    DO_TEST("disk-sata-device",
1109
            QEMU_CAPS_ICH9_AHCI);
J
Ján Tomko 已提交
1110
    DO_TEST("disk-aio", NONE);
1111
    DO_TEST_CAPS_LATEST("disk-aio");
1112 1113
    DO_TEST("disk-source-pool", NONE);
    DO_TEST("disk-source-pool-mode", NONE);
1114
    DO_TEST("disk-ioeventfd",
1115
            QEMU_CAPS_VIRTIO_IOEVENTFD,
1116
            QEMU_CAPS_VIRTIO_TX_ALG,
1117
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1118
    DO_TEST("disk-copy_on_read",
1119
            QEMU_CAPS_VIRTIO_TX_ALG,
1120
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1121
    DO_TEST_CAPS_LATEST("disk-copy_on_read");
1122
    DO_TEST("disk-discard",
1123
            QEMU_CAPS_DRIVE_DISCARD);
1124
    DO_TEST("disk-detect-zeroes",
1125 1126
            QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DRIVE_DETECT_ZEROES);
1127
    DO_TEST_CAPS_LATEST("disk-detect-zeroes");
1128
    DO_TEST("disk-snapshot", NONE);
1129 1130
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
1131
                        QEMU_CAPS_DEVICE_USB_STORAGE);
1132
    DO_TEST_PARSE_ERROR("disk-address-conflict",
1133 1134 1135 1136 1137 1138 1139
                        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);
1140
    DO_TEST("event_idx",
1141 1142
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
1143
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1144
    DO_TEST("virtio-lun",
1145
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1146
    DO_TEST("disk-scsi-lun-passthrough",
1147
            QEMU_CAPS_SCSI_BLOCK,
1148
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1149
    DO_TEST("disk-serial",
1150
            QEMU_CAPS_KVM);
1151 1152 1153 1154 1155 1156 1157 1158
    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);
1159

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

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

1185 1186
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1187
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
1188
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1189 1190
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1191
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1192 1193
    DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
    DO_TEST_CAPS_LATEST("graphics-vnc-tls");
1194
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1195 1196
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1197 1198 1199 1200
    DO_TEST("graphics-vnc-egl-headless",
            QEMU_CAPS_VNC,
            QEMU_CAPS_EGL_HEADLESS,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1201

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

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

1316

1317 1318
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1319
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1320
            QEMU_CAPS_CHARDEV_LOGFILE);
1321
    DO_TEST("serial-spiceport",
1322
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1323
            QEMU_CAPS_DEVICE_QXL,
1324
            QEMU_CAPS_SPICE,
1325
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1326
            QEMU_CAPS_CHARDEV_SPICEPORT);
1327
    DO_TEST("serial-spiceport-nospice", NONE);
1328

1329 1330 1331 1332
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1333 1334

    DO_TEST("serial-vc-chardev",
1335
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1336
    DO_TEST("serial-pty-chardev",
1337
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1338
    DO_TEST("serial-dev-chardev",
1339
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1340
    DO_TEST("serial-dev-chardev-iobase",
1341
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1342
    DO_TEST("serial-file-chardev",
1343
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1344
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1345
    DO_TEST("serial-unix-chardev",
1346
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1347
    DO_TEST_CAPS_LATEST("serial-unix-chardev");
1348
    DO_TEST("serial-tcp-chardev",
1349
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1350
    DO_TEST("serial-udp-chardev",
1351
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1352
    DO_TEST("serial-tcp-telnet-chardev",
1353
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1354 1355
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1356
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1357
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1358 1359
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1360
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1361 1362
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1363
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1364
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1365
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1366 1367 1368 1369 1370 1371 1372 1373
    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,
1374
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1375
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1376 1377
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1378
    DO_TEST("serial-many-chardev",
1379 1380 1381
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
1382
    DO_TEST("console-compat-chardev",
1383
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1384 1385
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1386

1387 1388 1389 1390 1391 1392 1393
    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);
1394
    DO_TEST("console-virtio-many",
1395
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1396
    DO_TEST("console-virtio-s390",
1397 1398
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390);
1399
    DO_TEST("console-virtio-ccw",
1400
            QEMU_CAPS_BOOTINDEX,
1401
            QEMU_CAPS_CCW,
1402
            QEMU_CAPS_VIRTIO_S390);
1403
    DO_TEST("console-sclp",
1404
            QEMU_CAPS_VIRTIO_S390,
1405
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1406
    DO_TEST("channel-spicevmc",
1407
            QEMU_CAPS_SPICE,
1408
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1409
    DO_TEST("channel-virtio-default",
1410
            QEMU_CAPS_SPICE);
1411
    DO_TEST("channel-virtio-unix", NONE);
1412

1413
    DO_TEST("smartcard-host",
1414
            QEMU_CAPS_CCID_EMULATED);
1415
    DO_TEST("smartcard-host-certificates",
1416
            QEMU_CAPS_CCID_EMULATED);
1417 1418
    DO_TEST("smartcard-host-certificates-database",
            QEMU_CAPS_CCID_EMULATED);
1419
    DO_TEST("smartcard-passthrough-tcp",
1420
            QEMU_CAPS_CCID_PASSTHRU);
1421
    DO_TEST("smartcard-passthrough-spicevmc",
1422
            QEMU_CAPS_CCID_PASSTHRU);
1423
    DO_TEST("smartcard-controller",
1424
            QEMU_CAPS_CCID_EMULATED);
1425

1426 1427 1428 1429 1430 1431 1432 1433
    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);
1434 1435
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1436

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

1537 1538 1539
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1540

1541
    DO_TEST("watchdog", NONE);
1542
    DO_TEST("watchdog-device", NONE);
1543
    DO_TEST("watchdog-dump", NONE);
1544
    DO_TEST("watchdog-injectnmi", NONE);
1545
    DO_TEST("watchdog-diag288",
1546
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
1547 1548
    DO_TEST("balloon-device", NONE);
    DO_TEST("balloon-device-deflate",
1549
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1550
    DO_TEST("balloon-ccw-deflate",
1551
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1552
    DO_TEST("balloon-mmio-deflate",
J
Ján Tomko 已提交
1553
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
1554
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1555
    DO_TEST("balloon-device-deflate-off",
1556
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1557 1558
    DO_TEST("balloon-device-auto", NONE);
    DO_TEST("balloon-device-period", NONE);
1559 1560
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1561
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1562
            QEMU_CAPS_HDA_OUTPUT,
1563 1564
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1565
    DO_TEST("fs9p", NONE);
1566
    DO_TEST("fs9p-ccw",
1567
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1568

1569
    DO_TEST("hostdev-usb-address", NONE);
1570
    DO_TEST("hostdev-usb-address-device", NONE);
1571
    DO_TEST("hostdev-usb-address-device-boot",
1572
            QEMU_CAPS_BOOTINDEX,
1573
            QEMU_CAPS_USB_HOST_BOOTINDEX);
J
Ján Tomko 已提交
1574
    DO_TEST("hostdev-pci-address", NONE);
1575
    DO_TEST("hostdev-pci-address-device", NONE);
1576 1577
    DO_TEST("hostdev-vfio",
            QEMU_CAPS_DEVICE_VFIO_PCI);
1578
    DO_TEST("hostdev-vfio-multidomain",
1579
            QEMU_CAPS_DEVICE_VFIO_PCI);
1580 1581 1582 1583 1584 1585
    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);
1586 1587 1588 1589 1590 1591 1592
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-opengl");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-egl-headless");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-vnc");
    DO_TEST_CAPS_LATEST("hostdev-mdev-display-vnc-egl-headless");
    DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics",
            QEMU_CAPS_DEVICE_VFIO_PCI,
            QEMU_CAPS_VFIO_PCI_DISPLAY);
1593
    DO_TEST("pci-rom", NONE);
1594
    DO_TEST("pci-rom-disabled", NONE);
1595
    DO_TEST("pci-rom-disabled-invalid", NONE);
1596

1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
    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);

1613 1614 1615 1616
    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);
1617

A
Andrea Bolognani 已提交
1618 1619 1620
    DO_TEST_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE,
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1621

1622
    DO_TEST("qemu-ns", NONE);
1623
    DO_TEST("qemu-ns-no-env", NONE);
1624
    DO_TEST("qemu-ns-alt", NONE);
1625

1626
    DO_TEST("smp", NONE);
1627

J
John Ferlan 已提交
1628
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1629 1630
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1631
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1632 1633
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1634
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1635 1636 1637 1638 1639
    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,
1640
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
J
John Ferlan 已提交
1641

1642 1643
    DO_TEST("cpu-topology1", NONE);
    DO_TEST("cpu-topology2", NONE);
1644
    DO_TEST("cpu-topology3", NONE);
1645 1646 1647 1648 1649 1650 1651 1652
    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);
1653
    DO_TEST("cpu-numa1", NONE);
1654 1655
    DO_TEST("cpu-numa2", NONE);
    DO_TEST("cpu-numa-no-memory-element", NONE);
1656
    DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
1657 1658
    DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
    DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
1659 1660
    DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
    DO_TEST_FAILURE("cpu-numa-memshared", NONE);
1661
    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
1662
    DO_TEST("cpu-host-model", NONE);
1663
    DO_TEST("cpu-host-model-vendor", NONE);
1664
    skipLegacyCPUs = true;
1665
    DO_TEST("cpu-host-model-fallback", NONE);
1666
    DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
1667
    skipLegacyCPUs = false;
A
Andrea Bolognani 已提交
1668 1669
    DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
    DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
1670

1671
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
1672
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1673 1674
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1675 1676
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1677
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1678 1679 1680 1681
    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);
1682
    DO_TEST("cpu-host-model-cmt", NONE);
1683
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1684
    qemuTestSetHostCPU(driver.caps, NULL);
1685

1686 1687
    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);
1688
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1689
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1690 1691
    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);
1692
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1693
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1694

1695 1696 1697 1698 1699 1700 1701 1702
    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);
1703
    DO_TEST("cputune-numatune",
1704
            QEMU_CAPS_KVM,
1705
            QEMU_CAPS_OBJECT_IOTHREAD,
1706 1707
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1708 1709 1710
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1711

1712
    DO_TEST("numatune-memory", NONE);
1713
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1714 1715 1716
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1717 1718
    DO_TEST_FAILURE("numatune-memnode", NONE);

A
Andrea Bolognani 已提交
1719 1720 1721
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1722 1723
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1724 1725
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1726
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1727 1728
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1729 1730
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1731 1732
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1733 1734
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1735
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1736 1737 1738
    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);
1739
    DO_TEST("blkdeviotune-max",
1740
            QEMU_CAPS_DRIVE_IOTUNE_MAX);
1741 1742 1743
    DO_TEST("blkdeviotune-group-num",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP);
1744 1745 1746
    DO_TEST("blkdeviotune-max-length",
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH);
1747

1748
    DO_TEST("multifunction-pci-device",
1749
            QEMU_CAPS_SCSI_LSI);
1750

1751
    DO_TEST("monitor-json", NONE);
1752

1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
    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);
1765

1766
    DO_TEST("pseries-basic",
1767
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1768
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1769
    DO_TEST("pseries-vio",
1770
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1771
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1772
    DO_TEST("pseries-usb-default",
1773
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1774
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1775
            QEMU_CAPS_PIIX3_USB_UHCI,
1776
            QEMU_CAPS_PCI_OHCI);
1777
    DO_TEST("pseries-usb-multi",
1778
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1779
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1780
            QEMU_CAPS_PIIX3_USB_UHCI,
1781
            QEMU_CAPS_PCI_OHCI);
1782
    DO_TEST("pseries-vio-user-assigned",
1783
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1784 1785
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash", NONE);
1786 1787 1788
    DO_TEST("pseries-nvram",
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_DEVICE_NVRAM);
1789
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1790
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1791
            QEMU_CAPS_DEVICE_USB_KBD,
1792
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1793
    DO_TEST("pseries-cpu-exact",
1794
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1795 1796
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST_PARSE_ERROR("pseries-no-parallel", NONE);
1797 1798

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1799
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1800
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1801
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1802 1803 1804
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
1805
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1806
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1807
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1808
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1809 1810 1811
    DO_TEST_FAILURE("pseries-cpu-compat-power9",
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
                    QEMU_CAPS_KVM);
1812 1813 1814

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1815
            QEMU_CAPS_KVM,
1816
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1817
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1818 1819
    qemuTestSetHostCPU(driver.caps, NULL);

1820 1821
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1822
    DO_TEST("pseries-panic-missing",
1823
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1824
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1825
    DO_TEST("pseries-panic-no-address",
1826
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1827
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1828
    DO_TEST_FAILURE("pseries-panic-address",
1829
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1830 1831 1832 1833 1834

    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);
1835 1836 1837 1838 1839 1840
    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);
1841 1842 1843
    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);
1844

1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
    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);

1867
    DO_TEST("pseries-features",
1868
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1869
            QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
1870
            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
1871
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1872
    DO_TEST_FAILURE("pseries-features",
1873
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1874
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
1875

1876
    DO_TEST("pseries-serial-native",
1877
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1878 1879
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
1880
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1881 1882
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
1883
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1884
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1885
    DO_TEST("pseries-serial-pci",
1886
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1887 1888
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
1889
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1890 1891
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
1892
    DO_TEST("pseries-console-native",
1893
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1894 1895
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
1896
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1897 1898
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);

1899
    DO_TEST("mach-virt-serial-native",
1900
            QEMU_CAPS_DEVICE_PL011);
1901
    DO_TEST("mach-virt-serial+console-native",
1902
            QEMU_CAPS_DEVICE_PL011);
1903
    DO_TEST("mach-virt-serial-compat",
1904
            QEMU_CAPS_DEVICE_PL011);
1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916
    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",
1917 1918
            QEMU_CAPS_DEVICE_PL011);
    DO_TEST("mach-virt-console-virtio", NONE);
1919 1920
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

1921
    DO_TEST("disk-ide-split",
1922
            QEMU_CAPS_IDE_CD);
1923
    DO_TEST("disk-ide-wwn",
1924
            QEMU_CAPS_IDE_CD,
1925
            QEMU_CAPS_IDE_DRIVE_WWN);
1926

1927
    DO_TEST("disk-geometry", NONE);
V
Viktor Mihajlovski 已提交
1928 1929
    DO_TEST("disk-blockio",
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1930

1931
    DO_TEST("video-device-pciaddr-default",
1932 1933
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
1934
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1935
            QEMU_CAPS_DEVICE_QXL);
1936
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
1937
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
1938
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1939
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
1940
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
1941
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
1942
    DO_TEST("video-qxl-device",
1943
            QEMU_CAPS_DEVICE_QXL,
1944
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1945
    DO_TEST("video-qxl-device-vgamem",
1946
            QEMU_CAPS_DEVICE_QXL,
1947
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1948 1949
            QEMU_CAPS_QXL_VGAMEM);
    DO_TEST("video-qxl-sec-device",
1950
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1951
    DO_TEST("video-qxl-sec-device-vgamem",
1952 1953
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1954
            QEMU_CAPS_QXL_VGAMEM);
1955 1956 1957
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1958
            QEMU_CAPS_QXL_MAX_OUTPUTS);
1959 1960 1961
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
1962 1963 1964
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
1965
            QEMU_CAPS_QXL_MAX_OUTPUTS);
M
Marc-André Lureau 已提交
1966
    DO_TEST("video-virtio-gpu-device",
1967
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
1968
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1969
    DO_TEST("video-virtio-gpu-virgl",
1970
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1971
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1972
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1973 1974
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
1975
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
1976 1977
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
1978
            QEMU_CAPS_SPICE_RENDERNODE,
1979
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1980 1981 1982 1983 1984
    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);
1985 1986 1987
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1988 1989 1990
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
1991 1992
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
1993 1994 1995
    DO_TEST("video-none-device",
            QEMU_CAPS_VNC);
    DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
1996

1997 1998
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
1999
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2000 2001
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2002
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2003 2004
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2005
            QEMU_CAPS_OBJECT_RNG_EGD);
2006 2007 2008 2009
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2010
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
2011 2012
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
2013
    DO_TEST("virtio-rng-ccw",
2014
            QEMU_CAPS_BOOTINDEX,
2015
            QEMU_CAPS_CCW,
2016 2017
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2018
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2019

2020
    DO_TEST("s390-allow-bogus-usb-none",
2021 2022 2023 2024
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2025
    DO_TEST("s390-allow-bogus-usb-controller",
2026 2027 2028 2029
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2030

2031
    DO_TEST("s390-panic-no-address",
2032
            QEMU_CAPS_CCW,
2033
            QEMU_CAPS_VIRTIO_S390);
2034
    DO_TEST_FAILURE("s390-panic-address",
2035
            QEMU_CAPS_CCW,
2036
            QEMU_CAPS_VIRTIO_S390);
2037
    DO_TEST("s390-panic-missing",
2038
            QEMU_CAPS_CCW,
2039
            QEMU_CAPS_VIRTIO_S390);
2040
    DO_TEST_PARSE_ERROR("s390-no-parallel",
2041
            QEMU_CAPS_CCW,
2042
            QEMU_CAPS_VIRTIO_S390);
2043
    DO_TEST("s390-serial",
2044
            QEMU_CAPS_CCW,
2045 2046 2047
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
2048
            QEMU_CAPS_CCW,
2049 2050 2051 2052
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
2053
            QEMU_CAPS_CCW,
2054 2055
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2056

2057
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2058
            QEMU_CAPS_KVM);
2059 2060
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2061

2062
    DO_TEST("tpm-passthrough",
2063
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2064 2065
    DO_TEST("tpm-passthrough-crb",
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_CRB);
2066
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2067
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2068
    DO_TEST_CAPS_LATEST("tpm-emulator");
2069
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2070

2071 2072 2073 2074
    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);
2075

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

    /* Test automatic and manual setting of pcie-root-port attributes */
2278 2279
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2280
            QEMU_CAPS_ICH9_AHCI,
2281
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2282
            QEMU_CAPS_DEVICE_QXL);
2283 2284 2285 2286 2287 2288

    /* 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,
2289
            QEMU_CAPS_DEVICE_IOH3420);
2290
    DO_TEST("pcie-root-port-model-ioh3420",
2291
            QEMU_CAPS_DEVICE_IOH3420);
2292

2293 2294 2295 2296 2297 2298 2299
    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,
2300
            QEMU_CAPS_ICH9_USB_EHCI1,
2301
            QEMU_CAPS_NEC_USB_XHCI);
2302 2303 2304 2305 2306 2307 2308
    /* 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);
2309

2310
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2311
            QEMU_CAPS_DEVICE_IOH3420,
2312
            QEMU_CAPS_ICH9_AHCI,
2313
            QEMU_CAPS_ICH9_USB_EHCI1,
2314
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2315
            QEMU_CAPS_DEVICE_QXL);
2316
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2317
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2318

2319
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2320
            QEMU_CAPS_DEVICE_IOH3420,
2321
            QEMU_CAPS_ICH9_AHCI,
2322
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2323
            QEMU_CAPS_DEVICE_QXL);
2324

2325 2326 2327
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2328
            QEMU_CAPS_ICH9_AHCI,
2329
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2330
            QEMU_CAPS_DEVICE_QXL);
2331 2332 2333 2334
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2335
            QEMU_CAPS_ICH9_AHCI,
2336
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2337
            QEMU_CAPS_DEVICE_QXL);
2338

2339 2340 2341 2342 2343 2344
    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);
2345 2346
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2347

2348 2349 2350 2351 2352 2353 2354 2355 2356 2357
    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);
2358 2359 2360
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2361

2362
    DO_TEST("hostdev-scsi-lsi",
2363 2364
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2365
    DO_TEST("hostdev-scsi-virtio-scsi",
2366 2367
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2368
    DO_TEST("hostdev-scsi-readonly",
J
Ján Tomko 已提交
2369
            QEMU_CAPS_VIRTIO_SCSI,
O
Osier Yang 已提交
2370
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
2371
    DO_TEST("hostdev-scsi-virtio-scsi",
2372 2373 2374
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
2375
    DO_TEST("hostdev-scsi-lsi-iscsi",
J
John Ferlan 已提交
2376 2377
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2378
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
J
John Ferlan 已提交
2379 2380
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2381
    DO_TEST("hostdev-scsi-virtio-iscsi",
J
John Ferlan 已提交
2382 2383
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2384
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
J
John Ferlan 已提交
2385 2386
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2387 2388 2389 2390
    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);
2391 2392
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2393
            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_CCW);
2394 2395 2396
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2397 2398 2399 2400 2401 2402
    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);
2403

2404
    DO_TEST("mlock-on", QEMU_CAPS_REALTIME_MLOCK);
2405
    DO_TEST_FAILURE("mlock-on", NONE);
2406
    DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK);
2407 2408
    DO_TEST("mlock-unsupported", NONE);

2409 2410 2411 2412
    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);
2413

2414
    DO_TEST("hotplug-base",
2415
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2416

2417 2418
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
2419
    DO_TEST("pcihole64-q35",
2420
            QEMU_CAPS_DEVICE_IOH3420,
2421
            QEMU_CAPS_ICH9_AHCI,
2422
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2423
            QEMU_CAPS_DEVICE_QXL,
2424 2425
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2426 2427
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2428
    DO_TEST("arm-vexpressa9-virtio",
2429
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2430
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2431
    DO_TEST("arm-virt-virtio",
2432
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2433
            QEMU_CAPS_DEVICE_PL011,
2434
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2435

2436
    DO_TEST("aarch64-virt-virtio",
2437
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2438
            QEMU_CAPS_DEVICE_PL011,
2439
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2440 2441 2442 2443 2444 2445

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

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

2593
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2594

2595
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2596
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2597

2598 2599 2600 2601
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2602

2603 2604
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2605

2606 2607
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2608
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2609 2610 2611
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2612
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2613
    DO_TEST_FAILURE("shmem-invalid-size",
2614
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2615
    DO_TEST_FAILURE("shmem-invalid-address",
2616
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2617
    DO_TEST_FAILURE("shmem-small-size",
2618
                    QEMU_CAPS_DEVICE_IVSHMEM);
2619
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2620
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2621

2622
    DO_TEST_FAILURE("memory-align-fail", NONE);
2623
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2624
    DO_TEST("memory-hotplug", NONE);
2625
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2626
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2627
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2628
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2629
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2630
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2631
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2632
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2633 2634
    DO_TEST("memory-hotplug-nvdimm",
            QEMU_CAPS_DEVICE_NVDIMM,
M
Michal Privoznik 已提交
2635
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2636 2637
    DO_TEST("memory-hotplug-nvdimm-access",
            QEMU_CAPS_DEVICE_NVDIMM,
2638
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2639 2640
    DO_TEST("memory-hotplug-nvdimm-label",
            QEMU_CAPS_DEVICE_NVDIMM,
2641
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2642

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

    DO_TEST("machine-aeskeywrap-on-cap",
2654
            QEMU_CAPS_AES_KEY_WRAP,
2655
            QEMU_CAPS_VIRTIO_SCSI,
2656
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2657
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2658
                    QEMU_CAPS_VIRTIO_SCSI,
2659
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2660 2661 2662
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2663
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2664
            QEMU_CAPS_VIRTIO_SCSI,
2665
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2666
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2667
                    QEMU_CAPS_VIRTIO_SCSI,
2668
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2669 2670 2671
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2672
            QEMU_CAPS_AES_KEY_WRAP,
2673
            QEMU_CAPS_VIRTIO_SCSI,
2674
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2675
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2676
                    QEMU_CAPS_VIRTIO_SCSI,
2677
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2678 2679 2680
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2681
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2682
            QEMU_CAPS_VIRTIO_SCSI,
2683
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2684
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2685
                    QEMU_CAPS_VIRTIO_SCSI,
2686
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2687 2688 2689
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2690
            QEMU_CAPS_DEA_KEY_WRAP,
2691
            QEMU_CAPS_VIRTIO_SCSI,
2692
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2693
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2694
                    QEMU_CAPS_VIRTIO_SCSI,
2695
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2696 2697 2698
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2699
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2700
            QEMU_CAPS_VIRTIO_SCSI,
2701
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2702
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2703
                    QEMU_CAPS_VIRTIO_SCSI,
2704
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2705 2706 2707
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2708
            QEMU_CAPS_DEA_KEY_WRAP,
2709
            QEMU_CAPS_VIRTIO_SCSI,
2710
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2711
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2712
                    QEMU_CAPS_VIRTIO_SCSI,
2713
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2714 2715 2716
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2717
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2718
            QEMU_CAPS_VIRTIO_SCSI,
2719
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2720
    DO_TEST("machine-keywrap-none",
2721
            QEMU_CAPS_VIRTIO_SCSI,
2722
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2723

2724
    DO_TEST("machine-loadparm-s390",
2725
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2726
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
2727
    DO_TEST("machine-loadparm-net-s390",
2728
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390,
2729 2730
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
2731
            QEMU_CAPS_CCW,
2732 2733 2734
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
2735
                        QEMU_CAPS_CCW,
2736 2737 2738
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
2739
                        QEMU_CAPS_CCW,
2740 2741 2742
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2743 2744 2745 2746 2747 2748 2749
    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);

2750
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2751
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2752
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2753

2754
    DO_TEST("ppc64-usb-controller",
2755
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2756
            QEMU_CAPS_PCI_OHCI);
2757
    DO_TEST("ppc64-usb-controller-legacy",
2758
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2759
            QEMU_CAPS_PIIX3_USB_UHCI);
2760 2761
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", NULL, -1, 0,
                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE,
2762
                 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
2763 2764 2765 2766 2767 2768 2769
                 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);
2770

2771 2772 2773 2774
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2775 2776 2777 2778
    DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                              VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                              NONE);

2779 2780 2781
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
2782 2783
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP,
2784 2785 2786 2787
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
2788
            QEMU_CAPS_SPICE_UNIX,
2789 2790 2791 2792 2793
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_SPICE_GL,
            QEMU_CAPS_SPICE_RENDERNODE,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2794
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2795
            QEMU_CAPS_CHARDEV_FILE_APPEND,
2796 2797 2798
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
M
Marc-André Lureau 已提交
2799 2800
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2801
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
2802
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
2803
            QEMU_CAPS_USB_HUB);
2804
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
2805
                        QEMU_CAPS_USB_HUB);
2806

2807
    DO_TEST("acpi-table", NONE);
2808
    DO_TEST("intel-iommu",
2809
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2810 2811
    DO_TEST("intel-iommu-machine",
            QEMU_CAPS_MACHINE_IOMMU);
J
Ján Tomko 已提交
2812
    DO_TEST("intel-iommu-caching-mode",
2813 2814
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
2815 2816 2817 2818 2819 2820 2821 2822
            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);
2823 2824 2825 2826 2827 2828
    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);
2829 2830 2831 2832 2833 2834
    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);
2835

2836
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2837 2838 2839
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2840 2841 2842 2843 2844 2845 2846
    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,
2847 2848 2849
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2850

J
Ján Tomko 已提交
2851
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2852
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2853
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
2854
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2855
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
2856 2857
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
2858
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2859 2860
            QEMU_CAPS_KVM);

2861 2862 2863 2864 2865 2866 2867 2868
    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);

2869 2870 2871 2872 2873 2874 2875 2876 2877
    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 已提交
2878
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2879

2880 2881 2882
    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,
2883
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2884
            QEMU_CAPS_HDA_DUPLEX,
2885 2886
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
2887
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2888 2889
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
2890
            QEMU_CAPS_ICH9_USB_EHCI1);
2891

2892
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
2893

2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918
    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);

2919
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
2920 2921 2922 2923 2924 2925
            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);

2926
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
2927 2928 2929 2930 2931 2932 2933
            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);

2934 2935 2936
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");

2937 2938 2939 2940
    DO_TEST("launch-security-sev",
            QEMU_CAPS_KVM,
            QEMU_CAPS_SEV_GUEST);

A
Andrea Bolognani 已提交
2941 2942 2943
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

2944
    VIR_FREE(driver.config->nbdTLSx509certdir);
2945
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
2946
    VIR_FREE(fakerootdir);
2947
    VIR_FREE(capslatest_x86_64);
2948

2949
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2950 2951
}

2952
VIR_TEST_MAIN_PRELOAD(mymain,
A
Andrea Bolognani 已提交
2953 2954 2955 2956
                      abs_builddir "/.libs/qemuxml2argvmock.so",
                      abs_builddir "/.libs/virrandommock.so",
                      abs_builddir "/.libs/qemucpumock.so",
                      abs_builddir "/.libs/virpcimock.so")
2957

2958 2959
#else

2960 2961 2962 2963
int main(void)
{
    return EXIT_AM_SKIP;
}
2964 2965

#endif /* WITH_QEMU */