mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage_util: Introduce storageBackendDoCreateQemuImg
Extract out command line setup and run from storageBackendCreateQemuImg as we'll need to run it twice soon. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
e1e1fcf769
commit
352e549450
@ -1354,6 +1354,31 @@ storageBackendGenerateSecretData(virStoragePoolObjPtr pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
storageBackendDoCreateQemuImg(virStoragePoolObjPtr pool,
|
||||||
|
virStorageVolDefPtr vol,
|
||||||
|
virStorageVolDefPtr inputvol,
|
||||||
|
unsigned int flags,
|
||||||
|
const char *create_tool,
|
||||||
|
const char *secretPath)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
virCommandPtr cmd;
|
||||||
|
|
||||||
|
cmd = virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol,
|
||||||
|
flags, create_tool,
|
||||||
|
secretPath);
|
||||||
|
if (!cmd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ret = virStorageBackendCreateExecCommand(pool, vol, cmd);
|
||||||
|
|
||||||
|
virCommandFree(cmd);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
|
storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
|
||||||
virStorageVolDefPtr vol,
|
virStorageVolDefPtr vol,
|
||||||
@ -1362,7 +1387,6 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *create_tool;
|
char *create_tool;
|
||||||
virCommandPtr cmd;
|
|
||||||
char *secretPath = NULL;
|
char *secretPath = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
|
||||||
@ -1378,15 +1402,8 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
|
|||||||
if (storageBackendGenerateSecretData(pool, vol, &secretPath) < 0)
|
if (storageBackendGenerateSecretData(pool, vol, &secretPath) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cmd = virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol,
|
ret = storageBackendDoCreateQemuImg(pool, vol, inputvol, flags,
|
||||||
flags, create_tool,
|
create_tool, secretPath);
|
||||||
secretPath);
|
|
||||||
if (!cmd)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = virStorageBackendCreateExecCommand(pool, vol, cmd);
|
|
||||||
|
|
||||||
virCommandFree(cmd);
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (secretPath) {
|
if (secretPath) {
|
||||||
unlink(secretPath);
|
unlink(secretPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user