From nobody Sun Oct 5 17:23:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540330846407764.7447750342686; Tue, 23 Oct 2018 14:40:46 -0700 (PDT) Received: from localhost ([::1]:44326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gF4Pt-0006lY-AX for importer@patchew.org; Tue, 23 Oct 2018 17:40:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gF4LY-0002lM-Ej for qemu-devel@nongnu.org; Tue, 23 Oct 2018 17:36:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gF4LW-0000mK-9U for qemu-devel@nongnu.org; Tue, 23 Oct 2018 17:36:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gF4LU-0000jS-4c for qemu-devel@nongnu.org; Tue, 23 Oct 2018 17:36:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0B3F3091746 for ; Tue, 23 Oct 2018 21:36:09 +0000 (UTC) Received: from red.redhat.com (ovpn-120-179.rdu2.redhat.com [10.10.120.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AF6B608EC; Tue, 23 Oct 2018 21:36:01 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 22:35:59 +0100 Message-Id: <20181023213600.364086-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 23 Oct 2018 21:36:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] vl: Avoid crash when -mon is underspecified X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, armbru@redhat.com, peterx@redhat.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A quick coredump on an incomplete command line: ./x86_64-softmmu/qemu-system-x86_64 -mon mode=3Dcontrol,pretty=3Don #0 0x00007ffff723d9e4 in g_str_hash () at /lib64/libglib-2.0.so.0 #1 0x00007ffff723ce38 in g_hash_table_lookup () at /lib64/libglib-2.0.so.0 #2 0x0000555555cc0073 in object_class_property_find (klass=3D0x5555566a94= b0, name=3D0x0, errp=3D0x0) at qom/object.c:1135 #3 0x0000555555cc004b in object_class_property_find (klass=3D0x5555566a94= 40, name=3D0x0, errp=3D0x0) at qom/object.c:1129 #4 0x0000555555cbfe6e in object_property_find (obj=3D0x5555568348c0, name= =3D0x0, errp=3D0x0) at qom/object.c:1080 #5 0x0000555555cc183d in object_resolve_path_component (parent=3D0x555556= 8348c0, part=3D0x0) at qom/object.c:1762 #6 0x0000555555d82071 in qemu_chr_find (name=3D0x0) at chardev/char.c:802 #7 0x00005555559d77cb in mon_init_func (opaque=3D0x0, opts=3D0x5555566b65= a0, errp=3D0x0) at vl.c:2291 Fix it to instead fail gracefully. Signed-off-by: Eric Blake Reviewed-by: Paolo Bonzini Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vl.c b/vl.c index 4e25c78bff0..2ed8672eb79 100644 --- a/vl.c +++ b/vl.c @@ -2288,6 +2288,10 @@ static int mon_init_func(void *opaque, QemuOpts *opt= s, Error **errp) } chardev =3D qemu_opt_get(opts, "chardev"); + if (!chardev) { + error_report("chardev is required"); + exit(1); + } chr =3D qemu_chr_find(chardev); if (chr =3D=3D NULL) { error_report("chardev \"%s\" not found", chardev); --=20 2.17.2