qemu: add support for domain disk initiator IQN

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2018-08-07 14:57:43 +02:00
parent 1c36109e37
commit 0e9ce2d290
4 changed files with 28 additions and 1 deletions

View File

@ -819,6 +819,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
* lun:1, * lun:1,
* user:"username", * user:"username",
* password-secret:"secret-alias", * password-secret:"secret-alias",
* initiator-name:"iqn.2017-04.com.example:client"
* } * }
*/ */
@ -860,6 +861,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
"s:transport", "tcp", "s:transport", "tcp",
"S:user", username, "S:user", username,
"S:password-secret", objalias, "S:password-secret", objalias,
"S:initiator-name", src->initiator.iqn,
NULL)); NULL));
goto cleanup; goto cleanup;

View File

@ -4682,6 +4682,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
return -1; 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; return 0;
} }

View File

@ -49,4 +49,10 @@ id=virtio-disk3 \
file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,format=raw,\ file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,format=raw,\
if=none,id=drive-scsi0-0-0-0 \ if=none,id=drive-scsi0-0-0-0 \
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=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

View File

@ -55,6 +55,16 @@
</source> </source>
<target dev='sda' bus='scsi'/> <target dev='sda' bus='scsi'/>
</disk> </disk>
<disk type='network' device='lun'>
<driver name='qemu' type='raw'/>
<source protocol='iscsi' name='iqn.1992-01.com.example:server/0'>
<host name='example.org' port='3260'/>
<initiator>
<iqn name='iqn.1992-01.com.example:client'/>
</initiator>
</source>
<target dev='sdb' bus='scsi'/>
</disk>
<controller type='usb' index='0'/> <controller type='usb' index='0'/>
<controller type='pci' index='0' model='pci-root'/> <controller type='pci' index='0' model='pci-root'/>
<controller type='scsi' index='0' model='virtio-scsi'/> <controller type='scsi' index='0' model='virtio-scsi'/>