mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: block copy: Forbid block copy to relative paths
Similarly to 29bb066915
forbid paths used with blockjobs to be relative.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1300177
This commit is contained in:
parent
50b2a2375a
commit
9e9305542e
@ -170,9 +170,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* validate that the passed path is absolute */
|
/* validate that the passed path is absolute */
|
||||||
if (virStorageSourceIsLocalStorage(def->src) &&
|
if (virStorageSourceIsRelative(def->src)) {
|
||||||
def->src->path &&
|
|
||||||
def->src->path[0] != '/') {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("disk snapshot image path '%s' must be absolute"),
|
_("disk snapshot image path '%s' must be absolute"),
|
||||||
def->src->path);
|
def->src->path);
|
||||||
|
@ -2455,6 +2455,7 @@ virStorageSourceInitChainElement;
|
|||||||
virStorageSourceIsBlockLocal;
|
virStorageSourceIsBlockLocal;
|
||||||
virStorageSourceIsEmpty;
|
virStorageSourceIsEmpty;
|
||||||
virStorageSourceIsLocalStorage;
|
virStorageSourceIsLocalStorage;
|
||||||
|
virStorageSourceIsRelative;
|
||||||
virStorageSourceNewFromBacking;
|
virStorageSourceNewFromBacking;
|
||||||
virStorageSourceNewFromBackingAbsolute;
|
virStorageSourceNewFromBackingAbsolute;
|
||||||
virStorageSourceParseRBDColonString;
|
virStorageSourceParseRBDColonString;
|
||||||
|
@ -16665,6 +16665,12 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
|
|||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
cfg = virQEMUDriverGetConfig(driver);
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
|
if (virStorageSourceIsRelative(mirror)) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("absolute path must be used as block copy target"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -3672,3 +3672,34 @@ virStorageFileCheckCompat(const char *compat)
|
|||||||
virStringListFree(version);
|
virStringListFree(version);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virStorageSourceIsRelative:
|
||||||
|
* @src: storage source to check
|
||||||
|
*
|
||||||
|
* Returns true if given storage source definition is a relative path.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
virStorageSourceIsRelative(virStorageSourcePtr src)
|
||||||
|
{
|
||||||
|
virStorageType actual_type = virStorageSourceGetActualType(src);
|
||||||
|
|
||||||
|
if (!src->path)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (actual_type) {
|
||||||
|
case VIR_STORAGE_TYPE_FILE:
|
||||||
|
case VIR_STORAGE_TYPE_BLOCK:
|
||||||
|
case VIR_STORAGE_TYPE_DIR:
|
||||||
|
return src->path[0] != '/';
|
||||||
|
|
||||||
|
case VIR_STORAGE_TYPE_NETWORK:
|
||||||
|
case VIR_STORAGE_TYPE_VOLUME:
|
||||||
|
case VIR_STORAGE_TYPE_NONE:
|
||||||
|
case VIR_STORAGE_TYPE_LAST:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -388,4 +388,6 @@ int virStorageFileCheckCompat(const char *compat);
|
|||||||
|
|
||||||
virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *path);
|
virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *path);
|
||||||
|
|
||||||
|
bool virStorageSourceIsRelative(virStorageSourcePtr src);
|
||||||
|
|
||||||
#endif /* __VIR_STORAGE_FILE_H__ */
|
#endif /* __VIR_STORAGE_FILE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user