qemuxml2argvtest.c 114.4 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 "network/bridge_driver.h"
29
# include "virmock.h"
30

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

35
# include "testutilsqemu.h"
36

37 38
# define VIR_FROM_THIS VIR_FROM_QEMU

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

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

static virSecretPtr
fakeSecretLookupByUsage(virConnectPtr conn,
57
                        int usageType,
58 59
                        const char *usageID)
{
60
    unsigned char uuid[VIR_UUID_BUFLEN];
61 62 63 64 65 66 67 68 69 70
    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);
71
        return NULL;
72
    }
73

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

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

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

87
static virSecretDriver fakeSecretDriver = {
88 89
    .connectNumOfSecrets = NULL,
    .connectListSecrets = NULL,
90
    .secretLookupByUUID = fakeSecretLookupByUUID,
91 92 93 94 95 96
    .secretLookupByUsage = fakeSecretLookupByUsage,
    .secretDefineXML = NULL,
    .secretGetXMLDesc = NULL,
    .secretSetValue = NULL,
    .secretGetValue = fakeSecretGetValue,
    .secretUndefine = NULL,
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 125

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

126
 cleanup:
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 162
    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);

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

167
 fallback:
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 218
    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;

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

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

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

273 274 275 276 277 278 279
struct testInfo {
    const char *name;
    virQEMUCapsPtr qemuCaps;
    const char *migrateFrom;
    int migrateFd;
    unsigned int flags;
    unsigned int parseFlags;
280
    bool skipLegacyCPUs;
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
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_KVM);
    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                VIR_DOMAIN_VIRT_QEMU);
395

396 397 398 399 400 401 402 403 404
    virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);

    ret = 0;

 cleanup:
    return ret;
}


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

424 425
    memset(&monitor_chr, 0, sizeof(monitor_chr));

426
    if (!(conn = virGetConnect()))
427
        goto cleanup;
428

429
    conn->secretDriver = &fakeSecretDriver;
430
    conn->storageDriver = &fakeStorageDriver;
431

432 433 434 435 436 437
    if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_MONITOR_JSON))
        flags |= FLAG_JSON;

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

438
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
439 440
        goto cleanup;

441
    if (virAsprintf(&xml, "%s/qemuxml2argvdata/%s.xml",
442
                    abs_srcdir, info->name) < 0 ||
443
        virAsprintf(&args, "%s/qemuxml2argvdata/%s.args",
444 445 446 447 448 449 450 451
                    abs_srcdir, info->name) < 0)
        goto cleanup;

    if (info->migrateFrom &&
        !(migrateURI = qemuMigrationIncomingURI(info->migrateFrom,
                                                info->migrateFd)))
        goto cleanup;

452
    if (!(vm = virDomainObjNew(driver.xmlopt)))
453
        goto cleanup;
454

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

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

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

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

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

481
    if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
482
        goto cleanup;
483

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

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

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

P
Pavel Hrdina 已提交
498 499 500
    if (!(cmd = qemuProcessCreatePretendCmd(conn, &driver, vm, migrateURI,
                                            (flags & FLAG_FIPS), false,
                                            VIR_QEMU_PROCESS_START_COLD))) {
P
Pavel Hrdina 已提交
501 502
        if (flags & FLAG_EXPECT_FAILURE)
            goto ok;
503
        goto cleanup;
J
Jiri Denemark 已提交
504
    }
505 506 507 508
    if (flags & FLAG_EXPECT_FAILURE) {
        VIR_TEST_DEBUG("passed instead of expected failure");
        goto cleanup;
    }
J
Jiri Denemark 已提交
509

E
Eric Blake 已提交
510
    if (!(actualargv = virCommandToString(cmd)))
511
        goto cleanup;
E
Eric Blake 已提交
512

513
    if (virTestCompareToFile(actualargv, args) < 0)
514
        goto cleanup;
515

P
Pavel Hrdina 已提交
516 517
    ret = 0;

518
 ok:
519
    if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
P
Pavel Hrdina 已提交
520 521
        ret = -1;
        VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
522
        goto cleanup;
P
Pavel Hrdina 已提交
523
    }
524
    if (!virTestOOMActive()) {
525
        if (flags & FLAG_EXPECT_FAILURE) {
526
            if ((log = virTestLogContentAndReset()))
P
Pavel Hrdina 已提交
527 528
                VIR_TEST_DEBUG("Got expected error: \n%s", log);
        }
529
        virResetLastError();
P
Pavel Hrdina 已提交
530
        ret = 0;
531 532
    }

533
 cleanup:
534 535
    VIR_FREE(log);
    VIR_FREE(actualargv);
536
    virDomainChrSourceDefClear(&monitor_chr);
E
Eric Blake 已提交
537
    virCommandFree(cmd);
538
    virObjectUnref(vm);
539
    virObjectUnref(conn);
540
    VIR_FREE(migrateURI);
541 542
    VIR_FREE(xml);
    VIR_FREE(args);
543
    return ret;
544 545
}

A
Andrea Bolognani 已提交
546
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
547

548
static int
E
Eric Blake 已提交
549
mymain(void)
550 551
{
    int ret = 0;
A
Andrea Bolognani 已提交
552
    char *fakerootdir;
553
    bool skipLegacyCPUs = false;
554

A
Andrea Bolognani 已提交
555 556 557 558 559 560 561 562 563 564 565 566
    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);

567 568
    abs_top_srcdir = getenv("abs_top_srcdir");
    if (!abs_top_srcdir)
569
        abs_top_srcdir = abs_srcdir "/..";
570

571 572 573 574 575 576 577 578 579 580
    /* 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;
    }

581
    if (qemuTestDriverInit(&driver) < 0)
582
        return EXIT_FAILURE;
583

584 585 586
    if (networkRegister() < 0)
        return EXIT_FAILURE;

587
    driver.privileged = true;
588

589 590 591
    VIR_FREE(driver.config->defaultTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/qemu") < 0)
        return EXIT_FAILURE;
592
    VIR_FREE(driver.config->vncTLSx509certdir);
593
    if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
594 595
        return EXIT_FAILURE;
    VIR_FREE(driver.config->spiceTLSx509certdir);
596
    if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
597
        return EXIT_FAILURE;
598 599 600
    VIR_FREE(driver.config->chardevTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
        return EXIT_FAILURE;
601 602 603
    VIR_FREE(driver.config->vxhsTLSx509certdir);
    if (VIR_STRDUP_QUIET(driver.config->vxhsTLSx509certdir, "/etc/pki/libvirt-vxhs") < 0)
        return EXIT_FAILURE;
604

605
    VIR_FREE(driver.config->hugetlbfs);
606
    if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
607
        return EXIT_FAILURE;
608 609 610
    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)
611
        return EXIT_FAILURE;
612 613
    driver.config->hugetlbfs[0].size = 2048;
    driver.config->hugetlbfs[0].deflt = true;
614
    driver.config->hugetlbfs[1].size = 1048576;
615
    driver.config->spiceTLS = 1;
616
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
617
        return EXIT_FAILURE;
618 619 620
    VIR_FREE(driver.config->memoryBackingDir);
    if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
        return EXIT_FAILURE;
621

622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \
                      parseFlags, gic, ...) \
    do { \
        static struct testInfo info = { \
            name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
            false \
        }; \
        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; \
        virObjectUnref(info.qemuCaps); \
637 638
    } while (0)

639
# define DO_TEST(name, ...) \
640
    DO_TEST_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__)
641

642
# define DO_TEST_GIC(name, gic, ...) \
643 644
    DO_TEST_FULL(name, NULL, -1, 0, 0, gic, __VA_ARGS__)

645 646
# define DO_TEST_FAILURE(name, ...) \
    DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, \
647
                 0, GIC_NONE, __VA_ARGS__)
648

649 650 651
# define DO_TEST_PARSE_ERROR(name, ...) \
    DO_TEST_FULL(name, NULL, -1, \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
652
                 0, GIC_NONE, __VA_ARGS__)
653

654 655 656
# define DO_TEST_PARSE_FLAGS_ERROR(name, parseFlags, ...) \
    DO_TEST_FULL(name, NULL, -1, \
                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
657
                 parseFlags, GIC_NONE, __VA_ARGS__)
658

659
# define DO_TEST_LINUX(name, ...) \
660
    DO_TEST_LINUX_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__)
661

662 663 664 665 666 667
# ifdef __linux__
    /* This is a macro that invokes test only on Linux. It's
     * meant to be called in those cases where qemuxml2argvmock
     * cooperation is expected (e.g. we need a fixed time,
     * predictable NUMA topology and so on). On non-Linux
     * platforms the macro just consume its argument. */
668
#  define DO_TEST_LINUX_FULL(name, ...) \
669
    DO_TEST_FULL(name, __VA_ARGS__)
670
# else  /* __linux__ */
671 672 673
#  define DO_TEST_LINUX_FULL(name, ...) \
    do { \
        const char *tmp ATTRIBUTE_UNUSED = name; \
674 675 676
    } while (0)
# endif /* __linux__ */

677
# define NONE QEMU_CAPS_LAST
678

679 680 681
    /* 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 */
682 683 684 685 686 687 688
    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");
689 690
    unsetenv("QEMU_AUDIO_DRV");
    unsetenv("SDL_AUDIODRIVER");
691

692
    DO_TEST("minimal", NONE);
693
    DO_TEST_PARSE_ERROR("minimal-no-memory", NONE);
694
    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP);
695
    DO_TEST("machine-aliases1", NONE);
696
    DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
697 698
    DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
699
    driver.config->dumpGuestCore = true;
700 701
    DO_TEST("machine-core-off", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
702 703 704
    driver.config->dumpGuestCore = false;
    DO_TEST("machine-core-cfg-off", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_DUMP_GUEST_CORE);
705
    DO_TEST_FAILURE("machine-core-on", NONE);
706
    DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT);
M
Michal Privoznik 已提交
707 708 709
    DO_TEST("machine-smm-opt",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
710
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
711 712 713 714
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
L
Li Zhang 已提交
715 716
    DO_TEST("machine-usb-opt", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_USB_OPT);
717 718
    DO_TEST("machine-vmport-opt", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_VMPORT_OPT);
719
    DO_TEST("kvm", QEMU_CAPS_MACHINE_OPT);
720 721
    DO_TEST("default-kvm-host-arch", QEMU_CAPS_MACHINE_OPT);
    DO_TEST("default-qemu-host-arch", QEMU_CAPS_MACHINE_OPT);
722
    DO_TEST("x86-kvm-32-on-64", QEMU_CAPS_MACHINE_OPT);
723 724 725
    DO_TEST("boot-cdrom", NONE);
    DO_TEST("boot-network", NONE);
    DO_TEST("boot-floppy", NONE);
726
    DO_TEST("boot-floppy-q35",
727
            QEMU_CAPS_DEVICE_IOH3420,
728
            QEMU_CAPS_ICH9_AHCI);
729
    DO_TEST("bootindex-floppy-q35",
730
            QEMU_CAPS_DEVICE_IOH3420,
731
            QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_BOOT_MENU,
732
            QEMU_CAPS_BOOTINDEX);
733 734
    DO_TEST("boot-multi", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-enable",
735
            QEMU_CAPS_BOOT_MENU);
736
    DO_TEST("boot-menu-enable-bootindex",
737
            QEMU_CAPS_BOOT_MENU,
738
            QEMU_CAPS_BOOTINDEX);
739
    DO_TEST("boot-menu-enable-with-timeout",
740
            QEMU_CAPS_BOOT_MENU,
741
            QEMU_CAPS_SPLASH_TIMEOUT);
742
    DO_TEST_FAILURE("boot-menu-enable-with-timeout", QEMU_CAPS_BOOT_MENU);
743
    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE);
744 745
    DO_TEST("boot-menu-disable", QEMU_CAPS_BOOT_MENU);
    DO_TEST("boot-menu-disable-drive",
746
            QEMU_CAPS_BOOT_MENU);
747
    DO_TEST("boot-menu-disable-drive-bootindex",
748
            QEMU_CAPS_BOOT_MENU,
749
            QEMU_CAPS_BOOTINDEX);
750
    DO_TEST_PARSE_ERROR("boot-dev+order",
751
            QEMU_CAPS_BOOTINDEX,
752
            QEMU_CAPS_VIRTIO_BLK_SCSI);
753
    DO_TEST("boot-order",
754
            QEMU_CAPS_BOOTINDEX,
755
            QEMU_CAPS_VIRTIO_BLK_SCSI);
756
    DO_TEST("boot-complex",
757
            QEMU_CAPS_DRIVE_BOOT,
758
            QEMU_CAPS_VIRTIO_BLK_SCSI);
759
    DO_TEST("boot-complex-bootindex",
760
            QEMU_CAPS_DRIVE_BOOT,
761
            QEMU_CAPS_BOOTINDEX,
762
            QEMU_CAPS_VIRTIO_BLK_SCSI);
763
    DO_TEST("boot-strict",
764
            QEMU_CAPS_DRIVE_BOOT,
765
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT,
766
            QEMU_CAPS_VIRTIO_BLK_SCSI);
767 768 769 770 771

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

772
    DO_TEST("bios",
773
            QEMU_CAPS_DEVICE_ISA_SERIAL,
774
            QEMU_CAPS_SGA);
J
Ján Tomko 已提交
775
    DO_TEST("bios-nvram", NONE);
M
Michal Privoznik 已提交
776 777 778
    DO_TEST("bios-nvram-secure",
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
779
            QEMU_CAPS_DEVICE_IOH3420,
M
Michal Privoznik 已提交
780 781 782 783
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_SMM_OPT,
            QEMU_CAPS_VIRTIO_SCSI);
784 785 786 787 788 789 790

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

791
    DO_TEST("clock-utc", QEMU_CAPS_NODEFCONFIG);
792
    DO_TEST("clock-localtime", NONE);
793
    DO_TEST("clock-localtime-basis-localtime", QEMU_CAPS_RTC);
794 795
    DO_TEST("clock-variable", QEMU_CAPS_RTC);
    DO_TEST("clock-france", QEMU_CAPS_RTC);
796 797
    DO_TEST("clock-hpet-off", QEMU_CAPS_RTC);
    DO_TEST("clock-catchup", QEMU_CAPS_RTC);
798
    DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
A
Andrea Bolognani 已提交
799
    DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM);
800
    DO_TEST("kvmclock", QEMU_CAPS_KVM);
801
    DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
802

803 804
    DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM);
    DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM);
J
Ján Tomko 已提交
805
    DO_TEST("controller-order",
806 807 808 809 810 811 812 813 814 815 816
            QEMU_CAPS_KVM,
            QEMU_CAPS_ENABLE_KVM,
            QEMU_CAPS_BOOT_MENU,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_DRIVE_AIO,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_HDA_DUPLEX,
            QEMU_CAPS_USB_HUB,
817
            QEMU_CAPS_DEVICE_ISA_SERIAL,
818
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
819 820
    DO_TEST("eoi-disabled", NONE);
    DO_TEST("eoi-enabled", NONE);
821 822
    DO_TEST("pv-spinlock-disabled", NONE);
    DO_TEST("pv-spinlock-enabled", NONE);
M
Martin Kletzander 已提交
823
    DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
824

825
    DO_TEST("hyperv", NONE);
826
    DO_TEST("hyperv-off", NONE);
827
    DO_TEST("hyperv-panic", NONE);
828

829 830 831
    DO_TEST("kvm-features", NONE);
    DO_TEST("kvm-features-off", NONE);

832 833 834
    DO_TEST("pmu-feature", NONE);
    DO_TEST("pmu-feature-off", NONE);

835
    DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
836
    DO_TEST("hugepages-numa", QEMU_CAPS_RTC,
837
            QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
838
            QEMU_CAPS_VIRTIO_SCSI,
839 840
            QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC,
841
            QEMU_CAPS_DEVICE_QXL,
842
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
843
            QEMU_CAPS_DEVICE_PC_DIMM,
844
            QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE);
845 846 847
    DO_TEST_LINUX("hugepages-pages", QEMU_CAPS_MEM_PATH,
                  QEMU_CAPS_OBJECT_MEMORY_RAM,
                  QEMU_CAPS_OBJECT_MEMORY_FILE);
848 849 850 851
    DO_TEST("hugepages-pages2", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
    DO_TEST("hugepages-pages3", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
852 853 854
    DO_TEST_LINUX("hugepages-shared", QEMU_CAPS_MEM_PATH,
                  QEMU_CAPS_OBJECT_MEMORY_RAM,
                  QEMU_CAPS_OBJECT_MEMORY_FILE);
855
    DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
856 857
    DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_MEM_PATH,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
858
    DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
859
    DO_TEST("hugepages-pages6", NONE);
860 861
    DO_TEST("hugepages-pages7", QEMU_CAPS_MEM_PATH,
            QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE);
862 863 864
    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
865 866 867
    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
            QEMU_CAPS_NUMA);
868 869 870
    DO_TEST_FAILURE("hugepages-memaccess3", QEMU_CAPS_MEM_PATH,
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_VIRTIO_SCSI);
871
    DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
872
    DO_TEST("disk-cdrom", NONE);
873
    DO_TEST("disk-iscsi", NONE);
874 875 876 877 878
    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);
879
    DO_TEST("disk-cdrom-empty", NONE);
880
    DO_TEST("disk-cdrom-tray",
881
            QEMU_CAPS_VIRTIO_TX_ALG);
882 883
    DO_TEST("disk-cdrom-tray-no-device-cap", NONE);
    DO_TEST("disk-floppy", NONE);
884
    DO_TEST_FAILURE("disk-floppy-pseries", NONE);
885
    DO_TEST("disk-floppy-tray-no-device-cap", NONE);
886
    DO_TEST("disk-floppy-tray", NONE);
887
    DO_TEST("disk-virtio-s390",
888
            QEMU_CAPS_VIRTIO_S390);
889
    DO_TEST("disk-many", NONE);
890 891
    DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT);
    DO_TEST("disk-virtio-ccw",
892
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
893
    DO_TEST("disk-virtio-ccw-many",
894
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
895
    DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
896
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
897
    DO_TEST("disk-order",
898
            QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
L
Lin Ma 已提交
899 900
    DO_TEST("disk-virtio-drive-queues",
            QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
901
    DO_TEST("disk-drive-boot-disk",
902
            QEMU_CAPS_DRIVE_BOOT);
903
    DO_TEST("disk-drive-boot-cdrom",
904
            QEMU_CAPS_DRIVE_BOOT);
905
    DO_TEST("floppy-drive-fat",
906
            QEMU_CAPS_DRIVE_BOOT);
907
    DO_TEST("disk-drive-readonly-disk",
908
            QEMU_CAPS_NODEFCONFIG);
909
    DO_TEST("disk-drive-readonly-no-device",
J
Ján Tomko 已提交
910
            QEMU_CAPS_NODEFCONFIG);
911
    DO_TEST("disk-drive-fmt-qcow",
912
            QEMU_CAPS_DRIVE_BOOT);
913
    DO_TEST("disk-drive-shared",
914
            QEMU_CAPS_DRIVE_SERIAL);
915
    DO_TEST_PARSE_ERROR("disk-drive-shared-qcow", NONE);
916 917
    DO_TEST("disk-drive-shared-locking",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DISK_SHARE_RW);
918
    DO_TEST("disk-drive-error-policy-stop",
919
            QEMU_CAPS_MONITOR_JSON);
920
    DO_TEST("disk-drive-error-policy-enospace",
921
            QEMU_CAPS_MONITOR_JSON);
922
    DO_TEST("disk-drive-error-policy-wreport-rignore",
923 924 925 926
            QEMU_CAPS_MONITOR_JSON);
    DO_TEST("disk-drive-cache-v2-wt", NONE);
    DO_TEST("disk-drive-cache-v2-wb", NONE);
    DO_TEST("disk-drive-cache-v2-none", NONE);
927
    DO_TEST("disk-drive-cache-directsync",
928
            QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC);
929
    DO_TEST("disk-drive-cache-unsafe",
930
            QEMU_CAPS_DRIVE_CACHE_UNSAFE);
931
    DO_TEST("disk-drive-copy-on-read",
932 933 934 935 936 937 938 939
            QEMU_CAPS_DRIVE_COPY_ON_READ);
    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);
940 941
    DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-secrettype-invalid", NONE);
    DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-wrong-secrettype", NONE);
942
    DO_TEST_PARSE_ERROR("disk-drive-network-source-auth-both", NONE);
943 944
    DO_TEST("disk-drive-network-iscsi-lun",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
945
            QEMU_CAPS_SCSI_BLOCK);
946 947
    DO_TEST("disk-drive-network-gluster",
            QEMU_CAPS_GLUSTER_DEBUG_LEVEL);
948 949 950
    DO_TEST("disk-drive-network-rbd", NONE);
    DO_TEST("disk-drive-network-sheepdog", NONE);
    DO_TEST("disk-drive-network-rbd-auth", NONE);
951
    DO_TEST("disk-drive-network-source-auth", NONE);
952
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
953
    DO_TEST("disk-drive-network-rbd-auth-AES",
954
            QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_VIRTIO_SCSI);
955
# endif
956 957
    DO_TEST("disk-drive-network-rbd-ipv6", NONE);
    DO_TEST_FAILURE("disk-drive-network-rbd-no-colon", NONE);
958
    DO_TEST("disk-drive-network-vxhs", QEMU_CAPS_VXHS);
959 960 961 962 963
    driver.config->vxhsTLS = 1;
    DO_TEST("disk-drive-network-tlsx509-vxhs", QEMU_CAPS_VXHS,
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->vxhsTLS = 0;
    VIR_FREE(driver.config->vxhsTLSx509certdir);
964
    DO_TEST("disk-drive-no-boot",
965
            QEMU_CAPS_BOOTINDEX);
966
    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
967 968
                        QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST_FAILURE("disk-usb-nosupport", NONE);
969
    DO_TEST("disk-usb-device",
970
            QEMU_CAPS_DEVICE_USB_STORAGE,
971
            QEMU_CAPS_NODEFCONFIG);
972
    DO_TEST("disk-usb-device-removable",
973
            QEMU_CAPS_DEVICE_USB_STORAGE,
974
            QEMU_CAPS_USB_STORAGE_REMOVABLE, QEMU_CAPS_NODEFCONFIG);
975 976
    DO_TEST_FAILURE("disk-usb-pci",
                    QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
977
    DO_TEST("disk-scsi-device",
978
            QEMU_CAPS_NODEFCONFIG,
979
            QEMU_CAPS_SCSI_LSI);
980
    DO_TEST("disk-scsi-device-auto",
981
            QEMU_CAPS_NODEFCONFIG,
982
            QEMU_CAPS_SCSI_LSI);
983
    DO_TEST("disk-scsi-disk-split",
984
            QEMU_CAPS_NODEFCONFIG,
985
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
986
    DO_TEST("disk-scsi-disk-wwn",
987
            QEMU_CAPS_NODEFCONFIG,
988
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
989 990
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST("disk-scsi-disk-vpd",
991
            QEMU_CAPS_NODEFCONFIG,
992
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
993 994
            QEMU_CAPS_SCSI_DISK_WWN);
    DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
995
            QEMU_CAPS_NODEFCONFIG,
996
            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
997
            QEMU_CAPS_SCSI_DISK_WWN);
998
    DO_TEST("disk-scsi-vscsi",
999
            QEMU_CAPS_NODEFCONFIG);
1000
    DO_TEST("disk-scsi-virtio-scsi",
1001
            QEMU_CAPS_NODEFCONFIG,
1002
            QEMU_CAPS_VIRTIO_SCSI);
1003
    DO_TEST("disk-virtio-scsi-num_queues",
1004
            QEMU_CAPS_NODEFCONFIG,
1005
            QEMU_CAPS_VIRTIO_SCSI);
1006
    DO_TEST("disk-virtio-scsi-cmd_per_lun",
1007
            QEMU_CAPS_NODEFCONFIG,
1008 1009
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("disk-virtio-scsi-max_sectors",
1010
            QEMU_CAPS_NODEFCONFIG,
1011
            QEMU_CAPS_VIRTIO_SCSI);
1012
    DO_TEST("disk-virtio-scsi-ioeventfd",
1013
            QEMU_CAPS_NODEFCONFIG,
1014
            QEMU_CAPS_VIRTIO_IOEVENTFD, QEMU_CAPS_VIRTIO_SCSI);
1015
    DO_TEST("disk-scsi-megasas",
1016
            QEMU_CAPS_NODEFCONFIG,
1017
            QEMU_CAPS_SCSI_MEGASAS);
1018 1019 1020 1021
    DO_TEST("disk-scsi-mptsas1068",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SCSI_MPTSAS1068,
            QEMU_CAPS_SCSI_DISK_WWN);
1022
    DO_TEST("disk-sata-device",
J
Jim Fehlig 已提交
1023
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI);
1024
    DO_TEST("disk-aio",
1025
            QEMU_CAPS_DRIVE_AIO);
1026
    DO_TEST("disk-source-pool",
1027
            QEMU_CAPS_NODEFCONFIG);
1028
    DO_TEST("disk-source-pool-mode",
1029
            QEMU_CAPS_NODEFCONFIG);
1030
    DO_TEST("disk-ioeventfd",
1031
            QEMU_CAPS_VIRTIO_IOEVENTFD,
1032
            QEMU_CAPS_VIRTIO_TX_ALG,
1033
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1034
    DO_TEST("disk-copy_on_read",
1035
            QEMU_CAPS_DRIVE_COPY_ON_READ,
1036
            QEMU_CAPS_VIRTIO_TX_ALG,
1037
            QEMU_CAPS_VIRTIO_BLK_SCSI);
O
Osier Yang 已提交
1038
    DO_TEST("disk-drive-discard",
1039
            QEMU_CAPS_DRIVE_DISCARD);
1040 1041 1042
    DO_TEST("disk-drive-detect-zeroes",
            QEMU_CAPS_DRIVE_DISCARD,
            QEMU_CAPS_DRIVE_DETECT_ZEROES);
1043
    DO_TEST("disk-snapshot", NONE);
1044 1045 1046
    DO_TEST_PARSE_ERROR("disk-same-targets",
                        QEMU_CAPS_SCSI_LSI,
                        QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
1047 1048 1049 1050 1051 1052 1053 1054
    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);
1055
    DO_TEST("event_idx",
1056 1057
            QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
            QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
1058
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1059
    DO_TEST("virtio-lun",
1060
            QEMU_CAPS_VIRTIO_BLK_SCSI);
1061
    DO_TEST("disk-scsi-lun-passthrough",
1062
            QEMU_CAPS_SCSI_BLOCK,
1063
            QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
1064 1065 1066
    DO_TEST("disk-serial",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DRIVE_SERIAL);
1067 1068 1069 1070 1071 1072 1073 1074
    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);
1075

1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
    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);
    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY,
            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);
1086
    driver.config->vncAutoUnixSocket = true;
1087 1088
    DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1089
    driver.config->vncAutoUnixSocket = false;
1090 1091 1092 1093
    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);
1094 1095
    DO_TEST("graphics-vnc-socket-new-cmdline", QEMU_CAPS_VNC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_MULTI_SERVERS);
1096

1097 1098
    driver.config->vncSASL = 1;
    VIR_FREE(driver.config->vncSASLdir);
1099
    ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2"));
1100
    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1101 1102
    driver.config->vncTLS = 1;
    driver.config->vncTLSx509verify = 1;
1103
    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1104
    driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
1105 1106
    VIR_FREE(driver.config->vncSASLdir);
    VIR_FREE(driver.config->vncTLSx509certdir);
1107

1108 1109 1110
    DO_TEST("graphics-sdl", QEMU_CAPS_SDL, QEMU_CAPS_DEVICE_VGA);
    DO_TEST("graphics-sdl-fullscreen", QEMU_CAPS_SDL,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1111
    DO_TEST("nographics", NONE);
P
Paolo Bonzini 已提交
1112 1113
    DO_TEST("nographics-display",
            QEMU_CAPS_DISPLAY);
1114
    DO_TEST("nographics-vga",
1115
            QEMU_CAPS_VGA_NONE);
1116
    DO_TEST("graphics-spice",
1117
            QEMU_CAPS_SPICE,
1118 1119
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1120
    DO_TEST("graphics-spice-no-args",
1121
            QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA);
1122 1123 1124
    driver.config->spiceSASL = 1;
    ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
    DO_TEST("graphics-spice-sasl",
1125
            QEMU_CAPS_SPICE,
1126 1127 1128
            QEMU_CAPS_DEVICE_QXL);
    VIR_FREE(driver.config->spiceSASLdir);
    driver.config->spiceSASL = 0;
1129
    DO_TEST("graphics-spice-agentmouse",
1130
            QEMU_CAPS_DEVICE_QXL,
1131
            QEMU_CAPS_SPICE,
1132
            QEMU_CAPS_CHARDEV_SPICEVMC,
1133 1134
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1135
    DO_TEST("graphics-spice-compression",
1136
            QEMU_CAPS_SPICE,
1137
            QEMU_CAPS_DEVICE_QXL);
1138
    DO_TEST("graphics-spice-timeout",
1139
            QEMU_CAPS_KVM,
1140
            QEMU_CAPS_SPICE,
1141 1142
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VGA);
1143
    DO_TEST("graphics-spice-qxl-vga",
1144
            QEMU_CAPS_SPICE,
1145
            QEMU_CAPS_DEVICE_QXL);
1146
    DO_TEST("graphics-spice-usb-redir",
1147
            QEMU_CAPS_SPICE,
1148 1149 1150 1151 1152 1153 1154
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1155
    DO_TEST("graphics-spice-agent-file-xfer",
1156
            QEMU_CAPS_SPICE,
1157 1158
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
1159 1160
    DO_TEST("graphics-spice-socket",
            QEMU_CAPS_SPICE,
1161 1162
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1163 1164
    DO_TEST("graphics-spice-auto-socket",
            QEMU_CAPS_SPICE,
1165 1166
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1167 1168 1169
    driver.config->spiceAutoUnixSocket = true;
    DO_TEST("graphics-spice-auto-socket-cfg",
            QEMU_CAPS_SPICE,
1170 1171
            QEMU_CAPS_SPICE_UNIX,
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1172
    driver.config->spiceAutoUnixSocket = false;
1173

1174 1175 1176
    DO_TEST("input-usbmouse", NONE);
    DO_TEST("input-usbtablet", NONE);
    DO_TEST("misc-acpi", NONE);
1177 1178 1179
    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);
1180
    DO_TEST_FAILURE("misc-enable-s4", NONE);
1181
    DO_TEST("misc-no-reboot", NONE);
1182
    DO_TEST("misc-uuid", NONE);
1183
    DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
1184
    DO_TEST("net-vhostuser", QEMU_CAPS_NETDEV);
1185
    DO_TEST("net-vhostuser-multiq",
1186 1187
            QEMU_CAPS_NETDEV, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
    DO_TEST_FAILURE("net-vhostuser-multiq", QEMU_CAPS_NETDEV);
1188 1189 1190
    DO_TEST_FAILURE("net-vhostuser-fail",
                    QEMU_CAPS_NETDEV,
                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
1191
    DO_TEST("net-user", NONE);
1192
    DO_TEST("net-user-addr", QEMU_CAPS_NETDEV);
1193 1194
    DO_TEST("net-virtio", NONE);
    DO_TEST("net-virtio-device",
1195
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_TX_ALG);
1196
    DO_TEST("net-virtio-disable-offloads",
1197
            QEMU_CAPS_NODEFCONFIG);
1198
    DO_TEST("net-virtio-netdev",
1199
            QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
1200
    DO_TEST("net-virtio-s390",
1201
            QEMU_CAPS_VIRTIO_S390);
1202
    DO_TEST("net-virtio-ccw",
1203
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1204 1205 1206
    DO_TEST("net-virtio-rxtxqueuesize",
            QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE,
            QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE);
1207
    DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE);
1208 1209
    DO_TEST("net-eth", NONE);
    DO_TEST("net-eth-ifname", NONE);
1210
    DO_TEST("net-eth-names", NONE);
1211
    DO_TEST("net-eth-hostip", NONE);
1212 1213 1214
    DO_TEST("net-client", NONE);
    DO_TEST("net-server", NONE);
    DO_TEST("net-mcast", NONE);
1215
    DO_TEST("net-udp", NONE);
1216
    DO_TEST("net-hostdev",
J
Ján Tomko 已提交
1217
            QEMU_CAPS_NODEFCONFIG);
1218
    DO_TEST("net-hostdev-multidomain",
J
Ján Tomko 已提交
1219
            QEMU_CAPS_NODEFCONFIG,
1220 1221 1222
            QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
    DO_TEST_FAILURE("net-hostdev-multidomain",
                    QEMU_CAPS_NODEFCONFIG);
1223
    DO_TEST("net-hostdev-vfio",
J
Ján Tomko 已提交
1224
            QEMU_CAPS_NODEFCONFIG,
1225
            QEMU_CAPS_DEVICE_VFIO_PCI);
1226
    DO_TEST("net-hostdev-vfio-multidomain",
J
Ján Tomko 已提交
1227
            QEMU_CAPS_NODEFCONFIG,
1228 1229 1230
            QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
    DO_TEST_FAILURE("net-hostdev-vfio-multidomain",
                    QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
1231 1232 1233 1234
    DO_TEST_FAILURE("net-hostdev-fail",
                    QEMU_CAPS_NODEFCONFIG,
                    QEMU_CAPS_DEVICE_VFIO_PCI);

1235

1236 1237
    DO_TEST("serial-file-log",
            QEMU_CAPS_CHARDEV_FILE_APPEND,
1238
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1239
            QEMU_CAPS_CHARDEV_LOGFILE);
1240
    DO_TEST("serial-spiceport",
1241 1242
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1243
            QEMU_CAPS_DEVICE_QXL,
1244
            QEMU_CAPS_SPICE,
1245
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1246
            QEMU_CAPS_CHARDEV_SPICEPORT);
1247
    DO_TEST("serial-spiceport-nospice", NONE);
1248

1249 1250 1251 1252
    DO_TEST("console-compat",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
    DO_TEST("console-compat-auto",
            QEMU_CAPS_DEVICE_ISA_SERIAL);
1253 1254

    DO_TEST("serial-vc-chardev",
1255
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1256
            QEMU_CAPS_NODEFCONFIG);
1257
    DO_TEST("serial-pty-chardev",
1258
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1259
            QEMU_CAPS_NODEFCONFIG);
1260
    DO_TEST("serial-dev-chardev",
1261
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1262
            QEMU_CAPS_NODEFCONFIG);
1263
    DO_TEST("serial-dev-chardev-iobase",
1264
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1265
            QEMU_CAPS_NODEFCONFIG);
1266
    DO_TEST("serial-file-chardev",
1267
            QEMU_CAPS_NODEFCONFIG,
1268
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1269
            QEMU_CAPS_CHARDEV_FILE_APPEND);
1270
    DO_TEST("serial-unix-chardev",
1271
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1272
            QEMU_CAPS_NODEFCONFIG);
1273
    DO_TEST("serial-tcp-chardev",
1274
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1275
            QEMU_CAPS_NODEFCONFIG);
1276
    DO_TEST("serial-udp-chardev",
1277
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1278
            QEMU_CAPS_NODEFCONFIG);
1279
    DO_TEST("serial-tcp-telnet-chardev",
1280
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1281
            QEMU_CAPS_NODEFCONFIG);
1282 1283
    driver.config->chardevTLS = 1;
    DO_TEST("serial-tcp-tlsx509-chardev",
1284
            QEMU_CAPS_NODEFCONFIG,
1285
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1286
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1287 1288
    driver.config->chardevTLSx509verify = 1;
    DO_TEST("serial-tcp-tlsx509-chardev-verify",
1289
            QEMU_CAPS_NODEFCONFIG,
1290
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1291 1292
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
    driver.config->chardevTLSx509verify = 0;
1293
    DO_TEST("serial-tcp-tlsx509-chardev-notls",
1294
            QEMU_CAPS_NODEFCONFIG,
1295
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1296
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
1297 1298 1299 1300 1301 1302 1303 1304
    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;
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
    DO_TEST("serial-tcp-tlsx509-secret-chardev",
1305
            QEMU_CAPS_NODEFCONFIG,
1306
            QEMU_CAPS_OBJECT_SECRET,
1307
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1308 1309 1310
            QEMU_CAPS_OBJECT_TLS_CREDS_X509);
# else
    DO_TEST_FAILURE("serial-tcp-tlsx509-secret-chardev",
1311
                    QEMU_CAPS_NODEFCONFIG,
1312
                    QEMU_CAPS_OBJECT_SECRET,
1313
                    QEMU_CAPS_DEVICE_ISA_SERIAL,
1314 1315
                    QEMU_CAPS_OBJECT_TLS_CREDS_X509);
# endif
1316 1317
    driver.config->chardevTLS = 0;
    VIR_FREE(driver.config->chardevTLSx509certdir);
1318
    DO_TEST("serial-many-chardev",
1319
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1320
            QEMU_CAPS_NODEFCONFIG);
1321
    DO_TEST("parallel-tcp-chardev",
1322
            QEMU_CAPS_NODEFCONFIG);
1323
    DO_TEST("parallel-parport-chardev",
1324
            QEMU_CAPS_NODEFCONFIG);
1325
    DO_TEST("console-compat-chardev",
1326
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1327
            QEMU_CAPS_NODEFCONFIG);
M
Michal Privoznik 已提交
1328
    DO_TEST("pci-serial-dev-chardev",
1329
            QEMU_CAPS_NODEFCONFIG,
M
Michal Privoznik 已提交
1330
            QEMU_CAPS_DEVICE_PCI_SERIAL);
1331

1332
    DO_TEST("channel-guestfwd",
1333
            QEMU_CAPS_NODEFCONFIG);
1334
    DO_TEST("channel-virtio",
1335
            QEMU_CAPS_NODEFCONFIG);
1336
    DO_TEST("channel-virtio-state",
1337
            QEMU_CAPS_NODEFCONFIG);
1338
    DO_TEST("channel-virtio-auto",
1339
            QEMU_CAPS_NODEFCONFIG);
1340
    DO_TEST("channel-virtio-autoassign",
1341
            QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1342
    DO_TEST("channel-virtio-autoadd",
1343
            QEMU_CAPS_NODEFCONFIG);
1344
    DO_TEST("console-virtio",
1345
            QEMU_CAPS_NODEFCONFIG);
1346
    DO_TEST("console-virtio-many",
1347
            QEMU_CAPS_DEVICE_ISA_SERIAL,
1348
            QEMU_CAPS_NODEFCONFIG);
1349
    DO_TEST("console-virtio-s390",
1350 1351 1352
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390);
1353
    DO_TEST("console-virtio-ccw",
1354 1355 1356
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_CCW,
1357
            QEMU_CAPS_VIRTIO_S390);
1358
    DO_TEST("console-sclp",
1359 1360
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_S390,
1361
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
1362
    DO_TEST("channel-spicevmc",
1363
            QEMU_CAPS_NODEFCONFIG,
1364 1365
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC,
1366
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1367
    DO_TEST("channel-spicevmc-old",
1368
            QEMU_CAPS_NODEFCONFIG,
1369 1370
            QEMU_CAPS_SPICE,
            QEMU_CAPS_DEVICE_SPICEVMC,
1371
            QEMU_CAPS_DEVICE_CIRRUS_VGA);
1372
    DO_TEST("channel-virtio-default",
1373 1374 1375
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC);
1376
    DO_TEST("channel-virtio-unix",
1377
            QEMU_CAPS_NODEFCONFIG);
1378

1379
    DO_TEST("smartcard-host",
1380 1381
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_EMULATED);
1382
    DO_TEST("smartcard-host-certificates",
1383 1384
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_EMULATED);
1385
    DO_TEST("smartcard-passthrough-tcp",
1386 1387
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_PASSTHRU);
1388
    DO_TEST("smartcard-passthrough-spicevmc",
1389 1390 1391
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_PASSTHRU,
            QEMU_CAPS_CHARDEV_SPICEVMC);
1392
    DO_TEST("smartcard-controller",
1393 1394
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_CCID_EMULATED);
1395

1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
    DO_TEST("chardev-reconnect",
            QEMU_CAPS_NODEFCONFIG,
            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_NODEFCONFIG,
                        QEMU_CAPS_CHARDEV_RECONNECT);
1406 1407 1408
    DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path",
                        QEMU_CAPS_NODEFCONFIG,
                        QEMU_CAPS_CHARDEV_RECONNECT);
1409

1410
    DO_TEST("usb-controller",
1411
            QEMU_CAPS_NODEFCONFIG);
1412
    DO_TEST("usb-piix3-controller",
1413 1414 1415
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_NODEFCONFIG);
1416
    DO_TEST("usb-ich9-ehci-addr",
1417 1418 1419
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1);
1420
    DO_TEST("input-usbmouse-addr",
1421
            QEMU_CAPS_NODEFCONFIG);
1422
    DO_TEST("usb-ich9-companion",
1423 1424 1425
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1);
1426
    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
1427 1428 1429
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1);
1430
    DO_TEST("usb-ich9-autoassign",
1431 1432 1433
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1,
1434
            QEMU_CAPS_USB_HUB);
1435
    DO_TEST("usb-hub",
1436
            QEMU_CAPS_USB_HUB,
M
Marc-André Lureau 已提交
1437
            QEMU_CAPS_NODEFCONFIG);
1438
    DO_TEST("usb-hub-autoadd",
1439
            QEMU_CAPS_USB_HUB,
1440
            QEMU_CAPS_NODEFCONFIG);
1441
    DO_TEST("usb-hub-autoadd-deluxe",
1442
            QEMU_CAPS_USB_HUB,
1443
            QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1444
    DO_TEST_PARSE_ERROR("usb-hub-conflict",
1445
            QEMU_CAPS_USB_HUB,
J
Ján Tomko 已提交
1446
            QEMU_CAPS_NODEFCONFIG);
1447
    DO_TEST_PARSE_ERROR("usb-hub-nonexistent",
1448
            QEMU_CAPS_USB_HUB,
1449
            QEMU_CAPS_NODEFCONFIG);
J
Ján Tomko 已提交
1450
    DO_TEST("usb-port-missing",
1451
            QEMU_CAPS_USB_HUB,
J
Ján Tomko 已提交
1452
            QEMU_CAPS_NODEFCONFIG);
1453 1454 1455
    DO_TEST_FAILURE("usb-bus-missing",
                    QEMU_CAPS_USB_HUB,
                    QEMU_CAPS_NODEFCONFIG);
1456
    DO_TEST("usb-ports",
1457
            QEMU_CAPS_USB_HUB,
1458
            QEMU_CAPS_NODEFCONFIG);
1459
    DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
1460
            QEMU_CAPS_USB_HUB,
1461
            QEMU_CAPS_NODEFCONFIG);
1462
    DO_TEST("usb-port-autoassign",
1463
            QEMU_CAPS_USB_HUB,
1464
            QEMU_CAPS_NODEFCONFIG);
1465
    DO_TEST("usb-redir",
1466 1467 1468 1469 1470 1471 1472
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC);
1473
    DO_TEST("usb-redir-boot",
1474 1475 1476 1477 1478 1479 1480 1481
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC,
            QEMU_CAPS_BOOTINDEX,
1482
            QEMU_CAPS_USB_REDIR_BOOTINDEX);
1483
    DO_TEST("usb-redir-filter",
1484 1485 1486 1487 1488 1489 1490
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_USB_REDIR,
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC,
1491
            QEMU_CAPS_USB_REDIR_FILTER);
1492
    DO_TEST("usb-redir-filter-version",
1493
            QEMU_CAPS_NODEFCONFIG,
1494
            QEMU_CAPS_USB_REDIR,
1495 1496
            QEMU_CAPS_SPICE,
            QEMU_CAPS_CHARDEV_SPICEVMC,
1497
            QEMU_CAPS_USB_REDIR_FILTER);
1498
    DO_TEST("usb1-usb2",
1499 1500 1501 1502 1503
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_USB_HUB,
            QEMU_CAPS_ICH9_USB_EHCI1);
1504
    DO_TEST("usb-none",
1505
            QEMU_CAPS_NODEFCONFIG);
1506
    DO_TEST_PARSE_ERROR("usb-none-other",
1507
            QEMU_CAPS_NODEFCONFIG);
1508
    DO_TEST_PARSE_ERROR("usb-none-hub",
1509
            QEMU_CAPS_NODEFCONFIG,
1510 1511
            QEMU_CAPS_USB_HUB);
    DO_TEST_PARSE_ERROR("usb-none-usbtablet",
1512
            QEMU_CAPS_NODEFCONFIG);
1513
    DO_TEST("usb-controller-default-q35",
1514
            QEMU_CAPS_DEVICE_IOH3420,
1515 1516 1517
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1518
    DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
1519
                    QEMU_CAPS_DEVICE_IOH3420,
1520
                    QEMU_CAPS_PCI_OHCI,
1521 1522
                    QEMU_CAPS_NEC_USB_XHCI);
    DO_TEST("usb-controller-explicit-q35",
1523
            QEMU_CAPS_DEVICE_IOH3420,
1524 1525 1526
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI);
1527
    DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
1528
                    QEMU_CAPS_DEVICE_IOH3420,
1529
                    QEMU_CAPS_PCI_OHCI,
1530
                    QEMU_CAPS_PIIX3_USB_UHCI);
1531
    DO_TEST("usb-controller-xhci",
1532 1533 1534 1535
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1536
    DO_TEST("usb-xhci-autoassign",
1537 1538 1539 1540
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS,
1541
            QEMU_CAPS_USB_HUB);
1542
    DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
1543 1544 1545 1546
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_NEC_USB_XHCI,
            QEMU_CAPS_NEC_USB_XHCI_PORTS);
1547 1548 1549 1550
    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);
1551

1552
    DO_TEST("smbios", QEMU_CAPS_SMBIOS_TYPE);
1553
    DO_TEST_PARSE_ERROR("smbios-date", QEMU_CAPS_SMBIOS_TYPE);
1554
    DO_TEST_PARSE_ERROR("smbios-uuid-match", QEMU_CAPS_SMBIOS_TYPE);
1555

1556
    DO_TEST("watchdog", NONE);
1557
    DO_TEST("watchdog-device", QEMU_CAPS_NODEFCONFIG);
1558
    DO_TEST("watchdog-dump", NONE);
1559
    DO_TEST("watchdog-injectnmi", NONE);
1560
    DO_TEST("watchdog-diag288",
1561
            QEMU_CAPS_NODEFCONFIG,
1562
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390);
1563 1564
    DO_TEST("balloon-device", QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-deflate", QEMU_CAPS_NODEFCONFIG,
1565
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1566
    DO_TEST("balloon-ccw-deflate", QEMU_CAPS_NODEFCONFIG,
1567
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1568
    DO_TEST("balloon-mmio-deflate", QEMU_CAPS_NODEFCONFIG,
1569 1570
            QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1571
    DO_TEST("balloon-device-deflate-off", QEMU_CAPS_NODEFCONFIG,
1572
            QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
1573
    DO_TEST("balloon-device-auto",
1574 1575
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("balloon-device-period", QEMU_CAPS_NODEFCONFIG);
1576 1577
    DO_TEST("sound", NONE);
    DO_TEST("sound-device",
1578
            QEMU_CAPS_NODEFCONFIG,
1579
            QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
1580 1581
            QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
            QEMU_CAPS_OBJECT_USB_AUDIO);
1582
    DO_TEST("fs9p",
1583
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
1584
            QEMU_CAPS_FSDEV_WRITEOUT);
1585
    DO_TEST("fs9p-ccw",
1586
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
1587
            QEMU_CAPS_FSDEV_WRITEOUT,
1588
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1589

1590 1591
    DO_TEST("hostdev-usb-address", NONE);
    DO_TEST("hostdev-usb-address-device",
1592 1593
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("hostdev-usb-address-device-boot",
1594 1595
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_USB_HOST_BOOTINDEX);
J
Ján Tomko 已提交
1596
    DO_TEST("hostdev-pci-address", NONE);
1597
    DO_TEST("hostdev-pci-address-device",
J
Ján Tomko 已提交
1598
            QEMU_CAPS_NODEFCONFIG);
1599
    DO_TEST("hostdev-vfio",
J
Ján Tomko 已提交
1600
            QEMU_CAPS_NODEFCONFIG,
1601
            QEMU_CAPS_DEVICE_VFIO_PCI);
1602
    DO_TEST("hostdev-vfio-multidomain",
J
Ján Tomko 已提交
1603
            QEMU_CAPS_NODEFCONFIG,
1604
            QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
1605 1606 1607 1608 1609 1610 1611 1612 1613
    DO_TEST("hostdev-mdev-precreated",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST_PARSE_ERROR("hostdev-mdev-src-address-invalid",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_VFIO_PCI);
1614 1615
    DO_TEST_FAILURE("hostdev-vfio-multidomain",
                    QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
1616
    DO_TEST("pci-rom",
J
Ján Tomko 已提交
1617
            QEMU_CAPS_NODEFCONFIG);
1618

1619 1620 1621 1622
    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);
1623

1624
    DO_TEST_LINUX_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE,
1625
                       QEMU_CAPS_NUMA,
1626 1627
                       QEMU_CAPS_OBJECT_MEMORY_RAM);

1628
    DO_TEST("qemu-ns", NONE);
1629
    DO_TEST("qemu-ns-no-env", NONE);
1630
    DO_TEST("qemu-ns-alt", NONE);
1631

1632
    DO_TEST("smp", NONE);
1633

J
John Ferlan 已提交
1634
    DO_TEST("iothreads", QEMU_CAPS_OBJECT_IOTHREAD);
1635 1636
    DO_TEST("iothreads-ids", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-ids-partial", QEMU_CAPS_OBJECT_IOTHREAD);
1637
    DO_TEST_FAILURE("iothreads-nocap", NONE);
1638 1639
    DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD);
    DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD,
1640
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1641 1642 1643 1644 1645 1646
    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,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
J
John Ferlan 已提交
1647

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

1678 1679
    qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
    DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
1680 1681
    DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
    DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
1682 1683
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1684
    qemuTestSetHostCPU(driver.caps, cpuHaswell);
1685 1686 1687 1688
    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);
1689
    DO_TEST("cpu-host-model-cmt", NONE);
1690
    DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
1691
    qemuTestSetHostCPU(driver.caps, NULL);
1692

1693
    DO_TEST("encrypted-disk", NONE);
J
John Ferlan 已提交
1694
    DO_TEST("encrypted-disk-usage", NONE);
1695
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
1696
    DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
1697
    DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
1698 1699 1700
# else
    DO_TEST_FAILURE("luks-disks", QEMU_CAPS_OBJECT_SECRET);
# endif
1701
    DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE);
1702
    DO_TEST_PARSE_ERROR("luks-disks-source-both", QEMU_CAPS_OBJECT_SECRET);
1703

1704 1705 1706 1707 1708 1709 1710 1711
    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);
1712
    DO_TEST("cputune-numatune",
1713
            QEMU_CAPS_KVM,
1714
            QEMU_CAPS_OBJECT_IOTHREAD,
1715 1716
            QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1717 1718 1719
    DO_TEST("vcpu-placement-static",
            QEMU_CAPS_KVM,
            QEMU_CAPS_OBJECT_IOTHREAD);
1720

1721
    DO_TEST("numatune-memory", NONE);
1722
    DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE);
1723 1724
    DO_TEST_LINUX("numatune-memnode", QEMU_CAPS_NUMA,
                  QEMU_CAPS_OBJECT_MEMORY_RAM);
1725 1726
    DO_TEST_FAILURE("numatune-memnode", NONE);

1727 1728
    DO_TEST_LINUX("numatune-memnode-no-memory", QEMU_CAPS_NUMA,
                  QEMU_CAPS_OBJECT_MEMORY_RAM);
1729 1730
    DO_TEST_FAILURE("numatune-memnode-no-memory", NONE);

1731 1732
    DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST);

1733
    DO_TEST("numatune-auto-nodeset-invalid", NONE);
1734 1735
    DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM,
            QEMU_CAPS_OBJECT_MEMORY_FILE);
1736 1737
    DO_TEST_FAILURE("numatune-static-nodeset-exceed-hostnode",
                    QEMU_CAPS_OBJECT_MEMORY_RAM);
1738 1739
    DO_TEST_PARSE_ERROR("numatune-memnode-nocpu", NONE);
    DO_TEST_PARSE_ERROR("numatune-memnodes-problematic", NONE);
1740 1741
    DO_TEST("numad", NONE);
    DO_TEST("numad-auto-vcpu-static-numatune", NONE);
1742
    DO_TEST_PARSE_ERROR("numad-auto-vcpu-static-numatune-no-nodeset", NONE);
1743 1744 1745
    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);
1746
    DO_TEST("blkdeviotune",
1747
            QEMU_CAPS_DRIVE_IOTUNE);
1748
    DO_TEST("blkdeviotune-max",
1749
            QEMU_CAPS_DRIVE_IOTUNE,
1750
            QEMU_CAPS_DRIVE_IOTUNE_MAX);
1751 1752 1753 1754
    DO_TEST("blkdeviotune-group-num",
            QEMU_CAPS_DRIVE_IOTUNE,
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_GROUP);
1755 1756 1757 1758
    DO_TEST("blkdeviotune-max-length",
            QEMU_CAPS_DRIVE_IOTUNE,
            QEMU_CAPS_DRIVE_IOTUNE_MAX,
            QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH);
1759

1760
    DO_TEST("multifunction-pci-device",
1761
            QEMU_CAPS_NODEFCONFIG,
1762
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_SCSI_LSI);
1763

1764
    DO_TEST("monitor-json",
1765 1766
            QEMU_CAPS_MONITOR_JSON,
            QEMU_CAPS_NODEFCONFIG);
1767
    DO_TEST("no-shutdown",
1768 1769
            QEMU_CAPS_MONITOR_JSON,
            QEMU_CAPS_NODEFCONFIG,
1770
            QEMU_CAPS_NO_SHUTDOWN);
1771

1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
    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);
1784

1785
    DO_TEST("pseries-basic",
1786
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1787
            QEMU_CAPS_NODEFCONFIG);
1788
    DO_TEST("pseries-vio",
1789
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1790
            QEMU_CAPS_NODEFCONFIG);
1791
    DO_TEST("pseries-usb-default",
1792
            QEMU_CAPS_NODEFCONFIG,
1793
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1794 1795 1796
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION);
1797
    DO_TEST("pseries-usb-multi",
1798
            QEMU_CAPS_NODEFCONFIG,
1799
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1800 1801 1802
            QEMU_CAPS_PIIX3_USB_UHCI,
            QEMU_CAPS_PCI_OHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION);
1803
    DO_TEST("pseries-vio-user-assigned",
1804
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1805
            QEMU_CAPS_NODEFCONFIG);
1806
    DO_TEST_PARSE_ERROR("pseries-vio-address-clash",
1807
            QEMU_CAPS_NODEFCONFIG);
1808
    DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
1809
    DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
1810
            QEMU_CAPS_DEVICE_USB_KBD,
1811
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1812
            QEMU_CAPS_NODEFCONFIG);
1813
    DO_TEST("pseries-cpu-exact",
1814
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1815
            QEMU_CAPS_NODEFCONFIG);
1816 1817
    DO_TEST_PARSE_ERROR("pseries-no-parallel",
            QEMU_CAPS_NODEFCONFIG);
1818 1819

    qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
A
Andrea Bolognani 已提交
1820
    DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
1821
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1822
            QEMU_CAPS_NODEFCONFIG);
1823 1824 1825 1826 1827
    DO_TEST("pseries-machine-max-cpu-compat",
            QEMU_CAPS_KVM,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
            QEMU_CAPS_NODEFCONFIG);
A
Andrea Bolognani 已提交
1828
    DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
1829
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1830
            QEMU_CAPS_NODEFCONFIG);
1831 1832 1833 1834
    DO_TEST_FAILURE("pseries-cpu-compat-power9", QEMU_CAPS_KVM);

    qemuTestSetHostCPU(driver.caps, cpuPower9);
    DO_TEST("pseries-cpu-compat-power9",
1835
            QEMU_CAPS_KVM,
1836
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1837
            QEMU_CAPS_NODEFCONFIG);
1838 1839
    qemuTestSetHostCPU(driver.caps, NULL);

1840 1841
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);

1842
    DO_TEST("pseries-panic-missing",
1843
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1844
            QEMU_CAPS_NODEFCONFIG);
1845
    DO_TEST("pseries-panic-no-address",
1846
            QEMU_CAPS_DEVICE_SPAPR_VTY,
1847
            QEMU_CAPS_NODEFCONFIG);
1848
    DO_TEST_FAILURE("pseries-panic-address",
1849
                    QEMU_CAPS_NODEFCONFIG);
1850 1851 1852 1853 1854 1855 1856

    DO_TEST("pseries-phb-simple",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
    DO_TEST("pseries-phb-default-missing",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
1857 1858 1859 1860 1861 1862
    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);
1863 1864 1865
    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);
1866

1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897
    DO_TEST("pseries-many-devices",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-many-buses-1",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-many-buses-2",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_VIRTIO_SCSI);
    DO_TEST("pseries-hostdevs-1",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("pseries-hostdevs-2",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);
    DO_TEST("pseries-hostdevs-3",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
            QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
            QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_VFIO_PCI);

1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
    DO_TEST("pseries-hpt-resizing",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
    DO_TEST_FAILURE("pseries-hpt-resizing",
                    QEMU_CAPS_NODEFCONFIG,
                    QEMU_CAPS_MACHINE_OPT);
    DO_TEST_PARSE_ERROR("pseries-hpt-resizing-invalid-machine",
                        QEMU_CAPS_NODEFCONFIG,
                        QEMU_CAPS_MACHINE_OPT,
                        QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);

1910 1911 1912 1913 1914 1915 1916 1917 1918
    DO_TEST("pseries-serial-native",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial+console-native",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-serial-compat",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_VTY);
1919 1920 1921 1922 1923 1924 1925
    DO_TEST("pseries-serial-pci",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_PCI_SERIAL);
    DO_TEST("pseries-serial-usb",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
1926 1927 1928 1929 1930 1931 1932
    DO_TEST("pseries-console-native",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_DEVICE_SPAPR_VTY);
    DO_TEST("pseries-console-virtio",
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);

1933
    DO_TEST("mach-virt-serial-native",
1934
            QEMU_CAPS_DEVICE_PL011,
1935 1936
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("mach-virt-serial+console-native",
1937
            QEMU_CAPS_DEVICE_PL011,
1938 1939
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("mach-virt-serial-compat",
1940
            QEMU_CAPS_DEVICE_PL011,
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("mach-virt-serial-pci",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            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_NODEFCONFIG,
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_DEVICE_QEMU_XHCI,
            QEMU_CAPS_DEVICE_USB_SERIAL);
    DO_TEST("mach-virt-console-native",
1958
            QEMU_CAPS_DEVICE_PL011,
1959 1960 1961 1962 1963
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST("mach-virt-console-virtio",
            QEMU_CAPS_NODEFCONFIG);
    DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE);

1964
    DO_TEST("disk-ide-drive-split",
1965
            QEMU_CAPS_NODEFCONFIG,
1966
            QEMU_CAPS_IDE_CD);
1967
    DO_TEST("disk-ide-wwn",
1968
            QEMU_CAPS_IDE_CD,
1969
            QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_IDE_DRIVE_WWN);
1970

1971
    DO_TEST("disk-geometry", NONE);
V
Viktor Mihajlovski 已提交
1972
    DO_TEST("disk-blockio",
1973
            QEMU_CAPS_NODEFCONFIG,
V
Viktor Mihajlovski 已提交
1974
            QEMU_CAPS_IDE_CD, QEMU_CAPS_BLOCKIO);
1975

1976
    DO_TEST("video-device-pciaddr-default",
1977 1978
            QEMU_CAPS_KVM,
            QEMU_CAPS_VNC,
1979
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1980
            QEMU_CAPS_DEVICE_QXL);
1981
    DO_TEST("video-vga-nodevice", QEMU_CAPS_DEVICE_VGA);
1982
    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE_VGA,
1983
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1984
    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE_VGA,
1985
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
1986
    DO_TEST("video-qxl-nodevice", QEMU_CAPS_DEVICE_QXL);
1987
    DO_TEST("video-qxl-device",
1988
            QEMU_CAPS_DEVICE_QXL,
1989
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1990
    DO_TEST("video-qxl-device-vgamem",
1991
            QEMU_CAPS_DEVICE_QXL,
1992
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1993 1994
            QEMU_CAPS_QXL_VGAMEM);
    DO_TEST("video-qxl-sec-device",
1995
            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
1996
    DO_TEST("video-qxl-sec-device-vgamem",
1997 1998
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
1999
            QEMU_CAPS_QXL_VGAMEM);
2000 2001 2002
    DO_TEST("video-qxl-heads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2003
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2004 2005 2006
    DO_TEST("video-vga-qxl-heads",
            QEMU_CAPS_DEVICE_QXL,
            QEMU_CAPS_QXL_MAX_OUTPUTS);
2007 2008 2009
    DO_TEST("video-qxl-noheads",
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_QXL,
2010
            QEMU_CAPS_QXL_MAX_OUTPUTS);
M
Marc-André Lureau 已提交
2011
    DO_TEST("video-virtio-gpu-device",
2012
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
M
Marc-André Lureau 已提交
2013
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2014
    DO_TEST("video-virtio-gpu-virgl",
2015
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2016
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2017
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2018 2019
    DO_TEST("video-virtio-gpu-spice-gl",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
2020
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
2021 2022
            QEMU_CAPS_SPICE,
            QEMU_CAPS_SPICE_GL,
2023
            QEMU_CAPS_SPICE_RENDERNODE,
2024
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2025 2026 2027
    DO_TEST("video-virtio-gpu-secondary",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
2028 2029 2030
    DO_TEST("video-virtio-vga",
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_DEVICE_VIRTIO_VGA,
2031 2032
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
2033
    DO_TEST_PARSE_ERROR("video-invalid", NONE);
2034

2035 2036
    DO_TEST("virtio-rng-default",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2037
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2038 2039
    DO_TEST("virtio-rng-random",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2040
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2041 2042
    DO_TEST("virtio-rng-egd",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2043
            QEMU_CAPS_OBJECT_RNG_EGD);
2044 2045 2046 2047
    DO_TEST("virtio-rng-multiple",
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2048
    DO_TEST_PARSE_ERROR("virtio-rng-egd-crash",
2049 2050
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_EGD);
2051
    DO_TEST("virtio-rng-ccw",
2052 2053 2054 2055 2056
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
2057
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2058

2059
    DO_TEST("s390-allow-bogus-usb-none",
2060 2061 2062 2063 2064
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2065
    DO_TEST("s390-allow-bogus-usb-controller",
2066 2067 2068 2069 2070
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM);
2071

2072
    DO_TEST("s390-panic-no-address",
2073 2074 2075
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390);
2076
    DO_TEST_FAILURE("s390-panic-address",
2077 2078 2079
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390);
2080
    DO_TEST("s390-panic-missing",
2081 2082 2083
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390);
2084 2085 2086 2087
    DO_TEST_PARSE_ERROR("s390-no-parallel",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390);
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103
    DO_TEST("s390-serial",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
    DO_TEST("s390-serial-2",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE,
            QEMU_CAPS_DEVICE_SCLPLMCONSOLE);
    DO_TEST("s390-serial-console",
            QEMU_CAPS_NODEFCONFIG,
            QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_DEVICE_SCLPCONSOLE);
2104

2105 2106 2107 2108 2109
    DO_TEST("ppc-dtb",
            QEMU_CAPS_KVM,
            QEMU_CAPS_DTB);
    DO_TEST("ppce500-serial",
            QEMU_CAPS_KVM);
O
Olivia Yin 已提交
2110

2111
    DO_TEST("tpm-passthrough",
2112
            QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2113
    DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
2114
                        QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
2115

2116

2117 2118 2119 2120
    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);
2121

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

    /* Test automatic and manual setting of pcie-root-port attributes */
2353 2354
    DO_TEST("pcie-root-port",
            QEMU_CAPS_DEVICE_IOH3420,
2355
            QEMU_CAPS_ICH9_AHCI,
2356
            QEMU_CAPS_PCI_MULTIFUNCTION,
2357
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2358
            QEMU_CAPS_DEVICE_QXL);
2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370

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

2371 2372 2373 2374 2375 2376 2377
    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,
2378 2379
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1,
2380
            QEMU_CAPS_NEC_USB_XHCI);
2381 2382 2383 2384 2385 2386 2387
    /* 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);
2388

2389
    DO_TEST_PARSE_ERROR("q35-wrong-root",
2390
            QEMU_CAPS_DEVICE_IOH3420,
2391 2392 2393
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2394
            QEMU_CAPS_DEVICE_QXL);
2395
    DO_TEST_PARSE_ERROR("440fx-wrong-root", NONE);
2396
    DO_TEST_PARSE_ERROR("440fx-ide-address-conflict", NONE);
2397

2398
    DO_TEST_PARSE_ERROR("pcie-root-port-too-many",
2399
            QEMU_CAPS_DEVICE_IOH3420,
2400
            QEMU_CAPS_ICH9_AHCI,
2401
            QEMU_CAPS_PCI_MULTIFUNCTION,
2402
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2403
            QEMU_CAPS_DEVICE_QXL);
2404

2405 2406 2407
    DO_TEST("pcie-switch-upstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
2408
            QEMU_CAPS_ICH9_AHCI,
2409
            QEMU_CAPS_PCI_MULTIFUNCTION,
2410
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2411
            QEMU_CAPS_DEVICE_QXL);
2412 2413 2414 2415
    DO_TEST("pcie-switch-downstream-port",
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
            QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
2416
            QEMU_CAPS_ICH9_AHCI,
2417
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2418
            QEMU_CAPS_DEVICE_QXL);
2419

2420 2421 2422 2423 2424 2425
    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);
2426 2427
    DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_PXB);
2428

2429 2430 2431 2432 2433 2434 2435 2436 2437 2438
    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);
2439 2440 2441
    DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
                        QEMU_CAPS_DEVICE_IOH3420,
                        QEMU_CAPS_DEVICE_PXB_PCIE);
2442

2443
    DO_TEST("hostdev-scsi-lsi",
2444 2445
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2446
    DO_TEST("hostdev-scsi-virtio-scsi",
2447 2448
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2449
    DO_TEST("hostdev-scsi-readonly",
J
Ján Tomko 已提交
2450
            QEMU_CAPS_VIRTIO_SCSI,
O
Osier Yang 已提交
2451
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
2452
    DO_TEST("hostdev-scsi-virtio-scsi",
2453 2454 2455
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC,
            QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
2456
    DO_TEST("hostdev-scsi-lsi-iscsi",
J
John Ferlan 已提交
2457 2458
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2459
    DO_TEST("hostdev-scsi-lsi-iscsi-auth",
J
John Ferlan 已提交
2460 2461
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2462
    DO_TEST("hostdev-scsi-virtio-iscsi",
J
John Ferlan 已提交
2463 2464
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2465
    DO_TEST("hostdev-scsi-virtio-iscsi-auth",
J
John Ferlan 已提交
2466 2467
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2468 2469 2470 2471 2472 2473
# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
    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);
# endif
2474 2475 2476 2477 2478 2479
    DO_TEST("hostdev-scsi-vhost-scsi-ccw",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_VIRTIO_CCW);
    DO_TEST("hostdev-scsi-vhost-scsi-pci",
            QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
            QEMU_CAPS_DEVICE_SCSI_GENERIC);
2480 2481 2482 2483 2484 2485 2486
    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_PCI_MULTIFUNCTION,
            QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
2487

2488
    DO_TEST("mlock-on", QEMU_CAPS_REALTIME_MLOCK);
2489
    DO_TEST_FAILURE("mlock-on", NONE);
2490
    DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK);
2491 2492
    DO_TEST("mlock-unsupported", NONE);

2493 2494 2495 2496
    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);
2497

2498
    DO_TEST("hotplug-base",
2499
            QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
2500

2501 2502
    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
    DO_TEST_FAILURE("pcihole64-none", NONE);
2503
    DO_TEST("pcihole64-q35",
2504
            QEMU_CAPS_DEVICE_IOH3420,
2505
            QEMU_CAPS_ICH9_AHCI,
2506
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
2507
            QEMU_CAPS_DEVICE_QXL,
2508 2509
            QEMU_CAPS_Q35_PCI_HOLE64_SIZE);

2510
    DO_TEST("arm-vexpressa9-nodevs",
2511
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB);
2512
    DO_TEST("arm-vexpressa9-basic",
2513
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB);
2514
    DO_TEST("arm-vexpressa9-virtio",
2515
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2516
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2517
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2518
    DO_TEST("arm-virt-virtio",
2519
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2520
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2521
            QEMU_CAPS_DEVICE_PL011,
2522
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2523

2524
    DO_TEST("aarch64-virt-virtio",
2525
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2526
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2527
            QEMU_CAPS_DEVICE_PL011,
2528
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2529 2530 2531 2532 2533 2534

    /* 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",
2535
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2536
            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
2537 2538 2539
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2540
            QEMU_CAPS_PCI_MULTIFUNCTION,
2541
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2542
            QEMU_CAPS_DEVICE_IOH3420,
2543
            QEMU_CAPS_DEVICE_PL011,
2544
            QEMU_CAPS_VIRTIO_SCSI);
2545 2546
    DO_TEST("aarch64-virt-2.6-virtio-pci-default",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2547
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2548 2549
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2550
            QEMU_CAPS_PCI_MULTIFUNCTION,
2551
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
2552
            QEMU_CAPS_DEVICE_PL011,
2553
            QEMU_CAPS_DEVICE_IOH3420);
2554 2555 2556
    /* Example of using virtio-pci with no explicit PCI controller
       but with manual PCI addresses */
    DO_TEST("aarch64-virtio-pci-manual-addresses",
2557
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2558
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2559 2560
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
            QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
2561
            QEMU_CAPS_PCI_MULTIFUNCTION,
2562 2563 2564
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_VIRTIO_SCSI);
2565 2566 2567 2568 2569
    DO_TEST("aarch64-video-virtio-gpu-pci",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_BOOTINDEX);
2570 2571 2572 2573 2574 2575
    DO_TEST("aarch64-video-default",
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_VNC);
2576
    DO_TEST("aarch64-aavmf-virtio-mmio",
2577
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
2578
            QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2579
            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
2580
    DO_TEST("aarch64-virt-default-nic",
2581
            QEMU_CAPS_NODEFCONFIG,
2582
            QEMU_CAPS_DEVICE_VIRTIO_MMIO);
2583
    qemuTestSetHostArch(driver.caps, VIR_ARCH_AARCH64);
2584
    DO_TEST("aarch64-cpu-passthrough",
2585
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2586
            QEMU_CAPS_KVM);
2587 2588 2589
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
    DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
A
Andrea Bolognani 已提交
2590
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2591
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2592 2593 2594 2595
    DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3,
A
Andrea Bolognani 已提交
2596
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2597
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2598 2599 2600
    DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2601 2602 2603
    DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2604
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
A
Andrea Bolognani 已提交
2605
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
2606 2607 2608
    DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2609
    DO_TEST_GIC("aarch64-gic-default-v2", GIC_V2,
A
Andrea Bolognani 已提交
2610
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2611
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2612
    DO_TEST_GIC("aarch64-gic-default-v3", GIC_V3,
2613 2614
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
A
Andrea Bolognani 已提交
2615
    DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
2616 2617 2618
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
A
Andrea Bolognani 已提交
2619
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
2620 2621 2622 2623 2624 2625 2626
    DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v2", GIC_V3,
A
Andrea Bolognani 已提交
2627
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2628
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2629 2630 2631
    DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2632
    DO_TEST_FAILURE("aarch64-gic-v3",
A
Andrea Bolognani 已提交
2633
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
2634 2635 2636 2637 2638 2639 2640 2641 2642 2643
    DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_V3,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
A
Andrea Bolognani 已提交
2644
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2645
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2646
    DO_TEST_FAILURE("aarch64-gic-host",
A
Andrea Bolognani 已提交
2647
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659
    DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V2,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_V3,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2660
    DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
A
Andrea Bolognani 已提交
2661
            QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
2662
            QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2663 2664 2665 2666 2667 2668
    DO_TEST_PARSE_ERROR("aarch64-gic-not-virt",
                        QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
    DO_TEST_PARSE_ERROR("aarch64-gic-not-arm",
                        QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
                        QEMU_CAPS_MACH_VIRT_GIC_VERSION);
2669
    DO_TEST("aarch64-kvm-32-on-64",
2670
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
2671
            QEMU_CAPS_DEVICE_PL011,
A
Andrea Bolognani 已提交
2672
            QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
2673
    DO_TEST_FAILURE("aarch64-kvm-32-on-64",
2674
            QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
A
Andrea Bolognani 已提交
2675
            QEMU_CAPS_KVM);
2676 2677 2678 2679 2680 2681 2682 2683
    DO_TEST("aarch64-pci-serial",
            QEMU_CAPS_NODEFCONFIG,
            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);
2684 2685 2686 2687 2688 2689 2690

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

2691
    qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
2692

2693
    DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2694
    DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY);
2695
    DO_TEST("no-kvm-pit-device", NONE);
2696

H
Hu Tao 已提交
2697
    DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
2698
            QEMU_CAPS_NODEFCONFIG);
D
Dmitry Andreev 已提交
2699
    DO_TEST("panic-double", QEMU_CAPS_DEVICE_PANIC,
2700
            QEMU_CAPS_NODEFCONFIG);
H
Hu Tao 已提交
2701

2702
    DO_TEST("panic-no-address", QEMU_CAPS_DEVICE_PANIC,
2703
            QEMU_CAPS_NODEFCONFIG);
2704

2705 2706
    DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS);

J
Ján Tomko 已提交
2707
    DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM);
2708 2709 2710
    DO_TEST("shmem-plain-doorbell", QEMU_CAPS_DEVICE_IVSHMEM,
            QEMU_CAPS_DEVICE_IVSHMEM_PLAIN,
            QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
2711
    DO_TEST_FAILURE("shmem", NONE);
J
Ján Tomko 已提交
2712
    DO_TEST_FAILURE("shmem-invalid-size",
2713
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2714
    DO_TEST_FAILURE("shmem-invalid-address",
2715
                    QEMU_CAPS_DEVICE_IVSHMEM);
J
Ján Tomko 已提交
2716
    DO_TEST_FAILURE("shmem-small-size",
2717
                    QEMU_CAPS_DEVICE_IVSHMEM);
2718
    DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
A
Andrea Bolognani 已提交
2719
    DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
2720

2721
    DO_TEST_FAILURE("memory-align-fail", NONE);
2722
    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
M
Michal Privoznik 已提交
2723
    DO_TEST("memory-hotplug", NONE);
2724
    DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
2725
    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2726
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2727
    DO_TEST("memory-hotplug-dimm-addr", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2728
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2729
    DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
2730
            QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
M
Michal Privoznik 已提交
2731 2732
    DO_TEST("memory-hotplug-nvdimm", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEVICE_NVDIMM,
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2733 2734
    DO_TEST("memory-hotplug-nvdimm-access", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEVICE_NVDIMM,
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2735 2736
    DO_TEST("memory-hotplug-nvdimm-label", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEVICE_NVDIMM,
            QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
2737

2738 2739
    DO_TEST("machine-aeskeywrap-on-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2740
            QEMU_CAPS_DEA_KEY_WRAP,
2741
            QEMU_CAPS_VIRTIO_SCSI,
2742 2743
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", QEMU_CAPS_MACHINE_OPT,
2744
                    QEMU_CAPS_VIRTIO_SCSI,
2745 2746 2747 2748 2749
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE);

    DO_TEST("machine-aeskeywrap-on-cap",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2750
            QEMU_CAPS_VIRTIO_SCSI,
2751 2752
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", QEMU_CAPS_MACHINE_OPT,
2753
                    QEMU_CAPS_VIRTIO_SCSI,
2754 2755 2756 2757 2758
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE);

    DO_TEST("machine-aeskeywrap-off-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2759
            QEMU_CAPS_VIRTIO_SCSI,
2760 2761
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", QEMU_CAPS_MACHINE_OPT,
2762
                    QEMU_CAPS_VIRTIO_SCSI,
2763 2764 2765 2766
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE);

    DO_TEST("machine-aeskeywrap-off-cap",
2767
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP,
2768
            QEMU_CAPS_VIRTIO_SCSI,
2769 2770
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", QEMU_CAPS_MACHINE_OPT,
2771
                    QEMU_CAPS_VIRTIO_SCSI,
2772 2773 2774 2775 2776
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE);

    DO_TEST("machine-deakeywrap-on-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2777
            QEMU_CAPS_VIRTIO_SCSI,
2778
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
2779
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", QEMU_CAPS_MACHINE_OPT,
2780
                    QEMU_CAPS_VIRTIO_SCSI,
2781 2782 2783 2784
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE);

    DO_TEST("machine-deakeywrap-on-cap",
2785
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEA_KEY_WRAP,
2786
            QEMU_CAPS_VIRTIO_SCSI,
2787 2788
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", QEMU_CAPS_MACHINE_OPT,
2789
                    QEMU_CAPS_VIRTIO_SCSI,
2790 2791 2792 2793 2794
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE);

    DO_TEST("machine-deakeywrap-off-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2795
            QEMU_CAPS_VIRTIO_SCSI,
2796 2797
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", QEMU_CAPS_MACHINE_OPT,
2798
                    QEMU_CAPS_VIRTIO_SCSI,
2799 2800 2801 2802
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE);

    DO_TEST("machine-deakeywrap-off-cap",
2803
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DEA_KEY_WRAP,
2804
            QEMU_CAPS_VIRTIO_SCSI,
2805 2806
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", QEMU_CAPS_MACHINE_OPT,
2807
                    QEMU_CAPS_VIRTIO_SCSI,
2808 2809 2810 2811 2812
                    QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE);

    DO_TEST("machine-keywrap-none-caps",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP,
2813
            QEMU_CAPS_VIRTIO_SCSI,
2814 2815
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
    DO_TEST("machine-keywrap-none",
2816
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_VIRTIO_SCSI,
2817
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
2818

2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837
    DO_TEST("machine-loadparm-s390", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
    DO_TEST("machine-loadparm-net-s390", QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390,
            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_LOADPARM);
    DO_TEST("machine-loadparm-multiple-disks-nets-s390",
            QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_VIRTIO_CCW,
            QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
            QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-char-invalid",
                        QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_VIRTIO_CCW,
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);
    DO_TEST_PARSE_ERROR("machine-loadparm-s390-len-invalid",
                        QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_VIRTIO_CCW,
                        QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_BOOTINDEX,
                        QEMU_CAPS_LOADPARM);

J
Jiri Denemark 已提交
2838 2839 2840 2841 2842 2843 2844
    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);

2845
    DO_TEST("virtio-input", QEMU_CAPS_VIRTIO_KEYBOARD,
2846
            QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
2847
    DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST);
2848

2849
    DO_TEST("ppc64-usb-controller",
2850
            QEMU_CAPS_PCI_OHCI);
2851
    DO_TEST("ppc64-usb-controller-legacy",
2852
            QEMU_CAPS_PIIX3_USB_UHCI);
2853 2854 2855 2856 2857 2858 2859 2860 2861
    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", NULL, -1, 0,
                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE,
                 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);
2862

2863 2864 2865 2866
    DO_TEST("aarch64-usb-controller-nec-xhci",
            QEMU_CAPS_OBJECT_GPEX,
            QEMU_CAPS_NEC_USB_XHCI);

2867 2868 2869 2870
    DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                              VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                              NONE);

2871 2872 2873 2874 2875 2876 2877 2878
    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 已提交
2879 2880
    DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS);

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

2887
    DO_TEST("acpi-table", NONE);
2888
    DO_TEST("intel-iommu",
2889
            QEMU_CAPS_DEVICE_INTEL_IOMMU);
2890 2891 2892
    DO_TEST("intel-iommu-machine",
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_IOMMU);
J
Ján Tomko 已提交
2893
    DO_TEST("intel-iommu-caching-mode",
2894 2895 2896
            QEMU_CAPS_MACHINE_OPT,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
2897 2898 2899 2900 2901 2902 2903 2904 2905
            QEMU_CAPS_DEVICE_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
            QEMU_CAPS_DEVICE_IOH3420,
            QEMU_CAPS_ICH9_AHCI,
            QEMU_CAPS_PCI_MULTIFUNCTION,
            QEMU_CAPS_ICH9_USB_EHCI1,
            QEMU_CAPS_DEVICE_INTEL_IOMMU,
            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
            QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
2906 2907 2908 2909 2910 2911 2912
    DO_TEST("intel-iommu-eim",
            QEMU_CAPS_MACHINE_OPT,
            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);
2913 2914 2915 2916 2917 2918 2919
    DO_TEST("intel-iommu-device-iotlb",
            QEMU_CAPS_MACHINE_OPT,
            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);
2920

2921
    DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
2922 2923 2924
    DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
                        QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);

2925 2926 2927 2928 2929 2930 2931 2932
    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_FSDEV, QEMU_CAPS_FSDEV_WRITEOUT,
            QEMU_CAPS_DEVICE_VIRTIO_GPU,
            QEMU_CAPS_VIRTIO_GPU_VIRGL,
            QEMU_CAPS_DEVICE_VIRTIO_RNG,
            QEMU_CAPS_OBJECT_RNG_RANDOM,
2933 2934 2935
            QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
            QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM,
            QEMU_CAPS_VIRTIO_PCI_ATS);
2936

2937 2938 2939 2940 2941 2942 2943 2944 2945 2946
    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_KVM);
    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_KVM);
    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_KVM);

    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE,
            QEMU_CAPS_KVM);

2947 2948 2949 2950 2951 2952 2953 2954
    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);

2955 2956 2957 2958 2959 2960 2961 2962 2963
    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 已提交
2964
    DO_TEST("vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO);
2965

2966 2967 2968
    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,
2969
            QEMU_CAPS_DEVICE_ISA_SERIAL,
2970
            QEMU_CAPS_HDA_DUPLEX);
2971
    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
2972

A
Andrea Bolognani 已提交
2973 2974 2975
    if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
        virFileDeleteTree(fakerootdir);

2976
    qemuTestDriverFree(&driver);
A
Andrea Bolognani 已提交
2977
    VIR_FREE(fakerootdir);
2978

2979
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2980 2981
}

2982
VIR_TEST_MAIN_PRELOAD(mymain,
A
Andrea Bolognani 已提交
2983 2984 2985 2986
                      abs_builddir "/.libs/qemuxml2argvmock.so",
                      abs_builddir "/.libs/virrandommock.so",
                      abs_builddir "/.libs/qemucpumock.so",
                      abs_builddir "/.libs/virpcimock.so")
2987

2988 2989
#else

2990 2991 2992 2993
int main(void)
{
    return EXIT_AM_SKIP;
}
2994 2995

#endif /* WITH_QEMU */