diff options
author | 2012-09-11 16:57:04 +0800 | |
---|---|---|
committer | 2012-09-18 15:00:01 +0800 | |
commit | 6e73850b01ee7d5816a803d684e9d669dad036f3 (patch) | |
tree | 7a30fb84c2a4ce9b1cf33dac300cad39c98f85d3 /src | |
parent | qemu: Add caps to indentify if setting wwn is supported by qemu (diff) | |
download | libvirt-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/qemu/qemu_command.c | 33 |
1 files changed, 33 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; |