vl: take iothread lock very early
PATCH 1/1 vl: take iothread lock very early
If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that.
--- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
vl.c +3 -3
@@ -2763,6 +2763,9 @@ int main(int argc, char **argv, char **envp)FILE *vmstate_dump_file =NULL ;Error *main_loop_err =NULL ; +qemu_init_cpu_loop (); +qemu_mutex_lock_iothread (); +atexit (qemu_run_exit_notifiers);error_set_progname (argv[0 ]);qemu_init_exec_dir (argv[0 ]);
@@ -4098,9 +4101,6 @@ int main(int argc, char **argv, char **envp)os_set_line_buffering (); -qemu_init_cpu_loop (); -qemu_mutex_lock_iothread (); -#ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init ();
Signature · 1 line
2.3.0
Am 03.03.2015 um 11:36 schrieb Paolo Bonzini:
Quoted 4 lines
If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 29 lines
--- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)vl.c +3
-3@@ -2763,6 +2763,9 @@ int main(int argc, char **argv, char **envp)FILE *vmstate_dump_file =NULL ;Error *main_loop_err =NULL ; +qemu_init_cpu_loop (); +qemu_mutex_lock_iothread (); +atexit (qemu_run_exit_notifiers);error_set_progname (argv[0 ]);qemu_init_exec_dir (argv[0 ]);@@ -4098,9 +4101,6 @@ int main(int argc, char **argv, char **envp)os_set_line_buffering (); -qemu_init_cpu_loop (); -qemu_mutex_lock_iothread (); -#ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init ();
Quoted 8 lines · Paolo Bonzini
If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that.
Signed-off-by Paolo Bonzini <[email protected]>--- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Regards,
-Gonglei
Peter Maydell
AppliedQuoted 4 lines · Paolo Bonzini
If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that.
Signed-off-by Paolo Bonzini <[email protected]>
Applied, thanks.
-- PMM
Hi all,
just brief, this small one breaks my qemu-system-x86_64 with:
qemu: qemu_cond_wait: Operation not permitted
My most complete qemu-starter:
/usr/local/qemu-2.3.0/bin/qemu-system-x86_64 -daemonize -usbdevice tablet -enable-kvm -pidfile /var/run/qemu-server/3371.pid -monitor unix:/var/run/qemu-server/3371.mon,server,nowait -vnc unix:/var/run/qemu-server/3371.vnc,password -qmp unix:/var/run/qemu-server/3371.qmp,server,nowait -nodefaults -serial none -parallel none -device rtl8139,mac=00:F1:70:00:D2:B0,netdev=vlan0d0 -netdev type=tap,id=vlan0d0,ifname=tap3371i0d0,script=/etc/fcms/add_if.sh,downscript=/etc/fcms/downscript.sh -name 1155823384-7 -vga cirrus -k de -smp sockets=1,cores=1 -m 512 -device virtio-blk-pci,drive=virtio0 -drive format=raw,file=rbd:4/vm-3371-disk-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=none,id=virtio0,media=disk,index=0 -drive format=raw,file=rbd:4/vm-3371-swap-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=virtio,media=disk,index=1 -drive if=ide,media=cdrom,id=ide1-cd0,readonly=on -drive if=ide,media=cdrom,id=ide1-cd1,readonly=on -boot order=dc
Up to the former commit everything works well as expected.
Hope it helps,
Oliver.
Quoted 32 lines · Paolo Bonzini
If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that.
Signed-off-by Paolo Bonzini <[email protected]>--- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)vl.c +3
-3@@ -2763,6 +2763,9 @@ int main(int argc, char **argv, char **envp)FILE *vmstate_dump_file =NULL ;Error *main_loop_err =NULL ; +qemu_init_cpu_loop (); +qemu_mutex_lock_iothread (); +atexit (qemu_run_exit_notifiers);error_set_progname (argv[0 ]);qemu_init_exec_dir (argv[0 ]);@@ -4098,9 +4101,6 @@ int main(int argc, char **argv, char **envp)os_set_line_buffering (); -qemu_init_cpu_loop (); -qemu_mutex_lock_iothread (); -#ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init ();
Signature · 10 lines
Oliver Francke filoo GmbH Moltkestraße 25a 33330 Gütersloh HRB4355 AG Gütersloh Geschäftsführer: J.Rehpöhler | C.Kunz Folgen Sie uns auf Twitter: http://twitter.com/filoogmbh
Quoted 17 lines · Oliver Francke
/usr/local/qemu-2.3.0/bin/qemu-system-x86_64-daemonize -usbdevice
tablet -enable-kvm -pidfile/var/run/qemu-server/3371.pid-monitor unix:/var/run/qemu-server/3371.mon,server,nowait -vnc unix:/var/run/qemu-server/3371.vnc,password -qmp unix:/var/run/qemu-server/3371.qmp,server,nowait -nodefaults -serial
none -parallel none -device rtl8139,mac=00:F1:70:00:D2:B0,netdev=vlan0d0
-netdev type=tap,id=vlan0d0,ifname=tap3371i0d0,script=/etc/fcms/add_if.sh,downscript=/etc/fcms/downscript.sh(quoted diff) +0
-2-name 1155823384-7 -vga cirrus -k de -smp sockets=1,cores=1 -m 512 -device virtio-blk-pci,drive=virtio0 -driveformat=raw,file=rbd:4/vm-3371-disk-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=none,id=virtio0,media=disk,index=0 -drive format=raw,file=rbd:4/vm-3371-swap-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=virtio,media=disk,index=1 -drive if=ide,media=cdrom,id=ide1-cd0,readonly=on -drive
if=ide,media=cdrom,id=ide1-cd1,readonly=on -boot order=dc
Quoted 1 line
Up to the former commit everything works well as expected.
Can you gather a backtrace?
Paolo
First bt try below...
Quoted 18 lines · Paolo Bonzini
Quoted 16 lines · Oliver Francke
/usr/local/qemu-2.3.0/bin/qemu-system-x86_64-daemonize -usbdevice
tablet -enable-kvm -pidfile/var/run/qemu-server/3371.pid-monitor unix:/var/run/qemu-server/3371.mon,server,nowait -vnc unix:/var/run/qemu-server/3371.vnc,password -qmp unix:/var/run/qemu-server/3371.qmp,server,nowait -nodefaults -serial
none -parallel none -device rtl8139,mac=00:F1:70:00:D2:B0,netdev=vlan0d0
-netdev type=tap,id=vlan0d0,ifname=tap3371i0d0,script=/etc/fcms/add_if.sh,downscript=/etc/fcms/downscript.sh(quoted diff) +0
-2-name 1155823384-7 -vga cirrus -k de -smp sockets=1,cores=1 -m 512 -device virtio-blk-pci,drive=virtio0 -driveformat=raw,file=rbd:4/vm-3371-disk-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=none,id=virtio0,media=disk,index=0 -drive format=raw,file=rbd:4/vm-3371-swap-1.rbd:rbd_cache=true:rbd_cache_size=16777216:rbd_cache_max_dirty=12582912:rbd_cache_target_dirty=8388608,cache=writeback,if=virtio,media=disk,index=1 -drive if=ide,media=cdrom,id=ide1-cd0,readonly=on -drive
if=ide,media=cdrom,id=ide1-cd1,readonly=on -boot order=dc
Quoted 2 lines
Quoted 1 line
Up to the former commit everything works well as expected.
Can you gather a backtrace?
(gdb) bt
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8, envp=0x7fffffffe270) at vl.c:3770
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Oliver.
Quoted 2 lines
Paolo
Signature · 10 lines
Oliver Francke filoo GmbH Moltkestraße 25a 33330 Gütersloh HRB4355 AG Gütersloh Geschäftsführer: J.Rehpöhler | C.Kunz Folgen Sie uns auf Twitter: http://twitter.com/filoogmbh
Quoted 8 lines · Oliver Francke
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8,envp=0x7fffffffe270) at vl.c:3770
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Try removing -daemonize (hmm, that might actually fix the bug). You should not need "b exit", because the error is a SIGABRT and gdb stops automatically. The fix could be something like this:
vl.c +2 -0
@@ -3759,7 +3759,9 @@ int main(int argc, char **argv, char **envp)loc_set_none (); +qemu_mutex_unlock_iothread ();os_daemonize (); +qemu_mutex_lock_iothread ();if (qemu_init_main_loop (&main_loop_err)) {error_report_err (main_loop_err);
Paolo
Hi,
Quoted 11 lines
Am 03.03.2015 um 18:32 schrieb Paolo Bonzini <[email protected]>:
Quoted 6 lines · Oliver Francke
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8,envp=0x7fffffffe270) at vl.c:3770
Quoted 7 lines
Quoted 2 lines
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Try removing -daemonize (hmm, that might actually fix the bug). You should not need "b exit", because the error is a SIGABRT and gdb stops automatically. The fix could be something like this:
I can confirm, that un-daemonized the VM works, as well as…
vl.c int main(int argc, char **argv, char **envp) · line 3765
Quoted 12 lines
vl.c +2
-0@@ -3759,7 +3759,9 @@ int main(int argc, char **argv, char **envp)loc_set_none (); +qemu_mutex_unlock_iothread ();os_daemonize (); +qemu_mutex_lock_iothread ();
… after applying these 2 lines.
So thnx very much for the quick help/fix.
Oliver.
Quoted 4 lines
vl.c +0
-0if (qemu_init_main_loop (&main_loop_err)) {error_report_err (main_loop_err);Paolo
Am 03.03.2015 um 18:32 schrieb Paolo Bonzini:
Quoted 31 lines · Oliver Francke
Quoted 8 lines
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8,envp=0x7fffffffe270) at vl.c:3770
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Try removing -daemonize (hmm, that might actually fix the bug). You should not need "b exit", because the error is a SIGABRT and gdb stops automatically. The fix could be something like this:
vl.c +2
-0@@ -3759,7 +3759,9 @@ int main(int argc, char **argv, char **envp)loc_set_none (); +qemu_mutex_unlock_iothread ();os_daemonize (); +qemu_mutex_lock_iothread ();if (qemu_init_main_loop (&main_loop_err)) {error_report_err (main_loop_err);
Quoted 2 lines
Paolo
This also fixes some strange issues with libvirt after qemu updates, so probably also a candidate for a quick merge.
Christian
Eric Blake
Tested-byQuoted 9 lines · Paolo Bonzini
Quoted 6 lines · Oliver Francke
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8,envp=0x7fffffffe270) at vl.c:3770
Quoted 4 lines
Quoted 2 lines
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Try removing -daemonize (hmm, that might actually fix the bug).
I've confirmed that libvirt required -daemonize, and that (temporarily) removing -daemonize makes things work again. So we definitely need this.
Quoted 23 lines
You
should not need "b exit", because the error is a SIGABRT and gdb stops automatically. The fix could be something like this:vl.c +2
-0@@ -3759,7 +3759,9 @@ int main(int argc, char **argv, char **envp)loc_set_none (); +qemu_mutex_unlock_iothread ();os_daemonize (); +qemu_mutex_lock_iothread ();if (qemu_init_main_loop (&main_loop_err)) {error_report_err (main_loop_err);Paolo
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 05.03.2015 um 01:40 schrieb Eric Blake:
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Oliver Francke
Quoted 8 lines
#0 __GI_exit (status=1) at exit.c:104 #1 0x000055555575cf15 in os_daemonize () at os-posix.c:227 #2 0x0000555555773f2e in main (argc=50, argv=0x7fffffffe0d8,envp=0x7fffffffe270) at vl.c:3770
compiled with "--enable-debug" and in gdb "b exit". Not a coder, so if this is _not_ sufficient, please give me some adivce ;)
Quoted 6 lines
Quoted 1 line
Try removing -daemonize (hmm, that might actually fix the bug).
I've confirmed that libvirt required -daemonize, and that (temporarily) removing -daemonize makes things work again. So we definitely need this.
Tested-by Eric Blake <[email protected]>
Yes, came to the same conclusion.
Is there a chance to harden the error detection of libvirt somewhat? I got things like
"unsupported OS type hvm"
"unsupported configuration: QEMU 2.2.50 is too new for help parsing"
which made it quite hard to find out what was wrong.
Christian