From 3711c0b051242876e780610b114849c300a7b352 Mon Sep 17 00:00:00 2001 From: Taku Izumi Date: Fri, 10 Jun 2011 15:40:36 +0900 Subject: [PATCH] vcpupin: add virDomainVcpupinDel function This patch add the private API (virDomainVcpupinDel). This API can delete the vcpupin setting of a specified virtual cpu. Signed-off-by: Taku Izumi --- src/conf/domain_conf.c | 39 +++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 42 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8d5e173613..5360863091 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8206,6 +8206,45 @@ cleanup: return -1; } +int +virDomainVcpupinDel(virDomainDefPtr def, int vcpu) +{ + int n; + bool deleted = false; + virDomainVcpupinDefPtr *vcpupin_list = def->cputune.vcpupin; + + /* No vcpupin exists yet */ + if (!def->cputune.nvcpupin) { + return 0; + } + + for (n = 0; n < def->cputune.nvcpupin; n++) { + if (vcpupin_list[n]->vcpuid == vcpu) { + VIR_FREE(vcpupin_list[n]->cpumask); + VIR_FREE(vcpupin_list[n]); + memmove(&vcpupin_list[n], + &vcpupin_list[n+1], + (def->cputune.nvcpupin - n - 1) * sizeof(virDomainVcpupinDef *)); + deleted = true; + break; + } + } + + if (!deleted) + return 0; + + if (--def->cputune.nvcpupin == 0) { + virDomainVcpupinDefFree(def->cputune.vcpupin, 0); + } else { + if (VIR_REALLOC_N(def->cputune.vcpupin, def->cputune.nvcpupin) < 0) { + virReportOOMError(); + 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 3c54e8be2d..ff5c28d7c7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1412,6 +1412,8 @@ int virDomainVcpupinAdd(virDomainDefPtr def, int maplen, int vcpu); +int virDomainVcpupinDel(virDomainDefPtr def, int vcpu); + int virDomainDiskIndexByName(virDomainDefPtr def, const char *name); int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ae18c0dfca..03d2ddb6d2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -364,6 +364,7 @@ virDomainTimerTickpolicyTypeToString; virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainVcpupinAdd; +virDomainVcpupinDel; virDomainVcpupinFindByVcpu; virDomainVcpupinIsDuplicate; virDomainVideoDefFree;