devices: disk: Handle pool=iscsi-direct volumes

I don't have a working setup for this so I'm not positive
it actually works, but this roughly matches what I see in
libvirt test suite data and docs

https://bugzilla.redhat.com/show_bug.cgi?id=1658511
This commit is contained in:
Cole Robinson 2019-06-14 20:35:41 -04:00
parent 147a3b4790
commit c52e220504
4 changed files with 58 additions and 11 deletions

View File

@ -204,6 +204,13 @@
</source>
<target dev="sdae" bus="scsi"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu"/>
<source protocol="iscsi" name="iqn.2017-12.com.virttest:emulated-iscsi-noauth.target2-lun-1">
<host name="10.66.144.87"/>
</source>
<target dev="vdo" bus="virtio"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1">
<address type="pci" domain="0" bus="0" slot="4" function="7"/>
</controller>

View File

@ -597,6 +597,7 @@ vcpus.vcpu1.id=2,vcpus.vcpu1.enabled=yes
--disk /tmp/brand-new.img,size=1,backing_store=/dev/default-pool/iso-vol,boot.order=10,boot.loadparm=5
--disk path=/dev/disk-pool/diskvol7,device=lun,bus=scsi,reservations.managed=no,reservations.source.type=unix,reservations.source.path=/var/run/test/pr-helper0.sock,reservations.source.mode=client,\
source.reservations.managed=no,source.reservations.source.type=unix,source.reservations.source.path=/var/run/test/pr-helper0.sock,source.reservations.source.mode=client
--disk vol=iscsi-direct/unit:0:0:1
--network user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down,rom_bar=on,rom_file=/tmp/foo
--network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3,filterref=foobar,rom.bar=off,rom.file=/some/rom,source.portgroup=foo

View File

@ -2060,6 +2060,34 @@ ba</description>
</pool>
<pool type='iscsi-direct'>
<name>iscsi-direct</name>
<uuid>0799697a-94dd-4115-9601-8714b1931248</uuid>
<capacity unit='bytes'>524287488</capacity>
<allocation unit='bytes'>524287488</allocation>
<available unit='bytes'>0</available>
<source>
<host name='10.66.144.87'/>
<device path='iqn.2017-12.com.virttest:emulated-iscsi-noauth.target2'/>
<initiator>
<iqn name='iqn.2017-12.com.example:client'/>
</initiator>
</source>
<volume type="network">
<name>unit:0:0:1</name>
<key>ip-10.66.144.87:3260-iscsi-iqn.2017-12.com.virttest:emulated-iscsi-noauth.target2-lun-1</key>
<source>
</source>
<capacity unit="bytes">1376452096</capacity>
<allocation unit="bytes">1376452096</allocation>
<target>
<path>ip-10.66.144.87:3260-iscsi-iqn.2017-12.com.virttest:emulated-iscsi-noauth.target2-lun-1</path>
<format type="unknown"/>
</target>
</volume>
</pool>
<pool type='rbd'>
<name>rbd-ceph</name>
<uuid>4bcd023e-990e-fcf6-d95c-52dd0cd938c8</uuid>

View File

@ -458,9 +458,12 @@ class DeviceDisk(Device):
self.source_name = self.source_name[1:]
def _set_source_network_from_storage(self, volxml, poolxml):
self.source_protocol = poolxml.type
logging.debug("disk.set_vol_object: poolxml=\n%s",
dir(poolxml))
is_iscsi_direct = poolxml.type == "iscsi-direct"
protocol = poolxml.type
if is_iscsi_direct:
protocol = "iscsi"
self.source_protocol = protocol
if poolxml.auth_type:
self.auth_username = poolxml.auth_username
self.auth_secret_type = poolxml.auth_type
@ -474,14 +477,22 @@ class DeviceDisk(Device):
obj.port = host.port
path = ""
if poolxml.source_name:
path += poolxml.source_name
if poolxml.source_path:
path += poolxml.source_path
if not path.endswith('/'):
path += "/"
path += volxml.name
self.source_name = path
if is_iscsi_direct:
# Vol path is like this:
# ip-10.66.144.87:3260-iscsi-iqn.2017-12.com.virttest:emulated-iscsi-noauth.target2-lun-1
# Always seems to have -iscsi- embedded in it
if "-iscsi-iqn." in volxml.target_path:
path = volxml.target_path.split("-iscsi-", 1)[-1]
else:
if poolxml.source_name:
path += poolxml.source_name
if poolxml.source_path:
path += poolxml.source_path
if not path.endswith('/'):
path += "/"
path += volxml.name
self.source_name = path or None
self.type = "network"
def _set_network_source_from_backend(self):