Create a separate typedef for the hostdev union data describing SCSI
Then adjust the code to use the new pointer
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_audit.c | 7 +++---
src/conf/domain_conf.c | 40 ++++++++++++++++--------------
src/conf/domain_conf.h | 18 ++++++++------
src/qemu/qemu_cgroup.c | 7 +++---
src/qemu/qemu_command.c | 7 +++---
src/qemu/qemu_conf.c | 18 ++++++++------
src/qemu/qemu_hotplug.c | 12 ++++-----
src/security/security_apparmor.c | 10 +++-----
src/security/security_dac.c | 20 ++++++---------
src/security/security_selinux.c | 20 ++++++---------
src/util/virhostdev.c | 53 ++++++++++++++++------------------------
11 files changed, 98 insertions(+), 114 deletions(-)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index d3f0449..370dc3a 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -390,6 +390,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr
hostdev,
const char *virt;
virDomainHostdevSubsysUSBPtr usbsrc = &hostdev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
@@ -424,10 +425,8 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr
hostdev,
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
if (virAsprintfQuiet(&address, "%s:%d:%d:%d",
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit) < 0) {
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f1b9a46..e38771c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4025,6 +4025,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
bool got_address = false, got_adapter = false;
xmlNodePtr cur;
char *bus = NULL, *target = NULL, *unit = NULL;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
cur = node->children;
while (cur != NULL) {
@@ -4046,19 +4047,19 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
goto cleanup;
}
- if (virStrToLong_ui(bus, NULL, 0, &def->source.subsys.u.scsi.bus)
< 0) {
+ if (virStrToLong_ui(bus, NULL, 0, &scsisrc->bus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse bus '%s'"), bus);
goto cleanup;
}
- if (virStrToLong_ui(target, NULL, 0,
&def->source.subsys.u.scsi.target) < 0) {
+ if (virStrToLong_ui(target, NULL, 0, &scsisrc->target) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse target '%s'"),
target);
goto cleanup;
}
- if (virStrToLong_ui(unit, NULL, 0,
&def->source.subsys.u.scsi.unit) < 0) {
+ if (virStrToLong_ui(unit, NULL, 0, &scsisrc->unit) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse unit '%s'"), unit);
goto cleanup;
@@ -4072,8 +4073,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
"for scsi hostdev source"));
goto cleanup;
}
- if (!(def->source.subsys.u.scsi.adapter =
- virXMLPropString(cur, "name"))) {
+ if (!(scsisrc->adapter = virXMLPropString(cur, "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("'adapter' must be specified for scsi
hostdev source"));
goto cleanup;
@@ -4254,6 +4254,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
int backend;
int ret = -1;
virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
/* @managed can be read from the xml document - it is always an
* attribute of the toplevel element, no matter what type of
@@ -4311,8 +4312,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
goto error;
}
- if ((def->source.subsys.u.scsi.sgio =
- virDomainDeviceSGIOTypeFromString(sgio)) <= 0) {
+ if ((scsisrc->sgio = virDomainDeviceSGIOTypeFromString(sgio)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown sgio mode '%s'"), sgio);
goto error;
@@ -10139,10 +10139,13 @@ static int
virDomainHostdevMatchSubsysSCSI(virDomainHostdevDefPtr a,
virDomainHostdevDefPtr b)
{
- if (STREQ(a->source.subsys.u.scsi.adapter, b->source.subsys.u.scsi.adapter)
&&
- a->source.subsys.u.scsi.bus == b->source.subsys.u.scsi.bus &&
- a->source.subsys.u.scsi.target == b->source.subsys.u.scsi.target
&&
- a->source.subsys.u.scsi.unit == b->source.subsys.u.scsi.unit)
+ virDomainHostdevSubsysSCSIPtr ascsisrc = &a->source.subsys.u.scsi;
+ virDomainHostdevSubsysSCSIPtr bscsisrc = &b->source.subsys.u.scsi;
+
+ if (STREQ(ascsisrc->adapter, bscsisrc->adapter) &&
+ ascsisrc->bus == bscsisrc->bus &&
+ ascsisrc->target == bscsisrc->target &&
+ ascsisrc->unit == bscsisrc->unit)
return 1;
return 0;
}
@@ -15491,6 +15494,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;
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
pcisrc->backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
@@ -15559,12 +15563,10 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
virBufferAsprintf(buf, "<adapter name='%s'/>\n",
- def->source.subsys.u.scsi.adapter);
+ scsisrc->adapter);
virBufferAsprintf(buf, "<address %sbus='%d' target='%d'
unit='%d'/>\n",
includeTypeInAddr ? "type='scsi' " :
"",
- def->source.subsys.u.scsi.bus,
- def->source.subsys.u.scsi.target,
- def->source.subsys.u.scsi.unit);
+ scsisrc->bus, scsisrc->target, scsisrc->unit);
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -16960,6 +16962,7 @@ virDomainHostdevDefFormat(virBufferPtr buf,
unsigned int flags)
{
const char *mode = virDomainHostdevModeTypeToString(def->mode);
+ virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
const char *type;
if (!mode) {
@@ -16999,11 +17002,10 @@ virDomainHostdevDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " managed='%s'",
def->managed ? "yes" : "no");
- if (def->source.subsys.type ==
- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
- def->source.subsys.u.scsi.sgio)
+ if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
+ scsisrc->sgio)
virBufferAsprintf(buf, " sgio='%s'",
-
virDomainDeviceSGIOTypeToString(def->source.subsys.u.scsi.sgio));
+ virDomainDeviceSGIOTypeToString(scsisrc->sgio));
}
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f1f1929..273be7b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -409,6 +409,16 @@ struct _virDomainHostdevSubsysPCI {
int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};
+typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
+typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
+struct _virDomainHostdevSubsysSCSI {
+ char *adapter;
+ unsigned bus;
+ unsigned target;
+ unsigned unit;
+ int sgio; /* enum virDomainDeviceSGIO */
+};
+
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
@@ -416,13 +426,7 @@ struct _virDomainHostdevSubsys {
union {
virDomainHostdevSubsysUSB usb;
virDomainHostdevSubsysPCI pci;
- struct {
- char *adapter;
- unsigned bus;
- unsigned target;
- unsigned unit;
- int sgio; /* enum virDomainDeviceSGIO */
- } scsi;
+ virDomainHostdevSubsysSCSI scsi;
} u;
};
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index c18af84..0f95cbc 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -244,6 +244,7 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virPCIDevicePtr pci = NULL;
virUSBDevicePtr usb = NULL;
virSCSIDevicePtr scsi = NULL;
@@ -307,10 +308,8 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
if ((scsi = virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
dev->readonly,
dev->shareable)) == NULL)
goto cleanup;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d95566f..d990b6a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5125,13 +5125,12 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
qemuBuildCommandLineCallbacksPtr callbacks)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
char *sg = NULL;
sg = (callbacks->qemuGetSCSIDeviceSgName)(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit);
if (!sg)
goto error;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e62bec0..9809883 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -927,11 +927,12 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
if (!(key = qemuGetSharedDeviceKey(virDomainDiskGetSource(disk))))
goto cleanup;
} else {
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
if (!(dev_name = virSCSIDeviceGetDevName(NULL,
-
hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
-
hostdev->source.subsys.u.scsi.target,
-
hostdev->source.subsys.u.scsi.unit)))
+ scsisrc->adapter,
+ scsisrc->bus,
+ scsisrc->target,
+ scsisrc->unit)))
goto cleanup;
if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
@@ -1032,11 +1033,12 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
if (!(key = qemuGetSharedDeviceKey(virDomainDiskGetSource(disk))))
goto cleanup;
} else {
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
if (!(dev_name = virSCSIDeviceGetDevName(NULL,
-
hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
-
hostdev->source.subsys.u.scsi.target,
-
hostdev->source.subsys.u.scsi.unit)))
+ scsisrc->adapter,
+ scsisrc->bus,
+ scsisrc->target,
+ scsisrc->unit)))
goto cleanup;
if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f94e42d..1807702 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1573,12 +1573,11 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
if (qemuPrepareHostdevSCSIDevices(driver, vm->def->name,
&hostdev, 1)) {
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to prepare scsi hostdev: %s:%d:%d:%d"),
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit);
return -1;
}
@@ -3362,6 +3361,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
virDomainHostdevSubsysUSBPtr usbsrc = &subsys->u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &subsys->u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &subsys->u.scsi;
virDomainHostdevDefPtr detach = NULL;
int idx;
@@ -3396,8 +3396,8 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
virReportError(VIR_ERR_OPERATION_FAILED,
_("host scsi device %s:%d:%d.%d not found"),
- subsys->u.scsi.adapter, subsys->u.scsi.bus,
- subsys->u.scsi.target, subsys->u.scsi.unit);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit);
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index c2c4389..93841d1 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -803,6 +803,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
virDomainDefGetSecurityLabelDef(def, SECURITY_APPARMOR_NAME);
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
if (!secdef)
return -1;
@@ -860,12 +861,9 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
virSCSIDevicePtr scsi =
virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
- dev->readonly,
- dev->shareable);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ dev->readonly, dev->shareable);
if (!scsi)
goto done;
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 0844219..968568e 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -468,6 +468,7 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
virSecurityDACCallbackData cbdata;
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
int ret = -1;
if (!priv->dynamicOwnership)
@@ -529,12 +530,9 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
virSCSIDevicePtr scsi =
virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
- dev->readonly,
- dev->shareable);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ dev->readonly, dev->shareable);
if (!scsi)
goto done;
@@ -595,6 +593,7 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
virSecurityLabelDefPtr secdef;
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
int ret = -1;
secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
@@ -648,12 +647,9 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
virSCSIDevicePtr scsi =
virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
- dev->readonly,
- dev->shareable);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ dev->readonly, dev->shareable);
if (!scsi)
goto done;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 27300ed..a33ab45 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1321,6 +1321,7 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr
def,
{
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
int ret = -1;
switch (dev->source.subsys.type) {
@@ -1368,12 +1369,9 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr
def,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
virSCSIDevicePtr scsi =
virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
- dev->readonly,
- dev->shareable);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ dev->readonly, dev->shareable);
if (!scsi)
goto done;
@@ -1509,6 +1507,7 @@
virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
{
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
+ virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
int ret = -1;
switch (dev->source.subsys.type) {
@@ -1557,12 +1556,9 @@
virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
virSCSIDevicePtr scsi =
virSCSIDeviceNew(NULL,
- dev->source.subsys.u.scsi.adapter,
- dev->source.subsys.u.scsi.bus,
- dev->source.subsys.u.scsi.target,
- dev->source.subsys.u.scsi.unit,
- dev->readonly,
- dev->shareable);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ dev->readonly, dev->shareable);
if (!scsi)
goto done;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index f0a1193..1e52cc9 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -938,19 +938,18 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
virObjectLock(mgr->activeSCSIHostdevs);
for (i = 0; i < nhostdevs; i++) {
+ virDomainHostdevSubsysSCSIPtr scsisrc;
hostdev = hostdevs[i];
+ scsisrc = &hostdev->source.subsys.u.scsi;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
continue;
if (!(scsi = virSCSIDeviceNew(NULL,
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit,
- hostdev->readonly,
- hostdev->shareable)))
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ hostdev->readonly, hostdev->shareable)))
goto cleanup;
if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) {
@@ -1220,6 +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;
virSCSIDevicePtr scsi;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
@@ -1233,12 +1234,9 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
}
if (!(scsi = virSCSIDeviceNew(NULL,
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit,
- hostdev->readonly,
- hostdev->shareable)))
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ hostdev->readonly, hostdev->shareable)))
goto cleanup;
if (scsi && virSCSIDeviceListAdd(list, scsi) < 0) {
@@ -1383,6 +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;
virSCSIDevicePtr scsi;
virSCSIDevicePtr tmp;
@@ -1391,18 +1391,12 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
continue;
if (!(scsi = virSCSIDeviceNew(NULL,
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit,
- hostdev->readonly,
- hostdev->shareable))) {
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit,
+ hostdev->readonly, hostdev->shareable))) {
VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain
%s",
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit,
- dom_name);
+ scsisrc->adapter, scsisrc->bus, scsisrc->target,
+ scsisrc->unit, dom_name);
continue;
}
@@ -1412,20 +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",
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit);
+ scsisrc->adapter, scsisrc->bus,
+ scsisrc->target, scsisrc->unit);
virSCSIDeviceFree(scsi);
continue;
}
VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeSCSIHostdevs",
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit,
- dom_name);
+ scsisrc->adapter, scsisrc->bus, scsisrc->target,
+ scsisrc->unit, dom_name);
virSCSIDeviceListDel(hostdev_mgr->activeSCSIHostdevs, tmp,
drv_name, dom_name);
--
1.9.3