Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/cpu/cpu.c | 21 +++++++++++++++++++++ src/cpu/cpu.h | 7 +++++++ src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 0c1c7902f0..b5669246b4 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -294,6 +294,27 @@ virCPUDataNew(virArch arch) } +/** + * virCPUDataNewCopy: + * + * Returns a copy of @data or NULL on error. + */ +virCPUData * +virCPUDataNewCopy(virCPUData *data) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("data=%p", data); + + if (!data) + return NULL; + + if ((driver = cpuGetSubDriver(data->arch)) && driver->dataCopyNew) + return driver->dataCopyNew(data); + + return NULL; +} + /** * virCPUDataFree: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 7ecb0d6921..d3e5ca79f2 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -62,6 +62,9 @@ typedef int virCPUData **forbidden, virCPUData **vendor); +typedef virCPUData * +(*cpuArchDataCopyNew)(virCPUData *data); + typedef void (*cpuArchDataFree) (virCPUData *data); @@ -134,6 +137,7 @@ struct cpuArchDriver { virCPUArchCompare compare; cpuArchDecode decode; cpuArchEncode encode; + cpuArchDataCopyNew dataCopyNew; cpuArchDataFree dataFree; virCPUArchGetHost getHost; virCPUArchBaseline baseline; @@ -188,6 +192,9 @@ cpuEncode (virArch arch, virCPUData * virCPUDataNew(virArch arch); +virCPUData * +virCPUDataNewCopy(virCPUData *data); + void virCPUDataFree(virCPUData *data); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUData, virCPUDataFree); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3b6645b4a8..665db255a6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1462,6 +1462,7 @@ virCPUDataFormat; virCPUDataFree; virCPUDataIsIdentical; virCPUDataNew; +virCPUDataNewCopy; virCPUDataParse; virCPUDataParseNode; virCPUExpandFeatures; -- 2.31.1