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 0d34593..264adcc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1497,7 +1497,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 206ea3b..a18408e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1517,6 +1517,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 0934dba..c3b05d3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -501,6 +501,8 @@ virDomainTimerTickpolicyTypeToString; virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainVcpuPinAdd; +virDomainVcpuPinDefCopy; +virDomainVcpuPinDefFree; virDomainVcpuPinDel; virDomainVcpuPinFindByVcpu; virDomainVcpuPinIsDuplicate; -- 1.7.10.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list