mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
qemu: block: Split up qemuBlockStorageSourceAttachApply
Split up the addition of a storage source into the following sub-steps: 1) storage access dependencies (TLS transport, persistent reservation) 2) storage acccess node (file/gluster/nbd...) 3) format driver dependencies (encryption secret) 4) format driver node (qcow2, raw, ...) The functions split out will be later reused when implementing support for 'blockdev-create' as we'll need the dependencies plugged in first, then blockdev-create will be called and after that successfully finishes blockdev-add will be added. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
16ca234b56
commit
35e3069ce4
@ -1450,6 +1450,80 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceAttachApplyStorageDeps(qemuMonitorPtr mon,
|
||||
qemuBlockStorageSourceAttachDataPtr data)
|
||||
{
|
||||
if (data->prmgrProps &&
|
||||
qemuMonitorAddObject(mon, &data->prmgrProps, &data->prmgrAlias) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->authsecretProps &&
|
||||
qemuMonitorAddObject(mon, &data->authsecretProps,
|
||||
&data->authsecretAlias) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->tlsProps &&
|
||||
qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceAttachApplyStorage(qemuMonitorPtr mon,
|
||||
qemuBlockStorageSourceAttachDataPtr data)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (data->storageProps) {
|
||||
rv = qemuMonitorBlockdevAdd(mon, data->storageProps);
|
||||
data->storageProps = NULL;
|
||||
|
||||
if (rv < 0)
|
||||
return -1;
|
||||
|
||||
data->storageAttached = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceAttachApplyFormatDeps(qemuMonitorPtr mon,
|
||||
qemuBlockStorageSourceAttachDataPtr data)
|
||||
{
|
||||
if (data->encryptsecretProps &&
|
||||
qemuMonitorAddObject(mon, &data->encryptsecretProps,
|
||||
&data->encryptsecretAlias) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockStorageSourceAttachApplyFormat(qemuMonitorPtr mon,
|
||||
qemuBlockStorageSourceAttachDataPtr data)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (data->formatProps) {
|
||||
rv = qemuMonitorBlockdevAdd(mon, data->formatProps);
|
||||
data->formatProps = NULL;
|
||||
|
||||
if (rv < 0)
|
||||
return -1;
|
||||
|
||||
data->formatAttached = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBlockStorageSourceAttachApply:
|
||||
* @mon: monitor object
|
||||
@ -1467,46 +1541,12 @@ int
|
||||
qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon,
|
||||
qemuBlockStorageSourceAttachDataPtr data)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (data->prmgrProps &&
|
||||
qemuMonitorAddObject(mon, &data->prmgrProps, &data->prmgrAlias) < 0)
|
||||
if (qemuBlockStorageSourceAttachApplyStorageDeps(mon, data) < 0 ||
|
||||
qemuBlockStorageSourceAttachApplyStorage(mon, data) < 0 ||
|
||||
qemuBlockStorageSourceAttachApplyFormatDeps(mon, data) < 0 ||
|
||||
qemuBlockStorageSourceAttachApplyFormat(mon, data) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->authsecretProps &&
|
||||
qemuMonitorAddObject(mon, &data->authsecretProps,
|
||||
&data->authsecretAlias) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->encryptsecretProps &&
|
||||
qemuMonitorAddObject(mon, &data->encryptsecretProps,
|
||||
&data->encryptsecretAlias) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->tlsProps &&
|
||||
qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0)
|
||||
return -1;
|
||||
|
||||
if (data->storageProps) {
|
||||
rv = qemuMonitorBlockdevAdd(mon, data->storageProps);
|
||||
data->storageProps = NULL;
|
||||
|
||||
if (rv < 0)
|
||||
return -1;
|
||||
|
||||
data->storageAttached = true;
|
||||
}
|
||||
|
||||
if (data->formatProps) {
|
||||
rv = qemuMonitorBlockdevAdd(mon, data->formatProps);
|
||||
data->formatProps = NULL;
|
||||
|
||||
if (rv < 0)
|
||||
return -1;
|
||||
|
||||
data->formatAttached = true;
|
||||
}
|
||||
|
||||
if (data->driveCmd) {
|
||||
if (qemuMonitorAddDrive(mon, data->driveCmd) < 0)
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user