qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-serial: Fix segfault on guest boot
@ 2011-06-16 16:38 Luiz Capitulino
  2011-06-17  6:47 ` Amit Shah
  0 siblings, 1 reply; 16+ messages in thread
From: Luiz Capitulino @ 2011-06-16 16:38 UTC (permalink / raw)
  To: amit.shah; +Cc: qemu-devel, Markus Armbruster, mdroth

If I start qemu with:

 # qemu -hda disks/test.img -enable-kvm -m 1G -snapshot \
        -device virtio-serial \
        -chardev socket,host=localhost,port=1234,server,nowait,id=foo \
        -device virtserialport,chardev=foo,name=org.qemu.guest_agent

I get a segfault when booting a Fedora 14 guest. The backtrace says:

  Program terminated with signal 11, Segmentation fault.
  #0  0x0000000000420850 in handle_control_message (vser=0x3732bd0, buf=0x2c173e0, len=8) at /home/lcapitulino/src/qmp-unstable/hw/virtio-serial-bus.c:335
  335     info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);

I've also bisected this and git points out to commit:

  commit a15bb0d6a981de749452a5180fc8084d625671da
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   Wed May 25 14:21:13 2011 +0200

      virtio-serial: Drop redundant VirtIOSerialPort member info

I think what's happening is that the device is not initialized on a
VIRTIO_CONSOLE_DEVICE_READY event. Moving the DO_UPCAST() call to
the other events fixes the problem to me.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/virtio-serial-bus.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 9a12104..579f676 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -332,8 +332,6 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
     if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY)
         return;
 
-    info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);
-
     switch(cpkt.event) {
     case VIRTIO_CONSOLE_DEVICE_READY:
         if (!cpkt.value) {
@@ -363,6 +361,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
          * this port is a console port so that the guest can hook it
          * up to hvc.
          */
+        info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);
         if (info->is_console) {
             send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
         }
@@ -398,6 +397,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
         break;
 
     case VIRTIO_CONSOLE_PORT_OPEN:
+        info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);
         port->guest_connected = cpkt.value;
         if (cpkt.value && info->guest_open) {
             /* Send the guest opened notification if an app is interested */
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-07-04  6:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-16 16:38 [Qemu-devel] [PATCH] virtio-serial: Fix segfault on guest boot Luiz Capitulino
2011-06-17  6:47 ` Amit Shah
2011-06-17  7:47   ` Markus Armbruster
2011-06-17  8:44     ` Amit Shah
2011-06-17 13:16   ` Luiz Capitulino
2011-06-17 13:21     ` Luiz Capitulino
2011-06-17 16:09     ` Amit Shah
2011-06-17 18:08       ` Luiz Capitulino
2011-06-18  3:42         ` Amit Shah
2011-06-18 21:43           ` Blue Swirl
2011-06-22  4:53             ` Amit Shah
2011-06-26 17:43               ` Blue Swirl
2011-06-27  9:48                 ` [Qemu-devel] 80-column rule and breaking output statements Amit Shah
2011-07-01 19:43                   ` Blue Swirl
2011-07-02  8:38                     ` Stefan Hajnoczi
2011-07-04  6:05                       ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).