[libvirt] [PATCH] Speed up fallback to legacy non-QMP probing

2013-01-07 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Since we daemonized QEMU for capabilities probing there is a long
time if QEMU fals to launch. This is because we're not passing in
any virDomainObjPtr instance and thus the monitor code can not
check to see if the PID is still alive.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/qemu/qemu_capabilities.c | 34 --
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e16bc70..bcecc6d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2307,6 +2307,8 @@ qemuCapsInitQMP(qemuCapsPtr caps,
 char *pidfile = NULL;
 qemuCapsHookData hookData;
 char *archstr;
+pid_t pid = 0;
+virDomainObj vm;
 
 /* the .sock sufix is important to avoid a possible clash with a qemu
  * domain called capabilities
@@ -2360,7 +2362,16 @@ qemuCapsInitQMP(qemuCapsPtr caps,
 goto cleanup;
 }
 
-if (!(mon = qemuMonitorOpen(NULL, config, true, callbacks))) {
+if (virPidFileReadPath(pidfile, pid)  0) {
+VIR_DEBUG(Failed to read pidfile %s, pidfile);
+ret = 0;
+goto cleanup;
+}
+
+memset(vm, 0, sizeof(vm));
+vm.pid = pid;
+
+if (!(mon = qemuMonitorOpen(vm, config, true, callbacks))) {
 ret = 0;
 goto cleanup;
 }
@@ -2446,21 +2457,16 @@ cleanup:
 VIR_FREE(monpath);
 VIR_FREE(package);
 
-if (pidfile) {
+if (pid != 0) {
 char ebuf[1024];
-pid_t pid;
-int rc;
 
-if ((rc = virPidFileReadPath(pidfile, pid))  0) {
-VIR_DEBUG(Failed to read pidfile %s: %s,
-  pidfile, virStrerror(-rc, ebuf, sizeof(ebuf)));
-} else {
-VIR_DEBUG(Killing QMP caps process %lld, (long long) pid);
-if (virProcessKill(pid, SIGKILL)  0  errno != ESRCH)
-VIR_ERROR(_(Failed to kill process %lld: %s),
-  (long long) pid,
-  virStrerror(errno, ebuf, sizeof(ebuf)));
-}
+VIR_DEBUG(Killing QMP caps process %lld, (long long) pid);
+if (virProcessKill(pid, SIGKILL)  0  errno != ESRCH)
+VIR_ERROR(_(Failed to kill process %lld: %s),
+  (long long) pid,
+  virStrerror(errno, ebuf, sizeof(ebuf)));
+}
+if (pidfile) {
 unlink(pidfile);
 VIR_FREE(pidfile);
 }
-- 
1.8.0.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Speed up fallback to legacy non-QMP probing

2013-01-07 Thread Eric Blake
On 01/07/2013 09:20 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Since we daemonized QEMU for capabilities probing there is a long
 time if QEMU fals to launch. This is because we're not passing in

s/fals/fails/

 any virDomainObjPtr instance and thus the monitor code can not
 check to see if the PID is still alive.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/qemu/qemu_capabilities.c | 34 --
  1 file changed, 20 insertions(+), 14 deletions(-)

ACK.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list