mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 22:45:17 +00:00
virQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen
In an attempt to simplify qemuDomainSaveImageOpen we need to add automatic pointer clearing for virQEMUSaveData. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f76a571820
commit
92b9657986
@ -2856,6 +2856,7 @@ virQEMUSaveDataFree(virQEMUSaveDataPtr data)
|
|||||||
VIR_FREE(data);
|
VIR_FREE(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUSaveDataFree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function steals @domXML on success.
|
* This function steals @domXML on success.
|
||||||
@ -6692,7 +6693,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virQEMUSaveDataPtr data = NULL;
|
g_autoptr(virQEMUSaveData) data = NULL;
|
||||||
virQEMUSaveHeaderPtr header;
|
virQEMUSaveHeaderPtr header;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
int oflags = open_write ? O_RDWR : O_RDONLY;
|
int oflags = open_write ? O_RDWR : O_RDONLY;
|
||||||
@ -6809,13 +6810,12 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*ret_def = def;
|
*ret_def = def;
|
||||||
*ret_data = data;
|
*ret_data = g_steal_pointer(&data);
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
virQEMUSaveDataFree(data);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user