Extract the relevant parts of the existing checker and reuse them for blockcopy since copying to a non-block device creates an invalid configuration. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1209802 --- src/qemu/qemu_command.c | 14 +------------- src/qemu/qemu_domain.c | 31 +++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_driver.c | 4 ++++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0f0427f..16a044e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -908,20 +908,8 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk) return -1; } - if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_NETWORK) { - if (disk->src->protocol != VIR_STORAGE_NET_PROTOCOL_ISCSI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk device='lun' is not supported " - "for protocol='%s'"), - virStorageNetProtocolTypeToString(disk->src->protocol)); - return -1; - } - } else if (!virStorageSourceIsBlockLocal(disk->src)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("disk device='lun' is only valid for block " - "type disk source")); + if (qemuDomainDefValidateDiskLunSource(disk->src) < 0) return -1; - } if (disk->wwn) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d065edb..472b569 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5267,3 +5267,34 @@ qemuDomainDiskByName(virDomainDefPtr def, return ret; } + + +/** + * qemuDomainDefValidateDiskLunSource: + * @src: disk source struct + * + * Validate whether the disk source is valid for disk device='lun'. + * + * Returns 0 if the configuration is valid -1 and a libvirt error if the soure + * is invalid. + */ +int +qemuDomainDefValidateDiskLunSource(const virStorageSource *src) +{ + if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK) { + if (src->protocol != VIR_STORAGE_NET_PROTOCOL_ISCSI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk device='lun' is not supported " + "for protocol='%s'"), + virStorageNetProtocolTypeToString(src->protocol)); + return -1; + } + } else if (!virStorageSourceIsBlockLocal(src)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disk device='lun' is only valid for block " + "type disk source")); + return -1; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 63f98ba..7b71ae6 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -647,4 +647,7 @@ void qemuDomainSecretDestroy(virDomainObjPtr vm) int qemuDomainSecretPrepare(virConnectPtr conn, virDomainObjPtr vm) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int qemuDomainDefValidateDiskLunSource(const virStorageSource *src) + ATTRIBUTE_NONNULL(1); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3d0c7c8..cc50043 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16759,6 +16759,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainDiskBlockJobIsActive(disk)) goto endjob; + if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN && + qemuDomainDefValidateDiskLunSource(mirror) < 0) + goto endjob; + if (!(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_MIRROR) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -- 2.8.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list