提交 42bbde2d 编写于 作者: J Ján Tomko

Revert "storage: lvm: Separate creating of the volume from building"

This reverts commit af1fb38f.
With it, creating new logical volumes fails:
https://www.redhat.com/archives/libvir-list/2014-February/msg00658.html

In the storage driver, we expect CreateVol to fill out the volume key,
but the LVM backend fills the key with the uuid reported by lvs after the
logical volume is created.
上级 5b0dc11d
...@@ -702,16 +702,32 @@ cleanup: ...@@ -702,16 +702,32 @@ cleanup:
static int static int
virStorageBackendLogicalBuildVol(virConnectPtr conn, virStorageBackendLogicalCreateVol(virConnectPtr conn,
virStoragePoolObjPtr pool, virStoragePoolObjPtr pool,
virStorageVolDefPtr vol, virStorageVolDefPtr vol)
unsigned int flags)
{ {
int fd = -1; int fd = -1;
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
virErrorPtr err; virErrorPtr err;
virCheckFlags(0, -1); if (vol->target.encryption != NULL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("storage pool does not support encrypted "
"volumes"));
return -1;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
if (vol->target.path != NULL) {
/* A target path passed to CreateVol has no meaning */
VIR_FREE(vol->target.path);
}
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->target.path,
vol->name) == -1)
return -1;
cmd = virCommandNewArgList(LVCREATE, cmd = virCommandNewArgList(LVCREATE,
"--name", vol->name, "--name", vol->name,
...@@ -770,7 +786,7 @@ virStorageBackendLogicalBuildVol(virConnectPtr conn, ...@@ -770,7 +786,7 @@ virStorageBackendLogicalBuildVol(virConnectPtr conn,
return 0; return 0;
error: error:
err = virSaveLastError(); err = virSaveLastError();
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
virStorageBackendLogicalDeleteVol(conn, pool, vol, 0); virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
...@@ -780,36 +796,6 @@ error: ...@@ -780,36 +796,6 @@ error:
return -1; return -1;
} }
static int
virStorageBackendLogicalCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
if (vol->target.encryption != NULL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("storage pool does not support encrypted volumes"));
return -1;
}
vol->type = VIR_STORAGE_VOL_BLOCK;
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->target.path,
vol->name) == -1)
return -1;
if (virFileExists(vol->target.path)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("volume target path '%s' already exists"),
vol->target.path);
return -1;
}
return 0;
}
static int static int
virStorageBackendLogicalBuildVolFrom(virConnectPtr conn, virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
virStoragePoolObjPtr pool, virStoragePoolObjPtr pool,
...@@ -837,7 +823,7 @@ virStorageBackend virStorageBackendLogical = { ...@@ -837,7 +823,7 @@ virStorageBackend virStorageBackendLogical = {
.refreshPool = virStorageBackendLogicalRefreshPool, .refreshPool = virStorageBackendLogicalRefreshPool,
.stopPool = virStorageBackendLogicalStopPool, .stopPool = virStorageBackendLogicalStopPool,
.deletePool = virStorageBackendLogicalDeletePool, .deletePool = virStorageBackendLogicalDeletePool,
.buildVol = virStorageBackendLogicalBuildVol, .buildVol = NULL,
.buildVolFrom = virStorageBackendLogicalBuildVolFrom, .buildVolFrom = virStorageBackendLogicalBuildVolFrom,
.createVol = virStorageBackendLogicalCreateVol, .createVol = virStorageBackendLogicalCreateVol,
.deleteVol = virStorageBackendLogicalDeleteVol, .deleteVol = virStorageBackendLogicalDeleteVol,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册