}
/* validate that the passed path is absolute */
- if (virStorageSourceIsLocalStorage(def->src) &&
- def->src->path &&
- def->src->path[0] != '/') {
+ if (virStorageSourceIsRelative(def->src)) {
virReportError(VIR_ERR_XML_ERROR,
_("disk snapshot image path '%s' must be absolute"),
def->src->path);
virStorageSourceIsBlockLocal;
virStorageSourceIsEmpty;
virStorageSourceIsLocalStorage;
+virStorageSourceIsRelative;
virStorageSourceNewFromBacking;
virStorageSourceNewFromBackingAbsolute;
virStorageSourceParseRBDColonString;
priv = vm->privateData;
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)
goto cleanup;
virStringListFree(version);
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;
+}
virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *path);
+bool virStorageSourceIsRelative(virStorageSourcePtr src);
+
#endif /* __VIR_STORAGE_FILE_H__ */