[PATCH 2/2] qemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI

Peter Krempa pkrempa at redhat.com
Tue Sep 15 16:11:09 UTC 2020


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 at 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




More information about the libvir-list mailing list