qemuxml2argvtest.c 108.7 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 554 555 556 557 558 559 560 561 562 563
    if (vm->def->tpm) {
        switch (vm->def->tpm->type) {
        case VIR_DOMAIN_TPM_TYPE_EMULATOR:
            if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.path,
                           "/dev/test") < 0)
                goto cleanup;
            break;
        case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
        case VIR_DOMAIN_TPM_TYPE_LAST:
            break;
       }
    }

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

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

579
    if (virTestCompareToFile(actualargv, args) < 0)
580
        goto cleanup;
581

P
Pavel Hrdina 已提交
582 583
    ret = 0;

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

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

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

A
Andrea Bolognani 已提交
617
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
618

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

A
Andrea Bolognani 已提交
627 628 629 630 631 632 633 634 635 636 637 638
    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);

639 640
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
641
        abs_top_srcdir = abs_srcdir "/..";
642

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

653
    if (qemuTestDriverInit(&driver) < 0)
654
        return EXIT_FAILURE;
655 656

    driver.privileged = true;
657

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

677
    VIR_FREE(driver.config->hugetlbfs);
678
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
679
        return EXIT_FAILURE;
680 681 682
    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)
683
        return EXIT_FAILURE;
684 685
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
686
    driver.config->hugetlbfs[1].size = 1048576;
687
    driver.config->spiceTLS = 1;
688
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
689
        return EXIT_FAILURE;
690 691 692
    VIR_FREE(driver.config->memoryBackingDir);
    if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
        return EXIT_FAILURE;
693

694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
    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, \
716
                               arch, capsfile, stripmachinealiases) \
717 718 719 720 721 722 723 724 725
    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; \
726 727
        if (stripmachinealiases) \
            virQEMUCapsStripMachineAliases(info.qemuCaps); \
728 729 730 731 732 733 734 735 736
        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_"

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

741 742
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
    DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, arch, ver)
743 744

# define DO_TEST_CAPS_VER(name, ver) \
745
    DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)
746 747

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

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

761 762 763 764
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \
                      parseFlags, gic, ...) \
    do { \
        static struct testInfo info = { \
765
            name, NULL, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
766
            false, NULL \
767 768 769 770 771 772 773 774
        }; \
        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; \
775
        if (virTestRun("QEMU XML-2-startup-XML " name, \
J
Ján Tomko 已提交
776
                       testCompareXMLToStartupXML, &info) < 0) \
777
            ret = -1; \
778
        virObjectUnref(info.qemuCaps); \
779
        virObjectUnref(info.vm); \
780 781
    } while (0)

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

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

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

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

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

# define NONE QEMU_CAPS_LAST
803

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

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

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

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

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

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

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

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

918 919
    DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM);
J
Ján Tomko 已提交
920
    DO_TEST("controller-order",
921 922 923 924 925 926 927
            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,
928
            QEMU_CAPS_DEVICE_ISA_SERIAL,
929
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
930 931
    DO_TEST("eoi-disabled", NONE);
    DO_TEST("eoi-enabled", NONE);
932 933
    DO_TEST("pv-spinlock-disabled", NONE);
    DO_TEST("pv-spinlock-enabled", NONE);
M
Martin Kletzander 已提交
934
    DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
935

936
    DO_TEST("hyperv", NONE);
937
    DO_TEST("hyperv-off", NONE);
938
    DO_TEST("hyperv-panic", NONE);
939

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

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

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

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

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

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

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

1305

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

1318 1319 1320 1321
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1322 1323

    DO_TEST("serial-vc-chardev",
1324
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1325
    DO_TEST("serial-pty-chardev",
1326
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1327
    DO_TEST("serial-dev-chardev",
1328
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1329
    DO_TEST("serial-dev-chardev-iobase",
1330
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1331
    DO_TEST("serial-file-chardev",
1332
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1333
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1334
    DO_TEST("serial-unix-chardev",
1335
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1336
    DO_TEST("serial-tcp-chardev",
1337
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1338
    DO_TEST("serial-udp-chardev",
1339
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1340
    DO_TEST("serial-tcp-telnet-chardev",
1341
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1342 1343
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1344
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1345
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1346 1347
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1348
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1349 1350
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1351
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1352
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1353
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1354 1355 1356 1357 1358 1359 1360 1361
    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,
1362
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1363
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1364 1365
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1366
    DO_TEST("serial-many-chardev",
1367 1368 1369
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("parallel-tcp-chardev", NONE);
    DO_TEST("parallel-parport-chardev", NONE);
1370
    DO_TEST("console-compat-chardev",
1371
            QEMU_CAPS_DEVICE_ISA_SERIAL);
M
Michal Privoznik 已提交
1372 1373
    DO_TEST("pci-serial-dev-chardev",
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1374

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

1401
    DO_TEST("smartcard-host",
1402
            QEMU_CAPS_CCID_EMULATED);
1403
    DO_TEST("smartcard-host-certificates",
1404
            QEMU_CAPS_CCID_EMULATED);
1405
    DO_TEST("smartcard-passthrough-tcp",
1406
            QEMU_CAPS_CCID_PASSTHRU);
1407
    DO_TEST("smartcard-passthrough-spicevmc",
1408
            QEMU_CAPS_CCID_PASSTHRU);
1409
    DO_TEST("smartcard-controller",
1410
            QEMU_CAPS_CCID_EMULATED);
1411

1412 1413 1414 1415 1416 1417 1418 1419
    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);
1420 1421
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_CHARDEV_RECONNECT);
1422

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

1523 1524 1525
    DO_TEST("smbios", NONE);
    DO_TEST_PARSE_ERROR("smbios-date", NONE);
    DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE);
1526

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

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

1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
    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);

1592 1593 1594 1595
    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);
1596

A
Andrea Bolognani 已提交
1597 1598 1599
    DO_TEST_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE,
                 QEMU_CAPS_NUMA,
                 QEMU_CAPS_OBJECT_MEMORY_RAM);
1600

1601
    DO_TEST("qemu-ns", NONE);
1602
    DO_TEST("qemu-ns-no-env", NONE);
1603
    DO_TEST("qemu-ns-alt", NONE);
1604

1605
    DO_TEST("smp", NONE);
1606

J
John Ferlan 已提交
1607
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1608 1609
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1610
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1611 1612
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1613
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1614 1615 1616 1617 1618
    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,
1619
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
J
John Ferlan 已提交
1620

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

1650
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
1651
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
1652 1653
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1654 1655
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

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

1665 1666
    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);
1667
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1668
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1669 1670
    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);
1671
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1672
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1673

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

1691
    DO_TEST("numatune-memory", NONE);
1692
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
A
Andrea Bolognani 已提交
1693 1694 1695
    DO_TEST("numatune-memnode",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1696 1697
    DO_TEST_FAILURE("numatune-memnode", NONE);

A
Andrea Bolognani 已提交
1698 1699 1700
    DO_TEST("numatune-memnode-no-memory",
            QEMU_CAPS_NUMA,
            QEMU_CAPS_OBJECT_MEMORY_RAM);
1701 1702
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1703 1704
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

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

1727
    DO_TEST("multifunction-pci-device",
1728
            QEMU_CAPS_SCSI_LSI);
1729

1730
    DO_TEST("monitor-json", NONE);
1731

1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
    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);
1744

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

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

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1794
            QEMU_CAPS_KVM,
1795
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1796
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1797 1798
    qemuTestSetHostCPU(driver.caps, NULL);

1799 1800
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1801
    DO_TEST("pseries-panic-missing",
1802
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1803
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1804
    DO_TEST("pseries-panic-no-address",
1805
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1806
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1807
    DO_TEST_FAILURE("pseries-panic-address",
1808
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1809 1810 1811 1812 1813

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

1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845
    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);

1846
    DO_TEST("pseries-features",
1847
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
1848
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
1849
    DO_TEST_FAILURE("pseries-features",
1850
                    QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
A
Andrea Bolognani 已提交
1851
    DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE);
1852

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

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

1898
    DO_TEST("disk-ide-drive-split",
1899
            QEMU_CAPS_IDE_CD);
1900
    DO_TEST("disk-ide-wwn",
1901
            QEMU_CAPS_IDE_CD,
1902
            QEMU_CAPS_IDE_DRIVE_WWN);
1903

1904
    DO_TEST("disk-geometry", NONE);
V
Viktor Mihajlovski 已提交
1905 1906
    DO_TEST("disk-blockio",
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1907

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

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

1995
    DO_TEST("s390-allow-bogus-usb-none",
1996 1997 1998 1999
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2000
    DO_TEST("s390-allow-bogus-usb-controller",
2001 2002 2003 2004
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2005

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

2032
    DO_TEST("ppc-dtb",
J
Ján Tomko 已提交
2033
            QEMU_CAPS_KVM);
2034 2035
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2036

2037
    DO_TEST("tpm-passthrough",
2038
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2039 2040
    DO_TEST("tpm-passthrough-crb",
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_CRB);
2041
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2042
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2043
    DO_TEST_CAPS_LATEST("tpm-emulator");
2044
    DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
2045

2046 2047 2048 2049
    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);
2050

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

    /* Test automatic and manual setting of pcie-root-port attributes */
2253 2254
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2255
            QEMU_CAPS_ICH9_AHCI,
2256
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2257
            QEMU_CAPS_DEVICE_QXL);
2258 2259 2260 2261 2262 2263

    /* 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,
2264
            QEMU_CAPS_DEVICE_IOH3420);
2265
    DO_TEST("pcie-root-port-model-ioh3420",
2266
            QEMU_CAPS_DEVICE_IOH3420);
2267

2268 2269 2270 2271 2272 2273 2274
    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,
2275
            QEMU_CAPS_ICH9_USB_EHCI1,
2276
            QEMU_CAPS_NEC_USB_XHCI);
2277 2278 2279 2280 2281 2282 2283
    /* 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);
2284

2285
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2286
            QEMU_CAPS_DEVICE_IOH3420,
2287
            QEMU_CAPS_ICH9_AHCI,
2288
            QEMU_CAPS_ICH9_USB_EHCI1,
2289
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2290
            QEMU_CAPS_DEVICE_QXL);
2291
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2292
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2293

2294
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2295
            QEMU_CAPS_DEVICE_IOH3420,
2296
            QEMU_CAPS_ICH9_AHCI,
2297
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2298
            QEMU_CAPS_DEVICE_QXL);
2299

2300 2301 2302
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2303
            QEMU_CAPS_ICH9_AHCI,
2304
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2305
            QEMU_CAPS_DEVICE_QXL);
2306 2307 2308 2309
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2310
            QEMU_CAPS_ICH9_AHCI,
2311
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2312
            QEMU_CAPS_DEVICE_QXL);
2313

2314 2315 2316 2317 2318 2319
    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);
2320 2321
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2322

2323 2324 2325 2326 2327 2328 2329 2330 2331 2332
    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);
2333 2334 2335
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2336

2337
    DO_TEST("hostdev-scsi-lsi",
2338 2339
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2340
    DO_TEST("hostdev-scsi-virtio-scsi",
2341 2342
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2343
    DO_TEST("hostdev-scsi-readonly",
J
Ján Tomko 已提交
2344
            QEMU_CAPS_VIRTIO_SCSI,
O
Osier Yang 已提交
2345
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
2346
    DO_TEST("hostdev-scsi-virtio-scsi",
2347 2348 2349
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
2350
    DO_TEST("hostdev-scsi-lsi-iscsi",
J
John Ferlan 已提交
2351 2352
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2353
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
J
John Ferlan 已提交
2354 2355
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2356
    DO_TEST("hostdev-scsi-virtio-iscsi",
J
John Ferlan 已提交
2357 2358
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2359
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
J
John Ferlan 已提交
2360 2361
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2362 2363 2364 2365
    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);
2366 2367
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
2368
            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_CCW);
2369 2370 2371
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2372 2373 2374 2375 2376 2377
    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);
2378

2379
    DO_TEST("mlock-on", QEMU_CAPS_REALTIME_MLOCK);
2380
    DO_TEST_FAILURE("mlock-on", NONE);
2381
    DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK);
2382 2383
    DO_TEST("mlock-unsupported", NONE);

2384 2385 2386 2387
    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);
2388

2389
    DO_TEST("hotplug-base",
2390
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2391

2392 2393
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
2394
    DO_TEST("pcihole64-q35",
2395
            QEMU_CAPS_DEVICE_IOH3420,
2396
            QEMU_CAPS_ICH9_AHCI,
2397
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2398
            QEMU_CAPS_DEVICE_QXL,
2399 2400
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

J
Ján Tomko 已提交
2401 2402
    DO_TEST("arm-vexpressa9-nodevs", NONE);
    DO_TEST("arm-vexpressa9-basic", NONE);
2403
    DO_TEST("arm-vexpressa9-virtio",
2404
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2405
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2406
    DO_TEST("arm-virt-virtio",
2407
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2408
            QEMU_CAPS_DEVICE_PL011,
2409
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2410

2411
    DO_TEST("aarch64-virt-virtio",
2412
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2413
            QEMU_CAPS_DEVICE_PL011,
2414
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2415 2416 2417 2418 2419 2420

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

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

2568
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2569

2570
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2571
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2572

2573 2574 2575 2576
    DO_TEST("panic",
            QEMU_CAPS_DEVICE_PANIC);
    DO_TEST("panic-double",
            QEMU_CAPS_DEVICE_PANIC);
H
Hu Tao 已提交
2577

2578 2579
    DO_TEST("panic-no-address",
            QEMU_CAPS_DEVICE_PANIC);
2580

2581 2582
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

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

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

2618
    DO_TEST("machine-aeskeywrap-on-caps",
2619
            QEMU_CAPS_AES_KEY_WRAP,
2620
            QEMU_CAPS_DEA_KEY_WRAP,
2621
            QEMU_CAPS_VIRTIO_SCSI,
2622
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2623
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps",
2624
                    QEMU_CAPS_VIRTIO_SCSI,
2625
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2626 2627 2628
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
2629
            QEMU_CAPS_AES_KEY_WRAP,
2630
            QEMU_CAPS_VIRTIO_SCSI,
2631
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2632
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap",
2633
                    QEMU_CAPS_VIRTIO_SCSI,
2634
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2635 2636 2637
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
2638
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2639
            QEMU_CAPS_VIRTIO_SCSI,
2640
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2641
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps",
2642
                    QEMU_CAPS_VIRTIO_SCSI,
2643
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2644 2645 2646
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2647
            QEMU_CAPS_AES_KEY_WRAP,
2648
            QEMU_CAPS_VIRTIO_SCSI,
2649
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2650
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap",
2651
                    QEMU_CAPS_VIRTIO_SCSI,
2652
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2653 2654 2655
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
2656
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2657
            QEMU_CAPS_VIRTIO_SCSI,
2658
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2659
    DO_TEST_FAILURE("machine-deakeywrap-on-caps",
2660
                    QEMU_CAPS_VIRTIO_SCSI,
2661
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2662 2663 2664
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2665
            QEMU_CAPS_DEA_KEY_WRAP,
2666
            QEMU_CAPS_VIRTIO_SCSI,
2667
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2668
    DO_TEST_FAILURE("machine-deakeywrap-on-cap",
2669
                    QEMU_CAPS_VIRTIO_SCSI,
2670
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2671 2672 2673
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
2674
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2675
            QEMU_CAPS_VIRTIO_SCSI,
2676
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2677
    DO_TEST_FAILURE("machine-deakeywrap-off-caps",
2678
                    QEMU_CAPS_VIRTIO_SCSI,
2679
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2680 2681 2682
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2683
            QEMU_CAPS_DEA_KEY_WRAP,
2684
            QEMU_CAPS_VIRTIO_SCSI,
2685
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2686
    DO_TEST_FAILURE("machine-deakeywrap-off-cap",
2687
                    QEMU_CAPS_VIRTIO_SCSI,
2688
                    QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2689 2690 2691
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
2692
            QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2693
            QEMU_CAPS_VIRTIO_SCSI,
2694
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2695
    DO_TEST("machine-keywrap-none",
2696
            QEMU_CAPS_VIRTIO_SCSI,
2697
            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
2698

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

J
Jiri Denemark 已提交
2718 2719 2720 2721 2722 2723 2724
    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);

2725
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2726
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2727
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2728

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

2746 2747 2748 2749
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2750 2751 2752 2753
    DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                              VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                              NONE);

2754 2755 2756 2757 2758 2759 2760 2761
    DO_TEST("name-escape",
            QEMU_CAPS_NAME_DEBUG_THREADS,
            QEMU_CAPS_OBJECT_SECRET,
            QEMU_CAPS_VNC,
            QEMU_CAPS_NAME_GUEST,
            QEMU_CAPS_DEVICE_CIRRUS_VGA,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_UNIX);
M
Marc-André Lureau 已提交
2762 2763
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

2764
    DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
2765
    DO_TEST("usb-long-port-path",
J
Ján Tomko 已提交
2766
            QEMU_CAPS_USB_HUB);
2767
    DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
2768
                        QEMU_CAPS_USB_HUB);
2769

2770
    DO_TEST("acpi-table", NONE);
2771
    DO_TEST("intel-iommu",
2772
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2773 2774
    DO_TEST("intel-iommu-machine",
            QEMU_CAPS_MACHINE_IOMMU);
J
Ján Tomko 已提交
2775
    DO_TEST("intel-iommu-caching-mode",
2776 2777
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
2778 2779 2780 2781 2782 2783 2784 2785
            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);
2786 2787 2788 2789 2790 2791
    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);
2792 2793 2794 2795 2796 2797
    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);
2798

2799
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2800 2801 2802
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2803 2804 2805 2806 2807 2808 2809
    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,
2810 2811 2812
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2813

J
Ján Tomko 已提交
2814
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2815
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2816
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
2817
            QEMU_CAPS_KVM);
J
Ján Tomko 已提交
2818
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
2819 2820
            QEMU_CAPS_KVM);

J
Ján Tomko 已提交
2821
    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
2822 2823
            QEMU_CAPS_KVM);

2824 2825 2826 2827 2828 2829 2830 2831
    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);

2832 2833 2834 2835 2836 2837 2838 2839 2840
    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 已提交
2841
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2842

2843 2844 2845
    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,
2846
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2847
            QEMU_CAPS_HDA_DUPLEX,
2848 2849
            QEMU_CAPS_CCID_EMULATED,
            QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
2850
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2851 2852
    DO_TEST("user-aliases-usb", QEMU_CAPS_KVM,
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
2853
            QEMU_CAPS_ICH9_USB_EHCI1);
2854

2855
    DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations");
2856

2857
    DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW,
2858 2859 2860 2861 2862 2863
            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);

2864
    DO_TEST("input-virtio-ccw", QEMU_CAPS_CCW,
2865 2866 2867 2868 2869 2870 2871
            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);

2872 2873 2874
    DO_TEST_CAPS_LATEST("vhost-vsock");
    DO_TEST_CAPS_LATEST("vhost-vsock-auto");

A
Andrea Bolognani 已提交
2875 2876 2877
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

2878
    VIR_FREE(driver.config->nbdTLSx509certdir);
2879
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
2880
    VIR_FREE(fakerootdir);
2881
    VIR_FREE(capslatest_x86_64);
2882

2883
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2884 2885
}

2886
VIR_TEST_MAIN_PRELOAD(mymain,
A
Andrea Bolognani 已提交
2887 2888 2889 2890
                      abs_builddir "/.libs/qemuxml2argvmock.so",
                      abs_builddir "/.libs/virrandommock.so",
                      abs_builddir "/.libs/qemucpumock.so",
                      abs_builddir "/.libs/virpcimock.so")
2891

2892 2893
#else

2894 2895 2896 2897
int main(void)
{
    return EXIT_AM_SKIP;
}
2898 2899

#endif /* WITH_QEMU */