mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
qemuMonitorBlockdevAdd: Take double pointer argument
Modify qemuMonitorBlockdevAdd so that it takes a double pointer for the @props argument so that it's cleared inside the call. This allows writing cleaner callers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
a592d589aa
commit
db57e9daf5
@ -1537,13 +1537,8 @@ static int
|
|||||||
qemuBlockStorageSourceAttachApplyStorage(qemuMonitorPtr mon,
|
qemuBlockStorageSourceAttachApplyStorage(qemuMonitorPtr mon,
|
||||||
qemuBlockStorageSourceAttachDataPtr data)
|
qemuBlockStorageSourceAttachDataPtr data)
|
||||||
{
|
{
|
||||||
int rv;
|
|
||||||
|
|
||||||
if (data->storageProps) {
|
if (data->storageProps) {
|
||||||
rv = qemuMonitorBlockdevAdd(mon, data->storageProps);
|
if (qemuMonitorBlockdevAdd(mon, &data->storageProps) < 0)
|
||||||
data->storageProps = NULL;
|
|
||||||
|
|
||||||
if (rv < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
data->storageAttached = true;
|
data->storageAttached = true;
|
||||||
@ -1570,13 +1565,8 @@ static int
|
|||||||
qemuBlockStorageSourceAttachApplyFormat(qemuMonitorPtr mon,
|
qemuBlockStorageSourceAttachApplyFormat(qemuMonitorPtr mon,
|
||||||
qemuBlockStorageSourceAttachDataPtr data)
|
qemuBlockStorageSourceAttachDataPtr data)
|
||||||
{
|
{
|
||||||
int rv;
|
|
||||||
|
|
||||||
if (data->formatProps) {
|
if (data->formatProps) {
|
||||||
rv = qemuMonitorBlockdevAdd(mon, data->formatProps);
|
if (qemuMonitorBlockdevAdd(mon, &data->formatProps) < 0)
|
||||||
data->formatProps = NULL;
|
|
||||||
|
|
||||||
if (rv < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
data->formatAttached = true;
|
data->formatAttached = true;
|
||||||
|
@ -4400,23 +4400,19 @@ qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
|
|||||||
* @mon: monitor object
|
* @mon: monitor object
|
||||||
* @props: JSON object describing the blockdev to add
|
* @props: JSON object describing the blockdev to add
|
||||||
*
|
*
|
||||||
* Adds a new block device (BDS) to qemu. Note that @props is always consumed
|
* Adds a new block device (BDS) to qemu. Note that *@props is consumed
|
||||||
* by this function and should not be accessed after calling this function.
|
* and set to NULL on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
|
qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr props)
|
virJSONValuePtr *props)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("props=%p (node-name=%s)", props,
|
VIR_DEBUG("props=%p (node-name=%s)", *props,
|
||||||
NULLSTR(virJSONValueObjectGetString(props, "node-name")));
|
NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR_GOTO(mon, error);
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
return qemuMonitorJSONBlockdevAdd(mon, props);
|
return qemuMonitorJSONBlockdevAdd(mon, props);
|
||||||
|
|
||||||
error:
|
|
||||||
virJSONValueFree(props);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1330,7 +1330,7 @@ int qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr props);
|
virJSONValuePtr props);
|
||||||
|
|
||||||
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
|
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr props);
|
virJSONValuePtr *props);
|
||||||
|
|
||||||
int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
|
int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
|
||||||
const char *nodename);
|
const char *nodename);
|
||||||
|
@ -8821,12 +8821,13 @@ qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
|
qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr props)
|
virJSONValuePtr *props)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cmd = NULL;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
virJSONValuePtr pr = g_steal_pointer(props);
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", props)))
|
if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", pr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
|
@ -597,7 +597,7 @@ int qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon,
|
|||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
|
int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr props)
|
virJSONValuePtr *props)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
|
int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
|
||||||
|
Loading…
Reference in New Issue
Block a user