[libvirt] Fix locking in qemudDomainMemoryStats

When adding domainMemoryStats API support for the qemu driver, I didn't follow the locking rules exactly. The job condition must be held when executing monitor commands. This corrects the segfaults I was seeing when calling domainMemoryStats in a multi-threaded environment. If this patch is accepted, I would also consider it a candidate for the 0.7.6 stable patch stream (if such a thing exists). Thanks. Signed-off-by: Adam Litke <agl@us.ibm.com> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b8b7916..a9023da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7526,6 +7526,9 @@ qemudDomainMemoryStats (virDomainPtr dom, goto cleanup; } + if (qemuDomainObjBeginJob(vm) < 0) + goto cleanup; + if (virDomainObjIsActive(vm)) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjEnterMonitor(vm); @@ -7536,6 +7539,9 @@ qemudDomainMemoryStats (virDomainPtr dom, "%s", _("domain is not running")); } + if (qemuDomainObjEndJob(vm) == 0) + vm = NULL; + cleanup: if (vm) virDomainObjUnlock(vm); -- Thanks, Adam

On Fri, Mar 05, 2010 at 02:13:05PM -0600, Adam Litke wrote:
When adding domainMemoryStats API support for the qemu driver, I didn't follow the locking rules exactly. The job condition must be held when executing monitor commands. This corrects the segfaults I was seeing when calling domainMemoryStats in a multi-threaded environment.
If this patch is accepted, I would also consider it a candidate for the 0.7.6 stable patch stream (if such a thing exists). Thanks.
Since we're doing regular monthly releases we don't produce any formal patch streams currently, leaving it upto os distros
Signed-off-by: Adam Litke <agl@us.ibm.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b8b7916..a9023da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7526,6 +7526,9 @@ qemudDomainMemoryStats (virDomainPtr dom, goto cleanup; }
+ if (qemuDomainObjBeginJob(vm) < 0) + goto cleanup; + if (virDomainObjIsActive(vm)) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjEnterMonitor(vm); @@ -7536,6 +7539,9 @@ qemudDomainMemoryStats (virDomainPtr dom, "%s", _("domain is not running")); }
+ if (qemuDomainObjEndJob(vm) == 0) + vm = NULL; + cleanup: if (vm) virDomainObjUnlock(vm);
ACK, this is definitely required :-) Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Mar 05, 2010 at 02:13:05PM -0600, Adam Litke wrote:
When adding domainMemoryStats API support for the qemu driver, I didn't follow the locking rules exactly. The job condition must be held when executing monitor commands. This corrects the segfaults I was seeing when calling domainMemoryStats in a multi-threaded environment.
If this patch is accepted, I would also consider it a candidate for the 0.7.6 stable patch stream (if such a thing exists). Thanks.
no such thing, 0.7.8 (or 0.8.0) expected by March end, in the meantime this will need to be pushed along with 0.7.7,
Signed-off-by: Adam Litke <agl@us.ibm.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b8b7916..a9023da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7526,6 +7526,9 @@ qemudDomainMemoryStats (virDomainPtr dom, goto cleanup; }
+ if (qemuDomainObjBeginJob(vm) < 0) + goto cleanup; + if (virDomainObjIsActive(vm)) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjEnterMonitor(vm); @@ -7536,6 +7539,9 @@ qemudDomainMemoryStats (virDomainPtr dom, "%s", _("domain is not running")); }
+ if (qemuDomainObjEndJob(vm) == 0) + vm = NULL; + cleanup: if (vm) virDomainObjUnlock(vm);
Okay, pushed, too bad 0.7.7 was released before it. Thanks for chasing the issue ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Adam Litke
-
Daniel P. Berrange
-
Daniel Veillard