From patchwork Wed Sep 23 15:24:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Grunt X-Patchwork-Id: 521741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 383451401AF for ; Thu, 24 Sep 2015 01:24:48 +1000 (AEST) Received: from localhost ([::1]:48544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeluY-00029i-2J for incoming@patchwork.ozlabs.org; Wed, 23 Sep 2015 11:24:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeluH-0001ss-JY for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:24:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeluE-0000L9-Ho for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:24:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeluE-0000Kw-Cr for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:24:26 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B035C98C13 for ; Wed, 23 Sep 2015 15:24:25 +0000 (UTC) Received: from dhcp-4-208.brq.redhat.com (dhcp-4-181.brq.redhat.com [10.34.3.181]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NFOOHH014242 for ; Wed, 23 Sep 2015 11:24:25 -0400 From: Pavel Grunt To: qemu-devel@nongnu.org Date: Wed, 23 Sep 2015 17:24:23 +0200 Message-Id: <1443021863-20752-1-git-send-email-pgrunt@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] spice-qemu-char: do not use port device when it is not active X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Avoid segmentation fault when the webdav channel (spice port channel) is used with the vnc display: #0 0x00007ffff7ab2594 in spice_char_device_state_opaque_get (dev=0x0) at char_device.c:700 #1 0x00007ffff7b0def3 in spice_server_port_event (sin=, event=) at spicevmc.c:572 #2 0x0000555555781564 in set_guest_connected (port=, guest_connected=1) at hw/char/virtio-console.c:89 #3 0x000055555567273c in control_out (len=, buf=0x5555563b3cf0, vser=0x555557906370) at /home/pgrunt/RH/qemu/hw/char/virtio-serial-bus.c:404 #4 0x000055555567273c in control_out (vdev=0x555557906370, vq=0x5555579769f0) at /home/pgrunt/RH/qemu/hw/char/virtio-serial-bus.c:441 #5 0x0000555555883678 in aio_dispatch (ctx=0x5555562d9db0) at aio-posix.c:156 #6 0x0000555555876f5e in aio_ctx_dispatch (source=, callback=, user_data=) at async.c:226 #7 0x00007ffff618ff0a in g_main_context_dispatch (context=0x5555562dae00) at gmain.c:3154 #8 0x00007ffff618ff0a in g_main_context_dispatch (context=context@entry=0x5555562dae00) at gmain.c:3769 #9 0x00005555558823fb in main_loop_wait () at main-loop.c:211 #10 0x00005555558823fb in main_loop_wait (timeout=) at main-loop.c:256 #11 0x00005555558823fb in main_loop_wait (nonblocking=) at main-loop.c:504 #12 0x000055555561514c in main () at vl.c:1879 #13 0x000055555561514c in main (argc=, argv=, envp=) at vl.c:4633 Signed-off-by: Pavel Grunt --- I just changed the display of a VM from Spice to VNC in virt-manager, started the VM and the crash occurred. The VM is the latest Fedora with spice-webdavd installed. --- spice-qemu-char.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index d41bb74..840c181 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -229,6 +229,12 @@ static void spice_port_set_fe_open(struct CharDriverState *chr, int fe_open) #if SPICE_SERVER_VERSION >= 0x000c02 SpiceCharDriver *s = chr->opaque; + if (!s->active) { + fprintf(stderr, "spice-qemu-char: port '%s' is not active\n", + s->sin.portname); + return; + } + if (fe_open) { spice_server_port_event(&s->sin, SPICE_PORT_EVENT_OPENED); } else { @@ -242,6 +248,12 @@ static void spice_chr_fe_event(struct CharDriverState *chr, int event) #if SPICE_SERVER_VERSION >= 0x000c02 SpiceCharDriver *s = chr->opaque; + if (!s->active) { + fprintf(stderr, "spice-qemu-char: port '%s' is not active\n", + s->sin.portname); + return; + } + spice_server_port_event(&s->sin, event); #endif }