]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Add virCPUDataNewCopy
authorTim Wiederhake <twiederh@redhat.com>
Thu, 7 Oct 2021 11:46:44 +0000 (13:46 +0200)
committerTim Wiederhake <twiederh@redhat.com>
Fri, 5 Nov 2021 16:12:25 +0000 (17:12 +0100)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/cpu/cpu.c
src/cpu/cpu.h
src/libvirt_private.syms

index 0c1c7902f04e2fcfba720e79ccfd9399536f8f54..b5669246b4241f5de91b93374d1c4d3102bd305f 100644 (file)
@@ -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:
  *
index 7ecb0d6921e852c7a9e830a60f7ea6e072a180c8..d3e5ca79f2563eb73fba150b4fd70bd95b419e48 100644 (file)
@@ -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);
index d985ff77a1901aa0b9d206662feb3dafb5315f9b..37215ae0dfe96ccae9b732b0c77c1d07378c3488 100644 (file)
@@ -1464,6 +1464,7 @@ virCPUDataFormat;
 virCPUDataFree;
 virCPUDataIsIdentical;
 virCPUDataNew;
+virCPUDataNewCopy;
 virCPUDataParse;
 virCPUDataParseNode;
 virCPUExpandFeatures;