From nobody Sat Apr 27 05:38:55 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 1504714160723882.5783139624377; Wed, 6 Sep 2017 09:09:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F55CC057FAF; Wed, 6 Sep 2017 16:09:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1FBA5C544; Wed, 6 Sep 2017 16:09:18 +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 64C6E3FACE; Wed, 6 Sep 2017 16:09:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v86G5bY3014675 for ; Wed, 6 Sep 2017 12:05:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 99EE65C544; Wed, 6 Sep 2017 16:05:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-120.phx2.redhat.com [10.3.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62B004DA75 for ; Wed, 6 Sep 2017 16:05:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F55CC057FAF 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: Wed, 6 Sep 2017 12:05:32 -0400 Message-Id: <20170906160532.22612-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 06 Sep 2017 16:09:19 +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. Alter the command lines generated appropriately. This change does not effect the XML input files. One 'side effect' of this for the argv2xml is that if a "/0" is found on the command line, then the generated XML would need to add the "/0" to the output XML since it wouldn't be known whether it existed or not at qemu process creation time. Signed-off-by: John Ferlan --- NB: Investigated the history quite a bit between QEMU and libiscsi and it seems as though this probably never worked and of course never "tested" in a real environment. Ironically, in qapi/block-core.json, it is claimed that the LUN would default to 0, but the block/iscsi.c code that calls iscsi_parse_full_url would never (AFAICT) have supported not supplying some LUN on the command line. src/qemu/qemu_command.c | 20 ++++++++++++++++= ---- .../qemuargv2xml-disk-drive-network-iscsi.args | 2 +- .../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 +- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ed8cb6e..cff84de 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -830,10 +830,22 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, src->volume, src->path) < 0) goto cleanup; } else { - if (virAsprintf(&uri->path, "%s%s", - src->path[0] =3D=3D '/' ? "" : "/", - src->path) < 0) - goto cleanup; + if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + !strchr(src->path, '/')) { + + /* The details of 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. If ISCSI LUN is provided + * by /dev/disk/by-path/... , then that path will have the + * specific lun requested. */ + if (virAsprintf(&uri->path, "/%s/0", src->path) < 0) + goto cleanup; + } else { + if (virAsprintf(&uri->path, "%s%s", + src->path[0] =3D=3D '/' ? "" : "/", + src->path) < 0) + goto cleanup; + } } } =20 diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.a= rgs b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args index 62cc5c0..ec2e8dc 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args +++ b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.args @@ -16,7 +16,7 @@ QEMU_AUDIO_DRV=3Dnone \ -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=3Dvirtio \ -drive file=3Discsi://example.org:6000/iqn.1992-01.com.example/1,format=3D= raw,\ if=3Dvirtio \ diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.x= ml b/tests/qemuargv2xmldata/qemuargv2xml-disk-drive-network-iscsi.xml index 23542fa..694412b 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 b25f3a0..0fbfd9a 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 a1d93af..ed15fda 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 43c555a..07ae9f5 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 a78e309..d80c859 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 \ --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list