提交 9d80fdcd 编写于 作者: P Peter Krempa

qemu: snapshot: Restrict file existence check only for local storage

Soon we'll allow more protocols and storage types with snapshots where
we in some cases can't check whether the storage already exists.
Restrict the sanity checks whether the destination images exist or not
for local storage where it's easy. For any other case we will fail
later.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 7921e9b0
...@@ -15008,32 +15008,34 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk, ...@@ -15008,32 +15008,34 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk,
return -1; return -1;
} }
if (virStorageFileInit(snapdisk->src) < 0) if (virStorageSourceIsLocalStorage(snapdisk->src)) {
return -1; if (virStorageFileInit(snapdisk->src) < 0)
return -1;
rc = virStorageFileStat(snapdisk->src, &st); rc = virStorageFileStat(snapdisk->src, &st);
err = errno; err = errno;
virStorageFileDeinit(snapdisk->src); virStorageFileDeinit(snapdisk->src);
if (rc < 0) { if (rc < 0) {
if (err != ENOENT) { if (err != ENOENT) {
virReportSystemError(err, virReportSystemError(err,
_("unable to stat for disk %s: %s"), _("unable to stat for disk %s: %s"),
snapdisk->name, snapdisk->src->path); snapdisk->name, snapdisk->src->path);
return -1; return -1;
} else if (reuse) { } else if (reuse) {
virReportSystemError(err, virReportSystemError(err,
_("missing existing file for disk %s: %s"), _("missing existing file for disk %s: %s"),
snapdisk->name, snapdisk->src->path); snapdisk->name, snapdisk->src->path);
return -1;
}
} else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot file for disk %s already "
"exists and is not a block device: %s"),
snapdisk->name, snapdisk->src->path);
return -1; return -1;
} }
} else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot file for disk %s already "
"exists and is not a block device: %s"),
snapdisk->name, snapdisk->src->path);
return -1;
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册