aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-09-11 16:57:04 +0800
committerOsier Yang <jyang@redhat.com>2012-09-18 15:00:01 +0800
commit6e73850b01ee7d5816a803d684e9d669dad036f3 (patch)
tree7a30fb84c2a4ce9b1cf33dac300cad39c98f85d3
parentqemu: Add caps to indentify if setting wwn is supported by qemu (diff)
downloadlibvirt-6e73850b01ee7d5816a803d684e9d669dad036f3.tar.gz
libvirt-6e73850b01ee7d5816a803d684e9d669dad036f3.tar.bz2
libvirt-6e73850b01ee7d5816a803d684e9d669dad036f3.zip
qemu: Use disk wwn in qemu command line
All of ide-drive, ide-hd, ide-cd, scsi-disk, scsi-hd, and scsi-cd supports wwn property. (NB, scsi-block doesn't support to set wwn). * src/qemu/qemu_command.c: Error out if underlying QEMU doesn't support wwn property for the device; Set wwn for the device otherwise. * tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args: New test * tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml: Likewise * tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args: Likewise * tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml: Likewise * tests/qemuxml2argvtest.c: Add the new tests.
-rw-r--r--src/qemu/qemu_command.c33
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args6
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml28
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args10
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml35
-rw-r--r--tests/qemuxml2argvtest.c7
6 files changed, 119 insertions, 0 deletions
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 06a4bac87..ec29d4e9b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2453,6 +2453,15 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
goto error;
}
+ if (disk->wwn) {
+ if ((disk->bus != VIR_DOMAIN_DISK_BUS_IDE) &&
+ (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Only ide and scsi disk support wwn"));
+ goto error;
+ }
+ }
+
if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
/* make sure that both the bus and the qemu binary support
* type='lun' (SG_IO).
@@ -2475,6 +2484,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("disk device='lun' is not supported by this QEMU"));
goto error;
}
+ if (disk->wwn) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Setting wwn is not supported for lun device"));
+ goto error;
+ }
}
switch (disk->bus) {
@@ -2485,6 +2499,14 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
goto error;
}
+ if (disk->wwn &&
+ !qemuCapsGet(caps, QEMU_CAPS_IDE_DRIVE_WWN)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Setting wwn for ide disk is not supported "
+ "by this QEMU"));
+ goto error;
+ }
+
if (qemuCapsGet(caps, QEMU_CAPS_IDE_CD)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
virBufferAddLit(&opt, "ide-cd");
@@ -2508,6 +2530,14 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
+ if (disk->wwn &&
+ !qemuCapsGet(caps, QEMU_CAPS_SCSI_DISK_WWN)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Setting wwn for scsi disk is not supported "
+ "by this QEMU"));
+ goto error;
+ }
+
controllerModel =
virDomainDiskFindControllerModel(def, disk,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
@@ -2647,6 +2677,9 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
disk->blockio.physical_block_size);
}
+ if (disk->wwn)
+ virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
+
if (virBufferError(&opt)) {
virReportOOMError();
goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
new file mode 100644
index 000000000..4b8a54381
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1,serial=WD-WMAP9A966149 \
+-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,wwn=5000c50015ea71ad \
+-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml
new file mode 100644
index 000000000..dccec9570
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml
@@ -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='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <serial>WD-WMAP9A966149</serial>
+ <wwn>5000c50015ea71ad</wwn>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
new file mode 100644
index 000000000..fe4591bd5
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
@@ -0,0 +1,10 @@
+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 \
+-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-1-0 \
+-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0,wwn=5000c50015ea71ac \
+-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=5000c50015ea71ad \
+-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
new file mode 100644
index 000000000..dc355484b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
@@ -0,0 +1,35 @@
+<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='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='sda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='1' unit='0'/>
+ <serial>WD-WMAP9A966149</serial>
+ <wwn>5000c50015ea71ac</wwn>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sdb' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ <wwn>5000c50015ea71ad</wwn>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='scsi' index='1' model='lsilogic'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4daa68d0f..0ec3c2cb6 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -471,6 +471,10 @@ mymain(void)
DO_TEST("disk-scsi-disk-split",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI);
+ DO_TEST("disk-scsi-disk-wwn",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI,
+ QEMU_CAPS_SCSI_DISK_WWN);
DO_TEST("disk-scsi-vscsi",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-virtio-scsi",
@@ -802,6 +806,9 @@ mymain(void)
DO_TEST("disk-ide-drive-split",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_IDE_CD);
+ DO_TEST("disk-ide-wwn",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_IDE_CD,
+ QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_IDE_DRIVE_WWN);
DO_TEST("disk-geometry", QEMU_CAPS_DRIVE);
DO_TEST("disk-blockio",