From patchwork Thu Jan 16 16:02:37 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: 857906 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:cc8:b0:385:e875:8a9e with SMTP id dq8csp279975wrb; Thu, 16 Jan 2025 08:11:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVb6pxCtBkNf49NYog/WvHJXSzqfENB+akwABnQ97y6/2Rcfkmdm0pdj/Zjc5h69USF3T/iUA==@linaro.org X-Google-Smtp-Source: AGHT+IFU8AiNBDpCO1NaP7WqTUAMePpYrTvvHxCajpyUiIwTI4KwaIAXvajmbL2GgtkstjUP2XTj X-Received: by 2002:a5d:6d03:0:b0:385:df73:2f18 with SMTP id ffacd0b85a97d-38a8733bad0mr14708933f8f.51.1737043871735; Thu, 16 Jan 2025 08:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737043871; cv=none; d=google.com; s=arc-20240605; b=QPJVehm+KH+8GSwGvlwXhkYp7cOtmmgyHceH3zFSpsY20FEBkWcwBmSApcXEjJ1oN2 jOkDvV9R99rrEgqVReBUwOsPmMDrXt8jLUJYi4BycBuY3v5slRLi07i1N38lh4OutHre GEtIO9D9Np/vv7Ztyjumf7adZMleJpUnk3Kv1hzO19WRNfEsUKkZU1rdAYgzUjl4rQ2s TnQqZwXxdyaUp/GGFmTRK/Uey57jtUZBMv7WcyfgeQ+iyzQOkcUVNkZC1HpR58rQrzfE 0JZNVlrOaQtpWLHCiyOqeXRsHX5V53Gkm/PymhMCywscrJCNLOB1aYPoqSDAK5vf6oWv fqBA== 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=W+FezEXpyW2Kwr3H0HaqemTH3nJWuwesjRNair6bvmQ=; fh=LWJxUxOPIoAG7kV40OipmNLMiNyFM+gQ1dWz4vBqJQ4=; b=Z1K3cgrH1el8jrlPO70p1E0AMl/w/4srDyCL2wyxlRXF+TrU6+5R1bxsXUaq4ND6f8 41X8eGE54q33Gd8qXvoxGBC3i5GiwSNFKkmOiYbxQcOTNfMExJcx7ofjWXhBmLpc4DKz dPc7HbK/IcesHRzvDbQHK5oljNTyQyR4JUmPwcDiNKyn7GcZdx1IdqH/SmxCZ8QxVc5d 5egve0BkeUnWo6rkVGv/JXEhT5LrxvkIvXjH0RXoPT/0nKpWiKVhBeV+uL1Nx2Q7gc7P DH6n60sYLGt2n2tuiM6PeIVzFyKDrI2WxJLD2RxfSG6t+2G8R9HfBFbX06LIdb2V1gsk Dbew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmpAE9BO; 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 ffacd0b85a97d-38bf3222f61si172183f8f.194.2025.01.16.08.11.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jan 2025 08:11:10 -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=YmpAE9BO; 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 1tYSLn-0004FH-7u; Thu, 16 Jan 2025 11:04:07 -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 1tYSL6-0003Wh-MW for qemu-devel@nongnu.org; Thu, 16 Jan 2025 11:03:29 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tYSKy-0001GA-1x for qemu-devel@nongnu.org; Thu, 16 Jan 2025 11:03:23 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4364a37a1d7so10412425e9.3 for ; Thu, 16 Jan 2025 08:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737043394; x=1737648194; 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=W+FezEXpyW2Kwr3H0HaqemTH3nJWuwesjRNair6bvmQ=; b=YmpAE9BOL6OTCQDHiE/y9aysA8+UCDMTqVxzXTdHZLdZ+oDOL4SPY/aJwYPbTMEf5S 2JalkiOHTs5U1Ku05SySnQ0C24Zu3z8m8bvUgLZwI44P9KT0Uh7l4l7RjAv0J5IY02JE 4iayOQPSBDN9/wELpe5FXuzZDdhb9jYQeiKSpnoVE947bIgClOjmeW3N8OhRDq9aQXcc S6+m6NdAF15W7zseq/0SyGPkZ5tCbjrWMbyCI71aisskStFF+K8pcBbVqZ9omIimcFEu mqQf+p8Nwe3RdzI+dXeUc5M84EWm3YpgDa1XV3I+vc0ih2Q/u6vVMfCldvTDlunINsNb 2eDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737043394; x=1737648194; 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=W+FezEXpyW2Kwr3H0HaqemTH3nJWuwesjRNair6bvmQ=; b=bGZVzmwJ3X/a6b0MAJWSPJzG7L4FCWtWJiobLjInDq7iho2l92BziColsYRc1aTxkg 8E7rGfPAcRXHeU+QcJ707Xg+dwIC93KfI13ij7JIrmzhjjM2JBFeOwrC9axonITLu0iJ ggLkyohOP5CcUrpsJ/kYCrtiCG1Dat/C1FwH1ZVyUn22MAFIOTTrvNe2lk21iUS+ILFo 1qBAOAUQ4KQvjssdEg2PJoRbJOGFMlDF1Mib9hKAgarwry6QDlhqlAj+VkbpZOSD81G/ sH4LWyT7LtbYfgFWEJI2z/6E3nCh3v12lLvxHCJ1dwscESwmjq5jeb+FTUk5dJQoFzOL aQbA== X-Gm-Message-State: AOJu0YwbTFqzx9OPlJKgbEHRou/TTLb0HQkMZDa1ognzyM9l5yykJUZ5 q1NuqQuCCzVl/ci8BkqOdYMF10B40xBsnImkm90N1/XnkUUT0SLzry0btxN+qsE= X-Gm-Gg: ASbGncsQ6m36K39lR/f9uRWv2zXiCDk/qYfpP9Bsi/ucxYUVXqSwIs1AIiU3Q+T+QeN NOegzA5UbnkW6lw9ozwhHKQnINJOnwX60LFR9yUu9doX4MhtP7WbeYi6RXVkhpdbEqxHkY6Skh0 6bmmA+nf2jqTD0D/WqPeEakRmrDjkMfKtNp77tIiHCWk5XNc+7yIV/ZbaIf6+CvmWfxMGrw8aMo w8KySdyUKEQntsFXFXfw9rRI8x20F2MbZTkNq8yrIJ4AQ4AZfllx14= X-Received: by 2002:a05:6000:1a8a:b0:386:1cd3:8a07 with SMTP id ffacd0b85a97d-38a872fc363mr28367101f8f.7.1737043393988; Thu, 16 Jan 2025 08:03:13 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-437c752910esm65449005e9.28.2025.01.16.08.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 08:03:10 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2E62060866; Thu, 16 Jan 2025 16:03:07 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Markus Armbruster , Yuri Benditovich , Jason Wang , Cleber Rosa , "Dr. David Alan Gilbert" , Peter Xu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Stefano Garzarella , qemu-arm@nongnu.org, Michael Roth , Laurent Vivier , Mahmoud Mandour , Andrew Melnychenko , Konstantin Kostiuk , Kyle Evans , Richard Henderson , =?utf-8?q?Marc-Andr=C3=A9?= =?utf-8?q?_Lureau?= , John Snow , David Hildenbrand , Fabiano Rosas , Alexandre Iooss , Eric Blake , =?utf-8?q?Alex_Benn=C3=A9e?= , Vladimir Sementsov-Ogievskiy , Pierrick Bouvier , Kevin Wolf , Peter Maydell , Laurent Vivier , "Michael S. Tsirkin" , Thomas Huth , Warner Losh , =?utf-8?q?Dan?= =?utf-8?q?iel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 08/37] system/vl: more error exit into config enumeration code Date: Thu, 16 Jan 2025 16:02:37 +0000 Message-Id: <20250116160306.1709518-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250116160306.1709518-1-alex.bennee@linaro.org> References: <20250116160306.1709518-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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=unavailable 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. Message-Id: <20250109170619.2271193-9-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- v3 - split overly long line --- system/vl.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/system/vl.c b/system/vl.c index be029c52ef..22c1444da4 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1307,7 +1307,15 @@ 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 +1327,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 +2052,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(); @@ -2667,8 +2672,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 */ @@ -2715,10 +2719,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 "