Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 2:
- no change
Version 3:
- more glib functions
- the function now returns the pointer to the copy rather than int
as it can never fail
src/qemu/qemu_monitor.c | 23 +++++++++++++++++++++++
src/qemu/qemu_monitor.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index f906472cd1..39c3122074 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3594,6 +3594,29 @@ qemuMonitorCPUDefsNew(size_t count)
}
+qemuMonitorCPUDefsPtr
+qemuMonitorCPUDefsCopy(qemuMonitorCPUDefsPtr src)
+{
+ g_autoptr(qemuMonitorCPUDefs) defs = NULL;
+ size_t i;
+
+ if (!src)
+ return NULL;
+
+ defs = qemuMonitorCPUDefsNew(src->ncpus);
+ for (i = 0; i < src->ncpus; i++) {
+ qemuMonitorCPUDefInfoPtr cpuDst = defs->cpus + i;
+ qemuMonitorCPUDefInfoPtr cpuSrc = src->cpus + i;
+
+ cpuDst->usable = cpuSrc->usable;
+ cpuDst->name = g_strdup(cpuSrc->name);
+ cpuDst->blockers = g_strdupv(cpuSrc->blockers);
+ }
+
+ return g_steal_pointer(&defs);
+}
+
+
int
qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
qemuMonitorCPUModelExpansionType type,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index f275e910cf..629379802c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1122,6 +1122,7 @@ struct _qemuMonitorCPUDefs {
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
qemuMonitorCPUDefsPtr *cpuDefs);
qemuMonitorCPUDefsPtr qemuMonitorCPUDefsNew(size_t count);
+qemuMonitorCPUDefsPtr qemuMonitorCPUDefsCopy(qemuMonitorCPUDefsPtr src);
void qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorCPUDefs, qemuMonitorCPUDefsFree);
--
2.23.0