[libvirt] [PATCH 0/3] vcpu refactoring fixes

My recent refactros led to a few bugs. The memory leak was not caused by me, but it looked like I might have broken it so I've fixed it. Peter Krempa (3): qemu: cpu: Don't remove pinning of cold-unplugged cpu conf: Fix off-by-one in virDomainDefGetVcpu qemu: Fix memory leak in qemuGetSchedInfo src/conf/domain_conf.c | 2 +- src/qemu/qemu_driver.c | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) -- 2.6.2

After adding support for offline vcpu pinning the code that removes the pinning for cpu cold-unplug was forgotten. This fixes up commit 02ae21d Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316371 --- src/qemu/qemu_driver.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 72ed3c0..c1bae52 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4917,19 +4917,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, } if (persistentDef) { - /* remove vcpupin entries for vcpus that were unplugged */ - if (nvcpus < virDomainDefGetVcpus(persistentDef)) { - for (i = virDomainDefGetVcpus(persistentDef) - 1; i >= nvcpus; i--) { - virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(persistentDef, - i); - - if (vcpu) { - virBitmapFree(vcpu->cpumask); - vcpu->cpumask = NULL; - } - } - } - if (flags & VIR_DOMAIN_VCPU_MAXIMUM) { if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0) goto endjob; -- 2.6.2

On Thu, Mar 10, 2016 at 10:03:51AM +0100, Peter Krempa wrote:
After adding support for offline vcpu pinning the code that removes the pinning for cpu cold-unplug was forgotten. This fixes up commit 02ae21d
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316371 --- src/qemu/qemu_driver.c | 13 ------------- 1 file changed, 13 deletions(-)
ACK Jan

Cpus are indexed starting from '0' so the check was invalid. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316384 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316420 --- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 314a584..1aed318 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1405,7 +1405,7 @@ virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) { - if (vcpu > def->maxvcpus) { + if (vcpu >= def->maxvcpus) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vCPU '%u' is not present in domain definition"), vcpu); -- 2.6.2

On Thu, Mar 10, 2016 at 10:03:52 +0100, Peter Krempa wrote:
Cpus are indexed starting from '0' so the check was invalid.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316384 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316420 --- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 314a584..1aed318 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1405,7 +1405,7 @@ virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) { - if (vcpu > def->maxvcpus) { + if (vcpu >= def->maxvcpus) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vCPU '%u' is not present in domain definition"), vcpu);
ACK Jirka

Memory returned from virStringSplit shall be freed with virStringFreeList rather than VIR_FREE. Introduced in commit 511e7c5b. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316433 --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c1bae52..1d4b6ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1433,7 +1433,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait, cleanup: VIR_FREE(data); VIR_FREE(proc); - VIR_FREE(lines); + virStringFreeList(lines); return ret; } -- 2.6.2

On Thu, Mar 10, 2016 at 10:03:53 +0100, Peter Krempa wrote:
Memory returned from virStringSplit shall be freed with virStringFreeList rather than VIR_FREE. Introduced in commit 511e7c5b.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316433 --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c1bae52..1d4b6ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1433,7 +1433,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait, cleanup: VIR_FREE(data); VIR_FREE(proc); - VIR_FREE(lines); + virStringFreeList(lines); return ret; }
ACK Jirka
participants (3)
-
Jiri Denemark
-
Ján Tomko
-
Peter Krempa