From nobody Tue Apr 30 06:23:38 2024 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 1505173769561702.0437816379459; Mon, 11 Sep 2017 16:49:29 -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 DE2C0C0D8D58; Mon, 11 Sep 2017 23:49:26 +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 92295708E8; Mon, 11 Sep 2017 23:49:24 +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 D1C2418045C2; Mon, 11 Sep 2017 23:49:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8BNQN65012665 for ; Mon, 11 Sep 2017 19:26:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D0DA60317; Mon, 11 Sep 2017 23:26:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-114.phx2.redhat.com [10.3.117.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED4386031D for ; Mon, 11 Sep 2017 23:26:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE2C0C0D8D58 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Mon, 11 Sep 2017 19:26:18 -0400 Message-Id: <20170911232618.4433-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemu: Provide default LUN=0 for iSCSI if not provided 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.31]); Mon, 11 Sep 2017 23:49:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1477880 If the "/#" is missing from the provided iSCSI path, then we need to provide the default LUN of /0; otherwise, QEMU will fail to parse the URL causing a failure to either create the guest or hotplug attach the storage. During post parse, for any iSCSI disk or hostdev, scan the source path looking for the presence of '/', if found, then we can assume the LUN is provided. If not found, alter the input XML to add the "/0". This will cause the generated XML to have the generated value when the domain config is saved after post parse. Signed-off-by: John Ferlan --- v1: https://www.redhat.com/archives/libvir-list/2017-September/msg00122.ht= ml Alter the patch to make the adjustment during device post parsing rather than command line creation as requested by code review. This will alter the output XML as well as the command line arguments for those entries that don't supply a LUN. We had a few, so that works out testing wise! src/conf/domain_conf.c | 43 ++++++++++++++++++= ++++ .../qemuargv2xml-disk-drive-network-iscsi.xml | 2 +- .../qemuxml2argv-disk-drive-network-iscsi-lun.args | 2 +- .../qemuxml2argv-disk-drive-network-iscsi.args | 2 +- .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args | 2 +- .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args | 2 +- .../qemuxml2xmlout-disk-drive-network-iscsi.xml | 2 +- .../qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml | 2 +- .../qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml | 2 +- 9 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 676fc0f34..a43b25c31 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4308,16 +4308,54 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr= xmlopt, } =20 =20 +/** + * virDomainPostParseCheckISCSIPath + * @srcpath: Source path read (a/k/a, IQN) either disk or hostdev + * + * The details of an IQN is defined by RFC 3720 and 3721, but + * we just need to make sure there's a lun provided. If not + * provided, then default to zero. For an ISCSI LUN that is + * is provided by /dev/disk/by-path/... , then that path will + * have the specific lun requested. + * + * Returns 0 on success, -1 on failure + */ +static int +virDomainPostParseCheckISCSIPath(char **srcpath) +{ + char *path =3D NULL; + + if (strchr(*srcpath, '/')) + return 0; + + if (virAsprintf(&path, "%s/0", *srcpath) < 0) + return -1; + VIR_FREE(*srcpath); + VIR_STEAL_PTR(*srcpath, path); + return 0; +} + + static int virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev, const virDomainDef *def, virDomainXMLOptionPtr xmlopt) { + virDomainHostdevSubsysSCSIPtr scsisrc; + if (dev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) return 0; =20 switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: + scsisrc =3D &dev->source.subsys.u.scsi; + if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE= _ISCSI) { + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.is= csi; + + if (virDomainPostParseCheckISCSIPath(&iscsisrc->path) < 0) + return -1; + } + if (dev->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && virDomainHostdevAssignAddress(xmlopt, def, dev) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -4455,6 +4493,11 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, } } =20 + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + virDomainPostParseCheckISCSIPath(&disk->src->path) < 0) + return -1; + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && virDomainCheckVirtioOptions(disk->virtio) < 0) return -1; diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.x= ml b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml index 23542fa1d..694412b5c 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml @@ -16,7 +16,7 @@ /usr/bin/qemu-system-i686 - + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-l= un.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.= args index b25f3a0d6..0fbfd9a6d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args @@ -21,7 +21,7 @@ server,nowait \ -boot c \ -device virtio-scsi-pci,id=3Dscsi0,bus=3Dpci.0,addr=3D0x3 \ -usb \ --drive file=3Discsi://example.org:3260/iqn.1992-01.com.example,format=3Dra= w,\ +-drive file=3Discsi://example.org:3260/iqn.1992-01.com.example/0,format=3D= raw,\ if=3Dnone,id=3Ddrive-scsi0-0-0-0 \ -device scsi-block,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,\ drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.a= rgs b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args index a1d93af10..ed15fda21 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=3Discsi://example.org:6000/iqn.1992-01.com.example,format=3Dra= w,\ +-drive file=3Discsi://example.org:6000/iqn.1992-01.com.example/0,format=3D= raw,\ if=3Dnone,id=3Ddrive-virtio-disk0 \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,drive=3Ddrive-virtio-disk0,\ id=3Dvirtio-disk0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.arg= s b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args index 43c555a50..07ae9f592 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args @@ -22,7 +22,7 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --drive file=3Discsi://example.org:3260/iqn.1992-01.com.example,if=3Dnone,\ +-drive file=3Discsi://example.org:3260/iqn.1992-01.com.example/0,if=3Dnone= ,\ format=3Draw,id=3Ddrive-hostdev0 \ -device scsi-generic,bus=3Dscsi0.0,scsi-id=3D4,drive=3Ddrive-hostdev0,id= =3Dhostdev0 \ -drive file=3Discsi://example.org:3260/iqn.1992-01.com.example/1,if=3Dnone= ,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.= args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args index a78e3092c..d80c85918 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args @@ -22,7 +22,7 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --drive file=3Discsi://example.org:3260/iqn.1992-01.com.example,if=3Dnone,\ +-drive file=3Discsi://example.org:3260/iqn.1992-01.com.example/0,if=3Dnone= ,\ format=3Draw,id=3Ddrive-hostdev0 \ -device scsi-generic,bus=3Dscsi0.0,channel=3D0,scsi-id=3D2,lun=3D4,\ drive=3Ddrive-hostdev0,id=3Dhostdev0 \ diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-isc= si.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.x= ml index 23542fa1d..694412b5c 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-iscsi.xml @@ -16,7 +16,7 @@ /usr/bin/qemu-system-i686 - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi= .xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml index e19bce6ea..b7312ca4f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-lsi-iscsi.xml @@ -32,7 +32,7 @@ - +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-is= csi.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi= .xml index 37635b4f9..ddf780160 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-virtio-iscsi.xml @@ -32,7 +32,7 @@ - +
--=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list