From nobody Mon Feb 9 07:55:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581092571107490.93710750928653; Fri, 7 Feb 2020 08:22:51 -0800 (PST) Received: from localhost ([::1]:60234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j06P4-0003tP-1P for importer@patchew.org; Fri, 07 Feb 2020 11:22:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j06O5-0002WZ-7w for qemu-devel@nongnu.org; Fri, 07 Feb 2020 11:21:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j06O3-0006gN-Md for qemu-devel@nongnu.org; Fri, 07 Feb 2020 11:21:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45902 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j06O1-0006Ys-Rl for qemu-devel@nongnu.org; Fri, 07 Feb 2020 11:21:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-y2zPQzbFO2GgF2qsUL7uxw-1; Fri, 07 Feb 2020 11:21:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B31488014D8; Fri, 7 Feb 2020 16:21:32 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-88.brq.redhat.com [10.40.204.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 963A8790D8; Fri, 7 Feb 2020 16:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581092503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WkEfF1yWOwbM58Nn71tObxTOpGgWqOKG+23nqswcMZw=; b=GL+8iupobBqXCa1OW1aLn8Dd1wyvufR15w5LXHsuAfMnYw4j/IycuCRYWOvCyqKdoMocQL LyrqKndAXjrh3JjHrFMkW2A2QDVYNGLcudB9GXwTFdrvyBcjTKnXtOrp4pPgEi/jZLGA2N onYyrG1IrHk/7tSZ7qhor/5mbZkuT24= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default Date: Fri, 7 Feb 2020 17:19:48 +0100 Message-Id: <20200207161948.15972-4-philmd@redhat.com> In-Reply-To: <20200207161948.15972-1-philmd@redhat.com> References: <20200207161948.15972-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: y2zPQzbFO2GgF2qsUL7uxw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Wulff , Sagar Karandikar , "Michael S. Tsirkin" , Anthony Green , Mark Cave-Ayland , Alistair Francis , "Edgar E. Iglesias" , Guan Xuetao , Marek Vasut , Jia Liu , qemu-trivial@nongnu.org, Helge Deller , David Hildenbrand , Magnus Damm , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Aleksandar Rikalo , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Artyom Tarasenko , Eduardo Habkost , Richard Henderson , qemu-s390x@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Thomas Huth , Bastian Koppelmann , Cornelia Huck , Laurent Vivier , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It would be confusing to have multiple default machines. Abort if this ever occurs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Laurent Vivier --- v2: Use assert() instead of human friendly message (Marc-Andr=C3=A9) v3: Move the check to find_machine() (Michael) Cc: Marc-Andr=C3=A9 Lureau Cc: Laurent Vivier Cc: Michael S. Tsirkin --- vl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 7dcb0879c4..ebc203af0d 100644 --- a/vl.c +++ b/vl.c @@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name,= GSList *machines) static MachineClass *find_default_machine(GSList *machines) { GSList *el; + MachineClass *default_machineclass =3D NULL; =20 for (el =3D machines; el; el =3D el->next) { MachineClass *mc =3D el->data; =20 if (mc->is_default) { - return mc; + assert(default_machineclass =3D=3D NULL && "Multiple default m= achines"); + default_machineclass =3D mc; } } =20 - return NULL; + return default_machineclass; } =20 static int machine_help_func(QemuOpts *opts, MachineState *machine) --=20 2.21.1