On Thu, Jan 17, 2013 at 05:28:28PM +0000, Daniel P. Berrange wrote:
On Wed, Jan 16, 2013 at 10:53:03AM +0800, Hu Tao wrote:
> ---
> daemon/libvirtd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index 9cdf4d9..7cb99b1 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -1500,5 +1500,7 @@ cleanup:
>
> daemonConfigFree(config);
>
> + virStateCleanup();
> +
> return ret;
> }
Unfortunately this causes libvirtd to segv, if you Ctrl-C the daemon
shortly after startup. The problem is that virStateCleanup is running
before virStateInitialize has finished its work. We probably need to
put a mutex in the virStateInitialize+virStateCleanup functions to
make sure they serialize
Another problem about lockup is revealed by the method(Ctrl-C shortly after
the daemon startup), as below:
(gdb) bt
#0 0x000000336500ddcd in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x0000003365009c56 in _L_lock_840 () from /lib64/libpthread.so.0
#2 0x0000003365009b58 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007f2d21c2dbbd in virMutexLock (m=<optimized out>) at
util/virthreadpthread.c:85
#4 0x00007f2d153e776d in qemuDriverLock (driver=<optimized out>) at
qemu/qemu_conf.c:65
#5 0x00007f2d154180ee in qemuShutdown () at qemu/qemu_driver.c:1098
#6 0x00007f2d21c9fdaf in virStateCleanup () at libvirt.c:846
#7 0x000000000040c129 in main (argc=<optimized out>, argv=<optimized out>) at
libvirtd.c:1517
(gdb) thread 2
[Switching to thread 2 (Thread 0x7f2d14f43700 (LWP 20335))]
#0 0x000000336500b595 in pthread_cond_wait@(a)GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0 0x000000336500b595 in pthread_cond_wait@(a)GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f2d21c2dcea in virCondWait (c=c@entry=0x7f2d10059668,
m=m@entry=0x7f2d10059640)
at util/virthreadpthread.c:117
#2 0x00007f2d153fd9cc in qemuMonitorSend (mon=mon@entry=0x7f2d10059630,
msg=msg@entry=0x7f2d14f41f30) at qemu/qemu_monitor.c:889
#3 0x00007f2d1540e913 in qemuMonitorJSONCommandWithFd (mon=mon@entry=0x7f2d10059630,
cmd=cmd@entry=0x7f2d10014360, scm_fd=scm_fd@entry=-1,
reply=reply@entry=0x7f2d14f41fb0)
at qemu/qemu_monitor_json.c:265
#4 0x00007f2d1540ea95 in qemuMonitorJSONCommand (mon=mon@entry=0x7f2d10059630,
cmd=cmd@entry=0x7f2d10014360, reply=reply@entry=0x7f2d14f41fb0) at
qemu/qemu_monitor_json.c:294
#5 0x00007f2d15410027 in qemuMonitorJSONSetCapabilities (mon=mon@entry=0x7f2d10059630)
at qemu/qemu_monitor_json.c:991
#6 0x00007f2d153fea3d in qemuMonitorSetCapabilities (mon=mon@entry=0x7f2d10059630)
at qemu/qemu_monitor.c:1153
#7 0x00007f2d153bef70 in qemuCapsInitQMP (runGid=0, runUid=0, runDir=<optimized
out>,
libDir=0x7f2d10066310 "/var/lib/libvirt/qemu", caps=0x7f2d100567f0)
at qemu/qemu_capabilities.c:2381
#8 qemuCapsNewForBinary (binary=binary@entry=0x7f2d1005f300
"/usr/local/bin/qemu-system-x86_64",
libDir=0x7f2d10066310 "/var/lib/libvirt/qemu", runDir=<optimized out>,
runUid=0, runGid=0)
at qemu/qemu_capabilities.c:2505
#9 0x00007f2d153c058e in qemuCapsCacheLookup (cache=cache@entry=0x7f2d10002420,
binary=0x7f2d1005f300 "/usr/local/bin/qemu-system-x86_64") at
qemu/qemu_capabilities.c:2597
#10 0x00007f2d153c08c1 in qemuCapsInitGuest (guestarch=VIR_ARCH_I686,
hostarch=VIR_ARCH_X86_64,
cache=0x7f2d10002420, caps=0x7f2d100653f0) at qemu/qemu_capabilities.c:685
#11 qemuCapsInit (cache=0x7f2d10002420) at qemu/qemu_capabilities.c:920
#12 0x00007f2d15418436 in qemuCreateCapabilities (driver=driver@entry=0x7f2d100269b0)
at qemu/qemu_driver.c:424
#13 0x00007f2d15418d37 in qemuStartup (privileged=<optimized out>,
callback=<optimized out>,
opaque=<optimized out>) at qemu/qemu_driver.c:874
#14 0x00007f2d21c9fcc0 in virStateInitialize (privileged=true,
callback=callback@entry=0x40d480 <daemonInhibitCallback>,
opaque=opaque@entry=0x1ea2b40)
at libvirt.c:822
#15 0x000000000040d5d5 in daemonRunStateInit (opaque=opaque@entry=0x1ea2b40) at
libvirtd.c:877
#16 0x00007f2d21c2d986 in virThreadHelper (data=<optimized out>) at
util/virthreadpthread.c:161
#17 0x0000003365007d14 in start_thread () from /lib64/libpthread.so.0
#18 0x0000003364cf167d in clone () from /lib64/libc.so.6
(gdb)
--
Thanks,
Hu Tao