提交 c4dd2a1f 编写于 作者: J John Ferlan

storage: Track successful creation of LV for removal

https://bugzilla.redhat.com/show_bug.cgi?id=1233003

Track when the logical volume was successfully created in order to
properly handle the call to virStorageBackendLogicalDeleteVol. It's
possible that the failure to create was because someone created an
LV in the pool outside of libvirt's knowledge. In this case, we don't
want to delete that LV.  A subsequent or future refresh of the pool
will find the volume and cause an earlier failure
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 27d2d99f
...@@ -731,6 +731,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, ...@@ -731,6 +731,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
virErrorPtr err; virErrorPtr err;
struct stat sb; struct stat sb;
bool created = false;
if (vol->target.encryption != NULL) { if (vol->target.encryption != NULL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
...@@ -771,6 +772,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, ...@@ -771,6 +772,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto error; goto error;
created = true;
virCommandFree(cmd); virCommandFree(cmd);
cmd = NULL; cmd = NULL;
...@@ -816,7 +818,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, ...@@ -816,7 +818,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
error: error:
err = virSaveLastError(); err = virSaveLastError();
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
virStorageBackendLogicalDeleteVol(conn, pool, vol, 0); if (created)
virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
virCommandFree(cmd); virCommandFree(cmd);
virSetError(err); virSetError(err);
virFreeError(err); virFreeError(err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册