[PATCH 07/13] qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachHostPCIDevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/qemu/qemu_hotplug.c | 72 ++++++++++++++++++-------------------------------
 1 file changed, 26 insertions(+), 46 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b56936d..acad666 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1223,57 +1223,37 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
     if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
         teardownlabel = true;

-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -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->info->alias, -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;
+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("guest unexpectedly quit during hotplug"));
+        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 (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0,
+                                             configfd_name, priv->qemuCaps)))
+        goto error;

-        qemuDomainObjEnterMonitor(driver, vm);
-        ret = qemuMonitorAddPCIHostDevice(priv->mon, hostAddr, guestAddr);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0)
-            goto error;
+    qemuDomainObjEnterMonitor(driver, vm);
+    ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
+                                     configfd, configfd_name);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        goto error;

-        hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-    }
     virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
     if (ret < 0)
         goto error;
-- 
2.8.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]