These forms modify contents of a qemuMonitorCPUModelInfo structure but do not allocate or free the actual structure. Init - Initialize model name and empty properties within existing structure FreeContents - Free model name and properties within existing structure --- src/qemu/qemu_monitor.c | 35 ++++++++++++++++++++++++++++++++++- src/qemu/qemu_monitor.h | 4 ++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 371aaa15da..2d9297c3a7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3636,8 +3636,31 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, } +int +qemuMonitorCPUModelInfoInit(const char *name, qemuMonitorCPUModelInfoPtr model) +{ + int ret = -1; + + if (!model) + goto cleanup; + + model->name = NULL; + model->nprops = 0; + model->props = NULL; + model->props_migratable_valid = false; + + if (VIR_STRDUP(model->name, name) < 0) + goto cleanup; + + ret = 0; + + cleanup: + return ret; +} + + void -qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) +qemuMonitorCPUModelInfoFreeContents(qemuMonitorCPUModelInfoPtr model_info) { size_t i; @@ -3652,6 +3675,16 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) VIR_FREE(model_info->props); VIR_FREE(model_info->name); + + model_info->nprops = 0; + model_info->props_migratable_valid = false; +} + + +void +qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) +{ + qemuMonitorCPUModelInfoFreeContents(model_info); VIR_FREE(model_info); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 208a7f5d21..0b84a91fbc 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1021,6 +1021,10 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelInfoPtr *model_info); void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); +void qemuMonitorCPUModelInfoFreeContents(qemuMonitorCPUModelInfoPtr model_info); + +int qemuMonitorCPUModelInfoInit(const char *name, qemuMonitorCPUModelInfoPtr model) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list