mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu_block: Refactor qemuBlockExportAddNBD()
This patch improves readability of the function and makes the code look cleaner by removing the 'else' branches after return and reordering of the 'if' branches. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d73265af6e
commit
1780a49d7f
@ -3592,28 +3592,21 @@ qemuBlockExportAddNBD(virDomainObj *vm,
|
|||||||
const char *bitmap)
|
const char *bitmap)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
|
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD)) {
|
|
||||||
g_autoptr(virJSONValue) nbdprops = NULL;
|
g_autoptr(virJSONValue) nbdprops = NULL;
|
||||||
const char *bitmaps[2] = { bitmap, NULL };
|
const char *bitmaps[2] = { bitmap, NULL };
|
||||||
|
|
||||||
if (!(nbdprops = qemuBlockExportGetNBDProps(src->nodeformat,
|
/* older qemu versions didn't support configuring the exportname and
|
||||||
exportname,
|
* took the 'drivealias' as the export name */
|
||||||
writable,
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
|
||||||
bitmaps)))
|
return qemuMonitorNBDServerAdd(priv->mon, drivealias, NULL, writable, NULL);
|
||||||
|
|
||||||
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD))
|
||||||
|
return qemuMonitorNBDServerAdd(priv->mon, src->nodeformat,
|
||||||
|
exportname, writable, bitmap);
|
||||||
|
|
||||||
|
if (!(nbdprops = qemuBlockExportGetNBDProps(src->nodeformat, exportname,
|
||||||
|
writable, bitmaps)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return qemuMonitorBlockExportAdd(priv->mon, &nbdprops);
|
return qemuMonitorBlockExportAdd(priv->mon, &nbdprops);
|
||||||
} else {
|
|
||||||
return qemuMonitorNBDServerAdd(priv->mon, src->nodeformat,
|
|
||||||
exportname, writable, bitmap);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* older qemu versions didn't support configuring the exportname and
|
|
||||||
* took the 'drivealias' as the export name */
|
|
||||||
return qemuMonitorNBDServerAdd(priv->mon, drivealias, NULL, writable, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user