From nobody Sat Sep 26 20:01:43 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=1789770636; cv=none; d=zohomail.com; s=zohoarc; b=dJX3Ia/hE54fhvQqTxkoiIauy4q2j9meI3gpEO1h3R9q9BbgN/Z8AuDvr3IA/0rb+D+0MN7x0KtuQ791QqLxVn1Rkp6K9BGPy2tvshqw7Obmg/du56J7mqEqQmfTMFF+U39HwuQ4ARNk/5vcdnhTQ2kJ0nupdks6vTnLg2EngYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770636; 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=iIia9LF/FU6W/WcOdcz2d8EjzufmNNdj0WLEnEAJ3Tc=; b=gvKeRyTSa9ATCWRx8cXrunjD/9m2SDgTUYYigwRs/pFIE+x3TaUIcWfGebMPyFis9OGXzKHmjg4z00l59+unfhBvLicCFKBD62WKmWZ6vjQGiuEEsnRIrQYQ19TBCejr1AM0JBwOCCb9qrtlDvRbOMzlgM+OfyTSgH7Em4gAJ08= 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 1789770636719234.40806090099238; Fri, 18 Sep 2026 15:30:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h66-0007oM-B9; Fri, 18 Sep 2026 18:30:22 -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 1x7h64-0007o4-Tj for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:21 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x7h62-0000Xq-U6 for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:20 -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-out1.suse.de (Postfix) with ESMTPS id B067121EE0; Fri, 18 Sep 2026 22:30:08 +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 969D513927; Fri, 18 Sep 2026 22:30:06 +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 hQIbBW27rWrsdQAAD6G6ig:T2 (envelope-from ); Fri, 18 Sep 2026 22:30:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770612; 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=iIia9LF/FU6W/WcOdcz2d8EjzufmNNdj0WLEnEAJ3Tc=; b=nvhbntEye2eu6PYV81Q8T5ahb01/AjLuLBl5Ps+qyv8UTvMRUIcZiFfOop42etp/KwtQRr h3e32fHcLqx6OHRC7ix77RKSgkFmNKu6df82UmT3skJ9UpOiBqMIpQlqaOfDLujnQ1RtRU OaUq3AMu1leM6yghzzdvjDpDnUgcTqQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770612; 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=iIia9LF/FU6W/WcOdcz2d8EjzufmNNdj0WLEnEAJ3Tc=; b=t1jkIag+iXw7Zq0FqBtp5Ikcg6saGVg3sOif3KWh57o7hZQDGauCulZJe7QfYqRZPAgvtF c+jqRIHm/Qk75gBg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=XQLaGBSb; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=w+v6I+ye DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770608; 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=iIia9LF/FU6W/WcOdcz2d8EjzufmNNdj0WLEnEAJ3Tc=; b=XQLaGBSbIZCigj35i3yD+Mp0HqMwFPJ5Hu63gKQhjc/pxY9Q3ZwKGyLefvC5z+kuGTkIQI xfHEFRVhWsKweIwoAZrKm4oT+SwleQw1p9jN7npPRRLo1D0auGsex6qt4mar/ZIyjViV9N tga0xW5dKcX3EzoWzcHgw4HpD+5sbho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770608; 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=iIia9LF/FU6W/WcOdcz2d8EjzufmNNdj0WLEnEAJ3Tc=; b=w+v6I+yeaS2OuBUsEVNUZrsDlaugcXJiPpnYon5sxMI3W5Jf0Vr2LEord26OQ6HTFfruQY VI8sPpG3n5wa3VBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , John Snow , Cleber Rosa , Kevin Wolf , Hanna Reitz Subject: [RFC PATCH 01/14] meson: Fix meson suites invocation from make check Date: Fri, 18 Sep 2026 19:29:48 -0300 Message-ID: <20260918223002.1892021-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: B067121EE0 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RCPT_COUNT_SEVEN(0.00)[8]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,mtest2make.py:url,meson.build:url,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; 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:1; envelope-from=farosas@suse.de; helo=smtp-out1.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: 1789770638658158500 Content-Type: text/plain; charset="utf-8" make check is currently by default running tests tagged "slow". Running make check with no SPEED variable set should be equivalent to SPEED=3Dquick and run the meson 'quick' test setup, which explicitly excludes slow tests: add_test_setup('quick', exclude_suites: ['slow', 'thorough'] ... The problem is that the mtest2make.py script is effectively overriding the "meson test --setup" setting by using --suite which takes precedence over --setup according to meson documentation. Fix by excluding suites directly with the "--no-suite" option while generating Makefile.mtest. Although the 'exclude_suites' in meson.build are useless for make check, they still help when running 'meson test' from the command-line, so keep them around. For the configure line I'm using: make check goes from 1100 to 996 tests make SPEED=3Dslow check stays at 2158 tests make SPEED=3Dthorough check stays at 2279 tests (the rest of the test targets look sane, but maintainers please double-check) Signed-off-by: Fabiano Rosas --- - With this change we obviously lose coverage in make check. I suggest we use this opportunity to review what gets put in the quick suite. For migration, I want to keep only the smoke tests in make check. I'll send a patch adding them back if this change is accepted. - Some of the suffixes from functional tests could probably be removed and rely on having the tests in the proper suite instead. I.e. use 'slow' instead of 'foobar_slow'. --- scripts/mtest2make.py | 11 +++++++++-- tests/qemu-iotests/meson.build | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py index 383ea68b16..a61a83f775 100644 --- a/scripts/mtest2make.py +++ b/scripts/mtest2make.py @@ -26,6 +26,11 @@ def names(self, base): .speed.slow =3D $(sort $(filter-out %-thorough, $1)) .speed.thorough =3D $(sort $1) =20 +.speed_exclude_suites.quick =3D --no-suite slow --no-suite thorough \ + --no-suite optional +.speed_exclude_suites.slow =3D --no-suite thorough +.speed_exclude_suites.thorough =3D + TIMEOUT_MULTIPLIER ?=3D 1 .mtestargs =3D --no-rebuild -t $(TIMEOUT_MULTIPLIER) ifneq ($(SPEED), quick) @@ -34,7 +39,8 @@ def names(self, base): .mtestargs +=3D $(subst -j,--num-processes , $(filter-out -j, $(lastword -= j1 $(filter -j%, $(MAKEFLAGS))))) =20 .check.mtestargs =3D $(MTESTARGS) $(.mtestargs) $(if $(V),--verbose,--prin= t-errorlogs) \ - $(foreach s, $(sort $(.check.mtest-suites)), --suite $s) + $(foreach s, $(sort $(.check.mtest-suites)), --suite $s) \ + $(.speed_exclude_suites.$(SPEED)) .bench.mtestargs =3D $(MTESTARGS) $(.mtestargs) --benchmark --verbose \ $(foreach s, $(sort $(.bench.mtest-suites)), --suite $s)''') =20 @@ -102,7 +108,8 @@ def emit_suite(name, suite, prefix): targets +=3D f' {prefix} {prefix}-report.junit.xml' print(f'ifneq ($(filter {targets}, $(MAKECMDGOALS)),)') # for the "base" suite possibly add FOO-slow and FOO-thorough - print(f".{prefix}.mtest-suites +=3D {name} $(call .speed.$(SPEED), {na= mes})") + print(f".{prefix}.mtest-suites +=3D {name} $(call .speed.$(SPEED), {na= mes}) " + ".speed_exclude_suites.$(SPEED)") print(f'endif') =20 targets =3D {t['id']: [os.path.relpath(f) for f in t['filename']] diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build index 8857f25f29..34cfcdc53b 100644 --- a/tests/qemu-iotests/meson.build +++ b/tests/qemu-iotests/meson.build @@ -68,7 +68,7 @@ foreach driver, speed: qemu_iotests_drivers endif =20 # Every driver gets put in the driver specific suite - suites =3D ['block-' + driver + '-optional'] + suites =3D ['block-' + driver + '-optional', 'optional'] # Any driver tagged quick or slow also gets added to slow # otherwise its tagged thorough if speed !=3D 'thorough' --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770644; cv=none; d=zohomail.com; s=zohoarc; b=l7iHQs5G2oVRfBQud0kzp5oTBgbvWKp0fTDsqP3ahFCzJjouB0ZYLIwa+0ljB6MiNanIaEjusb9R1ifBBMcNume82eHLqMBhV1DKviI8/nzEjy6tvmjqllq6p99HlXGo2LliLiCqQ/dpue58Q5oZHF4o3/To0F0l+IO8yLADfEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770644; 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=GXUyeGboVwCGzOGFtHmMgzBd3At9yTet3cRQx4+5wCQ=; b=gKI2hLCAWMKbmt59RBzXgPiwWOG3CsueNjB8bjrrTVF/4Af/mVW9KMiRnptiCO1G1Ah/2V9OnT/tjrDs3lRCSM9I9nYTjM3zEJza6Th+FEpvn7+jyq+em+WMh4OUNXU3dNXE9RW6RPBM60FCJKNUSD4rgb+zUBMS4GtU5cCveJQ= 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 178977064442145.07761548719134; Fri, 18 Sep 2026 15:30:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h69-0007oe-1L; Fri, 18 Sep 2026 18:30:25 -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 1x7h64-0007o5-Ul for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:21 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x7h63-0000ZD-AL for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:20 -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 D2EE421ECF; Fri, 18 Sep 2026 22:30:09 +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 CBE0013991; Fri, 18 Sep 2026 22:30:08 +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 hQIbBW27rWrsdQAAD6G6ig:T3 (envelope-from ); Fri, 18 Sep 2026 22:30:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770614; 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=GXUyeGboVwCGzOGFtHmMgzBd3At9yTet3cRQx4+5wCQ=; b=HsEUA33H9pE+YC+xbpcX9vdw/sz25dVXDTHTUqASZ2NJ26WWUGiwVV2ZpTImGG1LH7U/vc 7noIN9w3EHXGbwxamQ5H8MPAuP8wd2B6bMVgwZe/FJfrdRtriMFAIPdQijTlgNHV536oKq G1P2eKXHJfvakEiZNo1jIx9LSno45hc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770614; 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=GXUyeGboVwCGzOGFtHmMgzBd3At9yTet3cRQx4+5wCQ=; b=NaNi0kES3kTREtA3O+efPs+7JbHAfxqM9IkTo/eNJcAoIfm68l3KW4+5biaa4+qF/hFBV9 J9lbi2rCGGpanuDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770609; 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=GXUyeGboVwCGzOGFtHmMgzBd3At9yTet3cRQx4+5wCQ=; b=NABI06tMSDxOmEk5hI5zVm8Et4VPo3SC78Y8T6MAiUtGvzuoasGPQetD/0ESf7m4OpxnGI ivmOmYDaahDOU/U0D31Yg3giDJPqkUn/zRWUAAfqRf7Yvdp0c4qVt/PbUsK4PL3os0VBaD DK85tBmSKHsxjutrCbZOaHcBCpl0E08= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770609; 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=GXUyeGboVwCGzOGFtHmMgzBd3At9yTet3cRQx4+5wCQ=; b=etKZD2yTuJphhRBXQ3xfns0GKpGboVy29yrk0JOKWsa5qidBnzEcgLXgmQ4XpcwG2+ebeS nBpJ+RTXMkWDbCDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 02/14] qemu-options: Use g_autofree when calling get_opt_name_value() Date: Fri, 18 Sep 2026 19:29:49 -0300 Message-ID: <20260918223002.1892021-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 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.996]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; 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)[]; TO_DN_SOME(0.00)[]; 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)[] 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:1; envelope-from=farosas@suse.de; helo=smtp-out1.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: 1789770646089158500 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 Sep 26 20:01:43 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=1789770650; cv=none; d=zohomail.com; s=zohoarc; b=eMufaFqKCeSU7XStqUlfSCDql9iKnP/8TbxsJ2egbKV2Fld5J7Q0T7w4atfpsmqU0hGt6J+goLWWkIQ48UKkDp8GGCSlB9sDP0hVrhzDjUYf2YWfOdTNo/kt+HYj0mcZu3L56P92Sb6xPRKwor/lzb3yWmPWp8wZQWF3Kic05qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770650; 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=l0Xc52nHv3u5ujrP4zfiyGstwX0hT67QnX+jedekjls=; b=WOYlITwvF09UQXFmnKYmRSbMulzZE5V2XOKgdmQOw9PbfqN0De5kkoAYcRjm4rjq9ZIOZEgesyecUYGZpkblzGala/3yW49NJNPye6GIKsMXNY0N1Q1TcBschUFWlypN3AbplDP8NMuJwBiLqis6XKCOEZW8aGuMN6Mx6YZCoeM= 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 1789770650202407.98924835411526; Fri, 18 Sep 2026 15:30:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6B-0007ou-13; Fri, 18 Sep 2026 18:30:27 -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 1x7h66-0007oN-Cc for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:22 -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 1x7h64-0000aR-DV for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:21 -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 ECD6A21EE2; Fri, 18 Sep 2026 22:30:10 +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 EB162139B1; Fri, 18 Sep 2026 22:30:09 +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 hQIbBW27rWrsdQAAD6G6ig:T4 (envelope-from ); Fri, 18 Sep 2026 22:30:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770615; 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=l0Xc52nHv3u5ujrP4zfiyGstwX0hT67QnX+jedekjls=; b=g2QOWvHGJYUMMmFeG4lhduv2gEMmVfsCPJv0O+Visgs6oNa1jI4bZYsFf5jvfHbID2T/rG PFVgzF3al3/mxPPaUB4UwI4oIikB5Q+3c2xPjYl49QxbW/s6t1Os1STqN9dFKGRPDfk3uH ZnuoIe08hDTBLhM1dKNv0nByJxkq5Wo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770615; 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=l0Xc52nHv3u5ujrP4zfiyGstwX0hT67QnX+jedekjls=; b=j31NgiNZGvdGpIKcy/LqbK0ICapS91JXJIVkQVDCGtTnemKk0R+gqvwEMIxNlTBALVOhDF ygU1/WyM8xA220Bw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770610; 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=l0Xc52nHv3u5ujrP4zfiyGstwX0hT67QnX+jedekjls=; b=VIMoww2TcogPRh0dMuzV9bqR9PZFWySlkTFOUxxPRxkIbjIeesvy06ETcKZuxBli+0XmhC a2fmCSi6hV6/lLuno7ofpdQ0Rz1x3lIOS1OfBGHBwYUkcQUcnhoNR3CIfL9A1TeaHhMVk+ oJuX/Van7PbaHE5z6+RL59orZei/zgo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770610; 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=l0Xc52nHv3u5ujrP4zfiyGstwX0hT67QnX+jedekjls=; b=TLhxOBQlKZqxBwahHjR8bBKoUycVw9YP62QPNY0jMPs+C+B4VU7N1bQ3ErJYiDHOP8k3Gt tnLycP9JnEL/YhDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 03/14] qemu-options: Consolidate branches in opts_parse Date: Fri, 18 Sep 2026 19:29:50 -0300 Message-ID: <20260918223002.1892021-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 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.997]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] 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: 1789770652417158500 Content-Type: text/plain; charset="utf-8" The two branches that return NULL can be put under a single branch because the qemu_opts_del function can take a NULL opt. The next patch will add common cleanup code to the error path so change this now to avoid code duplication. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- util/qemu-option.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 557d5d929c..e115e1acef 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -900,12 +900,8 @@ static QemuOpts *opts_parse(QemuOptsList *list, const = char *params, =20 opts =3D qemu_opts_create(list, id, !list->merge_lists, errp); g_free(id); - if (opts =3D=3D NULL) { - return NULL; - } - - if (!opts_do_parse(opts, params, firstname, - warn_on_flag, help_wanted, errp)) { + if (!opts || !opts_do_parse(opts, params, firstname, + warn_on_flag, help_wanted, errp)) { qemu_opts_del(opts); return NULL; } --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770706; cv=none; d=zohomail.com; s=zohoarc; b=Fi00QoXQwLSGIbosrkrRWYB7K5jDJuHY4iDBTcgBVH/xwcbkFSYA6mCQlVrcG2oUCVL/alvjQWPWfk0yZqvArYMNLE+vPx1Ytvq3Qg+lerojcJyHWswQ9MPjkIE+My77ghvIKN1e+Z7M8w4oEMYAZoKVOE6oOpJVFs5UF6sheJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770706; 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=uA9hjfjuOrCCUYezr2q3PaqiVZaDD2CfYnNvjnCwzDA=; b=bL0oJ3h9tvdIkAdsqDqjPnWmkG3fd7eEbM41WeVIB79Z2lR7ERqddN8KcYaLnwWy4Fk8H1U7hY5ZCw96ahd3TfZPFq1n1oo67BAV1lZLULjjjBcl6aQrvH5MbLoOJYdViFi+Vgy2HiekGvRKSKuVh6LyZGCDSXoROIfcEDDceno= 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 1789770706074736.3459319494127; Fri, 18 Sep 2026 15:31:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6D-0007qZ-HY; Fri, 18 Sep 2026 18:30:29 -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 1x7h69-0007oy-ME for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:26 -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 1x7h66-0000ak-4C for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:25 -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-out1.suse.de (Postfix) with ESMTPS id 4EC8821EE3; Fri, 18 Sep 2026 22:30:12 +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 1F144139B3; Fri, 18 Sep 2026 22:30:10 +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 hQIbBW27rWrsdQAAD6G6ig:T5 (envelope-from ); Fri, 18 Sep 2026 22:30:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770616; 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=uA9hjfjuOrCCUYezr2q3PaqiVZaDD2CfYnNvjnCwzDA=; b=Y9G5v+p1kT/IYPYSjw6TyG8jlegSJfJLuOliy/3ow3Nf5NlM6zXJGM0aAbwRDHJhR8K4DC uV83CUFKhi1cFh9UYmcpU/v2l7n/j7WfEgpYNG+HUytiVtBZiFI7aYDhrcjP93T8AJ2P75 4FyBmGIAG2reXxVoBr8NiiFxqhgbsO8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770616; 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=uA9hjfjuOrCCUYezr2q3PaqiVZaDD2CfYnNvjnCwzDA=; b=L0Nf8CEtHUWYIPq5LgpOraejtsj0Qcs9ySEDDRCTwxYgSmylhE34Ik8iZ3jylPXb3K6T1c DkDOK9Hv3IrlamDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jLWmSEZc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=rnaIfz8R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770612; 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=uA9hjfjuOrCCUYezr2q3PaqiVZaDD2CfYnNvjnCwzDA=; b=jLWmSEZcFWfTWw/Qm1QkTN7+GddsGiWr935/ongJVTeHy6kkNO1d4m3Azf/R+zXkU9WTyp 1i7xQNOVz6MrQcTM7+NKYAUtDhC56P5wtzUuI+RZKhTbkZZkg6mh0N2Yfpv83Gtru+LJ/Z smi6dl+/sf/E6TgpKQuLf71lQMt3SJs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770612; 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=uA9hjfjuOrCCUYezr2q3PaqiVZaDD2CfYnNvjnCwzDA=; b=rnaIfz8RNNPfwWQmAsQjT553t/2fOmZQhVuCKwScABIQyPQXkus7ErzQvvqviEqJdT710L l285gvbLhAnO3bCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [RFC PATCH 04/14] qemu-options: Add qemu_opts_parse_list Date: Fri, 18 Sep 2026 19:29:51 -0300 Message-ID: <20260918223002.1892021-5-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 4EC8821EE3 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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:+] 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: 1789770706386158500 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- include/qemu/option.h | 2 + tests/unit/test-qemu-opts.c | 169 +++++++++++++++++++----------------- util/qemu-option.c | 13 +++ util/qemu-sockets.c | 2 +- 4 files changed, 104 insertions(+), 82 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 8d03a69f7c..1257ef750b 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,95 +431,96 @@ 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 value (qemu_opts_parse warns but accepts it) */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", - false, &error_abort); + opts =3D qemu_opts_parse_list(&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, ""); =20 /* Implied value, negated empty key */ - opts =3D qemu_opts_parse(&opts_list_03, "no", false, &error_abort); + opts =3D qemu_opts_parse_list(&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"); =20 /* Implied key */ - opts =3D qemu_opts_parse(&opts_list_03, "an,noaus,noaus=3D", true, - &error_abort); + opts =3D qemu_opts_parse_list(&opts_list_03, "an,noaus,noaus=3D", true, + &error_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 3); 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); + 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 @@ -532,13 +533,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 @@ -551,59 +552,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 @@ -616,18 +618,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); @@ -637,11 +639,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); @@ -651,10 +654,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); @@ -662,47 +666,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 @@ -737,13 +742,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); @@ -877,8 +882,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); @@ -903,9 +909,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 */ @@ -962,7 +968,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 e115e1acef..aa879b78f8 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -922,6 +922,19 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const ch= ar *params, return opts_parse(list, params, permit_abbrev, false, NULL, 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 Sep 26 20:01:43 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=1789770684; cv=none; d=zohomail.com; s=zohoarc; b=OYxcgNM0+WZPxnmQwe1WnG+sTckSKv4jygCvwkOLF3FurhSyiaqtcCHRz5RsgNSrY3YsEVCgNyU/8b72ocJyFZMygAZhaHy8e1kc/34q3yDoyDztMhwl5n5kEJ7oTtzaylDo+wi+o++OOkjHuBK3wS+IR2JkzHdBfkWeBFBc6DM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770684; 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=ZohqxSeG85RlIE5adOBOVsTbnvnONZx0NzBIm2rUcc4=; b=PDwqtb+7xcjnK77upaUjiXNne2tqPRiW7UpNYWn7kJni9WW72ECG2QwQnSbxZuCPf+lCeklYM6LaW+n8SNDOoaCVhMUwii60utlRSMeJ5RRC0PyTsSYq1yYllxPBXqehaWu8tcZqqR3LhWQecHH2Ii+2kAZ7wDK8RkrO3kpW/d4= 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 1789770684414267.289714028635; Fri, 18 Sep 2026 15:31:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6G-0007rM-1p; Fri, 18 Sep 2026 18:30:32 -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 1x7h6B-0007p7-5Q for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:27 -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 1x7h68-0000e7-Oz for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:26 -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-out1.suse.de (Postfix) with ESMTPS id E1A5021EE4; Fri, 18 Sep 2026 22:30:14 +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 71B94139B6; Fri, 18 Sep 2026 22:30:12 +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 hQIbBW27rWrsdQAAD6G6ig:T6 (envelope-from ); Fri, 18 Sep 2026 22:30:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770619; 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=ZohqxSeG85RlIE5adOBOVsTbnvnONZx0NzBIm2rUcc4=; b=yZQOnRPD+RJEZTHgDTCaoeAVzAHo++N2RuGAZMFLr0mRXUm2a7HxJvnLkeVUPQ/lH6Nc+m tRZeM0ZsuBU1DrjpaB0J+siIY0mjLxyXz8A86vV4U8n1tiJjNwA61A8aENsYkDgT3Qok4I k+Rmu5x7fUss6kZGWMzRvqhXb8jJlTA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770619; 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=ZohqxSeG85RlIE5adOBOVsTbnvnONZx0NzBIm2rUcc4=; b=9L7ibfyXJK737bohFI8rAU80rYEmTK2hQPwkMyUuXF03vdQ0e1lQTqHyDKaKi/VmnKn1pt TgF1jwc3PCpGJ2Dg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=TFk7Ke0H; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=v+MCsqP5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770614; 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=ZohqxSeG85RlIE5adOBOVsTbnvnONZx0NzBIm2rUcc4=; b=TFk7Ke0HIahpECzK95TTzMZ51tQbwIuVh9zbCqNFKsxG64Vsqs6KAPe2uZPUWaI42yrKAV MnsmQJxCoHLNwzqssOMgoQhxaggV0qJHg2LituL9jtp7+1thftaq5hGgtgqH+ECvcOTpbb iIg01+mWPTH7jLUxGgssx6qO8evNdNA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770614; 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=ZohqxSeG85RlIE5adOBOVsTbnvnONZx0NzBIm2rUcc4=; b=v+MCsqP5eK2N24VBYQcritInVAGCmeTy9rAZ7mpvTT9USC4GAN5QOEV7drDoVdyHnZRKcg UlyAoL7hlzj80tAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , Paolo Bonzini , Michael Roth Subject: [RFC PATCH 05/14] qemu-options: Change qemu_parse_opts() to take the group name Date: Fri, 18 Sep 2026 19:29:52 -0300 Message-ID: <20260918223002.1892021-6-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Queue-Id: E1A5021EE4 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.de:+] 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: 1789770686293158500 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 9bd7664b85..239c537e45 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 aa879b78f8..2c23841376 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" @@ -910,16 +911,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, false, NULL, errp); + QemuOptsList *list =3D qemu_find_opts_err(group, errp); + + return qemu_opts_parse_list(list, params, permit_abbrev, errp); } =20 /** @@ -932,7 +935,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, false, NULL, errp); } =20 /** --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770671; cv=none; d=zohomail.com; s=zohoarc; b=EDMucVQfOyLdxhldnxDg1RKTq044s3peTIcsvPU/8M1UggOW9+qoRqFKy0pSIuzTgzn3X3eTijSUv4wEle9Yu9dEKBUsimblF11u81LSNbxdphRp1sM485g4ccyY1Q9DI9IZlUPzQcomNTgg53xg5qY7yWdFB6LECksMGqbf3GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770671; 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=F86IFDqgDxSfbOjUjcf4cWDqZ8pzBz8lL6Iyy5LIpN8=; b=IefAWePLghDOzDwMWMCgdYvMD53YamP+wDCZuw/DpqYJ/kiKQMxeAl3dZeKuGaSk2INYi2mNCJMndpM3are1kNMMLN8H4WxyeKiTMtgj+mmERdw9gyVx+gGdIARN3kCqYyZDMe8x+XP30eDe01NHPu4HPRPW59r1078s+Crmz/k= 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 1789770671919225.70163607439804; Fri, 18 Sep 2026 15:31:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6C-0007qB-TO; Fri, 18 Sep 2026 18:30:28 -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 1x7h6A-0007p0-Cx for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:26 -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 1x7h68-0000eV-Ok for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:26 -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 18EB220005; Fri, 18 Sep 2026 22:30:15 +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 EE205139B7; Fri, 18 Sep 2026 22:30:13 +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 hQIbBW27rWrsdQAAD6G6ig:T7 (envelope-from ); Fri, 18 Sep 2026 22:30:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770619; 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=F86IFDqgDxSfbOjUjcf4cWDqZ8pzBz8lL6Iyy5LIpN8=; b=sYvk3TaF9YvQusU9ALfn2iaV/KOf0q0vE28EFjZ0NnmPdUUuvtxwIayjqmPRKAQbelX9Ad 6iHURQhIvPyJT9DzVRnKgmWGrKsj0bWpAOAL4SX0RSTX4cv07wHxkS63+7GsFSl4iN7Q34 pYLJo5fSiS6PPyhSelj6DkgsRTU/yMs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770619; 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=F86IFDqgDxSfbOjUjcf4cWDqZ8pzBz8lL6Iyy5LIpN8=; b=PoowfdRpwHBGT6dTttMoUQ8d8Bt6FG3u/W8+lsdEE2XKYFEWxQXCcnqSFT9+9gx2gUSFqA 0bRHOGZlHglEvfDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zxX9JgzB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+5ILHfze DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770615; 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=F86IFDqgDxSfbOjUjcf4cWDqZ8pzBz8lL6Iyy5LIpN8=; b=zxX9JgzBdV1UzjpvAo4B9FQbTjj0ol9oZlBnVgduNSMGvrYT6a6Nm5ubR88E4XLHAHaxLx oJiUwtfQ3kykC72hUiVBEgJr7ERjx6esb9MT5pw1XzVjlkzhNjWAvDOktyQIJ+zgou/y+c XiFTTLe+7WaiPVUMrZ97T7HR++9p9dk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770615; 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=F86IFDqgDxSfbOjUjcf4cWDqZ8pzBz8lL6Iyy5LIpN8=; b=+5ILHfze3ws1I6719zk12U/1QXB3ZNVXuhFdH3XQ02gqAVUdgh3icQUxvPc+Z2ueKC3feS JSsOrcW6908jWbDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 06/14] qemu-options: Call qemu_opts_print_help() one level down Date: Fri, 18 Sep 2026 19:29:53 -0300 Message-ID: <20260918223002.1892021-7-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 18EB220005 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; 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=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: 1789770674132158500 Content-Type: text/plain; charset="utf-8" When calling opts_parse(), there is no need to pass in &help_wanted only to call qemu_opts_print_help() in case it's true. The opts_parse function itself can call qemu_opts_print_help() and avoid the roundtrip. qemu_opts_print_help() takes a QemuOptsList pointer. opts_parse() can access the list via opts->list. Note that this change doesn't avoid the need for opts_parse() to pass a pointer into get_opt_name_value(). Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- util/qemu-option.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 2c23841376..bb38d305c9 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -812,7 +812,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 warn_on_flag, bool help_wanted, Error **err= p) { const char *p; QemuOpt *opt; @@ -820,9 +820,12 @@ static bool opts_do_parse(QemuOpts *opts, const char *= params, for (p =3D params; *p;) { g_autofree char *option =3D NULL; g_autofree char *value =3D NULL; + bool is_help =3D false; =20 - p =3D get_opt_name_value(p, firstname, warn_on_flag, help_wanted, = &option, &value); - if (help_wanted && *help_wanted) { + p =3D get_opt_name_value(p, firstname, warn_on_flag, &is_help, &op= tion, + &value); + if (help_wanted && is_help) { + qemu_opts_print_help(opts->list, true); return false; } firstname =3D NULL; @@ -885,12 +888,12 @@ 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, false, false, errp); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, - bool warn_on_flag, bool *help_wanted, Error **= errp) + bool warn_on_flag, bool help_wanted, Error **e= rrp) { const char *firstname; char *id =3D opts_parse_id(params); @@ -935,7 +938,7 @@ QemuOpts *qemu_opts_parse(const char *group, const char= *params, QemuOpts *qemu_opts_parse_list(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, false, false, errp); } =20 /** @@ -951,15 +954,12 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list,= const char *params, { Error *err =3D NULL; QemuOpts *opts; - bool help_wanted =3D false; + bool help_wanted =3D !opts_accepts_any(list); =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, true, help_wanted, &e= rr); if (!opts) { - assert(!!err + !!help_wanted =3D=3D 1); if (help_wanted) { - qemu_opts_print_help(list, true); + assert(!err); } else { error_report_err(err); } --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770714; cv=none; d=zohomail.com; s=zohoarc; b=Rt8o+X2upT6RCvNd9QDuiURaQW4QHijrjimUKzNJ9cJdhvUrNxYJL2Q7FgG7rA/xqYPzElO4Cvu5mPww/0kR5kNjTu/hZDaXd6B27/A/8QjKNrpTnJXKnqAsU8vuOgc9QzmNlFPU379JehKfyWIWm9LBK76jI0B5ZKhit0EIGtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770714; 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=xKw/qSlgEJX8NppOT5mW4Ogp1/OYlPI6vcH8jQThncI=; b=aDXOzNUwBAtInZbONwhyia0pAxaU5/U2k0dGDMgcrpIHaxrugAlz3Rkxda9DcfZohCnq7li07qMUrpi/pa1ekWPDPZi9xcsd4R4+/VFnzXWZtv+3YqFeZ/T/TJQLxM009v3jNlSB0wzoQdpIE0l34wltL+Ka4sdS09WdQTbk9XQ= 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 1789770714307793.6496581889215; Fri, 18 Sep 2026 15:31:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6D-0007qd-Ku; Fri, 18 Sep 2026 18:30:29 -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 1x7h6C-0007px-EX for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:28 -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 1x7h6A-0000er-Jc for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:28 -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-out1.suse.de (Postfix) with ESMTPS id 301D221EDD; Fri, 18 Sep 2026 22:30:17 +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 1E3381348F; Fri, 18 Sep 2026 22:30:14 +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 hQIbBW27rWrsdQAAD6G6ig:T8 (envelope-from ); Fri, 18 Sep 2026 22:30:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770621; 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=xKw/qSlgEJX8NppOT5mW4Ogp1/OYlPI6vcH8jQThncI=; b=1CIaPbNTyyrzsHHT1kvsurHvzyEVQza+/QxQvsOHMNh7iNqHQuYzaUO3rx6i+bCMRjDSHO znw0R2cZZj31RPOmVWfeV68NlEy2pahJGiSh3poaxJFbzWgz32vsQyvDgjIBojvk/1odKB ROVUFWd96SCugvSE/QBuN2NEOMJazCg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770621; 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=xKw/qSlgEJX8NppOT5mW4Ogp1/OYlPI6vcH8jQThncI=; b=2w6et1sWOKP3hkmSLV//ddi609/93GuymC+My68UyyL9OggnX+QReABluT14AUyh1m0HmO PxBSKhwE6iLaBGDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eoAqlQtL; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=xm1uDZZv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770617; 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=xKw/qSlgEJX8NppOT5mW4Ogp1/OYlPI6vcH8jQThncI=; b=eoAqlQtLhgC3gp4jJs9OKlcu8m1ltA3lF0JKKzhRxvccu21QklDrnrfLfOhYU1IQeXDrG4 bEI2EUOp2XL+JYEhJlQjMtOqkR1b9PPfWJLk0lOjv7WCQ2J5jm9wnxjOKo3uk60xBn18jH JVC+sZvT6tzDwEgfoDqYYZwdRPzPHIw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770617; 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=xKw/qSlgEJX8NppOT5mW4Ogp1/OYlPI6vcH8jQThncI=; b=xm1uDZZvsTy9Kh9W/9ei789uv9eOx3qPq59eikQuZlHi8ZxMXyUUoulzYpdoZ1UQmlWGX0 yTv3Sn7a9Yf8ZjCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth Subject: [RFC PATCH 07/14] qemu-options: Consolidate qemu_opts_parse* functions Date: Fri, 18 Sep 2026 19:29:54 -0300 Message-ID: <20260918223002.1892021-8-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 301D221EDD 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)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; 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=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: 1789770716273158500 Content-Type: text/plain; charset="utf-8" The qemu_opts_parse, qemu_opts_parse_list and qemu_opts_parse_noisily functions all call opts_parse(), they can reuse code. Consolidate them at qemu_opts_parse_list(). Use the presence of the Error pointer to determine whether the caller wants to be noisy: if there is an Error pointer, then use it, otherwise print the message. This makes the code more opaque, so keep the qemu_opts_parse and qemu_opts_parse_noisily functions as wrappers to make sure the intent at the callers is still clear. Signed-off-by: Fabiano Rosas --- tests/unit/test-opts-visitor.c | 2 +- util/qemu-option.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/unit/test-opts-visitor.c b/tests/unit/test-opts-visitor.c index a9e45c0251..dd9a8faf12 100644 --- a/tests/unit/test-opts-visitor.c +++ b/tests/unit/test-opts-visitor.c @@ -39,7 +39,7 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_d= ata) QemuOpts *opts; Visitor *v; =20 - opts =3D qemu_opts_parse("userdef", opts_string, false, NULL); + opts =3D qemu_opts_parse("userdef", opts_string, false, &error_abort); g_assert(opts !=3D NULL); =20 v =3D opts_visitor_new(opts); diff --git a/util/qemu-option.c b/util/qemu-option.c index bb38d305c9..c8e552823b 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -938,7 +938,23 @@ QemuOpts *qemu_opts_parse(const char *group, const cha= r *params, QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { - return opts_parse(list, params, permit_abbrev, false, false, errp); + bool noisily =3D !errp; + QemuOpts *opts =3D NULL; + + if (noisily) { + Error *err =3D NULL; + bool help_wanted =3D !opts_accepts_any(list); + + opts =3D opts_parse(list, params, permit_abbrev, true, help_wanted= , &err); + if (!opts && err) { + error_report_err(err); + } + + } else { + opts =3D opts_parse(list, params, permit_abbrev, false, false, err= p); + } + + return opts; } =20 /** @@ -952,19 +968,7 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, con= st char *params, QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, bool permit_abbrev) { - Error *err =3D NULL; - QemuOpts *opts; - bool help_wanted =3D !opts_accepts_any(list); - - opts =3D opts_parse(list, params, permit_abbrev, true, help_wanted, &e= rr); - if (!opts) { - if (help_wanted) { - assert(!err); - } else { - error_report_err(err); - } - } - return opts; + return qemu_opts_parse_list(list, params, permit_abbrev, NULL); } =20 static bool qemu_opts_from_qdict_entry(QemuOpts *opts, --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770683; cv=none; d=zohomail.com; s=zohoarc; b=LZbtb6vOCDJs15Hw+VMVCN5UtwcecIigLK7zPg8b/Nj4bEeWtAT0BN2dc7TgqsE5FmSw89xDyMFQyyA45XLYxJv1lWGEUQpLhngOvnFVBQwEPaDC0zM1bkZGcpJ/s5d06JS5CU/Ick4fTwkCeMmNOxYbq4RiXu0ULyuAYMAmpoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770683; 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=vR6O5oKra26KLXec/atJFerxZThVQacujYKuSNGJ1/Q=; b=BcR9do+tTSrRzNZFeAYmsOw9JOZgmkFUrn3qFMAgIK5viJWNshmYxYmMdEee/WcKwGXMCLqoIKpxr2GF63hStjLRw49t3RtbsZCyTUzWeXl+2GAcQdkhKmBn/WB5B7ImJN253Q2D617SY7q2axuKCJP88IpleJQ91XuzuH+tk3E= 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 1789770683686765.0464523702691; Fri, 18 Sep 2026 15:31:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6H-0007ri-9l; Fri, 18 Sep 2026 18:30:33 -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 1x7h6F-0007qz-5N for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:31 -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 1x7h6C-0000fJ-Pp for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:30 -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-out1.suse.de (Postfix) with ESMTPS id 60CD821EDE; Fri, 18 Sep 2026 22:30:19 +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 848B5139B9; Fri, 18 Sep 2026 22:30:16 +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 hQIbBW27rWrsdQAAD6G6ig:T9 (envelope-from ); Fri, 18 Sep 2026 22:30:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770623; 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=vR6O5oKra26KLXec/atJFerxZThVQacujYKuSNGJ1/Q=; b=0z8+lSF3JTemUV0mxj3Cx8o9j2CX7tClR9Zf7lZvi/NWQNPBaSgW8O8KVIo1orbf1u5jnD cUPRbBxpsZM1TGTpwGEhWE11UqGG0588EmMFRGzRsRGpyNmRzu7T6OJ1BDXAehDoP/hRf9 0m2b5OeYHGPqaQYogvvg2c083pdTWSM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770623; 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=vR6O5oKra26KLXec/atJFerxZThVQacujYKuSNGJ1/Q=; b=Hy+2BDzxPB1yDNBUfmDEYgyD7Zaze2o0742qhYHKZG9EVjATHMkKzXyM3eW2yY0iktQxCQ kiTO/bPOB3UVa+AQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zpGu2Nsv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=XaNObXA7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770619; 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=vR6O5oKra26KLXec/atJFerxZThVQacujYKuSNGJ1/Q=; b=zpGu2Nsva1iPme1cqM8IFUoegeUDIibuwOXepuVbe0df8lzytRDeZcmWRbLgFUtjj4ZrP1 FGANBudHxMPD+XlFZ+hi18pF6pXBSEiZcpv4hVsKPtOKUVAfxWbw+VRb4QXWCzN2NP5vMZ MrluNvSuucecmhIwk9UIKNHSvDGMQ1k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770619; 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=vR6O5oKra26KLXec/atJFerxZThVQacujYKuSNGJ1/Q=; b=XaNObXA70JR4HEYhkLIBJOKinuzkS6pcTL5Ls60h0jG3/HDdTQ7G0+lCL28uND7VX9+KNt 5xLCsOyk28ZV74CA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , Kevin Wolf , Hanna Reitz , "Dr. David Alan Gilbert" , Jason Wang , Eric Blake , Vladimir Sementsov-Ogievskiy , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Berger , Lukas Straub , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC PATCH 08/14] qemu-options: Add qemu_opts_parse_list_noisily Date: Fri, 18 Sep 2026 19:29:55 -0300 Message-ID: <20260918223002.1892021-9-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 60CD821EDE 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)[]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; 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=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: 1789770686619158501 Content-Type: text/plain; charset="utf-8" Add a wrapper similar to qemu_opts_parse_list() with the same objective, to free the non _list version, i.e. qemu_opts_parse_noisily() to be converted to receive the group name. Signed-off-by: Fabiano Rosas --- block/monitor/block-hmp-cmds.c | 2 +- include/qemu/option.h | 2 ++ monitor/hmp.c | 2 +- net/net.c | 2 +- qemu-img.c | 10 +++++----- 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 +- util/qemu-option.c | 14 ++++++++++++++ 15 files changed, 43 insertions(+), 26 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/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/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..4996618a4e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -161,7 +161,7 @@ static OutputFormat parse_output_format(const char *arg= v0, const char *arg) * an odd number of ',' (or else a separating ',' following it gets * escaped), or be empty (or else a separating ',' preceding it can * escape a separating ',' following it). - *=20 + * */ static bool is_valid_option_list(const char *list) { @@ -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 a62ad23ecf..8ba85a59d7 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -1197,7 +1197,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 239c537e45..adda7b0f70 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3262,7 +3262,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; @@ -3277,7 +3277,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); } @@ -3626,7 +3626,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; } diff --git a/util/qemu-option.c b/util/qemu-option.c index c8e552823b..c762eb20a3 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -971,6 +971,20 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, = const char *params, return qemu_opts_parse_list(list, params, permit_abbrev, NULL); } =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. + * 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) +{ + return qemu_opts_parse_list(list, params, permit_abbrev, NULL); +} + static bool qemu_opts_from_qdict_entry(QemuOpts *opts, const QDictEntry *entry, Error **errp) --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770690; cv=none; d=zohomail.com; s=zohoarc; b=FYdpMZiYUJg7ff6YgvUwWOAG3RB4VAw85/baJ4Veky/JjEor7pIAc5c17/QiO0AZjfPq4DKfto4y2dSgVgywtNxMhCH0h/2JPzhgE8D2OfApMMHv9jpqdhvT/kBZA021Olzac8q2aUpNuij5y8gUoQcfu328xyj0wwvfZpTzUXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770690; 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=dCYExgrU5b7muvAYE8Ab9+v9ShlW58rboZcrfPhQoKo=; b=HRl9vtC/wN7yxYfuJnotpAJhP2HezzfhvixvLPX6zlztBvGIjXmLbo7Rqk8k/cPQqFblQNjoycNKDwzroTKtYGKegh71fyElAH9xAV9eXJ3o3CQYkeiNQG1/UyAErY9lojzcBwPikdmpxsJB62dxq9wTYACzgp/F0BoAwxlVk4w= 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 1789770690953691.9574854450527; Fri, 18 Sep 2026 15:31:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6L-00081s-Uc; Fri, 18 Sep 2026 18:30:37 -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 1x7h6K-0007x3-9a for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:36 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x7h6G-0000fb-Mj for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:35 -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-out1.suse.de (Postfix) with ESMTPS id 4421C21ECF; Fri, 18 Sep 2026 22:30:22 +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 BDC7013927; Fri, 18 Sep 2026 22:30:19 +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 hQIbBW27rWrsdQAAD6G6ig:T10 (envelope-from ); Fri, 18 Sep 2026 22:30:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770626; 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=dCYExgrU5b7muvAYE8Ab9+v9ShlW58rboZcrfPhQoKo=; b=zcRua9ui6ec/d6BCZMXDDGoMFHb6hHSomycaRKRatEGcYS2A741JXIGVlNoc7c+iPaUjHi +njizHidMqJyApTtn0kJsL9Xoflv/15em6s6vBgmjPMn+898zA/cfX/f1fsANWadRuUvfp 85wx8P4/nKcactYloCz/yU0TpLCSVbQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770626; 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=dCYExgrU5b7muvAYE8Ab9+v9ShlW58rboZcrfPhQoKo=; b=kiu4ERkozAGSRavyyobkhbo8eZ4MrFSaiuw5ouvXbOcGEyQD2V+JyXH49sdcQXpThXYs6g iU0dF1vSYBFrH8BA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=dQS3J5cB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=P5ggqldU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770622; 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=dCYExgrU5b7muvAYE8Ab9+v9ShlW58rboZcrfPhQoKo=; b=dQS3J5cBt+P0yrkn97cGFMtpVWrmcZT9MnLVMbLCrpBYY9XlKzUT5HjMH5KIDjQgu8frvM sVQl4Vtb4b+8Mq4RGbVdkAyYX6HyhdGx98k1j+ezcJDX5k8JY3CsAWgTp19HxCPs0E0P41 87WtfCy07lqW/ts/Wg80CWZINAEGHmk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770622; 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=dCYExgrU5b7muvAYE8Ab9+v9ShlW58rboZcrfPhQoKo=; b=P5ggqldU2sbVaAjCjYgEhDvu1F2e6QzCy0Urmc/kqPRjBu5TOJ6gU4KhjLMv+LUKJjqydK lunkh4ivEaC+eXDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster , 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 , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi Subject: [RFC PATCH 09/14] qemu-options: Change qemu_opts_parse_noisily() to take the group Date: Fri, 18 Sep 2026 19:29:56 -0300 Message-ID: <20260918223002.1892021-10-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 4421C21ECF X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,suse.de:mid,qemu.org:url,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] 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:1; envelope-from=farosas@suse.de; helo=smtp-out1.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: 1789770692624158500 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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 | 14 ++++++- 13 files changed, 54 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 4996618a4e..0459faac5f 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 adda7b0f70..4a6c3e5582 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1870,8 +1870,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); } @@ -1897,8 +1896,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); } @@ -2475,7 +2473,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); @@ -2975,8 +2973,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; @@ -3001,8 +2998,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; @@ -3061,8 +3057,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; @@ -3115,8 +3110,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; @@ -3244,15 +3238,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; @@ -3356,9 +3348,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: { @@ -3390,24 +3381,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; @@ -3430,8 +3418,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"); @@ -3470,8 +3457,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); } } @@ -3487,12 +3473,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) { @@ -3506,8 +3490,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); } @@ -3529,8 +3512,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); } @@ -3546,15 +3528,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); } @@ -3603,7 +3583,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); } @@ -3633,8 +3613,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); } @@ -3666,8 +3645,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); } @@ -3697,8 +3675,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 c762eb20a3..f8494c8842 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -941,6 +941,8 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, cons= t char *params, bool noisily =3D !errp; QemuOpts *opts =3D NULL; =20 + assert(list); + if (noisily) { Error *err =3D NULL; bool help_wanted =3D !opts_accepts_any(list); @@ -958,16 +960,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(list, params, permit_abbrev, NULL); } =20 --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770674; cv=none; d=zohomail.com; s=zohoarc; b=ICo4T9OpLVJAuYlH8ibKxaXV0mX9o+PW1xlQErsAqb2XGwh/hCvF1pUKA6F3YCmymlHecYUIe4EiRRogJOy7h2emr0WuPoyiz6sByWSR7luBf2EdFqLd9+fsuGcFTHi4FZf0l/1c88BxtWcT2vhnwxwkOW0d8fuJ0a8R1y41pS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770674; 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=MA2D+uX7KWzBPNhZ8TyuJuDVSGwK5uW7hfQDsEgS8Jw=; b=NY4i7XG1NROpC29sX5OBjAETFfMue8Lt23UnHlWK6buEK4urlbXvh65VGhDeTgTVy6YiLTJQd0oUM0j3hHZNLfD+meTqYrsj7c8poBt/DmZpshphpsaBSjioxjg1GUu/1QqThviJnvfJXGzxa/zG0nziAumXEadbx2yrP71c9KQ= 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 1789770674563933.5591919250712; Fri, 18 Sep 2026 15:31:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6K-0007xG-I4; Fri, 18 Sep 2026 18:30:36 -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 1x7h6I-0007ru-Cu for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:34 -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 1x7h6G-0000fk-T9 for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:34 -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 751202000A; Fri, 18 Sep 2026 22:30:23 +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 86A7513991; Fri, 18 Sep 2026 22:30:22 +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 hQIbBW27rWrsdQAAD6G6ig:T11 (envelope-from ); Fri, 18 Sep 2026 22:30:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770627; 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=MA2D+uX7KWzBPNhZ8TyuJuDVSGwK5uW7hfQDsEgS8Jw=; b=tpiZL5UkAs6Z/PsPapH88ZffKjVlLfzEoW6J238yJOri2xoVbPHBJgCBMG7ByJAycYGZhJ W8nEImZDm+ZhtsiN4V2BGwl0IvcKIEgay9Pz11BsQVXDXN4AJeHZO+WtoS2Ae732FMKygi OhYLarSu6Ii6G3Uplqmoa8vW0kBNILA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770627; 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=MA2D+uX7KWzBPNhZ8TyuJuDVSGwK5uW7hfQDsEgS8Jw=; b=cJcLsjMBSZ3Mvk4Pb/EffiN+eWgfufPbRk3I+r2VTJZw0xLwtKXd8BzaTaDm2QCcV6032p BdJ8jfSj1cS4uHCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770623; 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=MA2D+uX7KWzBPNhZ8TyuJuDVSGwK5uW7hfQDsEgS8Jw=; b=PuXCDPWXaTmMPdatFpypDkmuFe8yHJd0FO5j7gm/1SzL4PzrPj4IoEqzFZcC6TouMU9wLL WWyhUZPXTB3WdfHWYMtdZ8inSdQuM3qbQtRvKUqcw6OizYthE/KdE1Y7wx53Al2JHvuDPr mXOeMwUNKuGfjsnttWwJOvHxf/SK+WE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770623; 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=MA2D+uX7KWzBPNhZ8TyuJuDVSGwK5uW7hfQDsEgS8Jw=; b=XmU1sCVa0pVfLF02L7lKqhfum2DNpT3bdW7HoWYhgAfgj5VxuxaNtUdxinXd0a1tdvd4rA Jt+z91uhcS+6PfDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 10/14] qemu-options: Check for NULL list at qemu_opts_parse() Date: Fri, 18 Sep 2026 19:29:57 -0300 Message-ID: <20260918223002.1892021-11-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 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.997]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] 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: 1789770676137158500 Content-Type: text/plain; charset="utf-8" Now that qemu_opts_parse_noisily() is protected against NULL list, do the same for the non noisy version. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- util/qemu-option.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/qemu-option.c b/util/qemu-option.c index f8494c8842..37e6d68f02 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -925,6 +925,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 Sep 26 20:01:43 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=1789770710; cv=none; d=zohomail.com; s=zohoarc; b=Aa+DMCqhgD4BfzzKO55VwRF4kBBFzgusXZolQeZoEfmIZYV4kzpnZ4Zz4nPNnAQHb+GoE4SK/JhnlBOV8Xmaptgtc7EynrBToyF1COrKwMGshFqWqmBzyH4mbY0qHzzENrMIA59M6i7N4eIkOCEnz0+0COvFyZAjndpSNdjYAhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770710; 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=Pil+c5ItAOj/L/psslVm/o4LvQJFfan0el4xUxvvKmw=; b=ePchObxIn8TEfRWwKvOn1oOMxNrQq84NsBSgX2pphiko6ezV0ZpfBk8HiLDyjQGrBpjnTXSulnxrgQ5H2NqzAJ8RpHBuqQnVD3SmLfF4xDQNNNVxHSZqCEP2e6bxXGfum6KgYAEM88lEbKGYrVzGqMHgCxXOPH7wOhKxojyqJsY= 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 1789770710696625.6821141878206; Fri, 18 Sep 2026 15:31:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6M-000836-8P; Fri, 18 Sep 2026 18:30:38 -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 1x7h6K-0007x4-A0 for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:36 -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 1x7h6I-0000fu-1D for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:35 -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 90A9521EE0; Fri, 18 Sep 2026 22:30:24 +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 AFE91139B1; Fri, 18 Sep 2026 22:30:23 +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 hQIbBW27rWrsdQAAD6G6ig:T12 (envelope-from ); Fri, 18 Sep 2026 22:30:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770628; 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=Pil+c5ItAOj/L/psslVm/o4LvQJFfan0el4xUxvvKmw=; b=FK1BR9QOwtm6cbyuV2Ex0/nuPEDgQx/SQKnnGvChPbB8P/Fs3+juPBwp9dLrHbuepzPO4T v/EvUWONKm6oryShjG47mVAHx3iIARAaAMvNZf0LRgc7ZvzdgQzfZISF8WE8gAkP4Q8Etd AsIEhUxJ4oCO5DAL8zr3CtiTCsmxpyo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770628; 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=Pil+c5ItAOj/L/psslVm/o4LvQJFfan0el4xUxvvKmw=; b=ovYgVvAkBUZ7tve8tphe8sJSHFbbgQwyY/y9w1WIvWn6BG41dvqLRHwpzCGkOU0kd2K/uD 102cL73ryFSYNqAw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770624; 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=Pil+c5ItAOj/L/psslVm/o4LvQJFfan0el4xUxvvKmw=; b=2YlzxAYDv7ajKXDyCYAwC2k/EcjNWIZTq2N+8BsQSkQrvFcOlEUG8EQ3YIrfW6560lBNEE U7ai1f5n6Rxfze7WRUOxec9Nv2Inn/AhBq9eL5ZUO8X7ZNha70m7HN6gOBKW5D2+Ko8/RQ SE6/kZJndZUL7Qn1T+ND8e/UFPE9JeU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770624; 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=Pil+c5ItAOj/L/psslVm/o4LvQJFfan0el4xUxvvKmw=; b=iGA4Dbg4VfKKTIuLw5yxHrmx4dOplTbpTDWk2gPkeLHcsuf9bjGPd7GkfkG39bbm49/Yot /BEHLZz9cyDJKNDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 11/14] qemu-options: pass an Error into get_opt_name_value Date: Fri, 18 Sep 2026 19:29:58 -0300 Message-ID: <20260918223002.1892021-12-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 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.996]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; 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)[]; TO_DN_SOME(0.00)[]; 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)[] 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: 1789770712278158500 Content-Type: text/plain; charset="utf-8" Passing a boolean into get_opt_name_value() is to put too much responsibility into this low-level routine. Have it just fill an Error object and let the caller decide what to do with it. Setting an Error is an easily recognizable pattern so it saves the reader from mentally parsing the boolean logic. Signed-off-by: Fabiano Rosas --- util/qemu-option.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 37e6d68f02..94e06b194d 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -756,9 +756,9 @@ void qemu_opts_print(QemuOpts *opts, const char *separa= tor) =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) + char **name, char **value, + Error **errp) { const char *p; const char *prefix =3D ""; @@ -783,13 +783,15 @@ static const char *get_opt_name_value(const char *par= ams, *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 (!is_help) { if (g_str_equal(*name, "delay")) { - error_printf("Please use nodelay=3D%s instead\n", pref= ix[0] ? "on" : "off"); + error_setg(errp, "Please use nodelay=3D%s instead", + prefix[0] ? "on" : "off"); } else { - error_printf("Please use %s=3D%s instead\n", *name, *v= alue); + error_setg(errp, "Please use %s=3D%s instead", *name, = *value); } + error_prepend(errp, "short-form boolean option '%s%s' " + "deprecated", prefix, *name); } } } else { @@ -821,9 +823,14 @@ static bool opts_do_parse(QemuOpts *opts, const char *= params, g_autofree char *option =3D NULL; g_autofree char *value =3D NULL; bool is_help =3D false; + Error *warn =3D NULL; + + p =3D get_opt_name_value(p, firstname, &is_help, &option, &value, = &warn); + + if (warn_on_flag && warn) { + warn_report_err(warn); + } =20 - p =3D get_opt_name_value(p, firstname, warn_on_flag, &is_help, &op= tion, - &value); if (help_wanted && is_help) { qemu_opts_print_help(opts->list, true); return false; @@ -852,7 +859,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, NULL); if (!strcmp(name, "id")) { return g_steal_pointer(&value); } @@ -870,7 +877,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, NULL); if (ret) { return true; } --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770694; cv=none; d=zohomail.com; s=zohoarc; b=iXZ7sfBbZg5jx1LRKahkIV+TazDWUD7E8dHxqJk/f8eUIpBiyT6HokmdUq3MIci+t1BV+qV+UJ6oSNAY7RFZoFTN3Dfu2zyiwZ1lEyoTJaOPBhJe9ZjzohKrGAVYWslZJtS6//Fi/v2+8a5HHi+vzaacQNSoA5J1Y8kFMO7lzTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770694; 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=32oWMLYxHK1bctb+3A1F7epM0ZGxRvTTPkuEwYrWqxM=; b=GnYEbNXFRXsZJ/EjISyoHw8WCzBa+cKkaNvhES549uRp2X+ovoUki7Rp53YQW+zUthdsSwZ/tCarpqUWkV+i70VzyzbrQiu+qmgWDLLEDL77pkBwAqSPNrB8lCnW+hDK5qVtEFa3UWBMSLKP172liD239GfofiT/Yg9NJWD5DK0= 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 1789770694360895.0940101800803; Fri, 18 Sep 2026 15:31:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6O-00086U-6c; Fri, 18 Sep 2026 18:30:40 -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 1x7h6L-0007zq-5S for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:37 -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 1x7h6J-0000g5-5H for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:36 -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 B15342000B; Fri, 18 Sep 2026 22:30: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 CE9EF139B3; Fri, 18 Sep 2026 22:30: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 hQIbBW27rWrsdQAAD6G6ig:T13 (envelope-from ); Fri, 18 Sep 2026 22:30:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770629; 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=32oWMLYxHK1bctb+3A1F7epM0ZGxRvTTPkuEwYrWqxM=; b=XTeE+iJ3iLYRQ88tlm6rjdcTEk0o/aKbU+nO3HyRfGILrYmK/sVUe6PLCQV7xmwfwEwUPh N8/srD+l95HcesdM9wSq7C9E0KcpjD9+nzs+t/wC4ArVwVGR/eqML1/4PJUrZItRtBNGQ8 DCAVTWGl/hcxEbXLu9642w1uiRyeVkM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770629; 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=32oWMLYxHK1bctb+3A1F7epM0ZGxRvTTPkuEwYrWqxM=; b=BXCb4whNtpvw5N5Xrrt63firv3AiQIZcj0UJPZha0DFxWlTN2xcwGtDMFHrgeh6ucwFAJT /SB4YnspfbfQPwBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="dyeOtG2/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=MU6bhO8q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770625; 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=32oWMLYxHK1bctb+3A1F7epM0ZGxRvTTPkuEwYrWqxM=; b=dyeOtG2/DboAKC12aTNvB2RCwUIaPB3w5ylohvn80VTF9pEXVF2ZG0AAP/ibKtrGG/LgYm hzarLnMS/ptzplk2eeYTdVGAp5O0PNEpmcpDWIjkrRm4+qJDqlAcHMf5wiR7AZsfsdDGal rSwdKo6fuLEXdK5v9z/6ZGA7viM+GnA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770625; 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=32oWMLYxHK1bctb+3A1F7epM0ZGxRvTTPkuEwYrWqxM=; b=MU6bhO8qVWyWpDfTxKZk9YIJxOMNkSiWXO8bfeJrYs3Tokp7+TELlJSAIAr5gGlZp5h5OX DIRmwJw2PflY+FAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 12/14] qemu-options: merge warn and help flags Date: Fri, 18 Sep 2026 19:29:59 -0300 Message-ID: <20260918223002.1892021-13-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: B15342000B 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)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; 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:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email,suse.de:mid]; 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=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: 1789770696230158500 Content-Type: text/plain; charset="utf-8" There's no need to propagate two separate flags to perform the "noisy" parsing. The catch is that the opposite scenario, the "silent" parsing never sets the flags and always uses the Error object, so we can just push the opts_accepts_any() check that is exclusive to the noisy case down the stack. Signed-off-by: Fabiano Rosas --- util/qemu-option.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 94e06b194d..8dadb47170 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -813,8 +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 **err= p) + const char *firstname, bool noisily, Error **err= p) { const char *p; QemuOpt *opt; @@ -827,13 +826,15 @@ static bool opts_do_parse(QemuOpts *opts, const char = *params, =20 p =3D get_opt_name_value(p, firstname, &is_help, &option, &value, = &warn); =20 - if (warn_on_flag && warn) { - warn_report_err(warn); - } + if (noisily) { + if (warn) { + warn_report_err(warn); + } =20 - if (help_wanted && is_help) { - qemu_opts_print_help(opts->list, true); - return false; + if (is_help && !opts_accepts_any(opts->list)) { + qemu_opts_print_help(opts->list, true); + return false; + } } firstname =3D NULL; =20 @@ -895,12 +896,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, false, errp); + return opts_do_parse(opts, params, firstname, false, errp); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, - bool permit_abbrev, - bool warn_on_flag, bool help_wanted, Error **e= rrp) + bool permit_abbrev, bool noisily, Error **errp) { const char *firstname; char *id =3D opts_parse_id(params); @@ -911,8 +911,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, =20 opts =3D qemu_opts_create(list, id, !list->merge_lists, errp); g_free(id); - if (!opts || !opts_do_parse(opts, params, firstname, - warn_on_flag, help_wanted, errp)) { + if (!opts || !opts_do_parse(opts, params, firstname, noisily, errp)) { qemu_opts_del(opts); return NULL; } @@ -956,15 +955,14 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, co= nst char *params, =20 if (noisily) { Error *err =3D NULL; - bool help_wanted =3D !opts_accepts_any(list); =20 - opts =3D opts_parse(list, params, permit_abbrev, true, help_wanted= , &err); + opts =3D opts_parse(list, params, permit_abbrev, noisily, &err); if (!opts && err) { error_report_err(err); } =20 } else { - opts =3D opts_parse(list, params, permit_abbrev, false, false, err= p); + opts =3D opts_parse(list, params, permit_abbrev, noisily, errp); } =20 return opts; --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770699; cv=none; d=zohomail.com; s=zohoarc; b=cyFRpLhk/kJxJZgH1uGxItBDanpVPRHthk8DXV6bWMishmhTmA3kx6pIa+MbqVks9bzFXNaYnbPjk8Xalwe0q+xkHuHIei0QUmLz/HktZG0hUX/2d6dnCDGZHjHXo01IqWIr+Skofd+6D16mqCoRL9PFEGc7kt2bb+R2NSxHQJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770699; 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=WfrKmIFuG5uSEY1zSMZt8t3wRpCkwiQiryE/71OpRkw=; b=X20/QTmnzyfEb3p27rBpTuaxcamfMUdKvv/WTF7EIGNKvSYdDiB0EnK8H8sUxICleNDOOPaiY5WezdqrxlxZxl7dBl91/UGvmR+2IwZdMZ7STvpgGhdwT9V0ouoOpm8pYxb2rNyPhz/bw6nezlUSO6TL1XhWW6FACQJ7MrMvuOE= 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 1789770699287252.41491668479182; Fri, 18 Sep 2026 15:31:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6N-000858-67; Fri, 18 Sep 2026 18:30:39 -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 1x7h6L-00081x-SJ for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:37 -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 1x7h6K-0000gI-DY for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30: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 CF32520005; Fri, 18 Sep 2026 22:30:26 +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 EFAB61348F; Fri, 18 Sep 2026 22:30: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 hQIbBW27rWrsdQAAD6G6ig:T14 (envelope-from ); Fri, 18 Sep 2026 22:30:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770631; 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=WfrKmIFuG5uSEY1zSMZt8t3wRpCkwiQiryE/71OpRkw=; b=zvyJObeAWZI6DbQtRysou5Hy1URI+rRfjA/imTUAJKR5uiyTKhoepSRl7LGtN2mfBWBCQo w8UiCI0FbO3AhdWuklzoej+2jxFUHiU4g4qcIa+GDVm2bVLCYTlPFyA+u9KZAgb7wV3+gp b7mS0BmKD8GSDTt8MVypKBtmTgdUi6A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770631; 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=WfrKmIFuG5uSEY1zSMZt8t3wRpCkwiQiryE/71OpRkw=; b=mW6FZHJT30fe/MO2e3LYHFnt2iQr6ELJdAjsIyj8qCTCrV+DW84okxq6Rsfbn3trGG2vRJ WHTL/7QKNL/beYAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GhmSCi9p; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=uwMep+1Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770626; 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=WfrKmIFuG5uSEY1zSMZt8t3wRpCkwiQiryE/71OpRkw=; b=GhmSCi9pPW5su/SMwxTOoV3U27awY8+GSjFOJ0BYxJblQ7WAODT+fD7JUggFx2O4m/f7tG 5V5mEESmVhRN4+tsyuYei+HOB8XisLXkMfbOjb0t9EgPiESheoVmpOdAzkH/53AzVci7Ha 4FT0gNa/9rili7Znn2y6EfiNOMKSjEk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770626; 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=WfrKmIFuG5uSEY1zSMZt8t3wRpCkwiQiryE/71OpRkw=; b=uwMep+1ZER7+vSYTyHlllsZZ/S5CxIhPA1ZlwsBGxIHsqeafu08l/Xw9+1hd5scNPEcz7+ sNF9/j7Np7bGLYBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 13/14] qemu-options: Further simplify qemu_opts_parse_list() Date: Fri, 18 Sep 2026 19:30:00 -0300 Message-ID: <20260918223002.1892021-14-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Queue-Id: CF32520005 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_TWO(0.00)[2]; 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_TLS_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]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] 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: 1789770702233158500 Content-Type: text/plain; charset="utf-8" Now that the two branches of this function are similar, turn it into a single call to opts_parse(). Signed-off-by: Fabiano Rosas --- util/qemu-option.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 8dadb47170..1e8042a1bd 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -950,19 +950,18 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, co= nst char *params, { bool noisily =3D !errp; QemuOpts *opts =3D NULL; + Error *err =3D NULL; =20 assert(list); + opts =3D opts_parse(list, params, permit_abbrev, noisily, &err); =20 - if (noisily) { - Error *err =3D NULL; - - opts =3D opts_parse(list, params, permit_abbrev, noisily, &err); - if (!opts && err) { + if (!opts) { + assert(err); + if (noisily) { error_report_err(err); + } else { + error_propagate(errp, err); } - - } else { - opts =3D opts_parse(list, params, permit_abbrev, noisily, errp); } =20 return opts; --=20 2.53.0 From nobody Sat Sep 26 20:01:43 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=1789770695; cv=none; d=zohomail.com; s=zohoarc; b=WsEl8FE1vInWXCC5kjP7SK0Y4LIcuP+jW6bpNsyxjZx83/aZAofHfA5xvjkNdrbn70ABF8xbm9BmQgbsZmByr5KoO+5GlWk6ZcWCr03TvkPgkc/LVG/XGok+CuVysoiwyigDVD/aMf1n73xvlKadwLNMaiwq1EdTPZhHL3Atchk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789770695; 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=YxYkFADoxXyzATxVbB7JPwava2v3rFjGlNEKscFuAZY=; b=FkZcUy2EgHS3kVIWoj2yOPYT3byXk0b4b20oXz9um8G7aD5InajZq5++IxJu+dRDMuZRNmU0krBSm4bIo3ykz/JduymmNtJZE4WOmXnblnFjubIhluwWjDr4iISGbwxHZMeDgQPJ7li4lGdWPt/0J4kUAfPWJakO6kaULp4dOgg= 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 1789770695957288.9184402047283; Fri, 18 Sep 2026 15:31:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x7h6P-00088F-Fl; Fri, 18 Sep 2026 18:30:41 -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 1x7h6N-00085U-Aa for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30:39 -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 1x7h6L-0000gZ-F7 for qemu-devel@nongnu.org; Fri, 18 Sep 2026 18:30: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 EEFA42000C; Fri, 18 Sep 2026 22:30: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 1A9C3139B6; Fri, 18 Sep 2026 22:30:26 +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 hQIbBW27rWrsdQAAD6G6ig:T15 (envelope-from ); Fri, 18 Sep 2026 22:30:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770632; 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=YxYkFADoxXyzATxVbB7JPwava2v3rFjGlNEKscFuAZY=; b=Ef18YtTUPYxOsAGduk17AolLHhdYIcjwNSDUg9B8ggN/ZPMn6czCSXnzYZQCSXn3B3KpfU snic5Fswc3YY2zokHfJEzB+K2PIGZm05z1RW45iy44cf35fo7uhotjhsjZZnFaHMZRjlcJ /hgOqpL/+9yMYwTIEmjMaNASlZDuuSM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770632; 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=YxYkFADoxXyzATxVbB7JPwava2v3rFjGlNEKscFuAZY=; b=u0LBExaQEpIbH8gUvCeFwo+FtJsnXE+CtsRVeTYBx2dSSLkXd1/lT5daMSCr6nfLyoVeeh QQONriYs7fWCVwDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1789770627; 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=YxYkFADoxXyzATxVbB7JPwava2v3rFjGlNEKscFuAZY=; b=SwkG98DHW8LOKBSwnzrulzli2BSxYY/hSRLKQzunUBdn+ca1NimxcdeU+kOvSXmJyTvQ1u SHY3zU4JJ/IR1m8J3PWIe9hAnDVnsBzyW2e52t1ZwGf1bBeRmVu1Q+QsudM3ZxWwZNJ8Xs jioN3qCUvFi0VvwlLa+Wihg40p+y34o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1789770627; 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=YxYkFADoxXyzATxVbB7JPwava2v3rFjGlNEKscFuAZY=; b=elp7zBK7+qqiuavyNLb7D446gpd0oLubRIEJrc7M/v6/Rwkgide5eyqfM0NUNBHIO7cNFi Z9nLYgiOZMjlaeCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [RFC PATCH 14/14] qemu-options: Remove opts_parse() Date: Fri, 18 Sep 2026 19:30:01 -0300 Message-ID: <20260918223002.1892021-15-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918223002.1892021-1-farosas@suse.de> References: <20260918223002.1892021-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 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.997]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; 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)[]; TO_DN_SOME(0.00)[]; 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)[] 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: 1789770696240158500 Content-Type: text/plain; charset="utf-8" There's only one caller of opts_parse(): qemu_opts_parse_list(). Merge the two functions. Signed-off-by: Fabiano Rosas --- util/qemu-option.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 1e8042a1bd..167c81c17a 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -899,26 +899,6 @@ bool qemu_opts_do_parse(QemuOpts *opts, const char *pa= rams, return opts_do_parse(opts, params, firstname, false, errp); } =20 -static QemuOpts *opts_parse(QemuOptsList *list, const char *params, - bool permit_abbrev, bool noisily, Error **errp) -{ - const char *firstname; - char *id =3D opts_parse_id(params); - QemuOpts *opts; - - assert(!permit_abbrev || list->implied_opt_name); - firstname =3D permit_abbrev ? list->implied_opt_name : NULL; - - opts =3D qemu_opts_create(list, id, !list->merge_lists, errp); - g_free(id); - if (!opts || !opts_do_parse(opts, params, firstname, noisily, errp)) { - qemu_opts_del(opts); - return NULL; - } - - return opts; -} - /** * Find the @group and create a QemuOpts with options parsed from * @params. If @permit_abbrev, the first key=3Dvalue in @params may @@ -948,20 +928,27 @@ QemuOpts *qemu_opts_parse(const char *group, const ch= ar *params, QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { + const char *firstname; + g_autofree char *id =3D opts_parse_id(params); bool noisily =3D !errp; QemuOpts *opts =3D NULL; Error *err =3D NULL; =20 assert(list); - opts =3D opts_parse(list, params, permit_abbrev, noisily, &err); + assert(!permit_abbrev || list->implied_opt_name); + + firstname =3D permit_abbrev ? list->implied_opt_name : NULL; + + opts =3D qemu_opts_create(list, id, !list->merge_lists, &err); + if (!opts || !opts_do_parse(opts, params, firstname, noisily, &err)) { + qemu_opts_del(opts); =20 - if (!opts) { - assert(err); if (noisily) { error_report_err(err); } else { error_propagate(errp, err); } + return NULL; } =20 return opts; --=20 2.53.0