[PATCH v2 8/9] qemu: Use qemuAssignSCSIHostDeviceDriveAlias

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

 



When building the command line alias and for SCSI Host Device deletion,
use the common API to build the alias

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 12 +++++++-----
 src/qemu/qemu_hotplug.c | 12 ++++--------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 482f993..0c4b1f5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4534,6 +4534,7 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *source = NULL;
+    char *drivealias = NULL;
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
 
     if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
@@ -4545,9 +4546,12 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
             goto error;
         virBufferAsprintf(&buf, "file=/dev/%s,if=none", source);
     }
-    virBufferAsprintf(&buf, ",id=%s-%s",
-                      virDomainDeviceAddressTypeToString(dev->info->type),
-                      dev->info->alias);
+    VIR_FREE(source);
+
+    if (!(drivealias = qemuAssignSCSIHostDeviceDriveAlias(dev)))
+        goto error;
+    virBufferAsprintf(&buf, ",id=%s", drivealias);
+    VIR_FREE(drivealias);
 
     if (dev->readonly)
         virBufferAddLit(&buf, ",readonly=on");
@@ -4555,10 +4559,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
     if (virBufferCheckError(&buf) < 0)
         goto error;
 
-    VIR_FREE(source);
     return virBufferContentAndReset(&buf);
  error:
-    VIR_FREE(source);
     virBufferFreeAndReset(&buf);
     return NULL;
 }
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9576509..4d3e913 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3132,7 +3132,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
     size_t i;
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    char *drivestr = NULL;
+    char *drivealias = NULL;
     bool is_vfio = false;
 
     VIR_DEBUG("Removing host device %s from domain %p %s",
@@ -3144,15 +3144,11 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
     }
 
     if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
-        /* build the actual drive id string as generated during
-         * qemuBuildSCSIHostdevDrvStr that is passed to qemu */
-        if (virAsprintf(&drivestr, "%s-%s",
-                        virDomainDeviceAddressTypeToString(hostdev->info->type),
-                        hostdev->info->alias) < 0)
+        if (!(drivealias = qemuAssignSCSIHostDeviceDriveAlias(hostdev)))
             goto cleanup;
 
         qemuDomainObjEnterMonitor(driver, vm);
-        qemuMonitorDriveDel(priv->mon, drivestr);
+        qemuMonitorDriveDel(priv->mon, drivealias);
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
     }
@@ -3216,7 +3212,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
     ret = 0;
 
  cleanup:
-    VIR_FREE(drivestr);
+    VIR_FREE(drivealias);
     virObjectUnref(cfg);
     return ret;
 }
-- 
2.5.5

--
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]