mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: disk: Separate creating of the volume from building
Separate the steps to create libvirt's volume metadata from the actual volume building process.
This commit is contained in:
parent
af1fb38f55
commit
67ccf91bf2
@ -617,28 +617,43 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr pool,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
virStoragePoolObjPtr pool,
|
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
|
||||||
virStorageVolDefPtr vol)
|
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;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virStorageBackendDiskBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
virStoragePoolObjPtr pool,
|
||||||
|
virStorageVolDefPtr vol,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
char *partFormat = NULL;
|
char *partFormat = NULL;
|
||||||
unsigned long long startOffset = 0, endOffset = 0;
|
unsigned long long startOffset = 0, endOffset = 0;
|
||||||
virCommandPtr cmd = virCommandNewArgList(PARTED,
|
virCommandPtr cmd = NULL;
|
||||||
pool->def->source.devices[0].path,
|
|
||||||
"mkpart",
|
|
||||||
"--script",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (vol->target.encryption != NULL) {
|
virCheckFlags(0, -1);
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
"%s", _("storage pool does not support encrypted "
|
|
||||||
"volumes"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) {
|
cmd = virCommandNewArgList(PARTED,
|
||||||
|
pool->def->source.devices[0].path,
|
||||||
|
"mkpart",
|
||||||
|
"--script",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
virCommandAddArg(cmd, partFormat);
|
virCommandAddArg(cmd, partFormat);
|
||||||
|
|
||||||
if (virStorageBackendDiskPartBoundries(pool, &startOffset,
|
if (virStorageBackendDiskPartBoundries(pool, &startOffset,
|
||||||
@ -768,5 +783,6 @@ virStorageBackend virStorageBackendDisk = {
|
|||||||
|
|
||||||
.createVol = virStorageBackendDiskCreateVol,
|
.createVol = virStorageBackendDiskCreateVol,
|
||||||
.deleteVol = virStorageBackendDiskDeleteVol,
|
.deleteVol = virStorageBackendDiskDeleteVol,
|
||||||
|
.buildVol = virStorageBackendDiskBuildVol,
|
||||||
.buildVolFrom = virStorageBackendDiskBuildVolFrom,
|
.buildVolFrom = virStorageBackendDiskBuildVolFrom,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user