On Tue, Oct 15, 2019 at 05:34:46PM +0200, Jiri Denemark wrote:
It is a container for a CPU models list (qemuMonitorCPUDefInfo) and a number of elements in this list. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> --- Notes: Version 2: - v1 reviewed by Ján Tomko, but the patch had to be changed because of the previous patch src/qemu/qemu_capabilities.c | 30 +++++++++---------- src/qemu/qemu_monitor.c | 39 +++++++++++++++++++------ src/qemu/qemu_monitor.h | 14 +++++++-- src/qemu/qemu_monitor_json.c | 56 ++++++++++++++---------------------- src/qemu/qemu_monitor_json.h | 2 +- tests/qemumonitorjsontest.c | 38 +++++++++--------------- 6 files changed, 93 insertions(+), 86 deletions(-)
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3384b538d0..e4e8d2ed0c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2457,7 +2457,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, virArch arch, virDomainCapsCPUModelsPtr *cpuModels) { - VIR_AUTOPTR(qemuMonitorCPUDefs) defs = NULL; + g_autoptr(qemuMonitorCPUDefs) defs = NULL; virDomainCapsCPUModelsPtr models = NULL; size_t i; int ret = -1; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2cce9af929..d1a53f82cb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3557,29 +3557,25 @@ qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs) return; for (i = 0; i < defs->ncpus; i++) { - virStringListFree(defs->cpus[i]->blockers); - VIR_FREE(defs->cpus[i]->name); - VIR_FREE(defs->cpus[i]); + g_strfreev(defs->cpus[i]->blockers); + g_free(defs->cpus[i]->name); + g_free(defs->cpus[i]); } - VIR_FREE(defs->cpus); - VIR_FREE(defs); + g_free(defs->cpus); + g_free(defs); } qemuMonitorCPUDefsPtr qemuMonitorCPUDefsNew(size_t count) { - VIR_AUTOPTR(qemuMonitorCPUDefs) defs = NULL; - - if (VIR_ALLOC(defs) < 0) - return NULL; - - if (count > 0 && VIR_ALLOC_N(defs->cpus, count) < 0) - return NULL; + g_autoptr(qemuMonitorCPUDefs) defs = NULL; + defs = g_new0(qemuMonitorCPUDefs, 1); + defs->cpus = g_new0(qemuMonitorCPUDefInfoPtr, count); defs->ncpus = count; - VIR_RETURN_PTR(defs); + return g_steal_pointer(&defs); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 3bce9a971d..4fed575fd3 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1112,7 +1112,7 @@ int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon, qemuMonitorCPUDefsPtr *cpuDefs); qemuMonitorCPUDefsPtr qemuMonitorCPUDefsNew(size_t count); void qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs); -VIR_DEFINE_AUTOPTR_FUNC(qemuMonitorCPUDefs, qemuMonitorCPUDefsFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorCPUDefs, qemuMonitorCPUDefsFree); typedef enum { diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 104d3a9fc0..b114fabbe0 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -428,7 +428,7 @@ testQemuMonitorJSONGetCPUDefinitions(const void *opaque) { const testGenericData *data = opaque; virDomainXMLOptionPtr xmlopt = data->xmlopt; - VIR_AUTOPTR(qemuMonitorCPUDefs) defs = NULL; + g_autoptr(qemuMonitorCPUDefs) defs = NULL; g_autoptr(qemuMonitorTest) test = NULL; if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list