qemuhotplugtest.c 21.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright (C) 2011-2013 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 */

#include <config.h>

22
#include "qemu/qemu_alias.h"
23 24
#include "qemu/qemu_conf.h"
#include "qemu/qemu_hotplug.h"
25
#include "qemu/qemu_hotplugpriv.h"
26 27 28 29 30 31 32 33 34 35 36 37
#include "qemumonitortestutils.h"
#include "testutils.h"
#include "testutilsqemu.h"
#include "virerror.h"
#include "virstring.h"
#include "virthread.h"
#include "virfile.h"

#define VIR_FROM_THIS VIR_FROM_NONE

static virQEMUDriver driver;

38 39 40 41 42 43
enum {
    ATTACH,
    DETACH,
    UPDATE
};

44 45
#define QEMU_HOTPLUG_TEST_DOMAIN_ID 7

46 47 48 49 50
struct qemuHotplugTestData {
    const char *domain_filename;
    const char *device_filename;
    bool fail;
    const char *const *mon;
51 52 53
    int action;
    bool keep;
    virDomainObjPtr vm;
54
    bool deviceDeletedEvent;
55 56 57 58 59
};

static int
qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr *vm,
60
                         const char *domxml,
P
Pavel Fedin 已提交
61
                         bool event, const char *testname)
62 63
{
    int ret = -1;
64
    qemuDomainObjPrivatePtr priv = NULL;
65 66 67 68

    if (!(*vm = virDomainObjNew(xmlopt)))
        goto cleanup;

69 70 71 72 73
    priv = (*vm)->privateData;

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

74
    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI);
75
    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE);
76
    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW);
77 78
    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN);
    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
79 80
    if (event)
        virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
81

82 83
    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, testname,
                                priv->qemuCaps) < 0)
P
Pavel Fedin 已提交
84 85 86 87 88
        goto cleanup;

    if (!((*vm)->def = virDomainDefParseString(domxml,
                                               driver.caps,
                                               driver.xmlopt,
89
                                               NULL,
P
Pavel Fedin 已提交
90 91 92
                                               VIR_DOMAIN_DEF_PARSE_INACTIVE)))
        goto cleanup;

93 94
    if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps,
                                  &driver, *vm, true) < 0) {
95
        goto cleanup;
96
    }
97 98 99

    if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
        goto cleanup;
100

101 102
    (*vm)->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;

103 104 105
    if (qemuDomainSetPrivatePaths(&driver, *vm) < 0)
        goto cleanup;

106
    ret = 0;
107
 cleanup:
108 109 110
    return ret;
}

111 112 113 114 115 116 117
static int
testQemuHotplugAttach(virDomainObjPtr vm,
                      virDomainDeviceDefPtr dev)
{
    int ret = -1;

    switch (dev->type) {
118 119 120 121 122 123
    case VIR_DOMAIN_DEVICE_DISK:
        /* conn in only used for storage pool and secrets lookup so as long
         * as we don't use any of them, passing NULL should be safe
         */
        ret = qemuDomainAttachDeviceDiskLive(NULL, &driver, vm, dev);
        break;
124
    case VIR_DOMAIN_DEVICE_CHR:
125
        ret = qemuDomainAttachChrDevice(NULL, &driver, vm, dev->data.chr);
126
        break;
127 128 129
    case VIR_DOMAIN_DEVICE_SHMEM:
        ret = qemuDomainAttachShmemDevice(&driver, vm, dev->data.shmem);
        break;
130
    default:
131 132
        VIR_TEST_VERBOSE("device type '%s' cannot be attached\n",
                virDomainDeviceTypeToString(dev->type));
133 134 135 136 137 138 139 140 141 142 143 144 145
        break;
    }

    return ret;
}

static int
testQemuHotplugDetach(virDomainObjPtr vm,
                      virDomainDeviceDefPtr dev)
{
    int ret = -1;

    switch (dev->type) {
146 147 148
    case VIR_DOMAIN_DEVICE_DISK:
        ret = qemuDomainDetachDeviceDiskLive(&driver, vm, dev);
        break;
149 150 151
    case VIR_DOMAIN_DEVICE_CHR:
        ret = qemuDomainDetachChrDevice(&driver, vm, dev->data.chr);
        break;
152 153 154
    case VIR_DOMAIN_DEVICE_SHMEM:
        ret = qemuDomainDetachShmemDevice(&driver, vm, dev->data.shmem);
        break;
155
    default:
156 157
        VIR_TEST_VERBOSE("device type '%s' cannot be detached\n",
                virDomainDeviceTypeToString(dev->type));
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
        break;
    }

    return ret;
}

static int
testQemuHotplugUpdate(virDomainObjPtr vm,
                      virDomainDeviceDefPtr dev)
{
    int ret = -1;

    /* XXX Ideally, we would call qemuDomainUpdateDeviceLive here.  But that
     * would require us to provide virConnectPtr and virDomainPtr (they're used
     * in case of updating a disk device. So for now, we will proceed with
     * breaking the function into pieces. If we ever learn how to fake those
     * required object, we can replace this code then. */
    switch (dev->type) {
    case VIR_DOMAIN_DEVICE_GRAPHICS:
        ret = qemuDomainChangeGraphics(&driver, vm, dev->data.graphics);
        break;
    default:
180 181
        VIR_TEST_VERBOSE("device type '%s' cannot be updated\n",
                virDomainDeviceTypeToString(dev->type));
182 183 184 185 186 187
        break;
    }

    return ret;
}

188 189 190
static int
testQemuHotplugCheckResult(virDomainObjPtr vm,
                           const char *expected,
191
                           const char *expectedFile,
192 193 194 195 196
                           bool fail)
{
    char *actual;
    int ret;

197 198
    actual = virDomainDefFormat(vm->def, driver.caps,
                                VIR_DOMAIN_DEF_FORMAT_SECURE);
199 200
    if (!actual)
        return -1;
201
    vm->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;
202 203

    if (STREQ(expected, actual)) {
204 205
        if (fail)
            VIR_TEST_VERBOSE("domain XML should not match the expected result\n");
206 207 208
        ret = 0;
    } else {
        if (!fail)
209 210 211
            virTestDifferenceFull(stderr,
                                  expected, expectedFile,
                                  actual, NULL);
212 213 214 215 216 217 218
        ret = -1;
    }

    VIR_FREE(actual);
    return ret;
}

219 220 221 222 223 224 225
static int
testQemuHotplug(const void *data)
{
    int ret = -1;
    struct qemuHotplugTestData *test = (struct qemuHotplugTestData *) data;
    char *domain_filename = NULL;
    char *device_filename = NULL;
226 227
    char *result_filename = NULL;
    char *domain_xml = NULL;
228
    char *device_xml = NULL;
229
    char *result_xml = NULL;
230 231
    const char *const *tmp;
    bool fail = test->fail;
232
    bool keep = test->keep;
233
    unsigned int device_parse_flags = 0;
234 235 236 237 238 239
    virDomainObjPtr vm = NULL;
    virDomainDeviceDefPtr dev = NULL;
    virCapsPtr caps = NULL;
    qemuMonitorTestPtr test_mon = NULL;
    qemuDomainObjPrivatePtr priv = NULL;

240
    if (virAsprintf(&domain_filename, "%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
241
                    abs_srcdir, test->domain_filename) < 0 ||
242
        virAsprintf(&device_filename, "%s/qemuhotplugtestdevices/qemuhotplug-%s.xml",
243 244
                    abs_srcdir, test->device_filename) < 0 ||
        virAsprintf(&result_filename,
245
                    "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml",
246 247 248 249
                    abs_srcdir, test->domain_filename,
                    test->device_filename) < 0)
        goto cleanup;

250 251
    if (virTestLoadFile(domain_filename, &domain_xml) < 0 ||
        virTestLoadFile(device_filename, &device_xml) < 0)
252 253
        goto cleanup;

254
    if (test->action == ATTACH &&
255
        virTestLoadFile(result_filename, &result_xml) < 0)
256 257 258 259 260
        goto cleanup;

    if (!(caps = virQEMUDriverGetCapabilities(&driver, false)))
        goto cleanup;

261 262 263
    if (test->vm) {
        vm = test->vm;
    } else {
264
        if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml,
P
Pavel Fedin 已提交
265 266
                                     test->deviceDeletedEvent,
                                     test->domain_filename) < 0)
267 268
            goto cleanup;
    }
269

270
    if (test->action == ATTACH)
271
        device_parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
272

273
    if (!(dev = virDomainDeviceDefParse(device_xml, vm->def,
274 275
                                        caps, driver.xmlopt,
                                        device_parse_flags)))
276 277 278 279
        goto cleanup;

    /* Now is the best time to feed the spoofed monitor with predefined
     * replies. */
280
    if (!(test_mon = qemuMonitorTestNew(true, driver.xmlopt, vm, &driver, NULL)))
281 282 283 284 285 286 287 288 289 290 291 292 293 294
        goto cleanup;

    tmp = test->mon;
    while (tmp && *tmp) {
        const char *command_name;
        const char *response;

        if (!(command_name = *tmp++) ||
            !(response = *tmp++))
            break;
        if (qemuMonitorTestAddItem(test_mon, command_name, response) < 0)
            goto cleanup;
    }

295
    priv = vm->privateData;
296 297 298 299 300 301 302 303
    priv->mon = qemuMonitorTestGetMonitor(test_mon);
    priv->monJSON = true;

    /* XXX We need to unlock the monitor here, as
     * qemuDomainObjEnterMonitorInternal (called from qemuDomainChangeGraphics)
     * tries to lock it again */
    virObjectUnlock(priv->mon);

304 305 306
    switch (test->action) {
    case ATTACH:
        ret = testQemuHotplugAttach(vm, dev);
307 308 309 310 311
        if (ret == 0) {
            /* vm->def stolen dev->data.* so we just need to free the dev
             * envelope */
            VIR_FREE(dev);
        }
312
        if (ret == 0 || fail)
313 314
            ret = testQemuHotplugCheckResult(vm, result_xml,
                                             result_filename, fail);
315
        break;
316 317 318

    case DETACH:
        ret = testQemuHotplugDetach(vm, dev);
319
        if (ret == 0 || fail)
320 321
            ret = testQemuHotplugCheckResult(vm, domain_xml,
                                             domain_filename, fail);
322
        break;
323 324 325

    case UPDATE:
        ret = testQemuHotplugUpdate(vm, dev);
326 327
    }

328
 cleanup:
329 330
    VIR_FREE(domain_filename);
    VIR_FREE(device_filename);
331 332
    VIR_FREE(result_filename);
    VIR_FREE(domain_xml);
333
    VIR_FREE(device_xml);
334
    VIR_FREE(result_xml);
335 336 337
    /* don't dispose test monitor with VM */
    if (priv)
        priv->mon = NULL;
338 339 340 341 342 343
    if (keep) {
        test->vm = vm;
    } else {
        virObjectUnref(vm);
        test->vm = NULL;
    }
344 345 346 347 348 349 350 351 352 353
    virDomainDeviceDefFree(dev);
    virObjectUnref(caps);
    qemuMonitorTestFree(test_mon);
    return ((ret < 0 && fail) || (!ret && !fail)) ? 0 : -1;
}

static int
mymain(void)
{
    int ret = 0;
354
    struct qemuHotplugTestData data = {0};
355 356 357 358 359 360 361

#if !WITH_YAJL
    fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
    return EXIT_AM_SKIP;
#endif

    if (virThreadInitialize() < 0 ||
362
        qemuTestDriverInit(&driver) < 0)
363 364 365 366 367 368
        return EXIT_FAILURE;

    virEventRegisterDefaultImpl();

    VIR_FREE(driver.config->spiceListen);
    VIR_FREE(driver.config->vncListen);
369 370 371
    /* some dummy values from 'config file' */
    if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
        return EXIT_FAILURE;
372

373
    if (!(driver.domainEventState = virObjectEventStateNew()))
374 375
        return EXIT_FAILURE;

376 377 378 379 380 381
    driver.lockManager = virLockManagerPluginNew("nop", "qemu",
                                                 driver.config->configBaseDir,
                                                 0);
    if (!driver.lockManager)
        return EXIT_FAILURE;

382 383 384 385
    /* wait only 100ms for DEVICE_DELETED event */
    qemuDomainRemoveDeviceWaitTime = 100;

#define DO_TEST(file, ACTION, dev, event, fial, kep, ...)                   \
386
    do {                                                                    \
387
        const char *my_mon[] = { __VA_ARGS__, NULL};                        \
388 389
        const char *name = file " " #ACTION " " dev;                        \
        data.action = ACTION;                                               \
390 391 392 393 394
        data.domain_filename = file;                                        \
        data.device_filename = dev;                                         \
        data.fail = fial;                                                   \
        data.mon = my_mon;                                                  \
        data.keep = kep;                                                    \
395
        data.deviceDeletedEvent = event;                                    \
396
        if (virTestRun(name, testQemuHotplug, &data) < 0)                   \
397
            ret = -1;                                                       \
398
    } while (0)
399 400

#define DO_TEST_ATTACH(file, dev, fial, kep, ...)                           \
401
    DO_TEST(file, ATTACH, dev, false, fial, kep, __VA_ARGS__)
402 403

#define DO_TEST_DETACH(file, dev, fial, kep, ...)                           \
404 405 406 407 408 409 410
    DO_TEST(file, DETACH, dev, false, fial, kep, __VA_ARGS__)

#define DO_TEST_ATTACH_EVENT(file, dev, fial, kep, ...)                     \
    DO_TEST(file, ATTACH, dev, true, fial, kep, __VA_ARGS__)

#define DO_TEST_DETACH_EVENT(file, dev, fial, kep, ...)                     \
    DO_TEST(file, DETACH, dev, true, fial, kep, __VA_ARGS__)
411 412

#define DO_TEST_UPDATE(file, dev, fial, kep, ...)                           \
413
    DO_TEST(file, UPDATE, dev, false, fial, kep, __VA_ARGS__)
414

415 416

#define QMP_OK      "{\"return\": {}}"
417
#define HMP(msg)    "{\"return\": \"" msg "\"}"
418

419 420 421 422 423 424 425 426 427 428 429 430 431
#define QMP_DEVICE_DELETED(dev) \
    "{"                                                     \
    "    \"timestamp\": {"                                  \
    "        \"seconds\": 1374137171,"                      \
    "        \"microseconds\": 2659"                        \
    "    },"                                                \
    "    \"event\": \"DEVICE_DELETED\","                    \
    "    \"data\": {"                                       \
    "        \"device\": \"" dev "\","                      \
    "        \"path\": \"/machine/peripheral/" dev "\""     \
    "    }"                                                 \
    "}\r\n"

432 433
    DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL);
    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false,
434
                   "set_password", QMP_OK, "expire_password", QMP_OK);
435
    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-password", false, false,
436
                   "set_password", QMP_OK, "expire_password", QMP_OK);
437
    DO_TEST_UPDATE("graphics-spice", "graphics-spice-listen", true, false, NULL);
438
    DO_TEST_UPDATE("graphics-spice-listen-network", "graphics-spice-listen-network-password", false, false,
439
                   "set_password", QMP_OK, "expire_password", QMP_OK);
440 441 442
    /* Strange huh? Currently, only graphics can be updated :-P */
    DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, NULL);

443
    DO_TEST_ATTACH("console-compat-2-live", "console-virtio", false, true,
444
                   "chardev-add", "{\"return\": {\"pty\": \"/dev/pts/26\"}}",
445
                   "device_add", QMP_OK);
446

447
    DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false,
448 449
                   "device_del", QMP_OK,
                   "chardev-remove", QMP_OK);
450

451
    DO_TEST_ATTACH("base-live", "disk-virtio", false, true,
452 453
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);
454
    DO_TEST_DETACH("base-live", "disk-virtio", false, false,
455 456 457
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

458
    DO_TEST_ATTACH_EVENT("base-live", "disk-virtio", false, true,
459 460
                         "human-monitor-command", HMP("OK\\r\\n"),
                         "device_add", QMP_OK);
461
    DO_TEST_DETACH("base-live", "disk-virtio", true, true,
462 463
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));
464
    DO_TEST_DETACH("base-live", "disk-virtio", false, false,
465 466 467
                   "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK,
                   "human-monitor-command", HMP(""));

468
    DO_TEST_ATTACH("base-live", "disk-usb", false, true,
469 470
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);
471
    DO_TEST_DETACH("base-live", "disk-usb", false, false,
472 473 474
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

475
    DO_TEST_ATTACH_EVENT("base-live", "disk-usb", false, true,
476 477
                         "human-monitor-command", HMP("OK\\r\\n"),
                         "device_add", QMP_OK);
478
    DO_TEST_DETACH("base-live", "disk-usb", true, true,
479 480
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));
481
    DO_TEST_DETACH("base-live", "disk-usb", false, false,
482 483 484
                   "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK,
                   "human-monitor-command", HMP(""));

485
    DO_TEST_ATTACH("base-live", "disk-scsi", false, true,
486 487
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);
488
    DO_TEST_DETACH("base-live", "disk-scsi", false, false,
489 490 491
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

492
    DO_TEST_ATTACH_EVENT("base-live", "disk-scsi", false, true,
493 494
                         "human-monitor-command", HMP("OK\\r\\n"),
                         "device_add", QMP_OK);
495
    DO_TEST_DETACH("base-live", "disk-scsi", true, true,
496 497
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));
498
    DO_TEST_DETACH("base-live", "disk-scsi", false, false,
499 500 501
                   "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK,
                   "human-monitor-command", HMP(""));

502
    DO_TEST_ATTACH("base-without-scsi-controller-live", "disk-scsi-2", false, true,
503 504 505 506 507 508 509 510
                   /* Four controllers added */
                   "device_add", QMP_OK,
                   "device_add", QMP_OK,
                   "device_add", QMP_OK,
                   "device_add", QMP_OK,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   /* Disk added */
                   "device_add", QMP_OK);
511
    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false,
512 513 514
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

515
    DO_TEST_ATTACH_EVENT("base-without-scsi-controller-live", "disk-scsi-2", false, true,
516 517 518 519 520 521 522 523
                         /* Four controllers added */
                         "device_add", QMP_OK,
                         "device_add", QMP_OK,
                         "device_add", QMP_OK,
                         "device_add", QMP_OK,
                         "human-monitor-command", HMP("OK\\r\\n"),
                         /* Disk added */
                         "device_add", QMP_OK);
524
    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", true, true,
525 526
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));
527
    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false,
528 529 530
                   "device_del", QMP_DEVICE_DELETED("scsi3-0-5-7") QMP_OK,
                   "human-monitor-command", HMP(""));

531
    DO_TEST_ATTACH("base-live", "qemu-agent", false, true,
532 533
                   "chardev-add", QMP_OK,
                   "device_add", QMP_OK);
534
    DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false,
535 536 537
                   "device_del", QMP_OK,
                   "chardev-remove", QMP_OK);

538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
    DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);
    DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false,
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, true,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);

    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false,
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);

    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false,
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

    /* Attach a second device, then detach the first one. Then attach the first one again. */
    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);

    DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true,
                   "device_del", QMP_OK,
                   "human-monitor-command", HMP(""));

    DO_TEST_ATTACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-reverse", false, false,
                   "human-monitor-command", HMP("OK\\r\\n"),
                   "device_add", QMP_OK);

574 575 576 577 578 579 580 581 582 583 584 585 586
    DO_TEST_ATTACH("base-live", "ivshmem-plain", false, true,
                   "object-add", QMP_OK,
                   "device_add", QMP_OK);
    DO_TEST_ATTACH("base-live", "ivshmem-doorbell", false, true,
                   "chardev-add", QMP_OK,
                   "device_add", QMP_OK);
    DO_TEST_DETACH("base-live+ivshmem-plain", "ivshmem-doorbell-detach", false, true,
                   "device_del", QMP_OK,
                   "chardev-remove", QMP_OK);
    DO_TEST_DETACH("base-live", "ivshmem-plain-detach", false, false,
                   "device_del", QMP_OK,
                   "object-del", QMP_OK);

587
    qemuTestDriverFree(&driver);
588 589 590 591
    return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

VIRT_TEST_MAIN(mymain)