示例#1
0
static int
testQemuHotplugAttach(virDomainObjPtr vm,
                      virDomainDeviceDefPtr dev)
{
    int ret = -1;

    switch (dev->type) {
    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;
    case VIR_DOMAIN_DEVICE_CHR:
        ret = qemuDomainAttachChrDevice(&driver, vm, dev->data.chr);
        break;
    default:
        if (virTestGetVerbose())
            fprintf(stderr, "device type '%s' cannot be attached\n",
                    virDomainDeviceTypeToString(dev->type));
        break;
    }

    return ret;
}
示例#2
0
static int
testQemuHotplugAttach(virDomainObjPtr vm,
                      virDomainDeviceDefPtr dev)
{
    int ret = -1;

    switch (dev->type) {
    case VIR_DOMAIN_DEVICE_CHR:
        ret = qemuDomainAttachChrDevice(&driver, vm, dev->data.chr);
        if (!ret) {
            /* vm->def stolen dev->data.chr so we ought to avoid freeing it */
            dev->data.chr = NULL;
        }
        break;
    default:
        if (virTestGetVerbose())
            fprintf(stderr, "device type '%s' cannot be attached",
                    virDomainDeviceTypeToString(dev->type));
        break;
    }

    return ret;
}