diff mbox

[7/8] qemu: hotplug: Drop !QEMU_CAPS_DEVICE code

Message ID cd7dbe62045b8cb574f2c3764c1e29153324f9ef.1452725836.git.crobinso@redhat.com
State Superseded
Headers show

Commit Message

Cole Robinson Jan. 13, 2016, 11:03 p.m. UTC
Nowadays we only support qemu 0.12.0+ which provides QEMU_CAPS_DEVICE,
so this is all dead code.
---
 src/qemu/qemu_hotplug.c | 480 +++++++++++++++---------------------------------
 1 file changed, 144 insertions(+), 336 deletions(-)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f8db960..ade02ed 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -317,7 +317,6 @@  qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
 {
     size_t i;
     int ret = -1;
-    const char* type = virDomainDiskBusTypeToString(disk->bus);
     qemuDomainObjPrivatePtr priv = vm->privateData;
     char *devstr = NULL;
     char *drivestr = NULL;
@@ -349,59 +348,47 @@  qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
     if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0)
         goto cleanup;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-            if (virDomainCCWAddressAssign(&disk->info, priv->ccwaddrs,
-                                          !disk->info.addr.ccw.assigned) < 0)
-                goto error;
-        } else if (!disk->info.type ||
-                    disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-            if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &disk->info) < 0)
-                goto error;
-        }
-        releaseaddr = true;
-        if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
+    if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        if (virDomainCCWAddressAssign(&disk->info, priv->ccwaddrs,
+                                      !disk->info.addr.ccw.assigned) < 0)
             goto error;
-
-        if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
+    } else if (!disk->info.type ||
+                disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &disk->info) < 0)
             goto error;
+    }
+    releaseaddr = true;
+    if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
+        goto error;
 
-        if (!(drivealias = qemuDeviceDriveHostAlias(disk, priv->qemuCaps)))
-            goto error;
+    if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
+        goto error;
 
-        if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
-            goto error;
-    }
+    if (!(drivealias = qemuDeviceDriveHostAlias(disk, priv->qemuCaps)))
+        goto error;
+
+    if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
+        goto error;
 
     if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
         goto error;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        ret = qemuMonitorAddDrive(priv->mon, drivestr);
-        if (ret == 0) {
-            ret = qemuMonitorAddDevice(priv->mon, devstr);
-            if (ret < 0) {
-                virErrorPtr orig_err = virSaveLastError();
-                if (!drivealias ||
-                    qemuMonitorDriveDel(priv->mon, drivealias) < 0) {
-                    VIR_WARN("Unable to remove drive %s (%s) after failed "
-                             "qemuMonitorAddDevice",
-                             NULLSTR(drivealias), drivestr);
-                }
-                if (orig_err) {
-                    virSetError(orig_err);
-                    virFreeError(orig_err);
-                }
+    ret = qemuMonitorAddDrive(priv->mon, drivestr);
+    if (ret == 0) {
+        ret = qemuMonitorAddDevice(priv->mon, devstr);
+        if (ret < 0) {
+            virErrorPtr orig_err = virSaveLastError();
+            if (!drivealias ||
+                qemuMonitorDriveDel(priv->mon, drivealias) < 0) {
+                VIR_WARN("Unable to remove drive %s (%s) after failed "
+                         "qemuMonitorAddDevice",
+                         NULLSTR(drivealias), drivestr);
+            }
+            if (orig_err) {
+                virSetError(orig_err);
+                virFreeError(orig_err);
             }
-        }
-    } else if (!disk->info.type ||
-                disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        virDevicePCIAddress guestAddr = disk->info.addr.pci;
-        ret = qemuMonitorAddPCIDisk(priv->mon, src, type, &guestAddr);
-        if (ret == 0) {
-            disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-            memcpy(&disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
         }
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
@@ -457,47 +444,39 @@  int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
         return -1;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
-            if (qemuDomainMachineIsS390CCW(vm->def) &&
-                virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
-                controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-            else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
-                controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
-        } else {
-            if (!qemuCheckCCWS390AddressSupport(vm->def, controller->info,
-                                                priv->qemuCaps, "controller"))
-                goto cleanup;
-        }
-
-        if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
-            controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-            if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0)
-                goto cleanup;
-        } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-            if (virDomainCCWAddressAssign(&controller->info, priv->ccwaddrs,
-                                          !controller->info.addr.ccw.assigned) < 0)
-                goto cleanup;
-        }
-        releaseaddr = true;
-        if (qemuAssignDeviceControllerAlias(vm->def, priv->qemuCaps, controller) < 0)
+    if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+        if (qemuDomainMachineIsS390CCW(vm->def) &&
+            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
+            controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
+        else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
+            controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
+    } else {
+        if (!qemuCheckCCWS390AddressSupport(vm->def, controller->info,
+                                            priv->qemuCaps, "controller"))
             goto cleanup;
+    }
 
-        if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL)))
+    if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
+        controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0)
+            goto cleanup;
+    } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        if (virDomainCCWAddressAssign(&controller->info, priv->ccwaddrs,
+                                      !controller->info.addr.ccw.assigned) < 0)
             goto cleanup;
     }
+    releaseaddr = true;
+    if (qemuAssignDeviceControllerAlias(vm->def, priv->qemuCaps, controller) < 0)
+        goto cleanup;
+
+    if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL)))
+        goto cleanup;
 
     if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0)
         goto cleanup;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        ret = qemuMonitorAddDevice(priv->mon, devstr);
-    } else {
-        ret = qemuMonitorAttachPCIDiskController(priv->mon,
-                                                 type,
-                                                 &controller->info.addr.pci);
-    }
+    ret = qemuMonitorAddDevice(priv->mon, devstr);
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         releaseaddr = false;
         ret = -1;
@@ -611,12 +590,10 @@  qemuDomainAttachSCSIDisk(virConnectPtr conn,
        and hence the above loop must iterate at least once.  */
     sa_assert(cont);
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
-            goto error;
-        if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
-            goto error;
-    }
+    if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
+        goto error;
+    if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
+        goto error;
 
     if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
         goto error;
@@ -625,36 +602,14 @@  qemuDomainAttachSCSIDisk(virConnectPtr conn,
         goto error;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        ret = qemuMonitorAddDrive(priv->mon, drivestr);
-        if (ret == 0) {
-            ret = qemuMonitorAddDevice(priv->mon, devstr);
-            if (ret < 0) {
-                VIR_WARN("qemuMonitorAddDevice failed on %s (%s)",
-                         drivestr, devstr);
-                /* XXX should call 'drive_del' on error but this does not
-                   exist yet */
-            }
-        }
-    } else {
-        if (cont->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("SCSI controller %d was missing its PCI address"),
-                           cont->idx);
-            goto error;
-        }
-
-        virDomainDeviceDriveAddress driveAddr;
-        ret = qemuMonitorAttachDrive(priv->mon,
-                                     drivestr,
-                                     &cont->info.addr.pci,
-                                     &driveAddr);
-        if (ret == 0) {
-            /* XXX we should probably validate that the addr matches
-             * our existing defined addr instead of overwriting */
-            disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
-            disk->info.addr.drive.bus = driveAddr.bus;
-            disk->info.addr.drive.unit = driveAddr.unit;
+    ret = qemuMonitorAddDrive(priv->mon, drivestr);
+    if (ret == 0) {
+        ret = qemuMonitorAddDevice(priv->mon, devstr);
+        if (ret < 0) {
+            VIR_WARN("qemuMonitorAddDevice failed on %s (%s)",
+                     drivestr, devstr);
+            /* XXX should call 'drive_del' on error but this does not
+               exist yet */
         }
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
@@ -713,32 +668,26 @@  qemuDomainAttachUSBMassStorageDevice(virConnectPtr conn,
         goto error;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
-            goto error;
-        if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
-            goto error;
-        if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
-            goto error;
-    }
+    if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
+        goto error;
+    if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
+        goto error;
+    if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
+        goto error;
 
     if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
         goto error;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        ret = qemuMonitorAddDrive(priv->mon, drivestr);
-        if (ret == 0) {
-            ret = qemuMonitorAddDevice(priv->mon, devstr);
-            if (ret < 0) {
-                VIR_WARN("qemuMonitorAddDevice failed on %s (%s)",
-                         drivestr, devstr);
-                /* XXX should call 'drive_del' on error but this does not
-                   exist yet */
-            }
+    ret = qemuMonitorAddDrive(priv->mon, drivestr);
+    if (ret == 0) {
+        ret = qemuMonitorAddDevice(priv->mon, devstr);
+        if (ret < 0) {
+            VIR_WARN("qemuMonitorAddDevice failed on %s (%s)",
+                     drivestr, devstr);
+            /* XXX should call 'drive_del' on error but this does not
+               exist yet */
         }
-    } else {
-        ret = qemuMonitorAddUSBDisk(priv->mon, src);
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         ret = -1;
@@ -868,7 +817,6 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
     char *netstr = NULL;
     virNetDevVPortProfilePtr vport = NULL;
     int ret = -1;
-    virDevicePCIAddress guestAddr;
     int vlan;
     bool releaseaddr = false;
     bool iface_connected = false;
@@ -987,10 +935,8 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
             goto cleanup;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
-            goto cleanup;
-    }
+    if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
+        goto cleanup;
 
     if (qemuDomainMachineIsS390CCW(vm->def) &&
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
@@ -1002,15 +948,13 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("virtio-s390 net device cannot be hotplugged."));
         goto cleanup;
-    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-               virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) {
+    } else if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) {
         goto cleanup;
     }
 
     releaseaddr = true;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
         vlan = -1;
     } else {
         vlan = qemuDomainNetVLAN(net);
@@ -1036,8 +980,7 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
             goto cleanup;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
         if (!(netstr = qemuBuildHostNetStr(net, driver,
                                            ',', -1,
                                            tapfdName, tapfdSize,
@@ -1052,8 +995,7 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
         if (qemuMonitorAddNetdev(priv->mon, netstr,
                                  tapfd, tapfdName, tapfdSize,
                                  vhostfd, vhostfdName, vhostfdSize) < 0) {
@@ -1078,32 +1020,15 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
     for (i = 0; i < vhostfdSize; i++)
         VIR_FORCE_CLOSE(vhostfd[i]);
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
-                                          vhostfdSize, priv->qemuCaps)))
-            goto try_remove;
-    } else {
-        if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
-            goto try_remove;
-    }
+    if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
+                                      vhostfdSize, priv->qemuCaps)))
+        goto try_remove;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
-            ignore_value(qemuDomainObjExitMonitor(driver, vm));
-            virDomainAuditNet(vm, NULL, net, "attach", false);
-            goto try_remove;
-        }
-    } else {
-        guestAddr = net->info.addr.pci;
-        if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
-                                     &guestAddr) < 0) {
-            ignore_value(qemuDomainObjExitMonitor(driver, vm));
-            virDomainAuditNet(vm, NULL, net, "attach", false);
-            goto try_remove;
-        }
-        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-        memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
+    if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
+        ignore_value(qemuDomainObjExitMonitor(driver, vm));
+        virDomainAuditNet(vm, NULL, net, "attach", false);
+        goto try_remove;
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -1198,8 +1123,7 @@  int qemuDomainAttachNetDevice(virConnectPtr conn,
         goto cleanup;
 
     if (vlan < 0) {
-        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
-            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
             char *netdev_name;
             if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0)
                 goto cleanup;
@@ -1291,57 +1215,36 @@  qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
         goto error;
     teardownlabel = true;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
-            goto error;
-        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, hostdev->info) < 0)
-            goto error;
-        releaseaddr = true;
-        if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO &&
-            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) {
-            configfd = qemuOpenPCIConfig(hostdev);
-            if (configfd >= 0) {
-                if (virAsprintf(&configfd_name, "fd-%s",
-                                hostdev->info->alias) < 0)
-                    goto error;
-            }
-        }
-
-        if (!virDomainObjIsActive(vm)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("guest unexpectedly quit during hotplug"));
-            goto error;
+    if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
+        goto error;
+    if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, hostdev->info) < 0)
+        goto error;
+    releaseaddr = true;
+    if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO &&
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) {
+        configfd = qemuOpenPCIConfig(hostdev);
+        if (configfd >= 0) {
+            if (virAsprintf(&configfd_name, "fd-%s",
+                            hostdev->info->alias) < 0)
+                goto error;
         }
+    }
 
-        if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0,
-                                                 configfd_name, priv->qemuCaps)))
-            goto error;
-
-        qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
-                                         configfd, configfd_name);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0)
-            goto error;
-    } else {
-        virDevicePCIAddressPtr guestAddr = &hostdev->info->addr.pci;
-        virDevicePCIAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr;
-
-        if (hostAddr->domain &&
-            !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("non-zero domain='%.4x' in host device "
-                             "PCI address not supported in this QEMU binary"),
-                           hostAddr->domain);
-            goto error;
-        }
+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("guest unexpectedly quit during hotplug"));
+        goto error;
+    }
 
-        qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorAddPCIHostDevice(priv->mon, hostAddr, guestAddr);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0)
-            goto error;
+    if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0,
+                                             configfd_name, priv->qemuCaps)))
+        goto error;
 
-        hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-    }
+    qemuDomainObjEnterMonitor(driver, vm);
+    ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
+                                     configfd, configfd_name);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        goto error;
     virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
     if (ret < 0)
         goto error;
@@ -1387,12 +1290,6 @@  int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
     virDomainDefPtr def = vm->def;
     char *devstr = NULL;
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("redirected devices are not supported by this QEMU"));
-        goto error;
-    }
-
     if (qemuAssignDeviceRedirdevAlias(vm->def, redirdev, -1) < 0)
         goto error;
     if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps)))
@@ -1580,12 +1477,6 @@  int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
     char *charAlias = NULL;
     bool need_release = false;
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                       _("qemu does not support -device"));
-        goto cleanup;
-    }
-
     if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
         goto cleanup;
 
@@ -1891,23 +1782,16 @@  qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
         goto cleanup;
     teardownlabel = true;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
-            goto cleanup;
-        if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
-            goto cleanup;
-    }
+    if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
+        goto cleanup;
+    if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
+        goto cleanup;
 
     if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
         goto cleanup;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
-        ret = qemuMonitorAddDevice(priv->mon, devstr);
-    else
-        ret = qemuMonitorAddUSBDeviceExact(priv->mon,
-                                           hostdev->source.subsys.u.usb.bus,
-                                           hostdev->source.subsys.u.usb.device);
+    ret = qemuMonitorAddDevice(priv->mon, devstr);
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         ret = -1;
         goto cleanup;
@@ -1948,8 +1832,7 @@  qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
     bool teardowncgroup = false;
     bool teardownlabel = false;
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) ||
-        !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("SCSI passthrough is not supported by this version of qemu"));
         return -1;
@@ -3106,8 +2989,7 @@  qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
         goto cleanup;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
         if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
             if (qemuDomainObjExitMonitor(driver, vm) < 0)
                 goto cleanup;
@@ -3441,8 +3323,7 @@  qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
         }
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-        !detach->info.alias) {
+    if (!detach->info.alias) {
         if (qemuAssignDeviceDiskAlias(vm->def, detach, priv->qemuCaps) < 0)
             goto cleanup;
     }
@@ -3450,21 +3331,11 @@  qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
     qemuDomainMarkDeviceForRemoval(vm, &detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
-            if (qemuDomainObjExitMonitor(driver, vm) < 0)
-                goto cleanup;
-            virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
-            goto cleanup;
-        }
-    } else {
-        if (qemuMonitorRemovePCIDevice(priv->mon,
-                                       &detach->info.addr.pci) < 0) {
-            if (qemuDomainObjExitMonitor(driver, vm) < 0)
-                goto cleanup;
-            virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
+    if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
-        }
+        virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
+        goto cleanup;
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -3489,13 +3360,6 @@  qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     int rc;
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       _("Underlying qemu does not support %s disk removal"),
-                       virDomainDiskBusTypeToString(detach->bus));
-        goto cleanup;
-    }
-
     if (detach->mirror) {
         virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
                        _("disk '%s' is in an active block job"),
@@ -3679,8 +3543,7 @@  int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-        !detach->info.alias) {
+    if (!detach->info.alias) {
         if (qemuAssignDeviceControllerAlias(vm->def, priv->qemuCaps, detach) < 0)
             goto cleanup;
     }
@@ -3688,17 +3551,9 @@  int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
     qemuDomainMarkDeviceForRemoval(vm, &detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
-            ignore_value(qemuDomainObjExitMonitor(driver, vm));
-            goto cleanup;
-        }
-    } else {
-        if (qemuMonitorRemovePCIDevice(priv->mon,
-                                       &detach->info.addr.pci) < 0) {
-            ignore_value(qemuDomainObjExitMonitor(driver, vm));
-            goto cleanup;
-        }
+    if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
+        ignore_value(qemuDomainObjExitMonitor(driver, vm));
+        goto cleanup;
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -3741,11 +3596,7 @@  qemuDomainDetachHostPCIDevice(virQEMUDriverPtr driver,
     qemuDomainMarkDeviceForRemoval(vm, detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        ret = qemuMonitorDelDevice(priv->mon, detach->info->alias);
-    } else {
-        ret = qemuMonitorRemovePCIDevice(priv->mon, &detach->info->addr.pci);
-    }
+    ret = qemuMonitorDelDevice(priv->mon, detach->info->alias);
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         ret = -1;
 
@@ -3766,12 +3617,6 @@  qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver,
         return -1;
     }
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       "%s", _("device cannot be detached with this QEMU version"));
-        return -1;
-    }
-
     qemuDomainMarkDeviceForRemoval(vm, detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
@@ -3796,12 +3641,6 @@  qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver,
         return -1;
     }
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       "%s", _("device cannot be detached with this QEMU version"));
-        return -1;
-    }
-
     qemuDomainMarkDeviceForRemoval(vm, detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
@@ -3818,11 +3657,9 @@  qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                virDomainHostdevDefPtr detach)
 {
-    qemuDomainObjPrivatePtr priv = vm->privateData;
     int ret = -1;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-        !detach->info->alias) {
+    if (!detach->info->alias) {
         if (qemuAssignDeviceHostdevAlias(vm->def, detach, -1) < 0)
             return -1;
     }
@@ -3978,8 +3815,7 @@  qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
         }
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-        !detach->info.alias) {
+    if (!detach->info.alias) {
         if (qemuAssignDeviceNetAlias(vm->def, detach, -1) < 0)
             goto cleanup;
     }
@@ -3999,21 +3835,11 @@  qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
     qemuDomainMarkDeviceForRemoval(vm, &detach->info);
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
-            if (qemuDomainObjExitMonitor(driver, vm) < 0)
-                goto cleanup;
-            virDomainAuditNet(vm, detach, NULL, "detach", false);
-            goto cleanup;
-        }
-    } else {
-        if (qemuMonitorRemovePCIDevice(priv->mon,
-                                       &detach->info.addr.pci) < 0) {
-            if (qemuDomainObjExitMonitor(driver, vm) < 0)
-                goto cleanup;
-            virDomainAuditNet(vm, detach, NULL, "detach", false);
+    if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
-        }
+        virDomainAuditNet(vm, detach, NULL, "detach", false);
+        goto cleanup;
     }
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -4166,12 +3992,6 @@  int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
         return ret;
     }
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                       _("qemu does not support -device"));
-        return ret;
-    }
-
     if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
         return ret;
 
@@ -4225,12 +4045,6 @@  qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
 
     tmpRNG = vm->def->rngs[idx];
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                       _("qemu does not support -device"));
-        return -1;
-    }
-
     if (!tmpRNG->info.alias) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("alias not set for RNG device"));
@@ -4267,12 +4081,6 @@  qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
     int rc;
     int ret = -1;
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                       _("qemu does not support -device"));
-        return -1;
-    }
-
     qemuDomainMemoryDeviceAlignSize(vm->def, memdef);
 
     if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) {