From patchwork Tue Jan 14 11:37:52 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: 857225 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1872062wrc; Tue, 14 Jan 2025 03:39:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX/dNtqy1vBXnJynwO3Bbyf/Ym4/WoT2Tn/aSUGn+vsq7oRar8kyYO26l6z0Lg0w9Pa4qjd0g==@linaro.org X-Google-Smtp-Source: AGHT+IHwMXYTobtIpJNwJuwkEa3JieKKwcnDKaBAIRhIP/b8+RGmXdeWbNhdsNONfLYZ6rh0XZ8w X-Received: by 2002:a05:6214:20ce:b0:6dd:d24:3072 with SMTP id 6a1803df08f44-6df9b1f453fmr388960226d6.3.1736854796883; Tue, 14 Jan 2025 03:39:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736854796; cv=none; d=google.com; s=arc-20240605; b=Ul7c1YD1N6KkBM89mLarfNltRoSVPWziZ5wW33RxO9owvJkfvDXiT2QCZPRUd1kV6d jBqeq+96BZl5m/LGlUgxHJ2AJMkRtF6vMUyZ8Im+KrRkXl5+FLcTY2y2OqxNG5fQelwa hDrM80eqR0JMSfQq9ugesRUXSIScGa/n4rwTNT1fCwjvSvhZdlip7XFemJCKi/ZbAFga 37WFZlmRbVI3RBCd7K3QBlwpSwl5LrLR4NNcY8yI2GT9Orv8dHNw1yb3JyUHyjYoorXg RVv7X5gi9Gs9mOeujyrFUAC6IFH1YWl/eykPhqpMVH+hDFLthFuyaeTOd5RN+qfECk/r KuMA== 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=acFhJ3tFQm8tIYCY6Z3d4lTsupXAHuvOYJbU2nvujpY=; fh=Gxi0FeWIEw7YMtSLFNHGdQ9/FkjufSPjgwQAlnIQDbc=; b=LfDoseoicERHkKT5CJdAdSsAscoj9LVdI+SiQt3PFucSL3kWgMSb5w+81lQUsmPM/u KOvNRAbhywx9yRFvqB/STk/Sh1ku87vKkGvDcbLywLha87/p4u1APi9uW+rAnWO41PQs 4ouV5QCTBhA6i2YbM1E6m0DIyi8vDZsGeIJ2wVt4rg7Zp+DQw2Z6tpz5GX20oEW51wEJ VjdJxAwXkZTQoySraH87BzhwgUr+28wjbVfbcYExdEVPta5M/gqKLgRa2JWktliJcqDR kgwDCz5jFzXqqzcSbtYflL9EfGSg12OFgL6hFutCs3Y3NFpMjrrv+e4BmZ80/r7iNpQc oUkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X4uD7h1f; 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 af79cd13be357-7bce3307de2si1427371485a.310.2025.01.14.03.39.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jan 2025 03:39:56 -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=X4uD7h1f; 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 1tXfFf-00056C-Jk; Tue, 14 Jan 2025 06:38:31 -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 1tXfFd-00055E-Hr for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:29 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXfFb-0005PC-Rc for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:29 -0500 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5d90a5581fcso9127822a12.1 for ; Tue, 14 Jan 2025 03:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736854706; x=1737459506; 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=acFhJ3tFQm8tIYCY6Z3d4lTsupXAHuvOYJbU2nvujpY=; b=X4uD7h1fq/abbI1k+9JGfjx2D6tP67q+quCrV12byiXQ93Eou75ENGH3vX66eSepDF a1sD44Yfpjs7WQSxdst7UfdfilvJO+kZkMUuhW8DWWvvgUaGuo4WvDXw6L+Sl+yhmFMj xcv/XrLude483AiOi1fU84tm/dUI5m9d57hY6rmzQiHAJtTLnskntnTXogJJ4UwjqJnr 6re81kahnO66bsyztFxu0smQV9n2Wj2TUl+8O1dTYeipJ3tfaaULJUsViftdHGjrjnhs PObSBPPx6RSkvEWRvIypjYHmRAHfbL3R3Cf3a5uS2cQ2UpzqZj8XoyXW3OjgUk4+Qrnb FHkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736854706; x=1737459506; 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=acFhJ3tFQm8tIYCY6Z3d4lTsupXAHuvOYJbU2nvujpY=; b=PmneoYlAks0BwXZrUPO1LWqN/I9GmrYmApQeEGTkBPKC68j/yUCaaAcD1zg8WyYx4z wGvSYMmOZ3uW+96H3QClWiGons7VZmTUTGx1jWp/W1hoNhTjjo0+VP7HU6u+zHLA5XCG Pl/agUW8gIRvKEqp0dDTSs7YofhpcyrXkS+b1jgnQfOwnbY8tqSZLcumthROAgnk6tEf /N6SxkLvrniRKeoxtnixCdP5m8xDPeC4RjOa+a/yzXEo8/B7jlMAvgVLLlLbbVXDfPzY nvd096G3jtryC7J87seuDgq04qc8F4LnQyQKq+OkEDyAU6qPis+Rr+L2R7qHtkFhxbw6 5SdQ== X-Gm-Message-State: AOJu0YytMXWT4YHmvoqAJYKLtmtbg09izGc1NzroF7q4q8XcCykeXe/b T+y05gdC1hIauqAsdZ27gEgks9zGfmE2QnMF4DbJNdpnjVhJC44p9YK5XtkjKrc= X-Gm-Gg: ASbGnctRNeEkT4Xb/6KQj60htGGoRVvSZSBggvu4u9oFwvLYfdxuEDZYYDEAOmE36rV CD62w+52emmM2q0hW3rWYb2zEksJ0uy3GcdmXhm2T8RncoBUJWHhxKe9yrQ9v3MvXOxh/kSMgUB Cukksc1PhTjRw3qbBbJtSIe42gXvDj8hZ3PgN3uOy0e0GrSZIxjl0gCkS8HJpPF0CgktW4fC+NP IJoFVuaFnj9emi3W/mQ4GzjOjpNz4+xfuwQTrQn8FYvGhCuefL7wcc= X-Received: by 2002:a05:6402:35d4:b0:5cf:e218:984f with SMTP id 4fb4d7f45d1cf-5d972e4e6d1mr21820742a12.27.1736854706310; Tue, 14 Jan 2025 03:38:26 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d99046d822sm5864624a12.56.2025.01.14.03.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 03:38:24 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7EE785F94C; Tue, 14 Jan 2025 11:38:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Paolo Bonzini Subject: [PATCH v2 08/37] system/vl: more error exit into config enumeration code Date: Tue, 14 Jan 2025 11:37:52 +0000 Message-Id: <20250114113821.768750-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250114113821.768750-1-alex.bennee@linaro.org> References: <20250114113821.768750-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.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. 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é --- system/vl.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/system/vl.c b/system/vl.c index be029c52ef..7e3e6fb353 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(); @@ -2667,8 +2671,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 +2718,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 "