From 9375ba2a6e0c1dba9e9e6feb1b4a698b64c47085 Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Fri, 20 Dec 2013 16:01:46 +0100 Subject: [PATCH] libxl: correctly handle affinity reset in virDomainPinVcpu[Flags] By actually removing the element (from within the section) from the XML, rather than jus update it with a fully set vcpu affinity mask. Signed-off-by: Dario Faggioli Cc: Jim Fehlig Cc: Ian Jackson --- src/libxl/libxl_driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d65fdd942a..b24c195c82 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2365,6 +2365,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, libxlDriverPrivatePtr driver = dom->conn->privateData; libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); virDomainDefPtr targetDef = NULL; + virBitmapPtr pcpumap = NULL; virDomainObjPtr vm; int ret = -1; @@ -2394,6 +2395,10 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, /* Make sure coverity knows targetDef is valid at this point. */ sa_assert(targetDef); + pcpumap = virBitmapNewData(cpumap, maplen); + if (!pcpumap) + goto cleanup; + if (flags & VIR_DOMAIN_AFFECT_LIVE) { libxl_bitmap map = { .size = maplen, .map = cpumap }; libxlDomainObjPrivatePtr priv; @@ -2407,6 +2412,17 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, } } + /* full bitmap means reset the settings (if any). */ + if (virBitmapIsAllSet(pcpumap)) { + if (virDomainVcpuPinDel(targetDef, vcpu) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to delete vcpupin xml for vcpu '%d'"), + vcpu); + goto cleanup; + } + goto out; + } + if (!targetDef->cputune.vcpupin) { if (VIR_ALLOC(targetDef->cputune.vcpupin) < 0) goto cleanup; @@ -2422,6 +2438,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, goto cleanup; } +out: ret = 0; if (flags & VIR_DOMAIN_AFFECT_LIVE) { @@ -2433,6 +2450,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, cleanup: if (vm) virObjectUnlock(vm); + virBitmapFree(pcpumap); virObjectUnref(cfg); return ret; }