qemu: support passthrough for iscsi disks

This enables usage of commands like persistent reservations.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2013-03-21 12:53:50 +01:00 committed by Osier Yang
parent 1a308ee015
commit c820fbff9f
5 changed files with 48 additions and 1 deletions

View File

@ -156,6 +156,7 @@ virDomainDiskIoTypeToString;
virDomainDiskPathByName;
virDomainDiskProtocolTransportTypeFromString;
virDomainDiskProtocolTransportTypeToString;
virDomainDiskProtocolTypeToString;
virDomainDiskRemove;
virDomainDiskRemoveByName;
virDomainDiskTypeFromString;

View File

@ -3026,7 +3026,14 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
bus);
goto error;
}
if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK) {
if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (disk->protocol != VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk device='lun' is not supported for protocol='%s'"),
virDomainDiskProtocolTypeToString(disk->protocol));
goto error;
}
} else if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk device='lun' is not supported for type='%s'"),
virDomainDiskTypeToString(disk->type));

View File

@ -0,0 +1,7 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \
-drive file=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\
id=drive-scsi0-0-0-0,format=raw -device scsi-block,bus=scsi0.0,channel=0,\
scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0

View File

@ -0,0 +1,28 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='network' device='lun'>
<driver name='qemu' type='raw'/>
<source protocol='iscsi' name='iqn.1992-01.com.example'>
<host name='example.org' port='3260'/>
</source>
<target dev='sda' bus='scsi'/>
</disk>
<controller type='usb' index='0'/>
<controller type='scsi' index='0' model='virtio-scsi'/>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -503,6 +503,10 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-network-iscsi",
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-network-iscsi-lun",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE_FORMAT,
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_VIRTIO_BLK_SG_IO, QEMU_CAPS_SCSI_BLOCK);
DO_TEST("disk-drive-network-gluster",
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-network-rbd",