From patchwork Thu Jan 9 17:06:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 855975 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1335109wra; Thu, 9 Jan 2025 09:08:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX68yZPu7m4f6Z0uFuhM3sRv5n9NDwFZRpuCsaxm838x/0GQVrDeHuDguMd3uxa35VoPaOqtQ==@linaro.org X-Google-Smtp-Source: AGHT+IGQkcFkEjtwpWB3JVyT9m5tS/zPLEVsudfR0benvxlRAkT/Vv7AlT/4wQPOY3KAWy1ok+22 X-Received: by 2002:a05:690c:7481:b0:6ef:805c:ea0d with SMTP id 00721157ae682-6f531227526mr68245677b3.16.1736442525759; Thu, 09 Jan 2025 09:08:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736442525; cv=none; d=google.com; s=arc-20240605; b=O5SrDU4jeRi7m8Ifg9SvMdEc6nbV88w1Zflhh4Mzorroh+0ZNw1/H74pIGI1/2kPwF 2+TuSznpod9dxoip4uuCjx2p7ziChw4q4A54I1yZwqcuHjCxLzy/WyIln1f7dcZlEv7I Oy3aiWFIWSTwtJLor/3zK0uP++KJ5LTf/Mkmw/fFWhpjD5udhw7urJAVWnN+fZzS3pGq G83LS0XkYfpMD5se2G78dFMJRq7pVf1XYHA5VANYaPXVepMsaIiDjMkM4+dm4MDHTvGC E/ljuAuuuJiZPo+fu3Qc34qfTpE0x/+RiIdyED4K490/8KYRSjVmTyurfqEW15V4nVuF rxzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m4HscSGSbgGDvVgJtmItkpjxqeI2JXO5tblvojQlyxc=; fh=FS+JTz/k+Dh1PAd9s6lkEQMFdt/HYT5+zFPDR3GvHJ0=; b=P4RzKnc5GQBzsAiWCYxxH+xHFBoS0L1mHoKrwKsYkeb+w1IksVrIZiLc5YyBn31K8v DGSj8bvjL1rU4AQGuKQOpLEbdvpjFpf4g2oLVnTFceMvF+dbgDv8eaYsqX1kew4yFjSf A/qo0BzfV/sV2hayzYVI4kgeF2vNPnU5/oKwRZNJEP+t419UfCFr/uh2+4sdOez61ig3 G48e3fteaId7duME4iwTBRxuDCeNokiobn8Qg0etD1Kp7ul1iGsUNEvdPZ97klFAFfTU pS3Ia+VvKN+r4bCQ5wJKa1zs3fm3NIcf36gquMLJMt/SUccT1hKmZWAhVuO1gfeAlju/ ja3Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HeUPOBUY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 00721157ae682-6f546d157bdsi11763187b3.217.2025.01.09.09.08.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 09:08:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HeUPOBUY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVvzb-0004j6-1B; Thu, 09 Jan 2025 12:06:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVvzQ-0004hW-QP for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:37 -0500 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVvzP-0006zH-65 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:36 -0500 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-ab2aea81cd8so164078466b.2 for ; Thu, 09 Jan 2025 09:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736442393; x=1737047193; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m4HscSGSbgGDvVgJtmItkpjxqeI2JXO5tblvojQlyxc=; b=HeUPOBUYQQFyA25g4kvtKrB1ujRne8ADc2aJYvjaYbm0G3JmH0XW6LSBueQew/++gU RPlktqkiNFTcCsIPTQCUHcXxmuDTGkBAtH7bVk5i20nX3wcNEuBKQOI4zF3En983vWsw Snbzu8Z07VLPlecPuwAqEU+YRFV7gn0DgVAA3rvxw8N0o1maUg9X19jWW3Hhj6/08cuK NznReSjWdPOmP2FcOQq+3EXgJiDuJBTBYePJ4k9NyoGv0ifpWDqZ5Pu0RBIx4iZqVOrv /0Lz6rld7LVGZY5hEkeR3RVWb5u3Vpp5F4jAEF978inreU3RoP4X+yr3ZuX9aUQh/o16 DNCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736442393; x=1737047193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m4HscSGSbgGDvVgJtmItkpjxqeI2JXO5tblvojQlyxc=; b=CM555AMAjX9bPkK8d554e4fdcY+aRz8jL+E21xCMNWwzBmRRZ3yiJdst6oY/Ux3jRh rpZUuT7r0CncUTrdqdbf1/27WZeDHj1fOAFdiRhFofHTIk7CFK8YeY3sytX+rWv3e0wz Q0XSDDSD111A4MyAlZSxjs/pZ4Clf3YEZTmFSqhg6apkUkGWyM4EzZsl8XO3Y7QoJL9T MFRIrZhMB7YZv8eBFk3ladb/pxpR+vBQIR6ZOXh1qM/ZlGylBVF4SbCjOKwNzOdtADOX LKqs8iXg4JSZNg7xMQ5P9iXsFjhocxTV/w2WzROgUx5e1sEqcJMINhEcFyRt9PCg08O8 Fp+g== X-Gm-Message-State: AOJu0YzEZE+DhbXffMK0ikeASCyLPPA/9qX+kfeYBf3difQ9nHnsQtIq hSSw5lztc51C8FiBjg8u3tPE2Hlj2y5/UHnmvihxbVKFxIMHKzTo+ZGxmaqtyDg= X-Gm-Gg: ASbGncuzESmsoE1Qgy2rwj2qy9teQFU9OCfu5KI1ejVeFUn+ktdG59GiiCTakhZH5jP zZiYWcmlqih1mA/mUPMaE7fINeudVk0/FKVA+y4NzwUmfGoYrGJEkWfHZm739sJn4aHKrXVcIVC vzcQeQqYvMH0PhZ3MYS9W6HaSyDD3U5cjLyZ3ZZoUcrGixkPmgoZpi/x6S0E52dxV5SFlBI+/Yo P0tM/nox1KwPzsj+w4jS2ztR2hCdiGQZBtXcKJ/zQ4SMqh9DSYgyko= X-Received: by 2002:a17:907:7e86:b0:aa6:92de:ddae with SMTP id a640c23a62f3a-ab2ab6a3fbemr654526166b.16.1736442393404; Thu, 09 Jan 2025 09:06:33 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9060a4fsm90134366b.15.2025.01.09.09.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 09:06:31 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 89A8C5FAA7; Thu, 9 Jan 2025 17:06:20 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Thomas Huth , Mahmoud Mandour , Alexandre Iooss , Richard Henderson , Paolo Bonzini , Laurent Vivier , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 08/22] system/vl: more error exit into config enumeration code Date: Thu, 9 Jan 2025 17:06:05 +0000 Message-Id: <20250109170619.2271193-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109170619.2271193-1-alex.bennee@linaro.org> References: <20250109170619.2271193-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org All of the failures to configure devices will result in QEMU exiting with an error code. In preparation for passing Error * down the chain re-name the iterator to foreach_device_config_or_exit and exit using &error_fatal instead of returning a failure indication. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- system/vl.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/system/vl.c b/system/vl.c index 0843b7ab49..25d9968ccc 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1307,7 +1307,14 @@ static void add_device_config(int type, const char *cmdline) QTAILQ_INSERT_TAIL(&device_configs, conf, next); } -static int foreach_device_config(int type, int (*func)(const char *cmdline)) +/** + * foreach_device_config_or_exit(): process per-device configs + * @type: device_config type + * @func: device specific config function, returning pass/fail + * + * Any failure is fatal and we exit with an error message. + */ +static void foreach_device_config_or_exit(int type, int (*func)(const char *cmdline)) { struct device_config *conf; int rc; @@ -1319,10 +1326,10 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) rc = func(conf->cmdline); loc_pop(&conf->loc); if (rc) { - return rc; + error_setg(&error_fatal, "failed to configure: %s", conf->cmdline); + exit(1); } } - return 0; } static void qemu_disable_default_devices(void) @@ -2044,12 +2051,9 @@ static void qemu_create_late_backends(void) qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); - if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) - exit(1); - if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) - exit(1); - if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) - exit(1); + foreach_device_config_or_exit(DEV_SERIAL, serial_parse); + foreach_device_config_or_exit(DEV_PARALLEL, parallel_parse); + foreach_device_config_or_exit(DEV_DEBUGCON, debugcon_parse); /* now chardevs have been created we may have semihosting to connect */ qemu_semihosting_chardev_init(); @@ -2670,8 +2674,7 @@ static void qemu_create_cli_devices(void) /* init USB devices */ if (machine_usb(current_machine)) { - if (foreach_device_config(DEV_USB, usb_parse) < 0) - exit(1); + foreach_device_config_or_exit(DEV_USB, usb_parse); } /* init generic devices */ @@ -2718,10 +2721,8 @@ static bool qemu_machine_creation_done(Error **errp) exit(1); } - if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { - error_setg(errp, "could not start gdbserver"); - return false; - } + foreach_device_config_or_exit(DEV_GDB, gdbserver_start); + if (!vga_interface_created && !default_vga && vga_interface_type != VGA_NONE) { warn_report("A -vga option was passed but this machine "