diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 66e63012109a902f82a6b16d7ada3ae5b9f9eeb7..be120b30f0b7e02b0c4871dd62a0852140e40c4e 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -819,6 +819,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src) * lun:1, * user:"username", * password-secret:"secret-alias", + * initiator-name:"iqn.2017-04.com.example:client" * } */ @@ -860,6 +861,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src) "s:transport", "tcp", "S:user", username, "S:password-secret", objalias, + "S:initiator-name", src->initiator.iqn, NULL)); goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b50e0c484820a1afb39e2be2002280f47aa968e..e8960105c31cd897534106cb0e9610ee63f89a3e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4682,6 +4682,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src, return -1; } + /* Use QEMU_CAPS_ISCSI_PASSWORD_SECRET as witness that iscsi 'initiator-name' + * option is available, it was introduced at the same time. */ + if (src->initiator.iqn && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("iSCSI initiator IQN not supported with this QEMU binary")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-network-iscsi-modern.args b/tests/qemuxml2argvdata/disk-network-iscsi-modern.args index 0a3e0bdb8b522d91bcc1591ef0f60a8ce55bf07f..a06b63a94059c0ce6b7652e4d021b8b194fcfcd9 100644 --- a/tests/qemuxml2argvdata/disk-network-iscsi-modern.args +++ b/tests/qemuxml2argvdata/disk-network-iscsi-modern.args @@ -49,4 +49,10 @@ id=virtio-disk3 \ file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,format=raw,\ if=none,id=drive-scsi0-0-0-0 \ -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ -drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-drive file.driver=iscsi,file.portal=example.org:3260,\ +file.target=iqn.1992-01.com.example:server,file.lun=0,file.transport=tcp,\ +file.initiator-name=iqn.1992-01.com.example:client,format=raw,if=none,\ +id=drive-scsi0-0-0-1 \ +-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=1,\ +drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 diff --git a/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml b/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml index fa2a889b54f1be2156177ecaa1af52d5f06e0e3d..d1be9c4e7dfb65419ba0341a14fbc8caba5d8219 100644 --- a/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml +++ b/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml @@ -55,6 +55,16 @@ + + + + + + + + + +