From nobody Thu May 15 11:33:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150721264659119.395495752408465; Thu, 5 Oct 2017 07:10:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E9C1C059B60; Thu, 5 Oct 2017 14:10:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 062E160636; Thu, 5 Oct 2017 14:10:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C0BE018355CA; Thu, 5 Oct 2017 14:10:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v95DN2CP006196 for ; Thu, 5 Oct 2017 09:23:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4263B63632; Thu, 5 Oct 2017 13:23:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-80.phx2.redhat.com [10.3.117.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2427163638 for ; Thu, 5 Oct 2017 13:23:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2E9C1C059B60 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 5 Oct 2017 09:22:17 -0400 Message-Id: <20171005132223.6751-11-jferlan@redhat.com> In-Reply-To: <20171005132223.6751-1-jferlan@redhat.com> References: <20171005132223.6751-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 10/16] conf, qemu: Replace iscsisrc fields with virStorageSourcePtr X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 05 Oct 2017 14:10:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than picking apart the two pieces we need/want (path, hosts, and auth)- let's just use the new virDomainDiskStorageSourceNew API in order to allocate and use a virStorageSourcePtr. The end result is that qemuBuildSCSIiSCSIHostdevDrvStr doesn't need to "fake" one for the qemuBuildNetworkDriveStr call. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 71 ++++++++++++++++++++++++++++-----------------= ---- src/conf/domain_conf.h | 5 +--- src/qemu/qemu_command.c | 10 +------ src/qemu/qemu_domain.c | 8 +++--- src/qemu/qemu_hotplug.c | 2 +- 5 files changed, 47 insertions(+), 49 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c2be9b7155..c9a0628001 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2497,10 +2497,9 @@ virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostde= vSubsysSCSIiSCSIPtr iscsisrc { if (!iscsisrc) return; - VIR_FREE(iscsisrc->path); - virStorageNetHostDefFree(iscsisrc->nhosts, iscsisrc->hosts); - virStorageAuthDefFree(iscsisrc->auth); - iscsisrc->auth =3D NULL; + + virStorageSourceFree(iscsisrc->src); + iscsisrc->src =3D NULL; } =20 =20 @@ -4373,7 +4372,7 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr d= ev, if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE= _ISCSI) { virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.is= csi; =20 - if (virDomainPostParseCheckISCSIPath(&iscsisrc->path) < 0) + if (virDomainPostParseCheckISCSIPath(&iscsisrc->src->path) < 0) return -1; } =20 @@ -6915,7 +6914,8 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, } =20 static int -virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode, +virDomainHostdevSubsysSCSIiSCSIDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr sourcenode, virDomainHostdevSubsysSCSIPtr d= ef) { int ret =3D -1; @@ -6924,24 +6924,29 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodeP= tr sourcenode, virStorageAuthDefPtr authdef =3D NULL; virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &def->u.iscsi; =20 - /* 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 (!(iscsisrc->src =3D virDomainDiskStorageSourceNew(xmlopt))) + return -1; + iscsisrc->src->type =3D VIR_STORAGE_TYPE_NETWORK; + iscsisrc->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; =20 - if (!(iscsisrc->path =3D virXMLPropString(sourcenode, "name"))) { + if (!(iscsisrc->src->path =3D virXMLPropString(sourcenode, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing iSCSI hostdev source path name")); goto cleanup; } =20 - if (virDomainStorageNetworkParseHosts(sourcenode, &iscsisrc->hosts, - &iscsisrc->nhosts) < 0) + if (virDomainStorageNetworkParseHosts(sourcenode, &iscsisrc->src->host= s, + &iscsisrc->src->nhosts) < 0) goto cleanup; =20 - if (iscsisrc->nhosts < 1) { + if (iscsisrc->src->nhosts < 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing the host address for the iSCSI hostdev")= ); goto cleanup; } - if (iscsisrc->nhosts > 1) { + if (iscsisrc->src->nhosts > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("only one source host address may be specified " "for the iSCSI hostdev")); @@ -6967,7 +6972,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr= sourcenode, authdef->secrettype); goto cleanup; } - iscsisrc->auth =3D authdef; + iscsisrc->src->auth =3D authdef; authdef =3D NULL; } cur =3D cur->next; @@ -6980,7 +6985,8 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr= sourcenode, } =20 static int -virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode, +virDomainHostdevSubsysSCSIDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr sourcenode, virDomainHostdevSubsysSCSIPtr scsisr= c) { char *protocol =3D NULL; @@ -6998,7 +7004,8 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sour= cenode, } =20 if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISC= SI) - ret =3D virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scs= isrc); + ret =3D virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlopt, sourcen= ode, + scsisrc); else ret =3D virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsi= src); =20 @@ -7099,7 +7106,8 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomai= nHostdevDefPtr def, } =20 static int -virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, +virDomainHostdevDefParseXMLSubsys(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, const char *type, virDomainHostdevDefPtr def, @@ -7243,7 +7251,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: - if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc) < 0) + if (virDomainHostdevSubsysSCSIDefParseXML(xmlopt, sourcenode, scsi= src) < 0) goto error; break; =20 @@ -10164,7 +10172,8 @@ virDomainFSDefParseXML(xmlNodePtr node, } =20 static int -virDomainActualNetDefParseXML(xmlNodePtr node, +virDomainActualNetDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, xmlXPathContextPtr ctxt, virDomainNetDefPtr parent, virDomainActualNetDefPtr *def, @@ -10274,7 +10283,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, VIR_STRDUP(addrtype, "usb") < 0) goto error; hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, + if (virDomainHostdevDefParseXMLSubsys(xmlopt, node, ctxt, addrtype, hostdev, flags) < 0) { goto error; } @@ -10607,7 +10616,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, (flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) && def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && virXMLNodeNameEqual(cur, "actual")) { - if (virDomainActualNetDefParseXML(cur, ctxt, def, + if (virDomainActualNetDefParseXML(xmlopt, cur, ctxt, def, &actual, flags) < 0) { goto error; } @@ -10868,7 +10877,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_STRDUP(addrtype, "usb") < 0) goto error; hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, + if (virDomainHostdevDefParseXMLSubsys(xmlopt, node, ctxt, addrtype, hostdev, flags) < 0) { goto error; } @@ -14466,7 +14475,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, switch (def->mode) { case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS: /* parse managed/mode/type, and the element */ - if (virDomainHostdevDefParseXMLSubsys(node, ctxt, type, def, flags= ) < 0) + if (virDomainHostdevDefParseXMLSubsys(xmlopt, node, ctxt, type, de= f, flags) < 0) goto error; break; case VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES: @@ -15440,9 +15449,9 @@ virDomainHostdevMatchSubsysSCSIiSCSI(virDomainHostd= evDefPtr first, virDomainHostdevSubsysSCSIiSCSIPtr second_iscsisrc =3D &second->source.subsys.u.scsi.u.iscsi; =20 - if (STREQ(first_iscsisrc->hosts[0].name, second_iscsisrc->hosts[0].nam= e) && - first_iscsisrc->hosts[0].port =3D=3D second_iscsisrc->hosts[0].por= t && - STREQ(first_iscsisrc->path, second_iscsisrc->path)) + if (STREQ(first_iscsisrc->src->hosts[0].name, second_iscsisrc->src->ho= sts[0].name) && + first_iscsisrc->src->hosts[0].port =3D=3D second_iscsisrc->src->ho= sts[0].port && + STREQ(first_iscsisrc->src->path, second_iscsisrc->src->path)) return 1; return 0; } @@ -22750,7 +22759,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protoc= ol); =20 virBufferAsprintf(buf, " protocol=3D'%s' name=3D'%s'", - protocol, iscsisrc->path); + protocol, iscsisrc->src->path); } =20 if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI= _HOST) { @@ -22802,9 +22811,9 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE= _ISCSI) { virBufferAddLit(buf, "hosts[0].= name); - if (iscsisrc->hosts[0].port) - virBufferAsprintf(buf, " port=3D'%u'", iscsisrc->hosts[0].= port); + virBufferEscapeString(buf, " name=3D'%s'", iscsisrc->src->host= s[0].name); + if (iscsisrc->src->hosts[0].port) + virBufferAsprintf(buf, " port=3D'%u'", iscsisrc->src->host= s[0].port); virBufferAddLit(buf, "/>\n"); } else { virBufferAsprintf(buf, "\n", @@ -22831,8 +22840,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, =20 if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI= && scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISC= SI && - iscsisrc->auth) { - if (virStorageAuthDefFormat(buf, iscsisrc->auth) < 0) + iscsisrc->src->auth) { + if (virStorageAuthDefFormat(buf, iscsisrc->src->auth) < 0) return -1; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ca334e0147..dd3017e31b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -357,10 +357,7 @@ struct _virDomainHostdevSubsysSCSIHost { typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSI= iSCSI; typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPt= r; struct _virDomainHostdevSubsysSCSIiSCSI { - char *path; - size_t nhosts; - virStorageNetHostDefPtr hosts; - virStorageAuthDefPtr auth; + virStorageSourcePtr src; }; =20 typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 97c4890935..26a98bd7e9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4952,21 +4952,13 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev) { char *source =3D NULL; - virStorageSource src; qemuDomainHostdevPrivatePtr hostdevPriv =3D QEMU_DOMAIN_HOSTDEV_PRIVAT= E(dev); =20 - memset(&src, 0, sizeof(src)); - virDomainHostdevSubsysSCSIPtr scsisrc =3D &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.iscsi; =20 - src.protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - src.path =3D iscsisrc->path; - src.hosts =3D iscsisrc->hosts; - src.nhosts =3D iscsisrc->nhosts; - /* Rather than pull what we think we want - use the network disk code = */ - source =3D qemuBuildNetworkDriveStr(&src, hostdevPriv->secinfo); + source =3D qemuBuildNetworkDriveStr(iscsisrc->src, hostdevPriv->secinf= o); =20 return source; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ad8d484cb1..ecf78b426c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1509,7 +1509,7 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn, virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.iscsi; =20 if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE= _ISCSI && - iscsisrc->auth) { + iscsisrc->src->auth) { =20 qemuDomainHostdevPrivatePtr hostdevPriv =3D QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev); @@ -1517,8 +1517,8 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn, if (!(hostdevPriv->secinfo =3D qemuDomainSecretInfoNew(conn, priv, hostdev->info->alias, VIR_SECRET_USAGE_TYPE_ISCSI, - iscsisrc->auth->username, - &iscsisrc->auth->seclookupdef, + iscsisrc->src->auth->username, + &iscsisrc->src->auth->seclookupd= ef, false))) return -1; } @@ -8046,7 +8046,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, /* Follow qemuSetupDiskCgroup() and qemuSetImageCgroupInte= rnal() * 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 { virDomainHostdevSubsysSCSIHostPtr scsihostsrc =3D &scsisrc= ->u.host; scsi =3D virSCSIDeviceNew(NULL, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7cfe8f1bc6..1b5385d967 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5065,7 +5065,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr drive= r, virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->= u.iscsi; virReportError(VIR_ERR_OPERATION_FAILED, _("host scsi iSCSI path %s not found"), - iscsisrc->path); + iscsisrc->src->path); } else { virDomainHostdevSubsysSCSIHostPtr scsihostsrc =3D &scsisrc->u.host; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list