[libvirt] [PATCH v1 13/19] qemu: Refactor hotplug in preparation for vhost-scsi

Eric Farman farman at linux.vnet.ibm.com
Mon Jul 25 20:48:14 UTC 2016


Let's adjust some of the indentation in the hotplug code for the
upcoming vhost-scsi support, so we can keep existing code separate
from the new code that we'll add.

Signed-off-by: Eric Farman <farman at linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
---
 src/qemu/qemu_hotplug.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4e4bf82..02f7017 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2048,23 +2048,25 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
     if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0)
         goto cleanup;
 
-    if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
-        goto cleanup;
+    if (hostdev->source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST) {
+        if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
+            goto cleanup;
 
-    if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
-        goto cleanup;
+        if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
+            goto cleanup;
 
-    if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
-        goto cleanup;
+        if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
+            goto cleanup;
 
-    qemuDomainObjEnterMonitor(driver, vm);
+        qemuDomainObjEnterMonitor(driver, vm);
 
-    if (qemuMonitorAddDrive(priv->mon, drvstr) < 0)
-        goto exit_monitor;
-    driveAdded = true;
+        if (qemuMonitorAddDrive(priv->mon, drvstr) < 0)
+           goto exit_monitor;
+        driveAdded = true;
 
-    if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
-        goto exit_monitor;
+        if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+            goto exit_monitor;
+    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
-- 
1.9.1




More information about the libvir-list mailing list