Signed-off-by: Tang Chen <tangchen(a)cn.fujitsu.com>
---
src/conf/domain_conf.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 6 ++++
src/libvirt_private.syms | 2 +
3 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cd3079f..4f56010 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10690,6 +10690,82 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu)
return 0;
}
+int
+virDomainHypervisorPinAdd(virDomainDefPtr def,
+ unsigned char *cpumap,
+ int maplen)
+{
+ virDomainVcpuPinDefPtr hypervisorpin = NULL;
+ char *cpumask = NULL;
+ int i;
+
+ if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* Reset cpumask to all 0s. */
+ for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++)
+ cpumask[i] = 0;
+
+ /* Convert bitmap (cpumap) to cpumask, which is byte map. */
+ for (i = 0; i < maplen; i++) {
+ int cur;
+
+ for (cur = 0; cur < 8; cur++) {
+ if (cpumap[i] & (1 << cur))
+ cpumask[i * 8 + cur] = 1;
+ }
+ }
+
+ if (!def->cputune.hypervisorpin) {
+ /* No hypervisorpin exists yet. */
+ if (VIR_ALLOC(hypervisorpin) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ hypervisorpin->vcpuid = -1;
+ hypervisorpin->cpumask = cpumask;
+ def->cputune.hypervisorpin = hypervisorpin;
+ } else {
+ /* Since there is only 1 hypervisorpin for each vm,
+ * juest replace the old one.
+ */
+ VIR_FREE(def->cputune.hypervisorpin->cpumask);
+ def->cputune.hypervisorpin->cpumask = cpumask;
+ }
+
+ return 0;
+
+cleanup:
+ if (cpumask)
+ VIR_FREE(cpumask);
+ return -1;
+}
+
+int
+virDomainHypervisorPinDel(virDomainDefPtr def)
+{
+ virDomainVcpuPinDefPtr hypervisorpin = NULL;
+
+ /* No hypervisorpin exists yet */
+ if (!def->cputune.hypervisorpin) {
+ return 0;
+ }
+
+ hypervisorpin = def->cputune.hypervisorpin;
+
+ VIR_FREE(hypervisorpin->cpumask);
+ VIR_FREE(hypervisorpin);
+ def->cputune.hypervisorpin = NULL;
+
+ if (def->cputune.hypervisorpin)
+ return -1;
+
+ return 0;
+}
+
static int
virDomainLifecycleDefFormat(virBufferPtr buf,
int type,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3db35d4..172cd95 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1944,6 +1944,12 @@ int virDomainVcpuPinAdd(virDomainDefPtr def,
int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
+int virDomainHypervisorPinAdd(virDomainDefPtr def,
+ unsigned char *cpumap,
+ int maplen);
+
+int virDomainHypervisorPinDel(virDomainDefPtr def);
+
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
bool allow_ambiguous);
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8612044..9e3238e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -476,6 +476,8 @@ virDomainTimerTrackTypeFromString;
virDomainTimerTrackTypeToString;
virDomainVcpuPinAdd;
virDomainVcpuPinDel;
+virDomainHypervisorPinAdd;
+virDomainHypervisorPinDel;
virDomainVcpuPinFindByVcpu;
virDomainVcpuPinIsDuplicate;
virDomainVideoDefFree;
--
1.7.3.1