[PATCH RFC] Rework existing code for scsi hostdev scsi_host protocol

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

 



In review feedback for my vhost-scsi series[1], we encountered a conflict
where existing structs/functions are named "...SCSIHost..." to represent
a hostdev type='scsi' protocol='scsi_host' element.  This is somewhat of
an abbreviation, but jives well with the other elements for this hostdev.
Specifically, a hostdev type='scsi' protocol='iscsi' uses structs and
functions named "...SCSIiSCSI..."

As my series is intending to add a hostdev type='scsi_host', the phrase
"SCSIHost" had to be avoided to prevent conflicts with existing code,
which means the abbreviation gets propogated in new and unplesant ways.

Let's remove this abbreviation and change the existing code from "SCSIHost"
to "SCSISCSIHost" so that a new hostdev type can be added without conflict.
The intention being "<type><protocol>" being used going forward.

[1] End of https://www.redhat.com/archives/libvir-list/2016-November/msg00738.html

Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_audit.c          |  2 +-
 src/conf/domain_conf.c           | 20 ++++++++---------
 src/conf/domain_conf.h           |  8 +++----
 src/qemu/qemu_cgroup.c           |  2 +-
 src/qemu/qemu_command.c          |  6 ++---
 src/qemu/qemu_conf.c             |  2 +-
 src/qemu/qemu_hotplug.c          |  4 ++--
 src/security/security_apparmor.c |  2 +-
 src/security/security_dac.c      |  4 ++--
 src/security/security_selinux.c  |  4 ++--
 src/util/virhostdev.c            | 47 ++++++++++++++++++++++------------------
 11 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 2decf02..164debb 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -432,7 +432,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
                  */
                 goto cleanup;
             } else {
-                virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+                virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc =
                     &scsisrc->u.host;
                 if (virAsprintfQuiet(&address, "%s:%u:%u:%llu",
                                      scsihostsrc->adapter, scsihostsrc->bus,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6e008e2..c985e21 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5907,14 +5907,14 @@ virDomainStorageHostParse(xmlNodePtr node,
 }
 
 static int
-virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
-                                          virDomainHostdevSubsysSCSIPtr scsisrc)
+virDomainHostdevSubsysSCSISCSIHostDefParseXML(xmlNodePtr sourcenode,
+                                              virDomainHostdevSubsysSCSIPtr scsisrc)
 {
     int ret = -1;
     bool got_address = false, got_adapter = false;
     xmlNodePtr cur;
     char *bus = NULL, *target = NULL, *unit = NULL;
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
 
     cur = sourcenode->children;
     while (cur != NULL) {
@@ -6081,7 +6081,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
     if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
         ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc);
     else
-        ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
+        ret = virDomainHostdevSubsysSCSISCSIHostDefParseXML(sourcenode, scsisrc);
 
  cleanup:
     VIR_FREE(protocol);
@@ -13846,12 +13846,12 @@ virDomainHostdevMatchSubsysPCI(virDomainHostdevDefPtr first,
 }
 
 static int
-virDomainHostdevMatchSubsysSCSIHost(virDomainHostdevDefPtr first,
-                                    virDomainHostdevDefPtr second)
+virDomainHostdevMatchSubsysSCSISCSIHost(virDomainHostdevDefPtr first,
+                                        virDomainHostdevDefPtr second)
 {
-    virDomainHostdevSubsysSCSIHostPtr first_scsihostsrc =
+    virDomainHostdevSubsysSCSISCSIHostPtr first_scsihostsrc =
         &first->source.subsys.u.scsi.u.host;
-    virDomainHostdevSubsysSCSIHostPtr second_scsihostsrc =
+    virDomainHostdevSubsysSCSISCSIHostPtr second_scsihostsrc =
         &second->source.subsys.u.scsi.u.host;
 
     if (STREQ(first_scsihostsrc->adapter, second_scsihostsrc->adapter) &&
@@ -13898,7 +13898,7 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
             VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
             return virDomainHostdevMatchSubsysSCSIiSCSI(a, b);
         else
-            return virDomainHostdevMatchSubsysSCSIHost(a, b);
+            return virDomainHostdevMatchSubsysSCSISCSIHost(a, b);
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
         return 0;
     }
@@ -20808,7 +20808,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
     virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
     virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci;
     virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
 
     if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 541b600..4303d0e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -338,9 +338,9 @@ struct _virDomainHostdevSubsysPCI {
     int backend; /* enum virDomainHostdevSubsysPCIBackendType */
 };
 
-typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
-typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
-struct _virDomainHostdevSubsysSCSIHost {
+typedef struct _virDomainHostdevSubsysSCSISCSIHost virDomainHostdevSubsysSCSISCSIHost;
+typedef virDomainHostdevSubsysSCSISCSIHost *virDomainHostdevSubsysSCSISCSIHostPtr;
+struct _virDomainHostdevSubsysSCSISCSIHost {
     char *adapter;
     unsigned bus;
     unsigned target;
@@ -363,7 +363,7 @@ struct _virDomainHostdevSubsysSCSI {
     int sgio; /* enum virDomainDeviceSGIO */
     int rawio; /* enum virTristateBool */
     union {
-        virDomainHostdevSubsysSCSIHost host;
+        virDomainHostdevSubsysSCSISCSIHost host;
         virDomainHostdevSubsysSCSIiSCSI iscsi;
     } u;
 };
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 1443f7e..462f74d 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -357,7 +357,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
                 VIR_DEBUG("Not updating cgroups for hostdev iSCSI path '%s'",
                           iscsisrc->path);
             } else {
-                virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+                virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc =
                     &scsisrc->u.host;
                 if ((scsi = virSCSIDeviceNew(NULL,
                                              scsihostsrc->adapter,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4a5fce3..37ce596 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4706,10 +4706,10 @@ qemuBuildHubCommandLine(virCommandPtr cmd,
 
 
 static char *
-qemuBuildSCSIHostHostdevDrvStr(virDomainHostdevDefPtr dev)
+qemuBuildSCSISCSIHostHostdevDrvStr(virDomainHostdevDefPtr dev)
 {
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
 
     return virSCSIDeviceGetSgName(NULL,
                                   scsihostsrc->adapter,
@@ -4754,7 +4754,7 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
             goto error;
         virBufferAsprintf(&buf, "file=%s,if=none,format=raw", source);
     } else {
-        if (!(source = qemuBuildSCSIHostHostdevDrvStr(dev)))
+        if (!(source = qemuBuildSCSISCSIHostHostdevDrvStr(dev)))
             goto error;
         virBufferAsprintf(&buf, "file=/dev/%s,if=none", source);
     }
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0ed88f5..169467f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1198,7 +1198,7 @@ static char *
 qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
 {
     virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
     char *dev_name = NULL;
     char *dev_path = NULL;
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 6b3a068..a3acda6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2355,7 +2355,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
                            _("Unable to prepare scsi hostdev for iSCSI: %s"),
                            iscsisrc->path);
         } else {
-            virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+            virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to prepare scsi hostdev: %s:%u:%u:%llu"),
                            scsihostsrc->adapter, scsihostsrc->bus,
@@ -4583,7 +4583,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
                                _("host scsi iSCSI path %s not found"),
                                iscsisrc->path);
             } else {
-                 virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+                 virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc =
                      &scsisrc->u.host;
                  virReportError(VIR_ERR_OPERATION_FAILED,
                                 _("host scsi device %s:%u:%u.%llu not found"),
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index beddf6d..521df8e 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -893,7 +893,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+        virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
                              scsihostsrc->adapter, scsihostsrc->bus,
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index fd74e8b..e3a01ae 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -658,7 +658,7 @@ virSecurityDACSetHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+        virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
                              scsihostsrc->adapter, scsihostsrc->bus,
@@ -789,7 +789,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+        virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
                              scsihostsrc->adapter, scsihostsrc->bus,
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 89c93dc..c916028 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1479,7 +1479,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+        virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
 
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
@@ -1684,7 +1684,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+        virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
                              scsihostsrc->adapter, scsihostsrc->bus,
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 9c2262e..13ee522 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -1044,13 +1044,13 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
 }
 
 static int
-virHostdevUpdateActiveSCSIHostDevices(virHostdevManagerPtr mgr,
-                                      virDomainHostdevDefPtr hostdev,
-                                      virDomainHostdevSubsysSCSIPtr scsisrc,
-                                      const char *drv_name,
-                                      const char *dom_name)
+virHostdevUpdateActiveSCSISCSIHostDevices(virHostdevManagerPtr mgr,
+                                          virDomainHostdevDefPtr hostdev,
+                                          virDomainHostdevSubsysSCSIPtr scsisrc,
+                                          const char *drv_name,
+                                          const char *dom_name)
 {
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
     virSCSIDevicePtr scsi = NULL;
     virSCSIDevicePtr tmp = NULL;
     int ret = -1;
@@ -1107,8 +1107,11 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
         if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
             continue;  /* Not supported for iSCSI */
         } else {
-            if (virHostdevUpdateActiveSCSIHostDevices(mgr, hostdev, scsisrc,
-                                                      drv_name, dom_name) < 0)
+            if (virHostdevUpdateActiveSCSISCSIHostDevices(mgr,
+                                                          hostdev,
+                                                          scsisrc,
+                                                          drv_name,
+                                                          dom_name) < 0)
                 goto cleanup;
         }
     }
@@ -1340,11 +1343,11 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr,
 }
 
 static int
-virHostdevPrepareSCSIHostDevices(virDomainHostdevDefPtr hostdev,
-                                 virDomainHostdevSubsysSCSIPtr scsisrc,
-                                 virSCSIDeviceListPtr list)
+virHostdevPrepareSCSISCSIHostDevices(virDomainHostdevDefPtr hostdev,
+                                     virDomainHostdevSubsysSCSIPtr scsisrc,
+                                     virSCSIDeviceListPtr list)
 {
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
     virSCSIDevicePtr scsi;
     int ret = -1;
 
@@ -1406,7 +1409,9 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr mgr,
         if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
             continue;  /* Not supported for iSCSI */
         } else {
-            if (virHostdevPrepareSCSIHostDevices(hostdev, scsisrc, list) < 0)
+            if (virHostdevPrepareSCSISCSIHostDevices(hostdev,
+                                                     scsisrc,
+                                                     list) < 0)
                 goto cleanup;
         }
     }
@@ -1533,13 +1538,13 @@ virHostdevReAttachUSBDevices(virHostdevManagerPtr mgr,
 }
 
 static void
-virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr mgr,
-                                  virDomainHostdevDefPtr hostdev,
-                                  virDomainHostdevSubsysSCSIPtr scsisrc,
-                                  const char *drv_name,
-                                  const char *dom_name)
+virHostdevReAttachSCSISCSIHostDevices(virHostdevManagerPtr mgr,
+                                      virDomainHostdevDefPtr hostdev,
+                                      virDomainHostdevSubsysSCSIPtr scsisrc,
+                                      const char *drv_name,
+                                      const char *dom_name)
 {
-    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
+    virDomainHostdevSubsysSCSISCSIHostPtr scsihostsrc = &scsisrc->u.host;
     virSCSIDevicePtr scsi;
     virSCSIDevicePtr tmp;
 
@@ -1598,8 +1603,8 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr mgr,
         if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
             continue; /* Not supported for iSCSI */
         else
-            virHostdevReAttachSCSIHostDevices(mgr, hostdev, scsisrc,
-                                              drv_name, dom_name);
+            virHostdevReAttachSCSISCSIHostDevices(mgr, hostdev, scsisrc,
+                                                  drv_name, dom_name);
     }
     virObjectUnlock(mgr->activeSCSIHostdevs);
 }
-- 
1.9.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]