提交 bd9d7078 编写于 作者: P Peter Krempa

qemu: Reject invalid block copy targets for <disk device='lun'>

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
上级 b66664ff
......@@ -972,20 +972,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",
......
......@@ -5297,3 +5297,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;
}
......@@ -666,4 +666,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__ */
......@@ -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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册