1. add a new function virDomainVcpuPinDefCopy
2. make virDomainVcpuPinDefFree non-static
---
src/conf/domain_conf.c | 34 +++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 5 +++++
src/libvirt_private.syms | 2 ++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 56ee4c9..ff27bc7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1505,7 +1505,39 @@ virDomainClockDefClear(virDomainClockDefPtr def)
VIR_FREE(def->timers);
}
-static void
+virDomainVcpuPinDefPtr *
+virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin)
+{
+ int i = 0;
+ virDomainVcpuPinDefPtr *ret;
+
+ if (VIR_ALLOC_N(ret, nvcpupin) < 0) {
+ goto nomem;
+ }
+
+ for (i = 0; i < nvcpupin; i++) {
+ if (VIR_ALLOC(ret[i]) < 0)
+ goto nomem;
+ if (VIR_ALLOC_N(ret[i]->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
+ goto nomem;
+ ret[i]->vcpuid = src[i]->vcpuid;
+ memcpy(ret[i]->cpumask, src[i]->cpumask, VIR_DOMAIN_CPUMASK_LEN);
+ }
+
+ return ret;
+
+nomem:
+ while (i >= 0) {
+ VIR_FREE(ret[i]->cpumask);
+ VIR_FREE(ret[i]);
+ }
+ VIR_FREE(ret);
+ virReportOOMError();
+
+ return NULL;
+}
+
+void
virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr *def,
int nvcpupin)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 30aef6b..025c7fe 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1520,6 +1520,11 @@ struct _virDomainVcpuPinDef {
char *cpumask;
};
+void virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr *def, int nvcpupin);
+
+virDomainVcpuPinDefPtr *virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src,
+ int nvcpupin);
+
int virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def,
int nvcpupin,
int vcpu);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0b0a70d..b513faf 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -504,6 +504,8 @@ virDomainTimerTickpolicyTypeToString;
virDomainTimerTrackTypeFromString;
virDomainTimerTrackTypeToString;
virDomainVcpuPinAdd;
+virDomainVcpuPinDefCopy;
+virDomainVcpuPinDefFree;
virDomainVcpuPinDel;
virDomainVcpuPinFindByVcpu;
virDomainVcpuPinIsDuplicate;
--
1.7.10.2