mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 03:42:19 +00:00
conf,qemu: Replace iscsisrc fields with virStorageSourcePtr
Rather than picking apart the two pieces we need/want (path, hosts, and auth)- let's allocate/use a virStorageSourcePtr for iSCSI storage. The end result is that qemuBuildSCSIiSCSIHostdevDrvStr doesn't need to "fake" one for the qemuBuildNetworkDriveStr call.
This commit is contained in:
parent
2814f66f28
commit
626ea2d596
@ -2507,10 +2507,9 @@ virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc
|
|||||||
{
|
{
|
||||||
if (!iscsisrc)
|
if (!iscsisrc)
|
||||||
return;
|
return;
|
||||||
VIR_FREE(iscsisrc->path);
|
|
||||||
virStorageNetHostDefFree(iscsisrc->nhosts, iscsisrc->hosts);
|
virStorageSourceFree(iscsisrc->src);
|
||||||
virStorageAuthDefFree(iscsisrc->auth);
|
iscsisrc->src = NULL;
|
||||||
iscsisrc->auth = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4397,7 +4396,7 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
|
|||||||
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
|
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
|
||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||||
|
|
||||||
if (virDomainPostParseCheckISCSIPath(&iscsisrc->path) < 0)
|
if (virDomainPostParseCheckISCSIPath(&iscsisrc->src->path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7163,24 +7162,29 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
|
|||||||
virStorageAuthDefPtr authdef = NULL;
|
virStorageAuthDefPtr authdef = NULL;
|
||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi;
|
||||||
|
|
||||||
/* Similar to virDomainDiskSourceParse for a VIR_STORAGE_TYPE_NETWORK */
|
/* For the purposes of command line creation, this needs to look
|
||||||
|
* like a disk storage source */
|
||||||
|
if (VIR_ALLOC(iscsisrc->src) < 0)
|
||||||
|
return -1;
|
||||||
|
iscsisrc->src->type = VIR_STORAGE_TYPE_NETWORK;
|
||||||
|
iscsisrc->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
|
||||||
|
|
||||||
if (!(iscsisrc->path = virXMLPropString(sourcenode, "name"))) {
|
if (!(iscsisrc->src->path = virXMLPropString(sourcenode, "name"))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing iSCSI hostdev source path name"));
|
_("missing iSCSI hostdev source path name"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainStorageNetworkParseHosts(sourcenode, &iscsisrc->hosts,
|
if (virDomainStorageNetworkParseHosts(sourcenode, &iscsisrc->src->hosts,
|
||||||
&iscsisrc->nhosts) < 0)
|
&iscsisrc->src->nhosts) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (iscsisrc->nhosts < 1) {
|
if (iscsisrc->src->nhosts < 1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing the host address for the iSCSI hostdev"));
|
_("missing the host address for the iSCSI hostdev"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (iscsisrc->nhosts > 1) {
|
if (iscsisrc->src->nhosts > 1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("only one source host address may be specified "
|
_("only one source host address may be specified "
|
||||||
"for the iSCSI hostdev"));
|
"for the iSCSI hostdev"));
|
||||||
@ -7206,7 +7210,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
|
|||||||
authdef->secrettype);
|
authdef->secrettype);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
iscsisrc->auth = authdef;
|
iscsisrc->src->auth = authdef;
|
||||||
authdef = NULL;
|
authdef = NULL;
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -15715,9 +15719,9 @@ virDomainHostdevMatchSubsysSCSIiSCSI(virDomainHostdevDefPtr first,
|
|||||||
virDomainHostdevSubsysSCSIiSCSIPtr second_iscsisrc =
|
virDomainHostdevSubsysSCSIiSCSIPtr second_iscsisrc =
|
||||||
&second->source.subsys.u.scsi.u.iscsi;
|
&second->source.subsys.u.scsi.u.iscsi;
|
||||||
|
|
||||||
if (STREQ(first_iscsisrc->hosts[0].name, second_iscsisrc->hosts[0].name) &&
|
if (STREQ(first_iscsisrc->src->hosts[0].name, second_iscsisrc->src->hosts[0].name) &&
|
||||||
first_iscsisrc->hosts[0].port == second_iscsisrc->hosts[0].port &&
|
first_iscsisrc->src->hosts[0].port == second_iscsisrc->src->hosts[0].port &&
|
||||||
STREQ(first_iscsisrc->path, second_iscsisrc->path))
|
STREQ(first_iscsisrc->src->path, second_iscsisrc->src->path))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -23095,7 +23099,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
|
|||||||
virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol);
|
virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol);
|
||||||
|
|
||||||
virBufferAsprintf(buf, " protocol='%s' name='%s'",
|
virBufferAsprintf(buf, " protocol='%s' name='%s'",
|
||||||
protocol, iscsisrc->path);
|
protocol, iscsisrc->src->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
|
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
|
||||||
@ -23147,9 +23151,9 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
|
|||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
||||||
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
|
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
|
||||||
virBufferAddLit(buf, "<host");
|
virBufferAddLit(buf, "<host");
|
||||||
virBufferEscapeString(buf, " name='%s'", iscsisrc->hosts[0].name);
|
virBufferEscapeString(buf, " name='%s'", iscsisrc->src->hosts[0].name);
|
||||||
if (iscsisrc->hosts[0].port)
|
if (iscsisrc->src->hosts[0].port)
|
||||||
virBufferAsprintf(buf, " port='%u'", iscsisrc->hosts[0].port);
|
virBufferAsprintf(buf, " port='%u'", iscsisrc->src->hosts[0].port);
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(buf, "<adapter name='%s'/>\n",
|
virBufferAsprintf(buf, "<adapter name='%s'/>\n",
|
||||||
@ -23176,8 +23180,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
|
|||||||
|
|
||||||
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||||
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
|
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
|
||||||
iscsisrc->auth) {
|
iscsisrc->src->auth) {
|
||||||
if (virStorageAuthDefFormat(buf, iscsisrc->auth) < 0)
|
if (virStorageAuthDefFormat(buf, iscsisrc->src->auth) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,10 +357,7 @@ struct _virDomainHostdevSubsysSCSIHost {
|
|||||||
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
|
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
|
||||||
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
|
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
|
||||||
struct _virDomainHostdevSubsysSCSIiSCSI {
|
struct _virDomainHostdevSubsysSCSIiSCSI {
|
||||||
char *path;
|
virStorageSourcePtr src;
|
||||||
size_t nhosts;
|
|
||||||
virStorageNetHostDefPtr hosts;
|
|
||||||
virStorageAuthDefPtr auth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
|
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
|
||||||
|
@ -4959,21 +4959,13 @@ static char *
|
|||||||
qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
|
qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
|
||||||
{
|
{
|
||||||
char *source = NULL;
|
char *source = NULL;
|
||||||
virStorageSource src;
|
|
||||||
qemuDomainHostdevPrivatePtr hostdevPriv = QEMU_DOMAIN_HOSTDEV_PRIVATE(dev);
|
qemuDomainHostdevPrivatePtr hostdevPriv = QEMU_DOMAIN_HOSTDEV_PRIVATE(dev);
|
||||||
|
|
||||||
memset(&src, 0, sizeof(src));
|
|
||||||
|
|
||||||
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
|
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
|
||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||||
|
|
||||||
src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
|
|
||||||
src.path = iscsisrc->path;
|
|
||||||
src.hosts = iscsisrc->hosts;
|
|
||||||
src.nhosts = iscsisrc->nhosts;
|
|
||||||
|
|
||||||
/* Rather than pull what we think we want - use the network disk code */
|
/* Rather than pull what we think we want - use the network disk code */
|
||||||
source = qemuBuildNetworkDriveStr(&src, hostdevPriv->secinfo);
|
source = qemuBuildNetworkDriveStr(iscsisrc->src, hostdevPriv->secinfo);
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
@ -1496,9 +1496,10 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
|
|||||||
if (virHostdevIsSCSIDevice(hostdev)) {
|
if (virHostdevIsSCSIDevice(hostdev)) {
|
||||||
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
|
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
|
||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||||
|
virStorageSourcePtr src = iscsisrc->src;
|
||||||
|
|
||||||
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
|
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
|
||||||
iscsisrc->auth) {
|
src->auth) {
|
||||||
|
|
||||||
qemuDomainHostdevPrivatePtr hostdevPriv =
|
qemuDomainHostdevPrivatePtr hostdevPriv =
|
||||||
QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
|
QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev);
|
||||||
@ -1506,8 +1507,8 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
|
|||||||
if (!(hostdevPriv->secinfo =
|
if (!(hostdevPriv->secinfo =
|
||||||
qemuDomainSecretInfoNew(conn, priv, hostdev->info->alias,
|
qemuDomainSecretInfoNew(conn, priv, hostdev->info->alias,
|
||||||
VIR_SECRET_USAGE_TYPE_ISCSI,
|
VIR_SECRET_USAGE_TYPE_ISCSI,
|
||||||
iscsisrc->auth->username,
|
src->auth->username,
|
||||||
&iscsisrc->auth->seclookupdef,
|
&src->auth->seclookupdef,
|
||||||
false)))
|
false)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -8259,7 +8260,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
|
|||||||
/* Follow qemuSetupDiskCgroup() and qemuSetImageCgroupInternal()
|
/* Follow qemuSetupDiskCgroup() and qemuSetImageCgroupInternal()
|
||||||
* which does nothing for non local storage
|
* which does nothing for non local storage
|
||||||
*/
|
*/
|
||||||
VIR_DEBUG("Not updating /dev for hostdev iSCSI path '%s'", iscsisrc->path);
|
VIR_DEBUG("Not updating /dev for hostdev iSCSI path '%s'", iscsisrc->src->path);
|
||||||
} else {
|
} else {
|
||||||
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
|
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
|
||||||
scsi = virSCSIDeviceNew(NULL,
|
scsi = virSCSIDeviceNew(NULL,
|
||||||
|
@ -4926,7 +4926,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("host scsi iSCSI path %s not found"),
|
_("host scsi iSCSI path %s not found"),
|
||||||
iscsisrc->path);
|
iscsisrc->src->path);
|
||||||
} else {
|
} else {
|
||||||
virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
|
virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
|
||||||
&scsisrc->u.host;
|
&scsisrc->u.host;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user