diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 697a2db62b..5a693e143f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1567,14 +1567,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, return NULL; } - if (disk->wwn && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_IDE_DRIVE_WWN)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Setting wwn for ide disk is not supported " - "by this QEMU")); - return NULL; - } - if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) virBufferAddLit(&opt, "ide-cd"); else @@ -1607,25 +1599,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, } } - if (disk->wwn && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Setting wwn for scsi disk is not supported " - "by this QEMU")); - return NULL; - } - - /* Properties wwn, vendor and product were introduced in the - * same QEMU release (1.2.0). - */ - if ((disk->vendor || disk->product) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Setting vendor or product for scsi disk is not " - "supported by this QEMU")); - return NULL; - } - controllerModel = qemuDomainFindSCSIControllerModel(def, &disk->info); if (controllerModel < 0) return NULL; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 28eae76cca..0362b0d34e 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2066,13 +2066,40 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, _("Only ide and scsi disk support wwn")); return -1; } + + if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_IDE_DRIVE_WWN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Setting wwn for ide disk is not supported " + "by this QEMU")); + return -1; + } + + if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Setting wwn for scsi disk is not supported " + "by this QEMU")); + return -1; + } } - if ((disk->vendor || disk->product) && - disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) { + if (disk->vendor || disk->product) { + if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only scsi disk supports vendor and product")); return -1; + } + + /* Properties wwn, vendor and product were introduced in the + * same QEMU release (1.2.0). + */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Setting vendor or product for scsi disk is not " + "supported by this QEMU")); + return -1; + } } if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8aa791d9f7..cd15ce5138 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2252,7 +2252,9 @@ mymain(void) DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE); DO_TEST("disk-ide-split", NONE); - DO_TEST("disk-ide-wwn", QEMU_CAPS_IDE_DRIVE_WWN); + DO_TEST("disk-ide-wwn", + QEMU_CAPS_IDE_DRIVE_WWN, + QEMU_CAPS_SCSI_DISK_WWN); DO_TEST("disk-geometry", NONE); DO_TEST("disk-blockio", QEMU_CAPS_BLOCKIO);