From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806412; cv=none; d=zohomail.com; s=zohoarc; b=jokeKWVw20gYvcS50+8LnuOa9rBK6WjjHzLnxokEyUzhzzMJsJyYBfgZOI9Rtpq1V3w9hL1IX4+UStoOkwrLKda7thu0HEAKxCVpO8n7iTGhzk7LF+PCUUg+2AJU1dhdRMDyWLBIMjtZW4LM0Qbkcql72wjmjptfHqYvgqzT5lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806412; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IL7p26SMX/LMSZIFbyh1Y8RvPwXs2rZDpFVWpTHGhwQ=; b=TqCBlWKrkEXwL203SQKCDsnJb4BUIme69m/LmRYqhJ9Dfv2gRz9UZaI4qagO/Y3UmtRRn7jbZaMJVs8t6plw/mUHimdi5+VIwkCnhK6eEpCRZ8XzhjrIheaVZdqTzMFI98lYWIpu28GOUUH9epdnvWNvCUO6/1HCStS715NHsLs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806412812308.77918489185504; Wed, 30 Sep 2026 15:13:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wh-0007w7-T7; Wed, 30 Sep 2026 18:11:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2WX-0007ui-Ln for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:38 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2WW-00051T-1D for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:37 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D586A1F7EE; Wed, 30 Sep 2026 22:11:25 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A4F1613B21; Wed, 30 Sep 2026 22:11:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T2 (envelope-from ); Wed, 30 Sep 2026 22:11:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806290; h=from:from:reply-to: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=IL7p26SMX/LMSZIFbyh1Y8RvPwXs2rZDpFVWpTHGhwQ=; b=SMsKWyQoxuCAw5WqzBsgh0cyvWnQd0LKHsC2AXWkjR2WV8XIbA4hc4L6+kRZg5hFDrWyb3 H9bGG12Yox3E79fy06k6uufulKc3pweZ9ClXx6ZPDdwWWhkY0sqsz625SsWDKLhB4zyYwR cVf0kmqW9J/l2wO/QLHP2gpmKMVpm6M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806290; h=from:from:reply-to: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=IL7p26SMX/LMSZIFbyh1Y8RvPwXs2rZDpFVWpTHGhwQ=; b=ibgZL+VoQzVfYtOcuegQF48X3sYQeYHWl7X77YVdgpAWgowoVgXzDgnoLy8UEITQnipjPG 0QayUGqD64qBVeBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hPJUR0L0; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wjW5a5uJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806285; h=from:from:reply-to: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=IL7p26SMX/LMSZIFbyh1Y8RvPwXs2rZDpFVWpTHGhwQ=; b=hPJUR0L0TYP5iWjVt0vtaaZhsNZ0ezTf/vy2j0vwVP0mis6CiycFA5W4RiPTEkyVXsDURn QJOIcHtx+9/MnExv/IG/fSmZhxFKokb0X/pTTzlsz4qejJDO380P69kIMJ1l7gtGYBo6B3 twqErhs8gO97tFXgIB+zVeLKPlPvUXA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806285; h=from:from:reply-to: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=IL7p26SMX/LMSZIFbyh1Y8RvPwXs2rZDpFVWpTHGhwQ=; b=wjW5a5uJH/kvoc1qamhUfdhEBAcnARdaS9UbVMk4F7Ayl9L4LEoxAdQ26vHC/RXL5ok7Os O1d00KfJySuQwFBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 01/11] qemu-option: Use g_autofree when calling get_opt_name_value() Date: Wed, 30 Sep 2026 19:10:55 -0300 Message-ID: <20260930221105.2262063-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.51 X-Rspamd-Action: no action X-Rspamd-Queue-Id: D586A1F7EE X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806413479158500 The get_opt_name_value function takes two pointer arguments that must be freed by the callers when not used. This is a good situation to use g_autofree. Steal the pointers that need to be passed forward. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- util/qemu-option.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 9fbf425f86..557d5d929c 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -813,27 +813,24 @@ static bool opts_do_parse(QemuOpts *opts, const char = *params, const char *firstname, bool warn_on_flag, bool *help_wanted, Error **er= rp) { - char *option, *value; const char *p; QemuOpt *opt; =20 for (p =3D params; *p;) { + g_autofree char *option =3D NULL; + g_autofree char *value =3D NULL; + p =3D get_opt_name_value(p, firstname, warn_on_flag, help_wanted, = &option, &value); if (help_wanted && *help_wanted) { - g_free(option); - g_free(value); return false; } firstname =3D NULL; =20 if (!strcmp(option, "id")) { - g_free(option); - g_free(value); continue; } =20 - opt =3D opt_create(opts, option, value); - g_free(option); + opt =3D opt_create(opts, option, g_steal_pointer(&value)); if (!opt_validate(opt, errp)) { qemu_opt_del(opt); return false; @@ -846,16 +843,15 @@ static bool opts_do_parse(QemuOpts *opts, const char = *params, static char *opts_parse_id(const char *params) { const char *p; - char *name, *value; =20 for (p =3D params; *p;) { + g_autofree char *name =3D NULL; + g_autofree char *value =3D NULL; + p =3D get_opt_name_value(p, NULL, false, NULL, &name, &value); if (!strcmp(name, "id")) { - g_free(name); - return value; + return g_steal_pointer(&value); } - g_free(name); - g_free(value); } =20 return NULL; @@ -864,13 +860,13 @@ static char *opts_parse_id(const char *params) bool has_help_option(const char *params) { const char *p; - char *name, *value; bool ret =3D false; =20 for (p =3D params; *p;) { + g_autofree char *name =3D NULL; + g_autofree char *value =3D NULL; + p =3D get_opt_name_value(p, NULL, false, &ret, &name, &value); - g_free(name); - g_free(value); if (ret) { return true; } --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806352; cv=none; d=zohomail.com; s=zohoarc; b=kRgwohyN8aEKav1qrHvaWjzJo9EGM5xEhQ5Kvs0ewdzlzPRNgdIQ4TYnFiyatHSarLQkxAe9HJxLihZI3hNdnvz8xY/vwBAmi50JXTfRZ4j4P6tuTQvBtz0rrBSn5et8HyyewXOJ0ghdOWZARFCpFnWuEJc7rrjV82/mki6XTEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806352; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XR0QL9shiCxvWQrrGSUIvcMDrpiDFHvfxGXPJwlQC4A=; b=EG391yJ24LYv2yWnwpgb+FLSkJZ7Amx6atAKZGotMtDJ1Esxu3K6GY1f/AFpLlOXCAuQRdGHdj3Vo/wxvcxs7vvOopme/lwtNSzFT9JbygQRklPSoywcd1MdkHtkHNbzXIGCPoKEHBjOP0s78mSLBfWwocGpYsYTkRdAvE8Du+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806352771446.62812368399625; Wed, 30 Sep 2026 15:12:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wq-0007wd-KU; Wed, 30 Sep 2026 18:11:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wa-0007v4-3k for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:41 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2WW-00051a-LW for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:38 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2F7951FB95; Wed, 30 Sep 2026 22:11:27 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F269313B22; Wed, 30 Sep 2026 22:11:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T3 (envelope-from ); Wed, 30 Sep 2026 22:11:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806291; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XR0QL9shiCxvWQrrGSUIvcMDrpiDFHvfxGXPJwlQC4A=; b=uNOwlQQAxn9fcwbz7EM8JOi+ZES72VEN1Qr6/MX1/F9s55boO3IHA2HmpIUqI3vLyIVMYk jQees+qBzMf0MkQ1JOOj7ifFQrTBSGvcX8ZeBWgy7AWM25HaUydS6pMVL0dck9OPHGz3PC 8GD51lnSqFDJqzFoTx+UsAItFbQG7bY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806291; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XR0QL9shiCxvWQrrGSUIvcMDrpiDFHvfxGXPJwlQC4A=; b=QeABxkTR3AcmunLmoQqfN2A8OUT5ejzlViQA5mTNgryR4fk1dtqAGQhNTVRRwUKLmrAYJk zsqeZK2ILMQQrICA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806287; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XR0QL9shiCxvWQrrGSUIvcMDrpiDFHvfxGXPJwlQC4A=; b=P3lrX0y6jSVJQHoCF59haNEqxwZgRmtbAuLMSB+rWSAi+MUud09oqiAHIbh3Nl0gyB8UGg zNHUH6UThdPz4UJxja9WAsBOLGtFXG5bLaBfMmTYG/l+zXD0g70KYMH3/GaWUCboS3DDRu 3/1HjQHI6kM8GklzgJJbNmEacaaSDHg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806287; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XR0QL9shiCxvWQrrGSUIvcMDrpiDFHvfxGXPJwlQC4A=; b=nuagZieyxTSFiiqd/m9+6qjDmOJ6jzypZH+18RYSpX5IZLrzu0GTfHfDsiWYPEKwzg2WVV oYdoSnV0DNB38CAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 02/11] tests/unit/test-qemu-opts: Validate help=foo options Date: Wed, 30 Sep 2026 19:10:56 -0300 Message-ID: <20260930221105.2262063-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806355611158500 Content-Type: text/plain; charset="utf-8" The test_has_help_option currently tests two functions: has_help_option() and qemu_opt_has_help_opt(). The former is only used by qemu-img and has a significant difference from the latter, which is used by QOM and qdev: - has_help_option() REJECTS help=3Don and all variants that provide a value, including invalid ones such as help=3Dfoo. - qemu_opt_has_help_opt() ACCEPTS help=3Don and all variants that provide a value, including invalid ones such as help=3Dfoo. Add a new test that validates these cases separately. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/unit/test-qemu-opts.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c index 8d03a69f7c..4ccb79d406 100644 --- a/tests/unit/test-qemu-opts.c +++ b/tests/unit/test-qemu-opts.c @@ -750,6 +750,31 @@ static void test_has_help_option(void) } } =20 +static void test_has_help_option_with_value(void) +{ + static const struct { + const char *params; + } test[] =3D { + { "help=3Don" }, + { "help=3Doff" }, + { "help=3Dfoo" }, + { "help=3D" }, + }; + int i; + QemuOpts *opts; + + for (i =3D 0; i < ARRAY_SIZE(test); i++) { + /* reject all */ + g_assert_cmpint(has_help_option(test[i].params), =3D=3D, false); + + /* accept all */ + opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, + &error_abort); + g_assert_cmpint(qemu_opt_has_help_opt(opts), =3D=3D, true); + qemu_opts_del(opts); + } +} + static void append_verify_list_01(QemuOptDesc *desc, bool with_overlapping) { int i =3D 0; @@ -1012,6 +1037,8 @@ int main(int argc, char *argv[]) g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number= ); g_test_add_func("/qemu-opts/opts_parse/size", test_opts_parse_size); g_test_add_func("/qemu-opts/has_help_option", test_has_help_option); + g_test_add_func("/qemu-opts/has_help_option_with_value", + test_has_help_option_with_value); g_test_add_func("/qemu-opts/append_to_null", test_opts_append_to_null); g_test_add_func("/qemu-opts/append", test_opts_append); g_test_add_func("/qemu-opts/to_qdict/basic", test_opts_to_qdict_basic); --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806353; cv=none; d=zohomail.com; s=zohoarc; b=K7LOvVVXI348nHP+uDVSYwLtJsjwKnLUIMDwpMwf7UYo56r766GE67GDlX6hdRYaki3zKBeYkw/srPDccroRQw99iTZbPiUtBJTfvbFluwG2J5dSMsH98wo25xvJWegzSFpgBn1cxkfr6GJH5pr0SoLVLc/Umb6mYR38SrYSY4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806353; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gq+/f3g4cnZFtacHHHaIK0bjD9eBRDuOiCpQiSAMofU=; b=VTozXXs03VeZToeckfBzvfeiDuVh6T5aI+bJEIMO8QPZ3Ut85+LJtGFm9U2g91TKHLgtKmWfRsdTLWGVWvUHxG/wznAbswFL41nCJ0fvwVUABuETZKNTaLVcofpzD/YBV5OUFLExIfyfNB+OIt6hmuVP1L9C0Tepi7iku1Lv3Ps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806353884778.4647954579914; Wed, 30 Sep 2026 15:12:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wi-0007w8-HD; Wed, 30 Sep 2026 18:11:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wc-0007vG-IS for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:45 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2WZ-00051q-DZ for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:42 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2A6CE1FB9A; Wed, 30 Sep 2026 22:11:29 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5AA1913B23; Wed, 30 Sep 2026 22:11:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T4 (envelope-from ); Wed, 30 Sep 2026 22:11:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806293; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gq+/f3g4cnZFtacHHHaIK0bjD9eBRDuOiCpQiSAMofU=; b=yIJjDN0olLiSgVcUyt9kHHkknVPWR7W/cHbFTpWgPg7YegRxygX+7oQavmNG24XKMm3+po e1wFhJ9oJr/Ke/iXmvA7r0HxWzghhsF/cKh0sJoKRThmeavHeeVzIKiSj7wj11tzvZxGtJ K5Fg2wCTUF1jNpKX6d8RYonQTLsLtkY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806293; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gq+/f3g4cnZFtacHHHaIK0bjD9eBRDuOiCpQiSAMofU=; b=qcLwiilKfJPnkvIbF2WF+nDDo/iGAgAE00lwT7FYXnpVlfhlTdjKMJPm0aT5gqutJeOgP/ yW7LVDUQLqPGATAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806289; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gq+/f3g4cnZFtacHHHaIK0bjD9eBRDuOiCpQiSAMofU=; b=1wU7zzyhk9y0KBiwJ/vQ94cc74LLTRWEbxbU9xsI/O6zWS1cy2VwPpV1NU5rcBZzBcwqA5 nsxR0Du72k+rHIFQiG3IYAMDCJELSumgYyyQ64VXy5fyxveLKX12EX2b79MRiPrvOxihus yjs2+SfiLhztR5mC6sbzAwI9OpjRtrc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806289; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gq+/f3g4cnZFtacHHHaIK0bjD9eBRDuOiCpQiSAMofU=; b=BZipXHydAHHAYrXAe47QzjwOV+h00szHNZV3hIyl0hGLIEuNNZy0SOvk3ph5ePH5pNz38p 3KtGQ18Che4rbwBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Pierrick Bouvier , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 03/11] qemu-option: Remove short form options support Date: Wed, 30 Sep 2026 19:10:57 -0300 Message-ID: <20260930221105.2262063-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806355711158500 Content-Type: text/plain; charset="utf-8" Option parameters without a value (i.e. key vs. key=3Dval) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no". Remove the implied behavior and start rejecting option parameters without values by emitting the error message: "Parameter 'foo' without a value." Two special cases remain: 1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on"). Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=3Don, help=3Doff, help=3Dfoo all result in the help text being emitted. This is not changed by this patch. 2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas. E.g.: share=3Don,, is parsed as: key:"share" value:"on" and key:"" value:"on" One effect of this change that might not be obvious is that parameter combinations of the form: id=3Dmem0,share,help no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely: id=3Dmem0,share=3Don,help id=3Dmem0,help About testing: A few strings from the test_has_help_option test were removed because they now trigger the missing value error during parsing and therefore cannot be used for testing the qemu_opt_has_help_opt() routine which needs the parsed QemuOpts. The two "Implied value" tests were replaced with 8 new tests. The "Implied key" test has had the extra parameters with implied values removed, otherwise the implied key cannot be tested due to the rejected missing values. The test_inet_parse_all_implicit_bool_good was removed entirely because it only tested the use case that is being removed. A few block tests were updated to use the key=3Dvalue form. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- docs/about/deprecated.rst | 13 ------- tests/qemu-iotests/084 | 2 +- tests/qemu-iotests/146 | 2 +- tests/qemu-iotests/197 | 2 +- tests/qemu-iotests/215 | 2 +- tests/unit/test-qemu-opts.c | 67 +++++++++++++++++++++------------- tests/unit/test-util-sockets.c | 33 ----------------- util/qemu-option.c | 57 ++++++++++++++--------------- 8 files changed, 73 insertions(+), 105 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index ccbc421949..f54905eba9 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -30,19 +30,6 @@ deprecated. System emulator command line arguments -------------------------------------- =20 -Short-form boolean options (since 6.0) -'''''''''''''''''''''''''''''''''''''' - -Boolean options such as ``share=3Don``/``share=3Doff`` could be written -in short form as ``share`` and ``noshare``. This is now deprecated -and will cause a warning. - -``delay`` option for socket character devices (since 6.0) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The replacement for the ``nodelay`` short-form boolean option is ``nodelay= =3Don`` -rather than ``delay=3Doff``. - Plugin argument passing through ``arg=3D`` (since 6.1) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 diff --git a/tests/qemu-iotests/084 b/tests/qemu-iotests/084 index 1181cb7cd0..f905396e72 100755 --- a/tests/qemu-iotests/084 +++ b/tests/qemu-iotests/084 @@ -51,7 +51,7 @@ bii_offset=3D384 # block in image field offset echo echo "=3D=3D=3D Statically allocated image creation =3D=3D=3D" echo -_make_test_img $size -o static +_make_test_img $size -o static=3Don _img_info stat -c"disk image file size in bytes: %s" "${TEST_IMG}" _cleanup_test_img diff --git a/tests/qemu-iotests/146 b/tests/qemu-iotests/146 index f63291d0ff..a7853e03c9 100755 --- a/tests/qemu-iotests/146 +++ b/tests/qemu-iotests/146 @@ -165,7 +165,7 @@ echo echo =3D=3D=3D Testing Image create, force_size =3D=3D=3D echo =20 -_make_test_img -o force_size 4G +_make_test_img -o force_size=3Don 4G =20 echo echo =3D=3D=3D Read created image, default opts =3D=3D=3D=3D diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 index 69849c800e..271d1283c5 100755 --- a/tests/qemu-iotests/197 +++ b/tests/qemu-iotests/197 @@ -63,7 +63,7 @@ echo # Prep the images # VPC rounds image sizes to a specific geometry, force a specific size. if [ "$IMGFMT" =3D "vpc" ]; then - IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size") + IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size=3Don") fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 index 6babbcdc1f..6a518a9f57 100755 --- a/tests/qemu-iotests/215 +++ b/tests/qemu-iotests/215 @@ -60,7 +60,7 @@ echo # Prep the images # VPC rounds image sizes to a specific geometry, force a specific size. if [ "$IMGFMT" =3D "vpc" ]; then - IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size") + IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size=3Don") fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c index 4ccb79d406..07ede50920 100644 --- a/tests/unit/test-qemu-opts.c +++ b/tests/unit/test-qemu-opts.c @@ -481,26 +481,10 @@ static void test_opts_parse(void) error_free_or_abort(&err); g_assert(!opts); =20 - /* Implied value (qemu_opts_parse warns but accepts it) */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", - false, &error_abort); - g_assert_cmpuint(opts_count(opts), =3D=3D, 3); - g_assert_cmpstr(qemu_opt_get(opts, "an"), =3D=3D, "on"); - g_assert_cmpstr(qemu_opt_get(opts, "aus"), =3D=3D, "off"); - g_assert_cmpstr(qemu_opt_get(opts, "noaus"), =3D=3D, ""); - - /* Implied value, negated empty key */ - opts =3D qemu_opts_parse(&opts_list_03, "no", false, &error_abort); - g_assert_cmpuint(opts_count(opts), =3D=3D, 1); - g_assert_cmpstr(qemu_opt_get(opts, ""), =3D=3D, "off"); - /* Implied key */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", true, - &error_abort); - g_assert_cmpuint(opts_count(opts), =3D=3D, 3); + opts =3D qemu_opts_parse(&opts_list_03, "an", true, &error_abort); + g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, "an"); - g_assert_cmpstr(qemu_opt_get(opts, "aus"), =3D=3D, "off"); - g_assert_cmpstr(qemu_opt_get(opts, "noaus"), =3D=3D, ""); =20 /* Implied key with empty value */ opts =3D qemu_opts_parse(&opts_list_03, ",", true, &error_abort); @@ -523,6 +507,45 @@ static void test_opts_parse(void) error_free_or_abort(&err); g_assert(!opts); =20 + /* Implied value */ + opts =3D qemu_opts_parse(&opts_list_03, "an", false, &err); + error_free_or_abort(&err); + g_assert(!opts); + + /* Implied value, unknown key */ + opts =3D qemu_opts_parse(&opts_list_01, "nonexistent", false, &err); + error_free_or_abort(&err); + g_assert(!opts); + + /* Implied value, negated key */ + opts =3D qemu_opts_parse(&opts_list_03, "noaus", false, &err); + error_free_or_abort(&err); + g_assert(!opts); + + /* Implied value, negated empty key */ + opts =3D qemu_opts_parse(&opts_list_03, "no", false, &err); + error_free_or_abort(&err); + g_assert(!opts); + + /* Empty value */ + opts =3D qemu_opts_parse(&opts_list_03, "aus=3D", false, &error_abort); + g_assert_cmpuint(opts_count(opts), =3D=3D, 1); + + /* Implied key */ + opts =3D qemu_opts_parse(&opts_list_03, "an", true, &error_abort); + g_assert_cmpuint(opts_count(opts), =3D=3D, 1); + + /* Implied key, implied value */ + opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", true, &er= r); + error_free_or_abort(&err); + g_assert(!opts); + + /* Implied key, empty value */ + opts =3D qemu_opts_parse(&opts_list_03, "an,noaus=3D", true, &error_ab= ort); + g_assert_cmpuint(opts_count(opts), =3D=3D, 2); + g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, "an"); + g_assert_cmpstr(qemu_opt_get(opts, "noaus"), =3D=3D, ""); + qemu_opts_reset(&opts_list_01); qemu_opts_reset(&opts_list_03); } @@ -720,16 +743,8 @@ static void test_has_help_option(void) } test[] =3D { { "help", true, false }, { "?", true, false }, - { "helpme", false, false }, - { "?me", false, false }, - { "a,help", true, true }, - { "a,?", true, true }, - { "a=3D0,help,b", true, true }, - { "a=3D0,?,b", true, true }, { "help,b=3D1", true, false }, { "?,b=3D1", true, false }, - { "a,b,,help", true, true }, - { "a,b,,?", true, true }, }; int i; QemuOpts *opts; diff --git a/tests/unit/test-util-sockets.c b/tests/unit/test-util-sockets.c index 006f5e579c..2875c547a0 100644 --- a/tests/unit/test-util-sockets.c +++ b/tests/unit/test-util-sockets.c @@ -516,36 +516,6 @@ static void test_inet_parse_all_options_good(void) , &exp_addr, true); } =20 -static void test_inet_parse_all_implicit_bool_good(void) -{ - char host[] =3D "::1"; - char port[] =3D "5000"; - InetSocketAddress exp_addr =3D { - .host =3D host, - .port =3D port, - .has_numeric =3D true, - .numeric =3D true, - .has_to =3D true, - .to =3D 5006, - .has_ipv4 =3D true, - .ipv4 =3D true, - .has_ipv6 =3D true, - .ipv6 =3D true, - .has_keep_alive =3D true, - .keep_alive =3D true, -#ifdef HAVE_IPPROTO_MPTCP - .has_mptcp =3D true, - .mptcp =3D true, -#endif - }; - inet_parse_test_helper( - "[::1]:5000,numeric,to=3D5006,ipv4,ipv6,keep-alive" -#ifdef HAVE_IPPROTO_MPTCP - ",mptcp" -#endif - , &exp_addr, true); -} - int main(int argc, char **argv) { bool has_ipv4, has_ipv6; @@ -613,9 +583,6 @@ int main(int argc, char **argv) test_inet_parse_hostname_good); g_test_add_func("/util/socket/inet-parse/all-options-good", test_inet_parse_all_options_good); - g_test_add_func("/util/socket/inet-parse/all-bare-bool-good", - test_inet_parse_all_implicit_bool_good); - end: return g_test_run(); } diff --git a/util/qemu-option.c b/util/qemu-option.c index 557d5d929c..8ac848bbc0 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -509,6 +509,11 @@ static bool opt_validate(QemuOpt *opt, Error **errp) const QemuOptDesc *desc; const QemuOptsList *list =3D opt->opts->list; =20 + if (!opt->str) { + error_setg(errp, "Parameter '%s' without a value", opt->name); + return false; + } + desc =3D find_desc_by_name(list->desc, opt->name); if (!desc && !opts_accepts_any(list)) { error_setg(errp, "Invalid parameter '%s'", opt->name); @@ -755,12 +760,10 @@ void qemu_opts_print(QemuOpts *opts, const char *sepa= rator) =20 static const char *get_opt_name_value(const char *params, const char *firstname, - bool warn_on_flag, bool *help_wanted, char **name, char **value) { const char *p; - const char *prefix =3D ""; size_t len; bool is_help =3D false; =20 @@ -772,23 +775,22 @@ static const char *get_opt_name_value(const char *par= ams, *name =3D g_strdup(firstname); p =3D get_opt_value(params, value); } else { - /* option without value, must be a flag */ p =3D get_opt_name(params, name, len); - if (strncmp(*name, "no", 2) =3D=3D 0) { - memmove(*name, *name + 2, strlen(*name + 2) + 1); - *value =3D g_strdup("off"); - prefix =3D "no"; - } else { + + /* + * Short-form flags (i.e. without any value) are not + * supported, except for two cases: + */ + + /* the 'help' or '?' flag */ + is_help =3D is_help_option(*name); + if (is_help) { *value =3D g_strdup("on"); - is_help =3D is_help_option(*name); } - if (!is_help && warn_on_flag) { - warn_report("short-form boolean option '%s%s' deprecated",= prefix, *name); - if (g_str_equal(*name, "delay")) { - error_printf("Please use nodelay=3D%s instead\n", pref= ix[0] ? "on" : "off"); - } else { - error_printf("Please use %s=3D%s instead\n", *name, *v= alue); - } + + /* a missing, non-implicit key, i.e. a single comma ',' */ + if (g_str_equal(*name, "") && *p =3D=3D ',') { + *value =3D g_strdup("on"); } } } else { @@ -811,7 +813,7 @@ static const char *get_opt_name_value(const char *param= s, =20 static bool opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, - bool warn_on_flag, bool *help_wanted, Error **er= rp) + bool *help_wanted, Error **errp) { const char *p; QemuOpt *opt; @@ -820,7 +822,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *p= arams, g_autofree char *option =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, firstname, warn_on_flag, help_wanted, = &option, &value); + p =3D get_opt_name_value(p, firstname, help_wanted, &option, &valu= e); if (help_wanted && *help_wanted) { return false; } @@ -848,7 +850,7 @@ static char *opts_parse_id(const char *params) g_autofree char *name =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, NULL, false, NULL, &name, &value); + p =3D get_opt_name_value(p, NULL, NULL, &name, &value); if (!strcmp(name, "id")) { return g_steal_pointer(&value); } @@ -866,7 +868,7 @@ bool has_help_option(const char *params) g_autofree char *name =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, NULL, false, &ret, &name, &value); + p =3D get_opt_name_value(p, NULL, &ret, &name, &value); if (ret) { return true; } @@ -884,12 +886,11 @@ bool has_help_option(const char *params) bool qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, Error **errp) { - return opts_do_parse(opts, params, firstname, false, NULL, errp); + return opts_do_parse(opts, params, firstname, NULL, errp); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, - bool permit_abbrev, - bool warn_on_flag, bool *help_wanted, Error **= errp) + bool permit_abbrev, bool *help_wanted, Error *= *errp) { const char *firstname; char *id =3D opts_parse_id(params); @@ -904,8 +905,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, return NULL; } =20 - if (!opts_do_parse(opts, params, firstname, - warn_on_flag, help_wanted, errp)) { + if (!opts_do_parse(opts, params, firstname, help_wanted, errp)) { qemu_opts_del(opts); return NULL; } @@ -923,7 +923,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { - return opts_parse(list, params, permit_abbrev, false, NULL, errp); + return opts_parse(list, params, permit_abbrev, NULL, errp); } =20 /** @@ -941,9 +941,8 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, c= onst char *params, QemuOpts *opts; bool help_wanted =3D false; =20 - opts =3D opts_parse(list, params, permit_abbrev, true, - opts_accepts_any(list) ? NULL : &help_wanted, - &err); + opts =3D opts_parse(list, params, permit_abbrev, + opts_accepts_any(list) ? NULL : &help_wanted, &err); if (!opts) { assert(!!err + !!help_wanted =3D=3D 1); if (help_wanted) { --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806413; cv=none; d=zohomail.com; s=zohoarc; b=L9GwaJZ2Yicaz20eSOcHskAHyalnTqmcB82K98DLGbjPVDvSfnB+RXTAzzReMqTIWCXK/9oQ3T1LwCEvPLg0WVbqCoYt0tUb+AVuroGAFDQWyfsYg4adsl2iDB17TfYDCRCndHpLR+S0kTLeLxfVAnqgjgbToHOmQNyq7nVrgP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806413; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IAbqzYN6qR2qqTDjflBVZPREghLvnsUT3GgJOI5aYN8=; b=bxLyqwQzc4anVgx7OJdGnr63jes3rhmDYWTBb8nUg1+j3mml41A89Q1GWp1Z/h9rlzBvljMbH1ORXe13o0m6t7jbxbLFy1CPEW2WawVkic3+zquSz6Wo4eCxYlpngD2Tu9VyDLV0Yn9iNGPCljzeDKK/rViU0q1n5tSAihR/QuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806413478486.8996525505879; Wed, 30 Sep 2026 15:13:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2X1-0007yD-K1; Wed, 30 Sep 2026 18:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wc-0007vE-8J for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:45 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2WZ-00051z-Um for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:41 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 763FE1FB9C; Wed, 30 Sep 2026 22:11:30 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 40BBD13B24; Wed, 30 Sep 2026 22:11:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T5 (envelope-from ); Wed, 30 Sep 2026 22:11:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806294; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAbqzYN6qR2qqTDjflBVZPREghLvnsUT3GgJOI5aYN8=; b=yghaE4U6/xhIzXkj7j1uzE0WSdIFaH3iL3l+IO1K2CI8jPR+IazmPbtOwmI87rQbQjyCxi 5uw9vRppURTaf/Kj4ttKCw+K6jW4SHxe0g5AaXjFl/b+YV213FJ7+JtO2kPxrqMB/Cgyk1 IsbetFZKUQUbb8+/FGgtZY+MLOk0cqA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806294; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAbqzYN6qR2qqTDjflBVZPREghLvnsUT3GgJOI5aYN8=; b=7P44AehnoONLK1ZG34Onwu6ApzAi/m/QAf8TcKbpmhG77qYTrpv6/6fnJvPWePaSDCwbhX ILy8U9rX4IvWM4Bg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806290; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAbqzYN6qR2qqTDjflBVZPREghLvnsUT3GgJOI5aYN8=; b=gVbRP+/R2kM1BD4IQj3rF6jFEBl4UIKR+yqKnUhBXrDx5gLOEq14Xk1QqSB06Gwl5PLtz0 c+HhTBQhc1QBop3Po8Mb0U8eAgGHoC1pHP1H2TJ4bxlDPHusnak8+hZzOMhtlTxr82QRKR PKAEg/RhnheFDdrOUOGmo9C3ZihvPpA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806290; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAbqzYN6qR2qqTDjflBVZPREghLvnsUT3GgJOI5aYN8=; b=OF6kzFYSTWX3HFxxO9aBHkChF2OupE6aICvQx/CQIsjd+qUiLQtAeU/0oZ4SHUhsH1ddmC ZLwjgegGNV9gWCDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 04/11] qemu-option: Fix 'help' parameter parsing Date: Wed, 30 Sep 2026 19:10:58 -0300 Message-ID: <20260930221105.2262063-5-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806415498158500 Content-Type: text/plain; charset="utf-8" Reject invalid values such as help=3D and help=3Dfoo. Reject valid, but not applicable values such has help=3Don and help=3Doff. To achieve the above: Add an 'is_help' member to QemuOpt so that information can be stored while creating the option. This allows moving the help handling out of get_opt_name_value(), which is necessary because that function doesn't take an Error. At the caller, opts_do_parse(), let the QemuOpt be created with the name and value fields as they come out of get_opt_name_value(). With a new routine, validate the new QemuOpt against the 'help' parameter rules (to fix the bug), then let the existing opt_validate() reject any NULL values. The two validations need to be separate because in between there needs to be a setting of opt->str to "on" whenever the special short-form parameters require it. The "on" value is required because of the conversions of QemuOpts from/to QDict since QDict cannot take a NULL value. The conversions also cause opt_validate() to be reentrant via qemu_opt_set(), so the initial validation of 'help' needs to be out of that function, otherwise there's no way to distinguish an user-set help=3Don vs. the help=3Don set for compatibility with QDict (the "in between" part from the previous paragraph). The passing around of help_wanted becomes redundant since opt->is_help can be checked throughout. Remove that argument everywhere. Stop returning false from opts_do_parse() when is_help=3Dtrue. Only return false when there's an error and let the callers decide what to do when is_help=3Dtrue. However, still break the loop when is_help=3Dtrue to keep the behavior of stopping parsing once the 'help' parameter is seen. At qemu_opts_parse_noisily(), due to the change of return value mentioned above, it becomes clear when to report the error and when to print the help text. Use qemu_opt_has_help_opt() to obtain the is_help information from QemuOpt. Since get_opt_name_value() can now return while value=3DNULL, the other two callsites need to be updated. At opts_parse_id(), assert value !=3D NULL. At has_help_option(), use the NULL value to keep the existing behavior of rejecting anything but 'help'. The unit tests are updated accordingly. Signed-off-by: Fabiano Rosas --- include/qemu/option_int.h | 1 + tests/unit/test-qemu-opts.c | 9 ++-- util/qemu-option.c | 104 ++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 51 deletions(-) diff --git a/include/qemu/option_int.h b/include/qemu/option_int.h index 5dd9a5162d..c31bd6e3ab 100644 --- a/include/qemu/option_int.h +++ b/include/qemu/option_int.h @@ -32,6 +32,7 @@ struct QemuOpt { char *name; char *str; + bool is_help; =20 const QemuOptDesc *desc; union { diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c index 07ede50920..7cedfba332 100644 --- a/tests/unit/test-qemu-opts.c +++ b/tests/unit/test-qemu-opts.c @@ -777,16 +777,15 @@ static void test_has_help_option_with_value(void) }; int i; QemuOpts *opts; + Error *err =3D NULL; =20 for (i =3D 0; i < ARRAY_SIZE(test); i++) { /* reject all */ g_assert_cmpint(has_help_option(test[i].params), =3D=3D, false); =20 - /* accept all */ - opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, - &error_abort); - g_assert_cmpint(qemu_opt_has_help_opt(opts), =3D=3D, true); - qemu_opts_del(opts); + opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, &er= r); + error_free_or_abort(&err); + g_assert(!opts); } } =20 diff --git a/util/qemu-option.c b/util/qemu-option.c index 8ac848bbc0..483e6cbf70 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -331,7 +331,7 @@ bool qemu_opt_has_help_opt(QemuOpts *opts) QemuOpt *opt; =20 QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) { - if (is_help_option(opt->name)) { + if (opt->is_help) { return true; } } @@ -499,6 +499,7 @@ static QemuOpt *opt_create(QemuOpts *opts, const char *= name, char *value) opt->name =3D g_strdup(name); opt->str =3D value; opt->opts =3D opts; + opt->is_help =3D is_help_option(name); QTAILQ_INSERT_TAIL(&opts->head, opt, next); =20 return opt; @@ -760,12 +761,10 @@ void qemu_opts_print(QemuOpts *opts, const char *sepa= rator) =20 static const char *get_opt_name_value(const char *params, const char *firstname, - bool *help_wanted, char **name, char **value) { const char *p; size_t len; - bool is_help =3D false; =20 len =3D strcspn(params, "=3D,"); if (params[len] !=3D '=3D') { @@ -776,22 +775,6 @@ static const char *get_opt_name_value(const char *para= ms, p =3D get_opt_value(params, value); } else { p =3D get_opt_name(params, name, len); - - /* - * Short-form flags (i.e. without any value) are not - * supported, except for two cases: - */ - - /* the 'help' or '?' flag */ - is_help =3D is_help_option(*name); - if (is_help) { - *value =3D g_strdup("on"); - } - - /* a missing, non-implicit key, i.e. a single comma ',' */ - if (g_str_equal(*name, "") && *p =3D=3D ',') { - *value =3D g_strdup("on"); - } } } else { /* found "foo=3Dbar,more" */ @@ -802,18 +785,46 @@ static const char *get_opt_name_value(const char *par= ams, } =20 assert(!*p || *p =3D=3D ','); - if (help_wanted && is_help) { - *help_wanted =3D true; - } if (*p =3D=3D ',') { p++; } return p; } =20 +/* + * Short-form parameters (i.e. without any value) are not + * supported, except for two cases: + * + * - the 'help' or '?' flag + * - the empty, non-implicit key combined with an empty + * non-implicit value, i.e. a single comma ',' + * + * The rest of the code is not prepared to deal with empty values, set + * the special cases to "on". + */ +static bool opt_short_form_compat(QemuOpt *opt, Error **errp) +{ + if (opt->str) { + /* + * Validate the 'help' parameter at this point because the + * opt_validate() routine can be reentrant and this very check + * would fail once the "on" value is set below. + */ + if (opt->is_help) { + error_setg(errp, "Parameter '%s' doesn't take any values", + opt->name); + return false; + } + } else { + if (opt->is_help || g_str_equal(opt->name, "")) { + opt->str =3D g_strdup("on"); + } + } + return true; +} + static bool opts_do_parse(QemuOpts *opts, const char *params, - const char *firstname, - bool *help_wanted, Error **errp) + const char *firstname, Error **errp) { const char *p; QemuOpt *opt; @@ -822,10 +833,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *= params, g_autofree char *option =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, firstname, help_wanted, &option, &valu= e); - if (help_wanted && *help_wanted) { - return false; - } + p =3D get_opt_name_value(p, firstname, &option, &value); firstname =3D NULL; =20 if (!strcmp(option, "id")) { @@ -833,10 +841,15 @@ static bool opts_do_parse(QemuOpts *opts, const char = *params, } =20 opt =3D opt_create(opts, option, g_steal_pointer(&value)); - if (!opt_validate(opt, errp)) { + if (!opt_short_form_compat(opt, errp) || + !opt_validate(opt, errp)) { qemu_opt_del(opt); return false; } + + if (opt->is_help) { + return true; + } } =20 return true; @@ -850,8 +863,9 @@ static char *opts_parse_id(const char *params) g_autofree char *name =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, NULL, NULL, &name, &value); + p =3D get_opt_name_value(p, NULL, &name, &value); if (!strcmp(name, "id")) { + assert(value); return g_steal_pointer(&value); } } @@ -862,14 +876,13 @@ static char *opts_parse_id(const char *params) bool has_help_option(const char *params) { const char *p; - bool ret =3D false; =20 for (p =3D params; *p;) { g_autofree char *name =3D NULL; g_autofree char *value =3D NULL; =20 - p =3D get_opt_name_value(p, NULL, &ret, &name, &value); - if (ret) { + p =3D get_opt_name_value(p, NULL, &name, &value); + if (is_help_option(name) && !value) { return true; } } @@ -886,11 +899,11 @@ bool has_help_option(const char *params) bool qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, Error **errp) { - return opts_do_parse(opts, params, firstname, NULL, errp); + return opts_do_parse(opts, params, firstname, errp); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, - bool permit_abbrev, bool *help_wanted, Error *= *errp) + bool permit_abbrev, Error **errp) { const char *firstname; char *id =3D opts_parse_id(params); @@ -905,7 +918,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, return NULL; } =20 - if (!opts_do_parse(opts, params, firstname, help_wanted, errp)) { + if (!opts_do_parse(opts, params, firstname, errp)) { qemu_opts_del(opts); return NULL; } @@ -923,7 +936,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { - return opts_parse(list, params, permit_abbrev, NULL, errp); + return opts_parse(list, params, permit_abbrev, errp); } =20 /** @@ -939,17 +952,16 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list,= const char *params, { Error *err =3D NULL; QemuOpts *opts; - bool help_wanted =3D false; =20 - opts =3D opts_parse(list, params, permit_abbrev, - opts_accepts_any(list) ? NULL : &help_wanted, &err); + opts =3D opts_parse(list, params, permit_abbrev, &err); if (!opts) { - assert(!!err + !!help_wanted =3D=3D 1); - if (help_wanted) { - qemu_opts_print_help(list, true); - } else { - error_report_err(err); - } + error_report_err(err); + return NULL; + } + + if (qemu_opt_has_help_opt(opts) && !opts_accepts_any(list)) { + qemu_opts_print_help(list, true); + return NULL; } return opts; } --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806367; cv=none; d=zohomail.com; s=zohoarc; b=ef+ShjM4XWsI6FrKdo+G+G0xSEtkbgZJwB6t54+7Hyv4pjB5l66HA/Wd15Xq+5Z1TeeVDp/SBezR/rG9HQ2wqwgMEYdgPlXxq6dPhRHdbHHPxDAPfZPt2nNlV6oVCkwTsN+IpezzGuYzE4j5PZfjpMg4K4ME683ff3NKpuL44NE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806367; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Y0Cy48Kfw7fwHXfYachCNmRMbvI6mV12N5r8rM8zoIY=; b=EnLAerQ+fZYLWTPV1dTxguRGF/JQdciwAZt63mYdy6/o42ZKbegcnWL98YjRvDijrxs2goHwCVkHJ8zjVlYcEkRlbWkc6Fhn2rEuusRrhz2jLUAzpA3dIT/4rjy1y8NmUEmnOw2BA3Vq6/NnmElP2PufvvM4cChXiCIQiDzfXaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806367658209.33231935468802; Wed, 30 Sep 2026 15:12:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wq-0007wu-L2; Wed, 30 Sep 2026 18:11:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wg-0007vr-Bg for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:46 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wc-00052C-Ds for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:45 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 03BE31FB9E; Wed, 30 Sep 2026 22:11:33 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9650613B25; Wed, 30 Sep 2026 22:11:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T6 (envelope-from ); Wed, 30 Sep 2026 22:11:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806297; h=from:from:reply-to: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=Y0Cy48Kfw7fwHXfYachCNmRMbvI6mV12N5r8rM8zoIY=; b=yommmJdnx84iJ4GyDn8Oq6uSvVvY5QXilX0Yms7+xDAfX+a3Ms/2Xqe6IiBwKhYAoG3VEE lM5gWQzpeFGL652RDGJ5u8GhuFwdOmA/JJXtXypTcq7FsUHmtcmkPbOE724rvx0mmJCTxF 0bcFcpKTXHfOuhYcyXWc3lK9jKSHKF4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806297; h=from:from:reply-to: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=Y0Cy48Kfw7fwHXfYachCNmRMbvI6mV12N5r8rM8zoIY=; b=j2jsZYSlZLVXQIIUKU+VW+gLV0fhg/Gd7y0Dr+4+f1UfbfBZ3BqWIRP6unuV793uA/s0tY BlWEz7We9vlflvAQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="fC/bqyXS"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=4hxLIlTp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806293; h=from:from:reply-to: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=Y0Cy48Kfw7fwHXfYachCNmRMbvI6mV12N5r8rM8zoIY=; b=fC/bqyXSzIm9+6eZYp1QYn5hBPoqHNHaPEIRfCBVWXjD3rzLGsLlXmXfyylROt8Y4q+U8Z hKaO2L8Pm+aaSPjeflqEKETW+ci1tk48x70C9Bye9syNl5koFymFOseRKyQ/HGPSkBBUvj +2g1NKDm1BUEzoEIAPTA/4YrEHC3iFE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806293; h=from:from:reply-to: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=Y0Cy48Kfw7fwHXfYachCNmRMbvI6mV12N5r8rM8zoIY=; b=4hxLIlTp7BzL0x7sKk25MyWF3SSl9oJXT8EhFqohN2A19k2uDzrJC3oMYREMwRha8LT/K1 S1Moyi6VC0NO3kBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 05/11] qemu-option: Add qemu_opts_parse_list Date: Wed, 30 Sep 2026 19:10:59 -0300 Message-ID: <20260930221105.2262063-6-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 03BE31FB9E X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.51 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806369287158500 Currently the qemu_opts_parse and qemu_opts_parse_noisily functions are called in one two ways: 1) qemu_opts_parse|_noisily(&some_group_list, ...) 2) qemu_opts_parse|_noisily(qemu_find_opts("some_opt"), ...) The second form is problematic. Having the result of qemu_find_opts() going directly into the first argument makes it difficult to handle a possible NULL pointer retuned by it. Next patches will change qemu_opts_parse() and qemu_opts_parse_noisily() to receive the option name and call qemu_find_opts() in their body so the return of the function can be handled properly. Add a new qemu_opts_parse_list() and change all callsites that pass the list directly to use it. In the next patches this new _list version will become the inner function, but at this point, simply make it defer to qemu_opts_parse() to make the refactoring easier. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qemu/option.h | 2 + tests/unit/test-qemu-opts.c | 179 +++++++++++++++++++----------------- util/qemu-option.c | 13 +++ util/qemu-sockets.c | 2 +- 4 files changed, 109 insertions(+), 87 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index 9a00ac0a35..f96d9fae42 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -132,6 +132,8 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, c= onst char *params, bool permit_abbrev); QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp); +QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, + bool permit_abbrev, Error **errp); QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, Error **errp); QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict, diff --git a/tests/unit/test-qemu-opts.c b/tests/unit/test-qemu-opts.c index 7cedfba332..c4b6be312e 100644 --- a/tests/unit/test-qemu-opts.c +++ b/tests/unit/test-qemu-opts.c @@ -349,7 +349,7 @@ static void test_qemu_opt_unset(void) int ret; =20 /* dynamically initialized (parsed) opts */ - opts =3D qemu_opts_parse(&opts_list_03, "key=3Dvalue", false, NULL); + opts =3D qemu_opts_parse_list(&opts_list_03, "key=3Dvalue", false, NUL= L); g_assert(opts !=3D NULL); =20 /* check default/parsed value */ @@ -431,117 +431,118 @@ static void test_opts_parse(void) QemuOpts *opts; =20 /* Nothing */ - opts =3D qemu_opts_parse(&opts_list_03, "", false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "", false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 0); =20 /* Empty key */ - opts =3D qemu_opts_parse(&opts_list_03, "=3Dval", false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "=3Dval", false, &error_a= bort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, ""), =3D=3D, "val"); =20 /* Multiple keys, last one wins */ - opts =3D qemu_opts_parse(&opts_list_03, "a=3D1,b=3D2,,x,a=3D3", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "a=3D1,b=3D2,,x,a=3D3", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 3); g_assert_cmpstr(qemu_opt_get(opts, "a"), =3D=3D, "3"); g_assert_cmpstr(qemu_opt_get(opts, "b"), =3D=3D, "2,x"); =20 /* Except when it doesn't */ - opts =3D qemu_opts_parse(&opts_list_03, "id=3Dfoo,id=3Dbar", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "id=3Dfoo,id=3Dbar", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 0); g_assert_cmpstr(qemu_opts_id(opts), =3D=3D, "foo"); =20 /* TODO Cover low-level access to repeated keys */ =20 /* Trailing comma is ignored */ - opts =3D qemu_opts_parse(&opts_list_03, "x=3Dy,", false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "x=3Dy,", false, &error_a= bort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, "x"), =3D=3D, "y"); =20 /* Except when it isn't */ - opts =3D qemu_opts_parse(&opts_list_03, ",", false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, ",", false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, ""), =3D=3D, "on"); =20 /* Duplicate ID */ - opts =3D qemu_opts_parse(&opts_list_03, "x=3Dy,id=3Dfoo", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_03, "x=3Dy,id=3Dfoo", false, = &err); error_free_or_abort(&err); g_assert(!opts); /* TODO Cover .merge_lists =3D true */ =20 /* Buggy ID recognition (fixed) */ - opts =3D qemu_opts_parse(&opts_list_03, "x=3D,,id=3Dbar", false, &erro= r_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "x=3D,,id=3Dbar", false, + &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert(!qemu_opts_id(opts)); g_assert_cmpstr(qemu_opt_get(opts, "x"), =3D=3D, ",id=3Dbar"); =20 /* Anti-social ID */ - opts =3D qemu_opts_parse(&opts_list_01, "id=3D666", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "id=3D666", false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied key */ - opts =3D qemu_opts_parse(&opts_list_03, "an", true, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "an", true, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, "an"); =20 /* Implied key with empty value */ - opts =3D qemu_opts_parse(&opts_list_03, ",", true, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, ",", true, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, ""); =20 /* Implied key with comma value */ - opts =3D qemu_opts_parse(&opts_list_03, ",,,a=3D1", true, &error_abort= ); + opts =3D qemu_opts_parse_list(&opts_list_03, ",,,a=3D1", true, &error_= abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, ","); g_assert_cmpstr(qemu_opt_get(opts, "a"), =3D=3D, "1"); =20 /* Empty key is not an implied key */ - opts =3D qemu_opts_parse(&opts_list_03, "=3Dval", true, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "=3Dval", true, &error_ab= ort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpstr(qemu_opt_get(opts, ""), =3D=3D, "val"); =20 /* Unknown key */ - opts =3D qemu_opts_parse(&opts_list_01, "nonexistent=3D", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "nonexistent=3D", false, = &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied value */ - opts =3D qemu_opts_parse(&opts_list_03, "an", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_03, "an", false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied value, unknown key */ - opts =3D qemu_opts_parse(&opts_list_01, "nonexistent", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "nonexistent", false, &er= r); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied value, negated key */ - opts =3D qemu_opts_parse(&opts_list_03, "noaus", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_03, "noaus", false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied value, negated empty key */ - opts =3D qemu_opts_parse(&opts_list_03, "no", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_03, "no", false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Empty value */ - opts =3D qemu_opts_parse(&opts_list_03, "aus=3D", false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "aus=3D", false, &error_a= bort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); =20 /* Implied key */ - opts =3D qemu_opts_parse(&opts_list_03, "an", true, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "an", true, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); =20 /* Implied key, implied value */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", true, &er= r); + opts =3D qemu_opts_parse_list(&opts_list_03, "an,noaus,noaus=3D", true= , &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Implied key, empty value */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus=3D", true, &error_ab= ort); + opts =3D qemu_opts_parse_list(&opts_list_03, "an,noaus=3D", true, &err= or_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmpstr(qemu_opt_get(opts, "implied"), =3D=3D, "an"); g_assert_cmpstr(qemu_opt_get(opts, "noaus"), =3D=3D, ""); @@ -555,13 +556,13 @@ static void test_opts_parse_bool(void) Error *err =3D NULL; QemuOpts *opts; =20 - opts =3D qemu_opts_parse(&opts_list_02, "bool1=3Don,bool2=3Doff", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_02, "bool1=3Don,bool2=3Doff", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert(qemu_opt_get_bool(opts, "bool1", false)); g_assert(!qemu_opt_get_bool(opts, "bool2", true)); =20 - opts =3D qemu_opts_parse(&opts_list_02, "bool1=3Doffer", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, "bool1=3Doffer", false, &= err); error_free_or_abort(&err); g_assert(!opts); =20 @@ -574,59 +575,60 @@ static void test_opts_parse_number(void) QemuOpts *opts; =20 /* Lower limit zero */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D0", false, &error_a= bort); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D0", false, + &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), =3D=3D, 0); =20 /* Upper limit 2^64-1 */ - opts =3D qemu_opts_parse(&opts_list_01, - "number1=3D18446744073709551615,number2=3D-1", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_01, + "number1=3D18446744073709551615,number2=3D= -1", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmphex(qemu_opt_get_number(opts, "number1", 1), =3D=3D, UINT6= 4_MAX); g_assert_cmphex(qemu_opt_get_number(opts, "number2", 0), =3D=3D, UINT6= 4_MAX); =20 /* Above upper limit */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D1844674407370955161= 6", - false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D18446744073709= 551616", + false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Below lower limit */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D-184467440737095516= 16", - false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D-1844674407370= 9551616", + false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Hex and octal */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D0x2a,number2=3D052", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D0x2a,number2= =3D052", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), =3D=3D, 42); g_assert_cmpuint(qemu_opt_get_number(opts, "number2", 0), =3D=3D, 42); =20 /* Invalid */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D", false, &err= ); error_free_or_abort(&err); g_assert(!opts); - opts =3D qemu_opts_parse(&opts_list_01, "number1=3Deins", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3Deins", false, = &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Leading whitespace */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D \t42", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D \t42", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), =3D=3D, 42); =20 /* Trailing crap */ - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D3.14", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D3.14", false, = &err); error_free_or_abort(&err); g_assert(!opts); - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D08", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D08", false, &e= rr); error_free_or_abort(&err); g_assert(!opts); - opts =3D qemu_opts_parse(&opts_list_01, "number1=3D0 ", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_01, "number1=3D0 ", false, &e= rr); error_free_or_abort(&err); g_assert(!opts); =20 @@ -639,18 +641,18 @@ static void test_opts_parse_size(void) QemuOpts *opts; =20 /* Lower limit zero */ - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D0", false, &error_abo= rt); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D0", false, &erro= r_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), =3D=3D, 0); =20 /* Note: full 64 bits of precision */ =20 /* Around double limit of precision: 2^53-1, 2^53, 2^53+1 */ - opts =3D qemu_opts_parse(&opts_list_02, - "size1=3D9007199254740991," - "size2=3D9007199254740992," - "size3=3D9007199254740993", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_02, + "size1=3D9007199254740991," + "size2=3D9007199254740992," + "size3=3D9007199254740993", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 3); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), =3D=3D, 0x1fffffffffffff); @@ -660,11 +662,12 @@ static void test_opts_parse_size(void) =3D=3D, 0x20000000000001); =20 /* Close to signed int limit: 2^63-1, 2^63, 2^63+1 */ - opts =3D qemu_opts_parse(&opts_list_02, - "size1=3D9223372036854775807," /* 7ffffffffffff= fff */ - "size2=3D9223372036854775808," /* 8000000000000= 000 */ - "size3=3D9223372036854775809", /* 8000000000000= 001 */ - false, &error_abort); + opts =3D qemu_opts_parse_list( + &opts_list_02, + "size1=3D9223372036854775807," /* 7fffffffffffffff */ + "size2=3D9223372036854775808," /* 8000000000000000 */ + "size3=3D9223372036854775809", /* 8000000000000001 */ + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 3); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), =3D=3D, 0x7fffffffffffffff); @@ -674,10 +677,11 @@ static void test_opts_parse_size(void) =3D=3D, 0x8000000000000001); =20 /* Close to actual upper limit 0xfffffffffffff800 (53 msbs set) */ - opts =3D qemu_opts_parse(&opts_list_02, - "size1=3D18446744073709549568," /* ffffffffffff= f800 */ - "size2=3D18446744073709550591", /* ffffffffffff= fbff */ - false, &error_abort); + opts =3D qemu_opts_parse_list( + &opts_list_02, + "size1=3D18446744073709549568," /* fffffffffffff800 */ + "size2=3D18446744073709550591", /* fffffffffffffbff */ + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), =3D=3D, 0xfffffffffffff800); @@ -685,47 +689,48 @@ static void test_opts_parse_size(void) =3D=3D, 0xfffffffffffffbff); =20 /* Actual limit, 2^64-1 */ - opts =3D qemu_opts_parse(&opts_list_02, - "size1=3D18446744073709551615", /* ffffffffffff= ffff */ - false, &error_abort); + opts =3D qemu_opts_parse_list( + &opts_list_02, + "size1=3D18446744073709551615", /* ffffffffffffffff */ + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1), =3D=3D, 0xffffffffffffffff); =20 /* Beyond limits */ - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D-1", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D-1", false, &err= ); error_free_or_abort(&err); g_assert(!opts); - opts =3D qemu_opts_parse(&opts_list_02, - "size1=3D18446744073709551616", /* 2^64 */ - false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, + "size1=3D18446744073709551616", /* 2^64 */ + false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Suffixes */ - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D8b,size2=3D1.5k,size3= =3D2M", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D8b,size2=3D1.5k,= size3=3D2M", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 3); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), =3D=3D, 8); g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), =3D=3D, 1536); g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), =3D=3D, 2 * MiB); - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D0.1G,size2=3D16777215= T", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D0.1G,size2=3D167= 77215T", + false, &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 2); g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), =3D=3D, GiB / 10); g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), =3D=3D, 16777215U= LL * TiB); =20 /* Beyond limit with suffix */ - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D16777216T", - false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D16777216T", + false, &err); error_free_or_abort(&err); g_assert(!opts); =20 /* Trailing crap */ - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D16E", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D16E", false, &er= r); error_free_or_abort(&err); g_assert(!opts); - opts =3D qemu_opts_parse(&opts_list_02, "size1=3D16Gi", false, &err); + opts =3D qemu_opts_parse_list(&opts_list_02, "size1=3D16Gi", false, &e= rr); error_free_or_abort(&err); g_assert(!opts); =20 @@ -752,13 +757,13 @@ static void test_has_help_option(void) for (i =3D 0; i < ARRAY_SIZE(test); i++) { g_assert_cmpint(has_help_option(test[i].params), =3D=3D, test[i].expect); - opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, - &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, test[i].params, false, + &error_abort); g_assert_cmpint(qemu_opt_has_help_opt(opts), =3D=3D, test[i].expect); qemu_opts_del(opts); - opts =3D qemu_opts_parse(&opts_list_03, test[i].params, true, - &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, test[i].params, true, + &error_abort); g_assert_cmpint(qemu_opt_has_help_opt(opts), =3D=3D, test[i].expect_implied); qemu_opts_del(opts); @@ -783,7 +788,7 @@ static void test_has_help_option_with_value(void) /* reject all */ g_assert_cmpint(has_help_option(test[i].params), =3D=3D, false); =20 - opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, &er= r); + opts =3D qemu_opts_parse_list(&opts_list_03, test[i].params, false= , &err); error_free_or_abort(&err); g_assert(!opts); } @@ -916,8 +921,9 @@ static void test_opts_to_qdict_basic(void) QemuOpts *opts; QDict *dict; =20 - opts =3D qemu_opts_parse(&opts_list_01, "str1=3Dfoo,str2=3D,str3=3Dbar= ,number1=3D42", - false, &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_01, + "str1=3Dfoo,str2=3D,str3=3Dbar,number1=3D4= 2", + false, &error_abort); g_assert(opts !=3D NULL); =20 dict =3D qemu_opts_to_qdict(opts, NULL); @@ -942,9 +948,9 @@ static void test_opts_to_qdict_filtered(void) first =3D qemu_opts_append(NULL, &opts_list_02); merged =3D qemu_opts_append(first, &opts_list_01); =20 - opts =3D qemu_opts_parse(merged, - "str1=3Dfoo,str2=3D,str3=3Dbar,bool1=3Doff,numb= er1=3D42", - false, &error_abort); + opts =3D qemu_opts_parse_list( + merged, "str1=3Dfoo,str2=3D,str3=3Dbar,bool1=3Doff,number1=3D42", + false, &error_abort); g_assert(opts !=3D NULL); =20 /* Convert to QDict without deleting from opts */ @@ -1001,7 +1007,8 @@ static void test_opts_to_qdict_duplicates(void) QemuOpt *opt; QDict *dict; =20 - opts =3D qemu_opts_parse(&opts_list_03, "foo=3Da,foo=3Db", false, &err= or_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "foo=3Da,foo=3Db", false, + &error_abort); g_assert(opts !=3D NULL); =20 /* Verify that opts has two options with the same name */ diff --git a/util/qemu-option.c b/util/qemu-option.c index 483e6cbf70..218bb8ae58 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -939,6 +939,19 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const ch= ar *params, return opts_parse(list, params, permit_abbrev, errp); } =20 +/** + * Create a QemuOpts from @list with options parsed from @params. If + * @permit_abbrev, the first key=3Dvalue in @params may omit key=3D and is + * treated as if key was @list->implied_opt_name. On error, store an + * error object through @errp if non-null. Return the new QemuOpts on + * success, null pointer on error. + */ +QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, + bool permit_abbrev, Error **errp) +{ + return qemu_opts_parse(list, params, permit_abbrev, errp); +} + /** * Create a QemuOpts in @list and with options parsed from @params. * If @permit_abbrev, the first key=3Dvalue in @params may omit key=3D, diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 4773755fd5..30226671a9 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -704,7 +704,7 @@ static QemuOptsList inet_opts =3D { =20 int inet_parse(InetSocketAddress *addr, const char *str, Error **errp) { - QemuOpts *opts =3D qemu_opts_parse(&inet_opts, str, true, errp); + QemuOpts *opts =3D qemu_opts_parse_list(&inet_opts, str, true, errp); if (!opts) { return -1; } --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806413; cv=none; d=zohomail.com; s=zohoarc; b=hUpGdIrBeWb7JGmeQXNO7UNsTvyZjXsTJfCA0WfBlDBiRTtndMI556IarMDk2NdwifhjWyq9GmHl6R1sIaM3H/KpcJjRX6wSyjgOr+cHjzp5j5x5rvV0GCvarcHl5coSjMHZK7vHXrTEE6aNpWa/IuT+YJMeapzfhhXGN1BDutw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806413; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vdgtygysyR7XstxwHmcdv3SLotaep1DmOn9ckWztz7A=; b=UN7oRMqeawVlfEHbTjHdKBagSx+13w/8Smgm71BlRJuWCqxo4vxfJ/9GDNKr4Jz1W30aCw1n8l4l5bqfVc5erPvQtRbdnUMLkPZiQo5veHHs407ldSPy156tkmlnGeFSh5F9dA73Gz+Bu2YCWfNW/SvK+WR9LO4PpVuTmgVifmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806413407755.6320797663461; Wed, 30 Sep 2026 15:13:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wi-0007wA-MH; Wed, 30 Sep 2026 18:11:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wg-0007vq-C2 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:46 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wd-00052M-O3 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:45 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B352221F52; Wed, 30 Sep 2026 22:11:33 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2434413B26; Wed, 30 Sep 2026 22:11:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T7 (envelope-from ); Wed, 30 Sep 2026 22:11:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806297; h=from:from:reply-to: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=vdgtygysyR7XstxwHmcdv3SLotaep1DmOn9ckWztz7A=; b=AgRmtRzeP+bxXC51qTAiFKytW32IbpTFZPqZifb6WIXgJfPnHhNq0LqxSXS3zlnsAK1pLE ONyJCh5OKl2xn9qC5VPKmtrR0BTJSeVWXrpNH8ajPqm5SJOGQkdBYt9tBwiXDk8x9mTvw3 4UzaTOXyNCIhv3UyDBB1LsXGNNpPblE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806297; h=from:from:reply-to: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=vdgtygysyR7XstxwHmcdv3SLotaep1DmOn9ckWztz7A=; b=43bSZi0f/1Xm02HkjLXO0FdHtVqDhzItfbFba0UNPLuiYZEDdFBk1dt7980B2N/Cp+tlJs yHZc1IBJn9i6ibBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806293; h=from:from:reply-to: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=vdgtygysyR7XstxwHmcdv3SLotaep1DmOn9ckWztz7A=; b=x2c1KJ4YVP/2pCVHm8TWBAO0OWq/2zu7NMxHLLIWfMhYUeQHH4AXKPFq2cDNQuH5epgiwB vudWVB3WHbqF1KSF7U8pRtM7Q6KWS6U9upvzaEf67HcXRqrYvXycj3AQMa5JuMprHhpICI MzdDGjR5Y+PFz9HQZVh7+1AEscKGzkc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806293; h=from:from:reply-to: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=vdgtygysyR7XstxwHmcdv3SLotaep1DmOn9ckWztz7A=; b=OwG2psBn4xvcqKCSD0gXl95fqqp1hLcheAIRXaXGBA7gWGJ38FdUt00S+Ox8vFGjmEfJgz 2slO9NsraRO/QYBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Paolo Bonzini , Michael Roth Subject: [PATCH v2 06/11] qemu-option: Change qemu_parse_opts() to take the group name Date: Wed, 30 Sep 2026 19:11:00 -0300 Message-ID: <20260930221105.2262063-7-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.993]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.de:email, suse.de:mid] X-Spam-Score: -3.30 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806415406158500 Get rid of the pattern qemu_parse_opts(qemu_find_opts("some-opt")) by passing the string directly to qemu_parse_opts(). Don't check for NULL list at this time to preserve the old behavior. A subsequent patch will correct that. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qemu/option.h | 2 +- system/vl.c | 5 ++--- tests/unit/test-opts-visitor.c | 12 ++++-------- util/qemu-option.c | 19 +++++++++++-------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index f96d9fae42..dfe0d9b893 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -130,7 +130,7 @@ bool qemu_opts_do_parse(QemuOpts *opts, const char *par= ams, const char *firstname, Error **errp); QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, bool permit_abbrev); -QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, +QemuOpts *qemu_opts_parse(const char *group, const char *params, bool permit_abbrev, Error **errp); QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp); diff --git a/system/vl.c b/system/vl.c index 468a9fc247..87398cc8d0 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1441,10 +1441,9 @@ static void qemu_create_default_devices(void) } =20 if (default_net) { - QemuOptsList *net =3D qemu_find_opts("net"); - qemu_opts_parse(net, "nic", true, &error_abort); + qemu_opts_parse("net", "nic", true, &error_abort); #ifdef CONFIG_SLIRP - qemu_opts_parse(net, "user", true, &error_abort); + qemu_opts_parse("net", "user", true, &error_abort); #endif } =20 diff --git a/tests/unit/test-opts-visitor.c b/tests/unit/test-opts-visitor.c index 23e897061c..a9e45c0251 100644 --- a/tests/unit/test-opts-visitor.c +++ b/tests/unit/test-opts-visitor.c @@ -39,8 +39,7 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_d= ata) QemuOpts *opts; Visitor *v; =20 - opts =3D qemu_opts_parse(qemu_find_opts("userdef"), opts_string, false, - NULL); + opts =3D qemu_opts_parse("userdef", opts_string, false, NULL); g_assert(opts !=3D NULL); =20 v =3D opts_visitor_new(opts); @@ -181,8 +180,7 @@ test_opts_range_unvisited(void) QemuOpts *opts; Visitor *v; =20 - opts =3D qemu_opts_parse(qemu_find_opts("userdef"), "ilist=3D0-2", fal= se, - &error_abort); + opts =3D qemu_opts_parse("userdef", "ilist=3D0-2", false, &error_abort= ); =20 v =3D opts_visitor_new(opts); =20 @@ -222,8 +220,7 @@ test_opts_range_beyond(void) Visitor *v; int64_t val; =20 - opts =3D qemu_opts_parse(qemu_find_opts("userdef"), "ilist=3D0", false, - &error_abort); + opts =3D qemu_opts_parse("userdef", "ilist=3D0", false, &error_abort); =20 v =3D opts_visitor_new(opts); =20 @@ -257,8 +254,7 @@ test_opts_dict_unvisited(void) Visitor *v; UserDefOptions *userdef; =20 - opts =3D qemu_opts_parse(qemu_find_opts("userdef"), "i64x=3D0,bogus=3D= 1", false, - &error_abort); + opts =3D qemu_opts_parse("userdef", "i64x=3D0,bogus=3D1", false, &erro= r_abort); =20 v =3D opts_visitor_new(opts); visit_type_UserDefOptions(v, NULL, &userdef, &err); diff --git a/util/qemu-option.c b/util/qemu-option.c index 218bb8ae58..7cb45f0710 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" =20 #include "qapi/error.h" +#include "qemu/config-file.h" #include "qemu/error-report.h" #include "qobject/qbool.h" #include "qobject/qdict.h" @@ -927,16 +928,18 @@ static QemuOpts *opts_parse(QemuOptsList *list, const= char *params, } =20 /** - * Create a QemuOpts in @list and with options parsed from @params. - * If @permit_abbrev, the first key=3Dvalue in @params may omit key=3D, - * and is treated as if key was @list->implied_opt_name. - * On error, store an error object through @errp if non-null. - * Return the new QemuOpts on success, null pointer on error. + * Find the @group and create a QemuOpts with options parsed from + * @params. If @permit_abbrev, the first key=3Dvalue in @params may + * omit key=3D. On error, store an error object through @errp if + * non-null. Return the new QemuOpts on success, null pointer on + * error. */ -QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, +QemuOpts *qemu_opts_parse(const char *group, const char *params, bool permit_abbrev, Error **errp) { - return opts_parse(list, params, permit_abbrev, errp); + QemuOptsList *list =3D qemu_find_opts_err(group, errp); + + return qemu_opts_parse_list(list, params, permit_abbrev, errp); } =20 /** @@ -949,7 +952,7 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const cha= r *params, QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { - return qemu_opts_parse(list, params, permit_abbrev, errp); + return opts_parse(list, params, permit_abbrev, errp); } =20 /** --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806440; cv=none; d=zohomail.com; s=zohoarc; b=hHnIpJCE6L0rnHj9l4TjSvWioHoPAgLhKzdlNZM0Xjb0clDunbzAWJgd29VvPnU4NKgS6uptcXpgzRFR7gabARK1Ci1nxHyF+x0511NNq+A/w3qPbLdKrD8VvqQblIwYClKPVr+5+z3y3yX96AY3xxVkjYVnwXFSHGQ08o1/X6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806440; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IxwT3cijmhc+wS0q1TDbdYSFNOPuYddUPyU+ZkUQk5k=; b=MmG6w3G+6s6Jd7TIAuabbVh6+HG1Mywx1kfBXZkAgkSBnt5eN884PkZsU5YK0wEHRlSd+DEkCdPZ8tdG3h7OtDC0Lc9WSpM2sCox/moqNIFOx/7n4IxPKX5TLLGa68y5ds/gLh9XTcHxGMLyQNCZtPF35EYmHHdyul5VElu5SbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806440409931.1786546069626; Wed, 30 Sep 2026 15:14:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2Wy-0007xs-H8; Wed, 30 Sep 2026 18:12:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wi-0007wE-I8 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:48 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wg-00052W-2W for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:47 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D9D931FBA1; Wed, 30 Sep 2026 22:11:34 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CD0B613AF1; Wed, 30 Sep 2026 22:11:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T8 (envelope-from ); Wed, 30 Sep 2026 22:11:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806299; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IxwT3cijmhc+wS0q1TDbdYSFNOPuYddUPyU+ZkUQk5k=; b=1jSGAUkeKr7lUBi6+mkNaFtgnsyDLwDf5g6J9gVh7LCvBcOnea3vS97dKeqNF754s06XeT ivghTsyE4B7aHIRx0gDdoM6HFtUm6h9AGXvJ8K4r3CQ45Jg2d/fPJzxivHrsBGyyMKta6M fSyrzoo7J/5vqhgnNPagXJHGvIKqjsA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806299; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IxwT3cijmhc+wS0q1TDbdYSFNOPuYddUPyU+ZkUQk5k=; b=EpjXuk15M2fh9U6J5tWEe0u8genJnlHrzHRtsG5FqdHHr+aLAXe9LvJorhrW5l+5yXA12n PIjuKp5BJeT33ABQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=D1uQKIG+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=a4LOdZb9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806294; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IxwT3cijmhc+wS0q1TDbdYSFNOPuYddUPyU+ZkUQk5k=; b=D1uQKIG+S1Z6hiinUvxkjuCLafbEJ9HCH10n6A8ZlOvm26xD0e28i8yccYnGTdRlJSo3np qduuxjY2xvd7CIRbXoy0rFbXUdmSmbiDbkF4yAJBflKBTzwDn/Q1k3JgVE68wY64RQmFbP wCzdvzeLYtsY7fnEhHofWRkCnjU0lB0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806294; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IxwT3cijmhc+wS0q1TDbdYSFNOPuYddUPyU+ZkUQk5k=; b=a4LOdZb9LOLX8pbzV2s3Wlh+ozN7sZQkba+xLIgdNHiPOU9uDspSPBCHPq+Ab9Sc2MpDe9 y4qV2qf+0lu1G/Cw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 07/11] qemu-option: Add qemu_opts_parse_list_noisily Date: Wed, 30 Sep 2026 19:11:01 -0300 Message-ID: <20260930221105.2262063-8-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: D9D931FBA1 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806441539158500 Content-Type: text/plain; charset="utf-8" Add a new function that takes a QemuOptsList pointer and expects informative messages to be printed instead of returned in an Error object. This makes the _noisily version simmetric with the "non-noisily". The next patch will convert the callers to use the appropriate version. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qemu/option.h | 2 ++ util/qemu-option.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/qemu/option.h b/include/qemu/option.h index dfe0d9b893..df68da9aa8 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -134,6 +134,8 @@ QemuOpts *qemu_opts_parse(const char *group, const char= *params, bool permit_abbrev, Error **errp); QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp); +QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *list, const char *par= ams, + bool permit_abbrev); QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, Error **errp); QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict, diff --git a/util/qemu-option.c b/util/qemu-option.c index 7cb45f0710..be9404ab7f 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -965,6 +965,20 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, con= st char *params, */ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, bool permit_abbrev) +{ + return qemu_opts_parse_list_noisily(list, params, permit_abbrev); +} + +/** + * Create a QemuOpts in @list and with options parsed from @params. + * If @permit_abbrev, the first key=3Dvalue in @params may omit key=3D, + * and is treated as if key was @list->implied_opt_name. + * Report errors with error_report_err(). This is inappropriate in + * QMP context. Do not use this function there! + * Return the new QemuOpts on success, null pointer on error. + */ +QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *list, const char *par= ams, + bool permit_abbrev) { Error *err =3D NULL; QemuOpts *opts; --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806413; cv=none; d=zohomail.com; s=zohoarc; b=nBieuq/Zn8ZgtmT08IhfcneJEjH/BLq/MC084na1UEq5K82qk0wh47akb1ZfFDRFaWxQ30YKbVcmK3rKxYpdo5w23E/ucdcfczqvzAJZD0bjyqe8gv2kkGMRHSs2LFavScesd6kVHWKfp8knOrNhOo5Yve97e2f+hwLCTtkKwVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806413; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6lBTCs/EyQSwar58n+/JjwbwaSnHhs158e0LdfcFJuo=; b=Wakc840gQpVW8h+lRe5CAhAOgefIW8RGdxU6KJ8Y1Hq4LmMf8Q5EsY+VCrWIr3SjzD3gJlPI1AzKohVR9qyhEyXEAO/fouEKprBfKS7M/S/RjXfNnlL4MVUaw0xVbMNzeV7dhM1t5GvuTuIEUiSgQakjilwX7y4ByOQAP1SHO9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17908064134181010.3129941305494; Wed, 30 Sep 2026 15:13:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2X1-0007yE-So; Wed, 30 Sep 2026 18:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wk-0007wY-V4 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:53 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wi-00052p-AN for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:50 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 243721F7EE; Wed, 30 Sep 2026 22:11:38 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3DD1213B21; Wed, 30 Sep 2026 22:11:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T9 (envelope-from ); Wed, 30 Sep 2026 22:11:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806302; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lBTCs/EyQSwar58n+/JjwbwaSnHhs158e0LdfcFJuo=; b=qmjlPLMCtYrcevf+XLq/177ZPM90tHLAa+83neLK0k9R/MY335nxkxz4MX9uKDm7XPsZfJ omvWHZbUyQhpNSar/5am+QNePw0Z2MsEQQa3Q2LhSw2kRiHKVhOpLINpRXb2o8Ll3QzC9p CNdKa2YJvlltrN5B1P2L8I9BGQhBB44= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806302; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lBTCs/EyQSwar58n+/JjwbwaSnHhs158e0LdfcFJuo=; b=+6CVMGidnujLXy0v8TVyHJM7TODiNnNt2oMdn+cIm2w0b8nJZflqvm0enCcNgXPnGQiF9P r/ahs5WwE++K9HCg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=iXF6c1bn; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=70YBWPYV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lBTCs/EyQSwar58n+/JjwbwaSnHhs158e0LdfcFJuo=; b=iXF6c1bnzC4avTdKkmjdp7fTLfuMHhAUtv0b7O4/6+xD+twkROc5zm18V3TgTs0kSeNMmC yrQqtYjkYRyRRmKwRCsykZvLLqgpEh+OMQ4I+lrK7XUdE9BuqCRlCvnnCp4IxzxwRxwrQt l97dd+o1YKoOW0W+So73UFsxZYaDAx4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lBTCs/EyQSwar58n+/JjwbwaSnHhs158e0LdfcFJuo=; b=70YBWPYVltwjDoLwGgyrnvWDu39rOP7FxXcLQTKJZHI8E3lCnVPLMSThoycqDg/WbKP1Pl mQHiJTX9jduMYbDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Kevin Wolf , Hanna Reitz , "Dr. David Alan Gilbert" , Jason Wang , Eric Blake , Vladimir Sementsov-Ogievskiy , Paolo Bonzini , Stefan Berger , Lukas Straub , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 08/11] qemu-option: Use qemu_opts_parse_list_noisily where appropriate Date: Wed, 30 Sep 2026 19:11:02 -0300 Message-ID: <20260930221105.2262063-9-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 243721F7EE X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,treblig.org,gmail.com,yandex-team.ru,linux.vnet.ibm.com,web.de]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com,web.de]; RCPT_COUNT_TWELVE(0.00)[13]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806416026158500 Content-Type: text/plain; charset="utf-8" Change the callers of qemu_opts_parse_noisily() that currently take a QemuOptsList pointer to call qemu_opts_parse_list_noisily(). This is done to free up the qemu_opts_parse_noisily() version to be used to take the group name instead. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- block/monitor/block-hmp-cmds.c | 2 +- monitor/hmp.c | 2 +- net/net.c | 2 +- qemu-img.c | 8 ++++---- qemu-io-cmds.c | 2 +- qemu-io.c | 7 ++++--- qemu-nbd.c | 6 +++--- storage-daemon/qemu-storage-daemon.c | 4 ++-- system/qdev-monitor.c | 2 +- system/tpm.c | 2 +- system/vl.c | 6 +++--- tests/unit/test-replication.c | 6 +++--- tools/qemu-vnc/qemu-vnc.c | 2 +- 13 files changed, 26 insertions(+), 25 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 7bae4d425c..cbd64166ec 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -63,7 +63,7 @@ static void hmp_drive_add_node(MonitorHMP *hmp, const cha= r *optstr) QDict *qdict; Error *err =3D NULL; =20 - opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false); + opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, optstr, false); if (!opts) { return; } diff --git a/monitor/hmp.c b/monitor/hmp.c index 488ec23937..fc32cfd1ff 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -897,7 +897,7 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon, if (get_str(buf, sizeof(buf), &p) < 0) { goto fail; } - opts =3D qemu_opts_parse_noisily(opts_list, buf, true); + opts =3D qemu_opts_parse_list_noisily(opts_list, buf, true= ); if (!opts) { goto fail; } diff --git a/net/net.c b/net/net.c index d7fa637ce5..37401ab2b4 100644 --- a/net/net.c +++ b/net/net.c @@ -2029,7 +2029,7 @@ void netdev_parse_modern(const char *optstr) =20 void net_client_parse(QemuOptsList *opts_list, const char *optstr) { - if (!qemu_opts_parse_noisily(opts_list, optstr, true)) { + if (!qemu_opts_parse_list_noisily(opts_list, optstr, true)) { exit(1); } } diff --git a/qemu-img.c b/qemu-img.c index 2f63d31141..c645de6462 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2383,8 +2383,8 @@ static int img_convert(const img_cmd_t *ccmd, int arg= c, char **argv) break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { - sn_opts =3D qemu_opts_parse_noisily(&internal_snapshot_opt= s, - optarg, false); + sn_opts =3D qemu_opts_parse_list_noisily(&internal_snapsho= t_opts, + optarg, false); if (!sn_opts) { error_report("Failed in parsing snapshot param '%s'", optarg); @@ -5768,8 +5768,8 @@ static int img_measure(const img_cmd_t *ccmd, int arg= c, char **argv) break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { - sn_opts =3D qemu_opts_parse_noisily(&internal_snapshot_opt= s, - optarg, false); + sn_opts =3D qemu_opts_parse_list_noisily(&internal_snapsho= t_opts, + optarg, false); if (!sn_opts) { error_report("Failed in parsing snapshot param '%s'", optarg); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index aa795fd87a..6c8c4c9540 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2540,7 +2540,7 @@ static int reopen_f(BlockBackend *blk, int argc, char= **argv, Error **errp) has_cache_option =3D true; break; case 'o': - if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) { + if (!qemu_opts_parse_list_noisily(&reopen_opts, optarg, 0)) { qemu_opts_reset(&reopen_opts); return -EINVAL; } diff --git a/qemu-io.c b/qemu-io.c index 598d5b1c9c..db0ee499e4 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -220,7 +220,7 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv, Error **errp) qemu_opts_reset(&empty_opts); return -EINVAL; } - if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) { + if (!qemu_opts_parse_list_noisily(&empty_opts, optarg, false))= { qemu_opts_reset(&empty_opts); return -EINVAL; } @@ -240,7 +240,7 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv, Error **errp) } =20 if (imageOpts && (optind =3D=3D argc - 1)) { - if (!qemu_opts_parse_noisily(&empty_opts, argv[optind], false)) { + if (!qemu_opts_parse_list_noisily(&empty_opts, argv[optind], false= )) { qemu_opts_reset(&empty_opts); return -EINVAL; } @@ -659,7 +659,8 @@ int main(int argc, char **argv) if ((argc - optind) =3D=3D 1) { if (imageOpts) { QemuOpts *qopts =3D NULL; - qopts =3D qemu_opts_parse_noisily(&file_opts, argv[optind], fa= lse); + qopts =3D qemu_opts_parse_list_noisily(&file_opts, argv[optind= ], + false); if (!qopts) { exit(1); } diff --git a/qemu-nbd.c b/qemu-nbd.c index ed5895861b..749c915b58 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -706,8 +706,8 @@ int main(int argc, char **argv) break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { - sn_opts =3D qemu_opts_parse_noisily(&internal_snapshot_opt= s, - optarg, false); + sn_opts =3D qemu_opts_parse_list_noisily(&internal_snapsho= t_opts, + optarg, false); if (!sn_opts) { error_report("Failed in parsing snapshot param `%s'", optarg); @@ -1117,7 +1117,7 @@ int main(int argc, char **argv) error_report("--image-opts and -f are mutually exclusive"); exit(EXIT_FAILURE); } - o =3D qemu_opts_parse_noisily(&file_opts, opts.srcpath, true); + o =3D qemu_opts_parse_list_noisily(&file_opts, opts.srcpath, true); if (!o) { qemu_opts_reset(&file_opts); exit(EXIT_FAILURE); diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 50dbfbd97a..5d63ef2efc 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -283,8 +283,8 @@ static void process_options(int argc, char *argv[], boo= l pre_init_pass) case OPTION_CHARDEV: { /* TODO This interface is not stable until we QAPIfy it */ - QemuOpts *opts =3D qemu_opts_parse_noisily(&qemu_chardev_o= pts, - optarg, true); + QemuOpts *opts =3D qemu_opts_parse_list_noisily( + &qemu_chardev_opts, optarg, true); if (opts =3D=3D NULL) { exit(EXIT_FAILURE); } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 8185822daa..dc2d9e76bc 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -1204,7 +1204,7 @@ int qemu_global_option(const char *str) return 0; } =20 - opts =3D qemu_opts_parse_noisily(&qemu_global_opts, str, false); + opts =3D qemu_opts_parse_list_noisily(&qemu_global_opts, str, false); if (!opts) { return -1; } diff --git a/system/tpm.c b/system/tpm.c index 903b29c043..f0f5a64d9a 100644 --- a/system/tpm.c +++ b/system/tpm.c @@ -184,7 +184,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const cha= r *optstr) tpm_display_backend_drivers(); exit(EXIT_SUCCESS); } - opts =3D qemu_opts_parse_noisily(opts_list, optstr, true); + opts =3D qemu_opts_parse_list_noisily(opts_list, optstr, true); if (!opts) { return -1; } diff --git a/system/vl.c b/system/vl.c index 87398cc8d0..bf5146d1c0 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3277,7 +3277,7 @@ void qemu_init(int argc, char **argv) error_report("fsdev support is disabled"); exit(1); } - if (!qemu_opts_parse_noisily(olist, optarg, true)) { + if (!qemu_opts_parse_list_noisily(olist, optarg, true)) { exit(1); } break; @@ -3292,7 +3292,7 @@ void qemu_init(int argc, char **argv) error_report("virtfs support is disabled"); exit(1); } - opts =3D qemu_opts_parse_noisily(olist, optarg, true); + opts =3D qemu_opts_parse_list_noisily(olist, optarg, true); if (!opts) { exit(1); } @@ -3644,7 +3644,7 @@ void qemu_init(int argc, char **argv) exit(1); } =20 - opts =3D qemu_opts_parse_noisily(olist, optarg, true); + opts =3D qemu_opts_parse_list_noisily(olist, optarg, true); if (!opts) { exit(1); } diff --git a/tests/unit/test-replication.c b/tests/unit/test-replication.c index 3aa98e6f56..101f72acdc 100644 --- a/tests/unit/test-replication.c +++ b/tests/unit/test-replication.c @@ -179,7 +179,7 @@ static BlockBackend *start_primary(void) "file.driver=3Dqcow2,file.file.filename=3D%s= ," "file.file.locking=3Doff" , p_local_disk); - opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false); + opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); @@ -295,7 +295,7 @@ static BlockBackend *start_secondary(void) cmdline =3D g_strdup_printf("file.filename=3D%s,driver=3Dqcow2," "file.locking=3Doff", s_local_disk); - opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false); + opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); @@ -321,7 +321,7 @@ static BlockBackend *start_secondary(void) "file.backing.backing=3D%s" , S_ID, s_active_disk, s_hidden_disk , S_LOCAL_DISK_ID); - opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false); + opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); diff --git a/tools/qemu-vnc/qemu-vnc.c b/tools/qemu-vnc/qemu-vnc.c index 5c2ba3b7a5..10ac76298a 100644 --- a/tools/qemu-vnc/qemu-vnc.c +++ b/tools/qemu-vnc/qemu-vnc.c @@ -377,7 +377,7 @@ setup_vnc_opts(const char *vnc_addr, const char *tls_cr= eds_dir, g_string_append(opts_str, ",non-adaptive=3Don"); } =20 - opts =3D qemu_opts_parse_noisily(olist, opts_str->str, true); + opts =3D qemu_opts_parse_list_noisily(olist, opts_str->str, true); if (!opts) { return false; } --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806394; cv=none; d=zohomail.com; s=zohoarc; b=d7d/+qUDPGRnxY/1Vz+TXVfV9FMsA2CeQSf2WjkaqraOUKnwhMaMO95g5P7L7JOuRYKeWOlIUeCPIzOYlA0xXbaZs40d/rFCsEi1gl2ggh7KUUiT3iLSk67ljIY2IOJ06xEnEqX68mDa72+ut6j1s/xLTCtQfOlJif2/2n/rGc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806394; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SVjErY61pOuzPXraql/0nwBhwIosE43oZ3vpfAzn7Zw=; b=auA63W42DPRN+FChMNX79RbGyjBgZYzUDMCpHJEDkCYXrKqHied5zrPw2Ay5I2TEaVrrY0kXe8DdNoQuehcQyNRURKrWO/sdum1QWg23ji9KBAEuiF9zs8YbzFovygsav2ukLA6Dr/LLt1V+0NFvLECS3T333pHS+r886EVrle0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806394457338.95907914432394; Wed, 30 Sep 2026 15:13:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2X2-0007yM-OE; Wed, 30 Sep 2026 18:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wn-0007we-Dx for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:54 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wk-000532-NF for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:53 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 08BD21FB95; Wed, 30 Sep 2026 22:11:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7AE7913B23; Wed, 30 Sep 2026 22:11:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T10 (envelope-from ); Wed, 30 Sep 2026 22:11:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806305; h=from:from:reply-to: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=SVjErY61pOuzPXraql/0nwBhwIosE43oZ3vpfAzn7Zw=; b=M4hNoBPQ5ytVNgBXJzme9aUQT1iMcznHdPPuhHzxCzqopx7A7WLv2uQGgkp/h0H4b6FzVO HPmGi0FmPD7JA4o1n2mNPkXh8iEdk7fYfIKEVCjLqKdkKSYkjf3Be7j+EghCwROwhzbffG NAoX262IyQmiCZexgoFaOH6vPNnQXuc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806305; h=from:from:reply-to: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=SVjErY61pOuzPXraql/0nwBhwIosE43oZ3vpfAzn7Zw=; b=ProFW+EfiTmM1g8JMmxeNbzSrsB+RAyTefTBwPdsoDzhrEsO4/s0aQwA+837sFjwitR/SI ERaq/5VTaaQuSzDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Q65M7khU; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=rqI2lsfg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806301; h=from:from:reply-to: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=SVjErY61pOuzPXraql/0nwBhwIosE43oZ3vpfAzn7Zw=; b=Q65M7khUXKMp35Qfxi330RGdTTJq1sywJdL+haTxFfRfsfBW0qkIwETnu6rARLZDx9grsI QVcO8Z5CNSA+7+5txO/9velldTpYml5b9jVRsbV+FtOwaihqCpS9RFVxQoKPnG/wgLlUT4 tq7wULwZfGfoRVdQDVi0gEKaphLXHBE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806301; h=from:from:reply-to: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=SVjErY61pOuzPXraql/0nwBhwIosE43oZ3vpfAzn7Zw=; b=rqI2lsfg+uC21W5jLE1N/Aykk1kkT1uifs1RMnE4DtFH9jDuPFbpVxm33CVaRQpHh/aSlB 3DWmv1lh4MK28hDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Alexandre Iooss Subject: [PATCH v2 09/11] qemu-option: Change qemu_opts_parse_noisily() to take the group Date: Wed, 30 Sep 2026 19:11:03 -0300 Message-ID: <20260930221105.2262063-10-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[11]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:email,suse.de:mid]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.51 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 08BD21FB95 X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806395515158501 Pass the group name as argument to qemu_opts_parse_noisily() to make it simmetric with qemu_opts_parse(). This change solves the issue of qemu_opts_parse_noisily() crashing on a NULL return from qemu_find_opts(), which can happen when an option is invoked for code in a module that is not loaded. Reviewed-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- block/monitor/block-hmp-cmds.c | 2 +- blockdev.c | 2 +- chardev/char-hmp-cmds.c | 5 +-- include/qemu/option.h | 2 +- plugins/loader.c | 2 +- qemu-img.c | 3 +- semihosting/config.c | 4 +- system/vl.c | 75 ++++++++++++---------------------- tests/unit/test-char.c | 12 ++---- tests/unit/test-seccomp.c | 6 +-- trace/control.c | 3 +- ui/vnc.c | 3 +- util/qemu-option.c | 12 +++++- 13 files changed, 52 insertions(+), 79 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index cbd64166ec..d94a07314f 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -101,7 +101,7 @@ void hmp_drive_add(MonitorHMP *hmp, const QDict *qdict) return; } =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, fals= e); + opts =3D qemu_opts_parse_noisily("drive", optstr, false); if (!opts) return; =20 diff --git a/blockdev.c b/blockdev.c index 6e86c6262f..21554500dc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -203,7 +203,7 @@ QemuOpts *drive_add(BlockInterfaceType type, int index,= const char *file, =20 GLOBAL_STATE_CODE(); =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, fals= e); + opts =3D qemu_opts_parse_noisily("drive", optstr, false); if (!opts) { return NULL; } diff --git a/chardev/char-hmp-cmds.c b/chardev/char-hmp-cmds.c index fb0560054b..938dbd3ba2 100644 --- a/chardev/char-hmp-cmds.c +++ b/chardev/char-hmp-cmds.c @@ -83,7 +83,7 @@ void hmp_chardev_add(MonitorHMP *hmp, const QDict *qdict) Error *err =3D NULL; QemuOpts *opts; =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true= ); + opts =3D qemu_opts_parse_noisily("chardev", args, true); if (opts =3D=3D NULL) { error_setg(&err, "Parsing chardev args failed"); } else { @@ -100,8 +100,7 @@ void hmp_chardev_change(MonitorHMP *hmp, const QDict *q= dict) Error *err =3D NULL; ChardevBackend *backend =3D NULL; ChardevReturn *ret =3D NULL; - QemuOpts *opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), = args, - true); + QemuOpts *opts =3D qemu_opts_parse_noisily("chardev", args, true); if (!opts) { error_setg(&err, "Parsing chardev args failed"); goto end; diff --git a/include/qemu/option.h b/include/qemu/option.h index df68da9aa8..2955ed3b2d 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -128,7 +128,7 @@ void qemu_opts_del(QemuOpts *opts); bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **e= rrp); bool qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, Error **errp); -QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, +QemuOpts *qemu_opts_parse_noisily(const char *group, const char *params, bool permit_abbrev); QemuOpts *qemu_opts_parse(const char *group, const char *params, bool permit_abbrev, Error **errp); diff --git a/plugins/loader.c b/plugins/loader.c index b10ebe8cc0..1808679c82 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -147,7 +147,7 @@ void qemu_plugin_opt_parse(const char *optstr, QemuPlug= inList *head) struct qemu_plugin_parse_arg arg; QemuOpts *opts; =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("plugin"), optstr, tru= e); + opts =3D qemu_opts_parse_noisily("plugin", optstr, true); if (opts =3D=3D NULL) { exit(1); } diff --git a/qemu-img.c b/qemu-img.c index c645de6462..5e58ccc587 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -358,8 +358,7 @@ static BlockBackend *img_open(bool image_opts, error_report("--image-opts and --format are mutually exclusive= "); return NULL; } - opts =3D qemu_opts_parse_noisily(qemu_find_opts("source"), - filename, true); + opts =3D qemu_opts_parse_noisily("source", filename, true); if (!opts) { return NULL; } diff --git a/semihosting/config.c b/semihosting/config.c index 56283b5c3c..c8c865ebae 100644 --- a/semihosting/config.c +++ b/semihosting/config.c @@ -134,8 +134,8 @@ void qemu_semihosting_enable(void) =20 int qemu_semihosting_config_options(const char *optstr) { - QemuOptsList *opt_list =3D qemu_find_opts("semihosting-config"); - QemuOpts *opts =3D qemu_opts_parse_noisily(opt_list, optstr, false); + QemuOpts *opts =3D qemu_opts_parse_noisily("semihosting-config", optst= r, + false); =20 semihosting.enabled =3D true; =20 diff --git a/system/vl.c b/system/vl.c index bf5146d1c0..4a3fa80c5c 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1871,8 +1871,7 @@ static void object_option_parse(const char *str) v =3D qobject_input_visitor_new(obj); qobject_unref(obj); } else { - opts =3D qemu_opts_parse_noisily(qemu_find_opts("object"), - str, true); + opts =3D qemu_opts_parse_noisily("object", str, true); if (!opts) { exit(1); } @@ -1898,8 +1897,7 @@ static void overcommit_parse(const char *str) QemuOpts *opts; const char *mem_lock_opt; =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("overcommit"), - str, false); + opts =3D qemu_opts_parse_noisily("overcommit", str, false); if (!opts) { exit(1); } @@ -2490,7 +2488,7 @@ static void configure_accelerators(const char *progna= me) * such as "-machine accel=3Dtcg,,thread=3Dsingle". */ if (accel_find(*tmp)) { - qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp, tru= e); + qemu_opts_parse_noisily("accel", *tmp, true); } else { init_failed =3D true; error_report("invalid accelerator %s", *tmp); @@ -2990,8 +2988,7 @@ void qemu_init(int argc, char **argv) break; } case QEMU_OPTION_drive: - if (!qemu_opts_parse_noisily(qemu_find_opts("drive"), - optarg, false)) { + if (!qemu_opts_parse_noisily("drive", optarg, false)) { exit(1); } break; @@ -3016,8 +3013,7 @@ void qemu_init(int argc, char **argv) replay_add_blocker("-snapshot"); break; case QEMU_OPTION_numa: - if (!qemu_opts_parse_noisily(qemu_find_opts("numa"), - optarg, true)) { + if (!qemu_opts_parse_noisily("numa", optarg, true)) { exit(1); } break; @@ -3076,8 +3072,7 @@ void qemu_init(int argc, char **argv) break; #ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: - if (!qemu_opts_parse_noisily(qemu_find_opts("iscsi"), - optarg, false)) { + if (!qemu_opts_parse_noisily("iscsi", optarg, false)) { exit(1); } break; @@ -3130,8 +3125,7 @@ void qemu_init(int argc, char **argv) exit(0); break; case QEMU_OPTION_m: - if (!qemu_opts_parse_noisily(qemu_find_opts("memory"), - optarg, true)) { + if (!qemu_opts_parse_noisily("memory", optarg, true)) { exit(1); } break; @@ -3259,15 +3253,13 @@ void qemu_init(int argc, char **argv) "See '-object' docs in the QEMU manual for further " "configuration guidance: " "https://www.qemu.org/docs/master/system/invocation.ht= ml"); - if (!qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg, - true)) { + if (!qemu_opts_parse_noisily("mon", optarg, true)) { exit(1); } default_monitor =3D 0; break; case QEMU_OPTION_chardev: - if (!qemu_opts_parse_noisily(qemu_find_opts("chardev"), - optarg, true)) { + if (!qemu_opts_parse_noisily("chardev", optarg, true)) { exit(1); } break; @@ -3371,9 +3363,8 @@ void qemu_init(int argc, char **argv) } break; case QEMU_OPTION_action: - olist =3D qemu_find_opts("action"); - if (!qemu_opts_parse_noisily(olist, optarg, false)) { - exit(1); + if (!qemu_opts_parse_noisily("action", optarg, false)) { + exit(1); } break; case QEMU_OPTION_watchdog_action: { @@ -3405,24 +3396,21 @@ void qemu_init(int argc, char **argv) object_register_sugar_prop("ide-device", "win2k-install-ha= ck", "true", true); break; case QEMU_OPTION_acpitable: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("acpi"), - optarg, true); + opts =3D qemu_opts_parse_noisily("acpi", optarg, true); if (!opts) { exit(1); } acpi_table_add(opts, &error_fatal); break; case QEMU_OPTION_smbios: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("smbios"), - optarg, false); + opts =3D qemu_opts_parse_noisily("smbios", optarg, false); if (!opts) { exit(1); } smbios_entry_add(opts, &error_fatal); break; case QEMU_OPTION_fwcfg: - if (!qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"), - optarg, true)) { + if (!qemu_opts_parse_noisily("fw_cfg", optarg, true)) { exit(1); } break; @@ -3445,8 +3433,7 @@ void qemu_init(int argc, char **argv) break; } case QEMU_OPTION_accel: - accel_opts =3D qemu_opts_parse_noisily(qemu_find_opts("acc= el"), - optarg, true); + accel_opts =3D qemu_opts_parse_noisily("accel", optarg, tr= ue); optarg =3D qemu_opt_get(accel_opts, "accel"); if (!optarg || is_help_option(optarg)) { printf("Accelerators supported in QEMU binary:\n"); @@ -3488,8 +3475,7 @@ void qemu_init(int argc, char **argv) assert(opt->opts !=3D NULL); QTAILQ_INSERT_TAIL(&device_opts, opt, next); } else { - if (!qemu_opts_parse_noisily(qemu_find_opts("device"), - optarg, true)) { + if (!qemu_opts_parse_noisily("device", optarg, true)) { exit(1); } } @@ -3505,12 +3491,10 @@ void qemu_init(int argc, char **argv) break; #endif case QEMU_OPTION_no_reboot: - olist =3D qemu_find_opts("action"); - qemu_opts_parse_noisily(olist, "reboot=3Dshutdown", false); + qemu_opts_parse_noisily("action", "reboot=3Dshutdown", fal= se); break; case QEMU_OPTION_no_shutdown: - olist =3D qemu_find_opts("action"); - qemu_opts_parse_noisily(olist, "shutdown=3Dpause", false); + qemu_opts_parse_noisily("action", "shutdown=3Dpause", fals= e); break; case QEMU_OPTION_uuid: if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) { @@ -3524,8 +3508,7 @@ void qemu_init(int argc, char **argv) error_report("too many option ROMs"); exit(1); } - opts =3D qemu_opts_parse_noisily(qemu_find_opts("option-ro= m"), - optarg, true); + opts =3D qemu_opts_parse_noisily("option-rom", optarg, tru= e); if (!opts) { exit(1); } @@ -3547,8 +3530,7 @@ void qemu_init(int argc, char **argv) } break; case QEMU_OPTION_name: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("name"), - optarg, true); + opts =3D qemu_opts_parse_noisily("name", optarg, true); if (!opts) { exit(1); } @@ -3564,15 +3546,13 @@ void qemu_init(int argc, char **argv) nb_prom_envs++; break; case QEMU_OPTION_rtc: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("rtc"), op= targ, - false); + opts =3D qemu_opts_parse_noisily("rtc", optarg, false); if (!opts) { exit(1); } break; case QEMU_OPTION_icount: - icount_opts =3D qemu_opts_parse_noisily(qemu_find_opts("ic= ount"), - optarg, true); + icount_opts =3D qemu_opts_parse_noisily("icount", optarg, = true); if (!icount_opts) { exit(1); } @@ -3621,7 +3601,7 @@ void qemu_init(int argc, char **argv) break; #ifdef CONFIG_SPICE case QEMU_OPTION_spice: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("spice"), = optarg, false); + opts =3D qemu_opts_parse_noisily("spice", optarg, false); if (!opts) { exit(1); } @@ -3651,8 +3631,7 @@ void qemu_init(int argc, char **argv) break; case QEMU_OPTION_add_fd: #ifndef _WIN32 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("add-fd"), - optarg, false); + opts =3D qemu_opts_parse_noisily("add-fd", optarg, false); if (!opts) { exit(1); } @@ -3684,8 +3663,7 @@ void qemu_init(int argc, char **argv) break; } case QEMU_OPTION_msg: - opts =3D qemu_opts_parse_noisily(qemu_find_opts("msg"), op= targ, - false); + opts =3D qemu_opts_parse_noisily("msg", optarg, false); if (!opts) { exit(1); } @@ -3715,8 +3693,7 @@ void qemu_init(int argc, char **argv) break; case QEMU_OPTION_run_with: { const char *str; - opts =3D qemu_opts_parse_noisily(qemu_find_opts("run-with"= ), - optarg, false); + opts =3D qemu_opts_parse_noisily("run-with", optarg, false= ); if (!opts) { exit(1); } diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index b88b557133..bbcdf9a9ce 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -1210,8 +1210,7 @@ static void char_socket_server_test(gconstpointer opa= que) config->fd_pass, NULL, true); - opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), - optstr, true); + opts =3D qemu_opts_parse_noisily("chardev", optstr, true); g_assert_nonnull(opts); chr =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); qemu_opts_del(opts); @@ -1352,8 +1351,7 @@ static void char_socket_client_dupid_test(gconstpoint= er opaque) config->reconnect, false); =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), - optstr, true); + opts =3D qemu_opts_parse_noisily("chardev", optstr, true); g_assert_nonnull(opts); chr1 =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); g_assert_nonnull(chr1); @@ -1412,8 +1410,7 @@ static void char_socket_client_test(gconstpointer opa= que) config->reconnect, false); =20 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), - optstr, true); + opts =3D qemu_opts_parse_noisily("chardev", optstr, true); g_assert_nonnull(opts); chr =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); qemu_opts_del(opts); @@ -1544,8 +1541,7 @@ static void char_socket_server_two_clients_test(gcons= tpointer opaque) false, NULL, true); - opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), - optstr, true); + opts =3D qemu_opts_parse_noisily("chardev", optstr, true); g_assert_nonnull(opts); chr =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); qemu_opts_del(opts); diff --git a/tests/unit/test-seccomp.c b/tests/unit/test-seccomp.c index 71d4083439..4438012989 100644 --- a/tests/unit/test-seccomp.c +++ b/tests/unit/test-seccomp.c @@ -31,15 +31,11 @@ static void test_seccomp_helper(const char *args, bool = killed, int errnum, int (*doit)(void)) { if (g_test_subprocess()) { - QemuOptsList *olist; QemuOpts *opts; int ret; =20 module_call_init(MODULE_INIT_OPTS); - olist =3D qemu_find_opts("sandbox"); - g_assert(olist !=3D NULL); - - opts =3D qemu_opts_parse_noisily(olist, args, true); + opts =3D qemu_opts_parse_noisily("sandbox", args, true); g_assert(opts !=3D NULL); =20 parse_sandbox(NULL, opts, &error_abort); diff --git a/trace/control.c b/trace/control.c index 49f0a4c5cd..51cecf5827 100644 --- a/trace/control.c +++ b/trace/control.c @@ -288,8 +288,7 @@ bool trace_init_backends(void) =20 void trace_opt_parse(const char *optstr) { - QemuOpts *opts =3D qemu_opts_parse_noisily(qemu_find_opts("trace"), - optstr, true); + QemuOpts *opts =3D qemu_opts_parse_noisily("trace", optstr, true); if (!opts) { exit(1); } diff --git a/ui/vnc.c b/ui/vnc.c index 656768f9c9..7ddf660856 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -4324,8 +4324,7 @@ static char *vnc_auto_assign_id(QemuOpts *opts) =20 void vnc_parse(const char *str) { - QemuOptsList *olist =3D qemu_find_opts("vnc"); - QemuOpts *opts =3D qemu_opts_parse_noisily(olist, str, !is_help_option= (str)); + QemuOpts *opts =3D qemu_opts_parse_noisily("vnc", str, !is_help_option= (str)); =20 if (!opts) { exit(1); diff --git a/util/qemu-option.c b/util/qemu-option.c index be9404ab7f..7c42b4feda 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -956,16 +956,24 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, co= nst char *params, } =20 /** - * Create a QemuOpts in @list and with options parsed from @params. + * Find the @group and create a QemuOpts with options parsed from @params. * If @permit_abbrev, the first key=3Dvalue in @params may omit key=3D, * and is treated as if key was @list->implied_opt_name. * Report errors with error_report_err(). This is inappropriate in * QMP context. Do not use this function there! * Return the new QemuOpts on success, null pointer on error. */ -QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, +QemuOpts *qemu_opts_parse_noisily(const char *group, const char *params, bool permit_abbrev) { + Error *err =3D NULL; + QemuOptsList *list =3D qemu_find_opts_err(group, &err); + + if (!list) { + error_report_err(err); + return NULL; + } + return qemu_opts_parse_list_noisily(list, params, permit_abbrev); } =20 --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806376; cv=none; d=zohomail.com; s=zohoarc; b=DsRiWw4zwN5Q61NyBOW5cAg12560XQ/aE7XCo+4VqbKa/zkS1uvvEnlNqDUqMwLzhFeg72oOhsmmCdE8hXiCMAIgqTkuCzZtzI9B4Pp/kF96wdjh2Dj4feaTLEMIRr+kgbaAxwosefb0ngNxAeFa0oSo3hgmVFHnPqXA3523Cw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806376; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xuiDDpmDXh47Fgd0I8y4cMCiRv6z5d2fdlK71G2PVZ4=; b=X1Dcy4EHa9MfsyEsBKl9t8u/rh2VFS0wRrKj3wRXUeLDAD9gshkyo607qcyUthE9NMf+VEdaZwb5GTJxEx/yTc5B6fEDjUCJer2vsEzupvOaHWiBWkBI+NLwKXq3lRwVzS9nPsKs1y7ZDGH+OKFZarUpcWG/WFkfUiUQHf+yD0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790806376392765.3013715511593; Wed, 30 Sep 2026 15:12:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2XA-00081F-QS; Wed, 30 Sep 2026 18:12:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wo-0007wv-Td for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:56 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wl-00053B-Os for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:53 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5ECC11FB97; Wed, 30 Sep 2026 22:11:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4706613B24; Wed, 30 Sep 2026 22:11:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T11 (envelope-from ); Wed, 30 Sep 2026 22:11:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806306; h=from:from:reply-to: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=xuiDDpmDXh47Fgd0I8y4cMCiRv6z5d2fdlK71G2PVZ4=; b=hYSpsZ9hltwKDE7//GyTtqHwLI/DsL49I67TiCjZVIE8aoEJ3zC/uX7Vjt0gdwwWyWJgP2 cr7hNJkWRmvA69XfAr7xYwA7gMkXbJPbAPIvY8sEL8H/Be5dUw2KYW0H7nDxLYlgXL52Ik OK2hlo6cRHbvrZiwPV77wrQDTa4DUjc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806306; h=from:from:reply-to: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=xuiDDpmDXh47Fgd0I8y4cMCiRv6z5d2fdlK71G2PVZ4=; b=gcvzVIb3BbJtKMYKEj6ZncBVa2tTm6rde0fqt6igylvjCyLyTuKNZez0XFmyLzZi7qr6bD wp1gEDbjibRB7FBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xcvqF3qb; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0Gy2chQP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806302; h=from:from:reply-to: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=xuiDDpmDXh47Fgd0I8y4cMCiRv6z5d2fdlK71G2PVZ4=; b=xcvqF3qbbBymw1kbk2HpYKfQ4T1JST9QPzpeTjb855/zA1O6FSiYDzzKacdEuxStIs4R/2 Hq9UX+eyNNfKRVz02rwpcB0wPuHjUgxSPiCvrLR7oKlNsW2fD6QH4e2YXr/Et7vs8SahNF lnXVkL7mjpxX6zMUYskLgzMhLte4kCk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806302; h=from:from:reply-to: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=xuiDDpmDXh47Fgd0I8y4cMCiRv6z5d2fdlK71G2PVZ4=; b=0Gy2chQPAod1GExwgUgoyLHUZ0o92McRmeNvAjD4AXLCYJKfB+qBhFtIPJF9ZexLDxvCMZ 3gywUPZ7AZc0LaAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 10/11] qemu-option: Check for NULL list at qemu_opts_parse() Date: Wed, 30 Sep 2026 19:11:04 -0300 Message-ID: <20260930221105.2262063-11-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 5ECC11FB97 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.51 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806377288158500 Now that qemu_opts_parse_noisily() is protected against NULL list, do the same for the non noisy version. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- util/qemu-option.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/qemu-option.c b/util/qemu-option.c index 7c42b4feda..83fa2399d3 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -939,6 +939,10 @@ QemuOpts *qemu_opts_parse(const char *group, const cha= r *params, { QemuOptsList *list =3D qemu_find_opts_err(group, errp); =20 + if (!list) { + return NULL; + } + return qemu_opts_parse_list(list, params, permit_abbrev, errp); } =20 --=20 2.53.0 From nobody Sat Oct 24 00:32:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1790806370; cv=none; d=zohomail.com; s=zohoarc; b=MpPL8LsphdFHILEb9iLfCjJV7ONxOy0gztG/nz9GNbHoB9Es8vsVeoi+KbNcDml/bXlImc7DpcNNDI1JPn3CJu7TILbl3T8yuzS6lBVNh5KhwI/DIS8/LudATJWwsiEnEWGG/wxOw738odZEDmxDoslawWkIjGZU6Xe+D6zILOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790806370; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SOnJeels2bSuMuCJo2UZOcjws9Swp1uxf8tu/IZHLBk=; b=DYG9IFbsAftHXM6ynpQV1A3TL1i0ZAY8HJp5/7fRS/1+qMGFxIVIgmGiMNAza/qpyF+xOOQRsAgEwgWPMymOOIsSuUg/Uz/9HUYLwQoikJy+sNvXB0XWrXe4LNGFP/jBtQVswbOAeMC82R4KBNhUyEj8fVQOrJ0ES8Zo5bT/4+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17908063702656.65879590937061; Wed, 30 Sep 2026 15:12:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xC2X8-00080f-4V; Wed, 30 Sep 2026 18:12:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xC2Wr-0007xT-Bb for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:58 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xC2Wp-00053M-0r for qemu-devel@nongnu.org; Wed, 30 Sep 2026 18:11:57 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9A8F41FB9A; Wed, 30 Sep 2026 22:11:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B514913B25; Wed, 30 Sep 2026 22:11:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id befqOAqJvWpwXAAAD6G6ig:T12 (envelope-from ); Wed, 30 Sep 2026 22:11:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SOnJeels2bSuMuCJo2UZOcjws9Swp1uxf8tu/IZHLBk=; b=S269t8tk/9rHpFgsx+KsIYc9DGAnYcaZz2nTVbfLGYXOj+xaB3IKarIwOhG+XXC18JansN utE5kCxuvi5AZEVbDnu02Vd1a4HTGqaT1RII81BsqR+GyO9gySdP0L//BsmLlGKQIYnk5M E4jHa1pnt6R8mfmZ6aXkNtzAsuons0Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806309; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SOnJeels2bSuMuCJo2UZOcjws9Swp1uxf8tu/IZHLBk=; b=ECLvAHSTrR+w1oTnAokko5hQ3ddoAyvsWvWfZhams2+kZziIyLWLWhSv8bLXoZFiVv4ogy SG0vdLioew5inBCQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=lxm3EXHc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=OrcW5oyK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790806305; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SOnJeels2bSuMuCJo2UZOcjws9Swp1uxf8tu/IZHLBk=; b=lxm3EXHcRhfRH4CNFEkjJhky0kTm7kDLBedm+nYgsuhvudNnk2T1il7dRt/VNySbNspTHD 62NlDkIjGAgKpKCklGmM8yscUbWVTV4AoKVkIPTgk7qErC8qkjfK809HOghuozOLkJT9Uw PK7h7yo/D4U50lA7drTNiv6VuWg9+xE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790806305; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SOnJeels2bSuMuCJo2UZOcjws9Swp1uxf8tu/IZHLBk=; b=OrcW5oyKaJFZvvjyJDcMu3nyVbqqvz3jVBnt6GSUJ3yomhlwK0TArbRR/4LPBNYPBVH9fe G4sRfV/UD7L0s6Ag== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Kevin Wolf , Hanna Reitz , Stefan Berger , "Dr. David Alan Gilbert" , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Alexandre Iooss , Paolo Bonzini , Lukas Straub Subject: [PATCH v2 11/11] qemu-option: Remove a few instances of noisily parsing Date: Wed, 30 Sep 2026 19:11:05 -0300 Message-ID: <20260930221105.2262063-12-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260930221105.2262063-1-farosas@suse.de> References: <20260930221105.2262063-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,linux.vnet.ibm.com,treblig.org,gmail.com,linaro.org,oss.qualcomm.com,crans.org,web.de]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com,web.de]; RCPT_COUNT_TWELVE(0.00)[13]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 9A8F41FB9A X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1790806371324158500 Content-Type: text/plain; charset="utf-8" With the removal of the support for short-form flags, the only other source of "noise" in the qemu_parse_*noisily() functions aside from errors is the printing of the help text. Therefore, the only difference from the _noisily versions to the normal ones is this block: if (qemu_opt_has_help_opt(opts) && !opts_accepts_any(list)) { qemu_opts_print_help(list, true); return NULL; } Stop calling qemu_parse_*noisily() in any case where it's certain that opts_accepts_any(list) returns true, i.e. when list->desc is empty. This creates some instances of the pattern: error_report -> exit(1). Use &error_fatal instead. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- block/monitor/block-hmp-cmds.c | 4 ++-- include/system/tpm.h | 3 ++- monitor/hmp.c | 4 +++- net/net.c | 4 +--- plugins/loader.c | 5 +--- qemu-img.c | 5 +++- qemu-io-cmds.c | 2 +- qemu-io.c | 7 ++---- system/tpm.c | 8 +++---- system/vl.c | 42 +++++++++++++++------------------- tests/unit/test-replication.c | 17 +++++++++++--- util/qemu-option.c | 3 +++ 12 files changed, 55 insertions(+), 49 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index d94a07314f..93b622227c 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -63,9 +63,9 @@ static void hmp_drive_add_node(MonitorHMP *hmp, const cha= r *optstr) QDict *qdict; Error *err =3D NULL; =20 - opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, optstr, false); + opts =3D qemu_opts_parse_list(&qemu_drive_opts, optstr, false, &err); if (!opts) { - return; + goto out; } =20 qdict =3D qemu_opts_to_qdict(opts, NULL); diff --git a/include/system/tpm.h b/include/system/tpm.h index 874068d19a..4132a3a641 100644 --- a/include/system/tpm.h +++ b/include/system/tpm.h @@ -17,7 +17,8 @@ =20 #ifdef CONFIG_TPM =20 -int tpm_config_parse(QemuOptsList *opts_list, const char *optstr); +bool tpm_config_parse(QemuOptsList *opts_list, const char *optstr, + Error **errp); int tpm_init(void); void tpm_cleanup(void); =20 diff --git a/monitor/hmp.c b/monitor/hmp.c index fc32cfd1ff..6a6be8f12f 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -883,6 +883,7 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon, { QemuOptsList *opts_list; QemuOpts *opts; + Error *err =3D NULL; =20 opts_list =3D qemu_find_opts(key); if (!opts_list || opts_list->desc->name) { @@ -897,8 +898,9 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon, if (get_str(buf, sizeof(buf), &p) < 0) { goto fail; } - opts =3D qemu_opts_parse_list_noisily(opts_list, buf, true= ); + opts =3D qemu_opts_parse_list(opts_list, buf, true, &err); if (!opts) { + error_report_err(err); goto fail; } qemu_opts_to_qdict(opts, qdict); diff --git a/net/net.c b/net/net.c index 37401ab2b4..09ed34557d 100644 --- a/net/net.c +++ b/net/net.c @@ -2029,9 +2029,7 @@ void netdev_parse_modern(const char *optstr) =20 void net_client_parse(QemuOptsList *opts_list, const char *optstr) { - if (!qemu_opts_parse_list_noisily(opts_list, optstr, true)) { - exit(1); - } + qemu_opts_parse_list(opts_list, optstr, true, &error_fatal); } =20 /* From FreeBSD */ diff --git a/plugins/loader.c b/plugins/loader.c index 1808679c82..db6ae6d1f4 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -147,10 +147,7 @@ void qemu_plugin_opt_parse(const char *optstr, QemuPlu= ginList *head) struct qemu_plugin_parse_arg arg; QemuOpts *opts; =20 - opts =3D qemu_opts_parse_noisily("plugin", optstr, true); - if (opts =3D=3D NULL) { - exit(1); - } + opts =3D qemu_opts_parse("plugin", optstr, true, &error_fatal); arg.head =3D head; arg.curr =3D NULL; qemu_opt_foreach(opts, plugin_add, &arg, &error_fatal); diff --git a/qemu-img.c b/qemu-img.c index 5e58ccc587..18501f7fb9 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -354,12 +354,15 @@ static BlockBackend *img_open(bool image_opts, BlockBackend *blk; if (image_opts) { QemuOpts *opts; + Error *err =3D NULL; + if (fmt) { error_report("--image-opts and --format are mutually exclusive= "); return NULL; } - opts =3D qemu_opts_parse_noisily("source", filename, true); + opts =3D qemu_opts_parse("source", filename, true, &err); if (!opts) { + error_report_err(err); return NULL; } blk =3D img_open_opts(filename, opts, flags, writethrough, quiet, diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 6c8c4c9540..fa52fbb900 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2540,7 +2540,7 @@ static int reopen_f(BlockBackend *blk, int argc, char= **argv, Error **errp) has_cache_option =3D true; break; case 'o': - if (!qemu_opts_parse_list_noisily(&reopen_opts, optarg, 0)) { + if (!qemu_opts_parse_list(&reopen_opts, optarg, 0, errp)) { qemu_opts_reset(&reopen_opts); return -EINVAL; } diff --git a/qemu-io.c b/qemu-io.c index db0ee499e4..837e5048ba 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -659,11 +659,8 @@ int main(int argc, char **argv) if ((argc - optind) =3D=3D 1) { if (imageOpts) { QemuOpts *qopts =3D NULL; - qopts =3D qemu_opts_parse_list_noisily(&file_opts, argv[optind= ], - false); - if (!qopts) { - exit(1); - } + qopts =3D qemu_opts_parse_list(&file_opts, argv[optind], false, + &error_fatal); opts =3D qemu_opts_to_qdict(qopts, NULL); if (openfile(NULL, flags, writethrough, force_share, opts)) { exit(1); diff --git a/system/tpm.c b/system/tpm.c index f0f5a64d9a..31aeaa5cc6 100644 --- a/system/tpm.c +++ b/system/tpm.c @@ -176,7 +176,7 @@ int tpm_init(void) * Parse the TPM configuration options. * To display all available TPM backends the user may use '-tpmdev help' */ -int tpm_config_parse(QemuOptsList *opts_list, const char *optstr) +bool tpm_config_parse(QemuOptsList *opts_list, const char *optstr, Error *= *errp) { QemuOpts *opts; =20 @@ -184,11 +184,11 @@ int tpm_config_parse(QemuOptsList *opts_list, const c= har *optstr) tpm_display_backend_drivers(); exit(EXIT_SUCCESS); } - opts =3D qemu_opts_parse_list_noisily(opts_list, optstr, true); + opts =3D qemu_opts_parse_list(opts_list, optstr, true, errp); if (!opts) { - return -1; + return false; } - return 0; + return true; } =20 /* diff --git a/system/vl.c b/system/vl.c index 4a3fa80c5c..8382bb902b 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1871,11 +1871,7 @@ static void object_option_parse(const char *str) v =3D qobject_input_visitor_new(obj); qobject_unref(obj); } else { - opts =3D qemu_opts_parse_noisily("object", str, true); - if (!opts) { - exit(1); - } - + opts =3D qemu_opts_parse("object", str, true, &error_fatal); type =3D qemu_opt_get(opts, "qom-type"); if (!type) { error_report(QERR_MISSING_PARAMETER, "qom-type"); @@ -2483,12 +2479,15 @@ static void configure_accelerators(const char *prog= name) accel_list =3D g_strsplit(accelerators, ":", 0); =20 for (tmp =3D accel_list; *tmp; tmp++) { + Error *err =3D NULL; /* * Filter invalid accelerators here, to prevent obscenities * such as "-machine accel=3Dtcg,,thread=3Dsingle". */ if (accel_find(*tmp)) { - qemu_opts_parse_noisily("accel", *tmp, true); + if (!qemu_opts_parse("accel", *tmp, true, &err)) { + error_report_err(err); + } } else { init_failed =3D true; error_report("invalid accelerator %s", *tmp); @@ -3013,9 +3012,7 @@ void qemu_init(int argc, char **argv) replay_add_blocker("-snapshot"); break; case QEMU_OPTION_numa: - if (!qemu_opts_parse_noisily("numa", optarg, true)) { - exit(1); - } + qemu_opts_parse("numa", optarg, true, &error_fatal); break; case QEMU_OPTION_display: parse_display(optarg); @@ -3131,9 +3128,7 @@ void qemu_init(int argc, char **argv) break; #ifdef CONFIG_TPM case QEMU_OPTION_tpmdev: - if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0= ) { - exit(1); - } + tpm_config_parse(qemu_find_opts("tpmdev"), optarg, &error_= fatal); break; #endif case QEMU_OPTION_mempath: @@ -3396,17 +3391,11 @@ void qemu_init(int argc, char **argv) object_register_sugar_prop("ide-device", "win2k-install-ha= ck", "true", true); break; case QEMU_OPTION_acpitable: - opts =3D qemu_opts_parse_noisily("acpi", optarg, true); - if (!opts) { - exit(1); - } + opts =3D qemu_opts_parse("acpi", optarg, true, &error_fata= l); acpi_table_add(opts, &error_fatal); break; case QEMU_OPTION_smbios: - opts =3D qemu_opts_parse_noisily("smbios", optarg, false); - if (!opts) { - exit(1); - } + opts =3D qemu_opts_parse("smbios", optarg, false, &error_f= atal); smbios_entry_add(opts, &error_fatal); break; case QEMU_OPTION_fwcfg: @@ -3433,7 +3422,13 @@ void qemu_init(int argc, char **argv) break; } case QEMU_OPTION_accel: - accel_opts =3D qemu_opts_parse_noisily("accel", optarg, tr= ue); + { + Error *err =3D NULL; + + accel_opts =3D qemu_opts_parse("accel", optarg, true, &err= ); + if (!accel_opts) { + error_report_err(err); + } optarg =3D qemu_opt_get(accel_opts, "accel"); if (!optarg || is_help_option(optarg)) { printf("Accelerators supported in QEMU binary:\n"); @@ -3459,6 +3454,7 @@ void qemu_init(int argc, char **argv) exit(0); } break; + } case QEMU_OPTION_usb: qdict_put_str(machine_opts_dict, "usb", "on"); break; @@ -3475,9 +3471,7 @@ void qemu_init(int argc, char **argv) assert(opt->opts !=3D NULL); QTAILQ_INSERT_TAIL(&device_opts, opt, next); } else { - if (!qemu_opts_parse_noisily("device", optarg, true)) { - exit(1); - } + qemu_opts_parse("device", optarg, true, &error_fatal); } break; case QEMU_OPTION_smp: diff --git a/tests/unit/test-replication.c b/tests/unit/test-replication.c index 101f72acdc..dbed415f87 100644 --- a/tests/unit/test-replication.c +++ b/tests/unit/test-replication.c @@ -174,12 +174,16 @@ static BlockBackend *start_primary(void) QemuOpts *opts; QDict *qdict; char *cmdline; + Error *err =3D NULL; =20 cmdline =3D g_strdup_printf("driver=3Dreplication,mode=3Dprimary,node-= name=3Dxxx," "file.driver=3Dqcow2,file.file.filename=3D%s= ," "file.file.locking=3Doff" , p_local_disk); - opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); + opts =3D qemu_opts_parse_list(&qemu_drive_opts, cmdline, false, &err); + if (!opts) { + error_report_err(err); + } g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); @@ -290,12 +294,16 @@ static BlockBackend *start_secondary(void) QDict *qdict; BlockBackend *blk; char *cmdline; + Error *err =3D NULL; =20 /* add s_local_disk and forge S_LOCAL_DISK_ID */ cmdline =3D g_strdup_printf("file.filename=3D%s,driver=3Dqcow2," "file.locking=3Doff", s_local_disk); - opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); + opts =3D qemu_opts_parse_list(&qemu_drive_opts, cmdline, false, &err); + if (!opts) { + error_report_err(err); + } g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); @@ -321,7 +329,10 @@ static BlockBackend *start_secondary(void) "file.backing.backing=3D%s" , S_ID, s_active_disk, s_hidden_disk , S_LOCAL_DISK_ID); - opts =3D qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false= ); + opts =3D qemu_opts_parse_list(&qemu_drive_opts, cmdline, false, &err); + if (!opts) { + error_report_err(err); + } g_free(cmdline); =20 qdict =3D qemu_opts_to_qdict(opts, NULL); diff --git a/util/qemu-option.c b/util/qemu-option.c index 83fa2399d3..833c69f6a5 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -995,6 +995,9 @@ QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *li= st, const char *params, Error *err =3D NULL; QemuOpts *opts; =20 + assert(g_str_equal("drive", list->name) || + !opts_accepts_any(list)); + opts =3D opts_parse(list, params, permit_abbrev, &err); if (!opts) { error_report_err(err); --=20 2.53.0