提交 185e07a5 编写于 作者: P Peter Krempa

qemu: snapshot: Use storage driver to pre-create snapshot file

Move the last operation done on local files to the storage driver API.
上级 a2a67eff
...@@ -12861,7 +12861,6 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12861,7 +12861,6 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
char *source = NULL; char *source = NULL;
const char *formatStr = NULL; const char *formatStr = NULL;
int ret = -1; int ret = -1;
int fd = -1;
bool need_unlink = false; bool need_unlink = false;
if (snap->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { if (snap->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
...@@ -12879,7 +12878,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12879,7 +12878,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
if (virStorageSourceInitChainElement(newDiskSrc, disk->src, false) < 0) if (virStorageSourceInitChainElement(newDiskSrc, disk->src, false) < 0)
goto cleanup; goto cleanup;
if (virStorageFileInit(newDiskSrc) < 0) if (qemuDomainStorageFileInit(driver, vm, newDiskSrc) < 0)
goto cleanup; goto cleanup;
if (qemuGetDriveSourceString(newDiskSrc, NULL, &source) < 0) if (qemuGetDriveSourceString(newDiskSrc, NULL, &source) < 0)
...@@ -12895,15 +12894,13 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12895,15 +12894,13 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
} }
/* pre-create the image file so that we can label it before handing it to qemu */ /* pre-create the image file so that we can label it before handing it to qemu */
/* XXX we should switch to storage driver based pre-creation of the image */
if (virStorageSourceIsLocalStorage(newDiskSrc)) {
if (!reuse && newDiskSrc->type != VIR_STORAGE_TYPE_BLOCK) { if (!reuse && newDiskSrc->type != VIR_STORAGE_TYPE_BLOCK) {
fd = qemuOpenFile(driver, vm, source, O_WRONLY | O_TRUNC | O_CREAT, if (virStorageFileCreate(newDiskSrc) < 0) {
&need_unlink, NULL); virReportSystemError(errno, _("failed to create image file '%s'"),
if (fd < 0) source);
goto cleanup; goto cleanup;
VIR_FORCE_CLOSE(fd);
} }
need_unlink = true;
} }
/* set correct security, cgroup and locking options on the new image */ /* set correct security, cgroup and locking options on the new image */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册