]> xenbits.xensource.com Git - libvirt.git/commitdiff
hostdev: Introduce virDomainHostdevSubsysSCSIHost
authorJohn Ferlan <jferlan@redhat.com>
Fri, 20 Jun 2014 15:35:46 +0000 (11:35 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 24 Jul 2014 10:39:28 +0000 (06:39 -0400)
Split virDomainHostdevSubsysSCSI further. In preparation for having
either SCSI or iSCSI data, create a union in virDomainHostdevSubsysSCSI
to contain just a virDomainHostdevSubsysSCSIHost to describe the
'scsi_host' host device

src/conf/domain_audit.c
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_cgroup.c
src/qemu/qemu_command.c
src/qemu/qemu_conf.c
src/qemu/qemu_hotplug.c
src/security/security_apparmor.c
src/security/security_dac.c
src/security/security_selinux.c
src/util/virhostdev.c

index 370dc3aa767242c7ec3125c689f1dbecc6e922cd..ee9baa27eab5c3869bd13892eb94bd4ba91dda2f 100644 (file)
@@ -423,14 +423,16 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
                 goto cleanup;
             }
             break;
-        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+            virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
             if (virAsprintfQuiet(&address, "%s:%d:%d:%d",
-                                 scsisrc->adapter, scsisrc->bus,
-                                 scsisrc->target, scsisrc->unit) < 0) {
+                                 scsihostsrc->adapter, scsihostsrc->bus,
+                                 scsihostsrc->target, scsihostsrc->unit) < 0) {
                 VIR_WARN("OOM while encoding audit message");
                 goto cleanup;
             }
             break;
+        }
         default:
             VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
                      hostdev->source.subsys.type);
index 79545d59671fd8e1e26a38ad0a32d5a9d3db162d..bd8b434373cc0059aa5ddb3a96e3aeb13748e03b 100644 (file)
@@ -1726,7 +1726,7 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
         break;
     case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
         if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
-            VIR_FREE(def->source.subsys.u.scsi.adapter);
+            VIR_FREE(def->source.subsys.u.scsi.u.host.adapter);
         break;
     }
 }
@@ -4011,16 +4011,16 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
 }
 
 static int
-virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
-                                      virDomainHostdevDefPtr def)
+virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
+                                          virDomainHostdevSubsysSCSIPtr scsisrc)
 {
     int ret = -1;
     bool got_address = false, got_adapter = false;
     xmlNodePtr cur;
     char *bus = NULL, *target = NULL, *unit = NULL;
-    virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
+    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
 
-    cur = node->children;
+    cur = sourcenode->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
             if (xmlStrEqual(cur->name, BAD_CAST "address")) {
@@ -4040,19 +4040,20 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(bus, NULL, 0, &scsisrc->bus) < 0) {
+                if (virStrToLong_ui(bus, NULL, 0, &scsihostsrc->bus) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse bus '%s'"), bus);
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(target, NULL, 0, &scsisrc->target) < 0) {
+                if (virStrToLong_ui(target, NULL, 0,
+                                    &scsihostsrc->target) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse target '%s'"), target);
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(unit, NULL, 0, &scsisrc->unit) < 0) {
+                if (virStrToLong_ui(unit, NULL, 0, &scsihostsrc->unit) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse unit '%s'"), unit);
                     goto cleanup;
@@ -4066,7 +4067,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
                                      "for scsi hostdev source"));
                     goto cleanup;
                 }
-                if (!(scsisrc->adapter = virXMLPropString(cur, "name"))) {
+                if (!(scsihostsrc->adapter = virXMLPropString(cur, "name"))) {
                     virReportError(VIR_ERR_XML_ERROR, "%s",
                                    _("'adapter' must be specified for scsi hostdev source"));
                     goto cleanup;
@@ -4098,6 +4099,13 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
     return ret;
 }
 
+static int
+virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
+                                      virDomainHostdevSubsysSCSIPtr scsisrc)
+{
+    return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
+}
+
 /* Check if a drive type address $controller:0:0:$unit is already
  * taken by a disk or not.
  */
@@ -4336,7 +4344,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
         break;
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
-        if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, def) < 0)
+        if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc) < 0)
             goto error;
         break;
 
@@ -10231,17 +10239,18 @@ virDomainHostdevMatchSubsysPCI(virDomainHostdevDefPtr first,
 }
 
 static int
-virDomainHostdevMatchSubsysSCSI(virDomainHostdevDefPtr first,
-                                virDomainHostdevDefPtr second)
-{
-    virDomainHostdevSubsysSCSIPtr first_scsisrc = &first->source.subsys.u.scsi;
-    virDomainHostdevSubsysSCSIPtr second_scsisrc =
-        &second->source.subsys.u.scsi;
-
-    if (STREQ(first_scsisrc->adapter, second_scsisrc->adapter) &&
-        first_scsisrc->bus == second_scsisrc->bus &&
-        first_scsisrc->target == second_scsisrc->target &&
-        first_scsisrc->unit == second_scsisrc->unit)
+virDomainHostdevMatchSubsysSCSIHost(virDomainHostdevDefPtr first,
+                                    virDomainHostdevDefPtr second)
+{
+    virDomainHostdevSubsysSCSIHostPtr first_scsihostsrc =
+        &first->source.subsys.u.scsi.u.host;
+    virDomainHostdevSubsysSCSIHostPtr second_scsihostsrc =
+        &second->source.subsys.u.scsi.u.host;
+
+    if (STREQ(first_scsihostsrc->adapter, second_scsihostsrc->adapter) &&
+        first_scsihostsrc->bus == second_scsihostsrc->bus &&
+        first_scsihostsrc->target == second_scsihostsrc->target &&
+        first_scsihostsrc->unit == second_scsihostsrc->unit)
         return 1;
     return 0;
 }
@@ -10259,7 +10268,7 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
         return virDomainHostdevMatchSubsysUSB(a, b);
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
-        return virDomainHostdevMatchSubsysSCSI(a, b);
+        return virDomainHostdevMatchSubsysSCSIHost(a, b);
     }
     return 0;
 }
@@ -15526,6 +15535,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;
 
     if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
         pcisrc->backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
@@ -15594,10 +15604,11 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
         break;
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
         virBufferAsprintf(buf, "<adapter name='%s'/>\n",
-                          scsisrc->adapter);
+                          scsihostsrc->adapter);
         virBufferAsprintf(buf, "<address %sbus='%d' target='%d' unit='%d'/>\n",
                           includeTypeInAddr ? "type='scsi' " : "",
-                          scsisrc->bus, scsisrc->target, scsisrc->unit);
+                          scsihostsrc->bus, scsihostsrc->target,
+                          scsihostsrc->unit);
         break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
index df5d421ae21294346672b3c2a843b631ae4467f8..42a088a8bc064d710cd19d1e8f018309e3ab4844 100644 (file)
@@ -407,14 +407,22 @@ struct _virDomainHostdevSubsysPCI {
     int backend; /* enum virDomainHostdevSubsysPCIBackendType */
 };
 
-typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
-typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
-struct _virDomainHostdevSubsysSCSI {
+typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
+typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
+struct _virDomainHostdevSubsysSCSIHost {
     char *adapter;
     unsigned bus;
     unsigned target;
     unsigned unit;
+};
+
+typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
+typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
+struct _virDomainHostdevSubsysSCSI {
     int sgio; /* enum virDomainDeviceSGIO */
+    union {
+        virDomainHostdevSubsysSCSIHost host;
+    } u;
 };
 
 typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
index 9155b9a5820083d4f673102105d584e8b38ec1a5..3d69b0991b0ef402695c650dd8332d7ea189fb07 100644 (file)
@@ -306,10 +306,11 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm,
             }
             break;
 
-        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+            virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
             if ((scsi = virSCSIDeviceNew(NULL,
-                                         scsisrc->adapter, scsisrc->bus,
-                                         scsisrc->target, scsisrc->unit,
+                                         scsihostsrc->adapter, scsihostsrc->bus,
+                                         scsihostsrc->target, scsihostsrc->unit,
                                          dev->readonly,
                                          dev->shareable)) == NULL)
                 goto cleanup;
@@ -318,6 +319,8 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm,
                                          qemuSetupHostSCSIDeviceCgroup,
                                          vm) < 0)
                 goto cleanup;
+            break;
+        }
 
         default:
             break;
index 470cafcacd4b1b783c41452590d57abd18358350..9c7e894070b1a1395bde3ec6652de6da9501d81d 100644 (file)
@@ -5131,11 +5131,14 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
+    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
     char *sg = NULL;
 
     sg = (callbacks->qemuGetSCSIDeviceSgName)(NULL,
-                                              scsisrc->adapter, scsisrc->bus,
-                                              scsisrc->target, scsisrc->unit);
+                                              scsihostsrc->adapter,
+                                              scsihostsrc->bus,
+                                              scsihostsrc->target,
+                                              scsihostsrc->unit);
     if (!sg)
         goto error;
 
index 98098830056b2e46e2dd64b70ce8d63f930db600..9636a87097a1ad62cd7c73bcaa572b5d618e8445 100644 (file)
@@ -928,11 +928,12 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
             goto cleanup;
     } else {
         virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         if (!(dev_name = virSCSIDeviceGetDevName(NULL,
-                                                 scsisrc->adapter,
-                                                 scsisrc->bus,
-                                                 scsisrc->target,
-                                                 scsisrc->unit)))
+                                                 scsihostsrc->adapter,
+                                                 scsihostsrc->bus,
+                                                 scsihostsrc->target,
+                                                 scsihostsrc->unit)))
             goto cleanup;
 
         if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
@@ -1034,11 +1035,12 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
             goto cleanup;
     } else {
         virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         if (!(dev_name = virSCSIDeviceGetDevName(NULL,
-                                                 scsisrc->adapter,
-                                                 scsisrc->bus,
-                                                 scsisrc->target,
-                                                 scsisrc->unit)))
+                                                 scsihostsrc->adapter,
+                                                 scsihostsrc->bus,
+                                                 scsihostsrc->target,
+                                                 scsihostsrc->unit)))
             goto cleanup;
 
         if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
index 1807702ee538286695e63547f897847c82115f73..7df58326d7ea6551d9d31fe5dcc7437b70663975 100644 (file)
@@ -1574,10 +1574,11 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
     if (qemuPrepareHostdevSCSIDevices(driver, vm->def->name,
                                       &hostdev, 1)) {
         virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to prepare scsi hostdev: %s:%d:%d:%d"),
-                       scsisrc->adapter, scsisrc->bus,
-                       scsisrc->target, scsisrc->unit);
+                       scsihostsrc->adapter, scsihostsrc->bus,
+                       scsihostsrc->target, scsihostsrc->unit);
         return -1;
     }
 
@@ -3393,12 +3394,14 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
                                usbsrc->vendor, usbsrc->product);
             }
             break;
-        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+        case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+            virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("host scsi device %s:%d:%d.%d not found"),
-                           scsisrc->adapter, scsisrc->bus,
-                           scsisrc->target, scsisrc->unit);
+                           scsihostsrc->adapter, scsihostsrc->bus,
+                           scsihostsrc->target, scsihostsrc->unit);
             break;
+        }
         default:
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("unexpected hostdev type %d"), subsys->type);
index 7796121a485772f3c2d1ed586020239b81f7c34d..a3f10255028df66641878545fb4fdd788342a391 100644 (file)
@@ -870,10 +870,11 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
-                             scsisrc->adapter, scsisrc->bus,
-                             scsisrc->target, scsisrc->unit,
+                             scsihostsrc->adapter, scsihostsrc->bus,
+                             scsihostsrc->target, scsihostsrc->unit,
                              dev->readonly, dev->shareable);
 
          if (!scsi)
index 0c94fa7d6df0c6e444f66c927aff36a5589ec0ab..9ef413e9aeee6ff26a1087219c36abaaabeaa1cd 100644 (file)
@@ -571,10 +571,11 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
-                             scsisrc->adapter, scsisrc->bus,
-                             scsisrc->target, scsisrc->unit,
+                             scsihostsrc->adapter, scsihostsrc->bus,
+                             scsihostsrc->target, scsihostsrc->unit,
                              dev->readonly, dev->shareable);
 
         if (!scsi)
@@ -688,10 +689,11 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
-                             scsisrc->adapter, scsisrc->bus,
-                             scsisrc->target, scsisrc->unit,
+                             scsihostsrc->adapter, scsihostsrc->bus,
+                             scsihostsrc->target, scsihostsrc->unit,
                              dev->readonly, dev->shareable);
 
         if (!scsi)
index a33ab45771dab47ed58ffa222f203122f2397173..f32816faec65c4aacebebbb463f1f8f7e58bef82 100644 (file)
@@ -1367,10 +1367,11 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
-                             scsisrc->adapter, scsisrc->bus,
-                             scsisrc->target, scsisrc->unit,
+                             scsihostsrc->adapter, scsihostsrc->bus,
+                             scsihostsrc->target, scsihostsrc->unit,
                              dev->readonly, dev->shareable);
 
         if (!scsi)
@@ -1554,10 +1555,11 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
         virSCSIDevicePtr scsi =
             virSCSIDeviceNew(NULL,
-                             scsisrc->adapter, scsisrc->bus,
-                             scsisrc->target, scsisrc->unit,
+                             scsihostsrc->adapter, scsihostsrc->bus,
+                             scsihostsrc->target, scsihostsrc->unit,
                              dev->readonly, dev->shareable);
 
             if (!scsi)
index 1e52cc96cb08cc22e29c09560e1fb8e6e2edda81..83f85aaba7b2ab4c25c6d9057079641d6f404d9d 100644 (file)
@@ -938,17 +938,17 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
 
     virObjectLock(mgr->activeSCSIHostdevs);
     for (i = 0; i < nhostdevs; i++) {
-        virDomainHostdevSubsysSCSIPtr scsisrc;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc;
         hostdev = hostdevs[i];
-        scsisrc = &hostdev->source.subsys.u.scsi;
+        scsihostsrc = &hostdev->source.subsys.u.scsi.u.host;
 
         if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
             hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
             continue;
 
         if (!(scsi = virSCSIDeviceNew(NULL,
-                                      scsisrc->adapter, scsisrc->bus,
-                                      scsisrc->target, scsisrc->unit,
+                                      scsihostsrc->adapter, scsihostsrc->bus,
+                                      scsihostsrc->target, scsihostsrc->unit,
                                       hostdev->readonly, hostdev->shareable)))
             goto cleanup;
 
@@ -1219,8 +1219,8 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
     /* Loop 1: build temporary list */
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
-        virDomainHostdevSubsysSCSIPtr scsisrc =
-            &hostdev->source.subsys.u.scsi;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+            &hostdev->source.subsys.u.scsi.u.host;
         virSCSIDevicePtr scsi;
 
         if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
@@ -1234,8 +1234,8 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
         }
 
         if (!(scsi = virSCSIDeviceNew(NULL,
-                                      scsisrc->adapter, scsisrc->bus,
-                                      scsisrc->target, scsisrc->unit,
+                                      scsihostsrc->adapter, scsihostsrc->bus,
+                                      scsihostsrc->target, scsihostsrc->unit,
                                       hostdev->readonly, hostdev->shareable)))
             goto cleanup;
 
@@ -1381,8 +1381,8 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
     virObjectLock(hostdev_mgr->activeSCSIHostdevs);
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
-        virDomainHostdevSubsysSCSIPtr scsisrc =
-            &hostdev->source.subsys.u.scsi;
+        virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+            &hostdev->source.subsys.u.scsi.u.host;
         virSCSIDevicePtr scsi;
         virSCSIDevicePtr tmp;
 
@@ -1391,12 +1391,12 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
             continue;
 
         if (!(scsi = virSCSIDeviceNew(NULL,
-                                      scsisrc->adapter, scsisrc->bus,
-                                      scsisrc->target, scsisrc->unit,
+                                      scsihostsrc->adapter, scsihostsrc->bus,
+                                      scsihostsrc->target, scsihostsrc->unit,
                                       hostdev->readonly, hostdev->shareable))) {
             VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
-                     scsisrc->adapter, scsisrc->bus, scsisrc->target,
-                     scsisrc->unit, dom_name);
+                     scsihostsrc->adapter, scsihostsrc->bus,
+                     scsihostsrc->target, scsihostsrc->unit, dom_name);
             continue;
         }
 
@@ -1406,15 +1406,15 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
         if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeSCSIHostdevs, scsi))) {
             VIR_WARN("Unable to find device %s:%d:%d:%d "
                      "in list of active SCSI devices",
-                     scsisrc->adapter, scsisrc->bus,
-                     scsisrc->target, scsisrc->unit);
+                     scsihostsrc->adapter, scsihostsrc->bus,
+                     scsihostsrc->target, scsihostsrc->unit);
             virSCSIDeviceFree(scsi);
             continue;
         }
 
         VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeSCSIHostdevs",
-                   scsisrc->adapter, scsisrc->bus, scsisrc->target,
-                   scsisrc->unit, dom_name);
+                   scsihostsrc->adapter, scsihostsrc->bus,
+                   scsihostsrc->target, scsihostsrc->unit, dom_name);
 
         virSCSIDeviceListDel(hostdev_mgr->activeSCSIHostdevs, tmp,
                              drv_name, dom_name);