[PATCH 0/2] qemu: Properly configure readonly iSCSI hostdevs

See patch 2/2. Peter Krempa (2): qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add <readonly/> to one of the iSCSI hostdevs qemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI src/qemu/qemu_command.c | 2 +- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args | 2 +- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 2 +- .../hostdev-scsi-virtio-scsi.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml | 1 + tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml | 1 + 6 files changed, 6 insertions(+), 4 deletions(-) -- 2.26.2

Test a readonly iSCSI backend as well. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args | 2 +- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 2 +- tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml | 1 + tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args index 3f007db2c3..bb8a466f70 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args @@ -47,7 +47,7 @@ format=raw,id=drive-hostdev2 \ -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\ drive=drive-hostdev2,id=hostdev2 \ -drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\ -format=raw,id=drive-hostdev3 \ +format=raw,id=drive-hostdev3,readonly=on \ -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ drive=drive-hostdev3,id=hostdev3 \ -drive file=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A@example.org:\ diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args index eb11d8f733..973ae5677a 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args @@ -48,7 +48,7 @@ format=raw,id=drive-hostdev2 \ drive=drive-hostdev2,id=hostdev2 \ -drive file.driver=iscsi,file.portal=example.org:3260,\ file.target=iqn.1992-01.com.example,file.lun=1,file.transport=tcp,if=none,\ -format=raw,id=drive-hostdev3 \ +format=raw,id=drive-hostdev3,readonly=on \ -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ drive=drive-hostdev3,id=hostdev3 \ -object secret,id=hostdev4-secret0,\ diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml index 4903a75d13..d096e0cb28 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml @@ -58,6 +58,7 @@ <source protocol='iscsi' name='iqn.1992-01.com.example/1'> <host name='example.org' port='3260'/> </source> + <readonly/> <address type='drive' controller='0' bus='0' target='2' unit='5'/> </hostdev> <hostdev mode='subsystem' type='scsi' managed='yes'> diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml b/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml index 3a2b10d815..3e2e21dc55 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml @@ -65,6 +65,7 @@ <source protocol='iscsi' name='iqn.1992-01.com.example/1'> <host name='example.org' port='3260'/> </source> + <readonly/> <address type='drive' controller='0' bus='0' target='2' unit='5'/> </hostdev> <hostdev mode='subsystem' type='scsi' managed='yes'> -- 2.26.2

The 'readonly' hostdev property is stored separately from the virStorageSource as some hostdevs are not described by a virStorage source. We need to propagate the flag to the virStorage source also for iSCSI backends as it's used to generate the backend properties. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1868856 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 2 +- .../hostdev-scsi-virtio-scsi.x86_64-latest.args | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c5c587b97d..0ba348e911 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5117,7 +5117,6 @@ qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDefPtr hostdev, src = scsisrc->u.host.src; src->type = VIR_STORAGE_TYPE_BLOCK; - src->readonly = hostdev->readonly; src->path = g_strdup_printf("/dev/%s", devstr); break; @@ -5132,6 +5131,7 @@ qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDefPtr hostdev, return NULL; } + src->readonly = hostdev->readonly; ret->storageNodeName = src->nodestorage; *backendAlias = src->nodestorage; diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args index 47c3f09db5..bd0d790b08 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args @@ -53,7 +53,7 @@ drive=libvirt-4-backend,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263 \ drive=libvirt-5-backend,id=hostdev2 \ -blockdev '{"driver":"iscsi","portal":"example.org:3260",\ "target":"iqn.1992-01.com.example","lun":1,"transport":"tcp",\ -"node-name":"libvirt-6-backend","read-only":false}' \ +"node-name":"libvirt-6-backend","read-only":true}' \ -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ drive=libvirt-6-backend,id=hostdev3 \ -object secret,id=libvirt-7-backend-secret0,\ -- 2.26.2

On 9/15/20 6:11 PM, Peter Krempa wrote:
See patch 2/2.
Peter Krempa (2): qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add <readonly/> to one of the iSCSI hostdevs qemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI
src/qemu/qemu_command.c | 2 +- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-2.8.0.args | 2 +- .../qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 2 +- .../hostdev-scsi-virtio-scsi.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml | 1 + tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml | 1 + 6 files changed, 6 insertions(+), 4 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Michal Privoznik
-
Peter Krempa