From nobody Fri May 17 05:54:50 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604417441; cv=none; d=zohomail.com; s=zohoarc; b=FIT4x3Nap+DD5zp0JqRggRSFEOkif7ySy/81E/SUsxp1t8s3rgOlkKHpDpDYEyJGlc0JkkkEA3XKuLUVRZ32bwxFy+QkUFq7mqsaa0NtPxA/S3yeZnZtF7pnhPKLRU2YGQt2qmWSgAxc8YhYKrxYOhOR3GHQ47MGQ4hbD+lztuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604417441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M10GQeYmnUrpQ9+MTbe43h9XrmzLCk+hoOUrwZE6wSc=; b=TyfcQhH+gX4cCgOxtcRytta3p5kkLB3H16nJnW04CqaS4eCsdUoozZ6k5KEgSwFtBsTxr4kbIRLO0D90R1N3LYZYkUIBvyYZ4BF3dZK8YEkhrLhQmRJJeCNEuTRnOeJdc9l+dzjkP1AoGu/TT3Anrl4orLwrgRIYKjHfmPTCNFw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604417441825713.9903792067563; Tue, 3 Nov 2020 07:30:41 -0800 (PST) Received: from localhost ([::1]:32802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyGd-0004kc-5F for importer@patchew.org; Tue, 03 Nov 2020 10:30:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZy1U-0002Cd-KH for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kZy1S-0002uf-Bz for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:14:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-unwJsK31PomFQl1me51p1A-1; Tue, 03 Nov 2020 10:14:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CCE681018F60 for ; Tue, 3 Nov 2020 15:14:53 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E1DD100239A; Tue, 3 Nov 2020 15:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604416496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M10GQeYmnUrpQ9+MTbe43h9XrmzLCk+hoOUrwZE6wSc=; b=c6mVh5QXPxHrErWdyJZQIMY5lQg6tgzWVfGEK0gcHT1gwNaTHc81Tvq6H4iqFWerzhSgr8 WvzEgY4XssBmvR+I/zzYjxGTeBcu2UDnfLVx5jyNnFa5xASh9ms1K0VPaR65sOTuI/WMqt Bmdied7Zdl2AWLIHBAsQKx4TxTiietY= X-MC-Unique: unwJsK31PomFQl1me51p1A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 1/4] ivshmem-test: do not use short-form boolean option Date: Tue, 3 Nov 2020 10:14:49 -0500 Message-Id: <20201103151452.416784-2-pbonzini@redhat.com> In-Reply-To: <20201103151452.416784-1-pbonzini@redhat.com> References: <20201103151452.416784-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This QemuOpts idiom will be deprecated, so get rid of it in the tests. Signed-off-by: Paolo Bonzini Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth --- tests/qtest/ivshmem-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c index d5c8b9f128..dfa69424ed 100644 --- a/tests/qtest/ivshmem-test.c +++ b/tests/qtest/ivshmem-test.c @@ -135,7 +135,7 @@ static void setup_vm_cmd(IVState *s, const char *cmd, b= ool msix) static void setup_vm(IVState *s) { char *cmd =3D g_strdup_printf("-object memory-backend-file" - ",id=3Dmb1,size=3D1M,share,mem-path=3D/dev= /shm%s" + ",id=3Dmb1,size=3D1M,share=3Don,mem-path= =3D/dev/shm%s" " -device ivshmem-plain,memdev=3Dmb1", tmp= shm); =20 setup_vm_cmd(s, cmd, false); --=20 2.26.2 From nobody Fri May 17 05:54:50 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604416758; cv=none; d=zohomail.com; s=zohoarc; b=etpfWbBX+EcOlU4D1lgBM+xJBRiXlnL5dDTwQHn/Vuhec/Ch+9UzuQIy0SgD8bJHLQDzb13ylaLZQZEGJxkc+Kd5O4K5/bmmvI+t0urml05qXlDkde7GCUcu21TBXGcsMDVO1BFzFPlNOrgaMlgsNPI+v2b6q02dSyyBJHwNOr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604416758; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iIXZc7JoR5bpYG+uhyyignMWIehfTtEWJo7IhSVzeAc=; b=QAApAmm4MWEB+1ZHLk33GPsr6bzC9IEFh7F7LUIw2PpmncPqnyS262+e4Qxhg6c+Oxaf//FxIH6aH2pJi12ta5ed3l0z6EpGk3Q6f8eH9QtEcGDxteK+kpyemF0zlvgyeVD4LKuAzRujXxK2LDpX4FKrlIi1YC5W2toyAra/ojo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604416758071569.5173372419121; Tue, 3 Nov 2020 07:19:18 -0800 (PST) Received: from localhost ([::1]:51916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZy5d-000651-CU for importer@patchew.org; Tue, 03 Nov 2020 10:19:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZy1W-0002FZ-TT for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kZy1S-0002vx-T3 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-OLdSudozN0izGz3SGq7Lcw-1; Tue, 03 Nov 2020 10:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47ACF1018F7D for ; Tue, 3 Nov 2020 15:14:54 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED3AB10016DA; Tue, 3 Nov 2020 15:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604416498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iIXZc7JoR5bpYG+uhyyignMWIehfTtEWJo7IhSVzeAc=; b=Mk2cXzFSAZsugyUdd9OGTVtT0TVhhcYHK9S3IN5cRefUyer3UnIfhNCT9m8krszuRMfFSk 2LBeqhjN9BdexCTXYjCXJjCBz5u/UnYVnMEYwvAywXrFfJ1cBJegU8+R18JFCUGnWi1KrR B6ZhvAulXFhfpnuYDXG0zGcFHh50D8Y= X-MC-Unique: OLdSudozN0izGz3SGq7Lcw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 2/4] qemu-option: move help handling to get_opt_name_value Date: Tue, 3 Nov 2020 10:14:50 -0500 Message-Id: <20201103151452.416784-3-pbonzini@redhat.com> In-Reply-To: <20201103151452.416784-1-pbonzini@redhat.com> References: <20201103151452.416784-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Right now, help options are parsed normally and then checked specially in opt_validate---but only if coming from qemu_opts_parse or qemu_opts_parse_noisily, not if coming from qemu_opt_set. Instead, move the check from opt_validate to the common workhorses of qemu_opts_parse and qemu_opts_parse_noisily, opts_do_parse and get_opt_name_value. This will come in handy in a subsequent patch, which will raise a warning for "-object memory-backend-ram,share" ("flag" option with no =3Don/=3Doff part) but not for "-object memory-backend-ram,help". Signed-off-by: Paolo Bonzini --- util/qemu-option.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index b9f93a7f8b..5824b7afe2 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -520,17 +520,13 @@ static QemuOpt *opt_create(QemuOpts *opts, const char= *name, char *value, return opt; } =20 -static bool opt_validate(QemuOpt *opt, bool *help_wanted, - Error **errp) +static bool opt_validate(QemuOpt *opt, Error **errp) { const QemuOptDesc *desc; =20 desc =3D find_desc_by_name(opt->opts->list->desc, opt->name); if (!desc && !opts_accepts_any(opt->opts)) { error_setg(errp, QERR_INVALID_PARAMETER, opt->name); - if (help_wanted && is_help_option(opt->name)) { - *help_wanted =3D true; - } return false; } =20 @@ -547,7 +543,7 @@ bool qemu_opt_set(QemuOpts *opts, const char *name, con= st char *value, { QemuOpt *opt =3D opt_create(opts, name, g_strdup(value), false); =20 - if (!opt_validate(opt, NULL, errp)) { + if (!opt_validate(opt, errp)) { qemu_opt_del(opt); return false; } @@ -783,14 +779,17 @@ void qemu_opts_print(QemuOpts *opts, const char *sepa= rator) =20 static const char *get_opt_name_value(const char *params, const char *firstname, + bool *help_wanted, char **name, char **value) { - const char *p, *pe, *pc; - - pe =3D strchr(params, '=3D'); - pc =3D strchr(params, ','); + const char *p; + size_t len; =20 - if (!pe || (pc && pc < pe)) { + len =3D strcspn(params, "=3D,"); + if (params[len] !=3D '=3D') { + if (help_wanted && starts_with_help_option(params) =3D=3D len) { + *help_wanted =3D true; + } /* found "foo,more" */ if (firstname) { /* implicitly named first option */ @@ -830,7 +829,10 @@ static bool opts_do_parse(QemuOpts *opts, const char *= params, QemuOpt *opt; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, firstname, &option, &value); + p =3D get_opt_name_value(p, firstname, help_wanted, &option, &valu= e); + if (help_wanted && *help_wanted) { + return false; + } firstname =3D NULL; =20 if (!strcmp(option, "id")) { @@ -841,7 +843,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *p= arams, =20 opt =3D opt_create(opts, option, value, prepend); g_free(option); - if (!opt_validate(opt, help_wanted, errp)) { + if (!opt_validate(opt, errp)) { qemu_opt_del(opt); return false; } @@ -856,7 +858,7 @@ static char *opts_parse_id(const char *params) char *name, *value; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, NULL, &name, &value); + p =3D get_opt_name_value(p, NULL, NULL, &name, &value); if (!strcmp(name, "id")) { g_free(name); return value; @@ -872,11 +874,10 @@ bool has_help_option(const char *params) { const char *p; char *name, *value; - bool ret; + bool ret =3D false; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, NULL, &name, &value); - ret =3D is_help_option(name); + p =3D get_opt_name_value(p, NULL, &ret, &name, &value); g_free(name); g_free(value); if (ret) { --=20 2.26.2 From nobody Fri May 17 05:54:50 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604416866; cv=none; d=zohomail.com; s=zohoarc; b=SCb2k+g3LDQONqAlVeyuR2YyLyH9p3UfUPL7vXlcyaGIiVadOVVpx5D4uiKw5I1ZjFw02QBw5d0ze+G/V9NFRaLU0NT05xl2gdHgJZmBS8pbZRH/hmaKVvO8ELJg2vCNvY4fmqSDU3MmCMqZYbbwS3z3o+dt7JmEsV5LWRJhZco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604416866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1jBDGMGT/1tJgzyUvHiZlF/GlXJL28Sljhs100quxes=; b=PL1u1SHvpY4F57ZU0gPcXX+5dTcX3QZVBHkhpK9pK/L9idPkrtjFj/ozu5552PtrieS6lvAZQ25aa7HLUr6JIu4qFvx1hGTFCuLCPdE0QRznUqHpE7aHrF2WplC20LnCDPCNd839Zj2OVWLvyAdJCm6fNL5icLHpzc6zVFomx30= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604416866126839.8156054842473; Tue, 3 Nov 2020 07:21:06 -0800 (PST) Received: from localhost ([::1]:58154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZy7M-0000GM-RZ for importer@patchew.org; Tue, 03 Nov 2020 10:21:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZy1X-0002GT-GG for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kZy1T-0002w7-DT for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-TXJDkYKqMaGPOB8tLRcczQ-1; Tue, 03 Nov 2020 10:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6F511018F81 for ; Tue, 3 Nov 2020 15:14:54 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68535100238E; Tue, 3 Nov 2020 15:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604416498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1jBDGMGT/1tJgzyUvHiZlF/GlXJL28Sljhs100quxes=; b=RLpON3p4DB7pyAp/ISdOwleuzQAHM/FdU37w3H+8ZrdiOqsI59tMD1EnrmObLTjMFdp95d ypCAk0r4oqe7B5S5wFCIFPZ71f5VbGqQHVwW2RPmojiO9/URjIuIBIdixgQLnLf9kdDWh7 HgV8Ja0fgERjVCCBEW8FipW+XfwxE/Y= X-MC-Unique: TXJDkYKqMaGPOB8tLRcczQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 3/4] qtest: escape device name in device-introspect-test Date: Tue, 3 Nov 2020 10:14:51 -0500 Message-Id: <20201103151452.416784-4-pbonzini@redhat.com> In-Reply-To: <20201103151452.416784-1-pbonzini@redhat.com> References: <20201103151452.416784-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" device-introspect-test uses HMP, so it should escape the device name properly. Because of this, a few devices that had commas in their names were escaping testing. Signed-off-by: Paolo Bonzini --- tests/qtest/device-introspect-test.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/qtest/device-introspect-test.c b/tests/qtest/device-intr= ospect-test.c index 9f22340ee5..f471b0e0dd 100644 --- a/tests/qtest/device-introspect-test.c +++ b/tests/qtest/device-introspect-test.c @@ -104,7 +104,9 @@ static QList *device_type_list(QTestState *qts, bool ab= stract) static void test_one_device(QTestState *qts, const char *type) { QDict *resp; - char *help; + g_autofree char *help; + g_autofree GRegex *comma; + g_autofree char *escaped; =20 g_test_message("Testing device '%s'", type); =20 @@ -113,8 +115,9 @@ static void test_one_device(QTestState *qts, const char= *type) type); qobject_unref(resp); =20 - help =3D qtest_hmp(qts, "device_add \"%s,help\"", type); - g_free(help); + comma =3D g_regex_new(",", 0, 0, NULL); + escaped =3D g_regex_replace_literal(comma, type, -1, 0, ",,", 0, NULL); + help =3D qtest_hmp(qts, "device_add \"%s,help\"", escaped); } =20 static void test_device_intro_list(void) --=20 2.26.2 From nobody Fri May 17 05:54:50 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604416630; cv=none; d=zohomail.com; s=zohoarc; b=GDnfX9ZPlLXqj77Ipy5f7ku0i1wPrlrbyxk94PobzVwYUV61XGyADe6krJLPOw1bLIJh2fCFZYLOx8enIOXeClespkVlDq1t/FOhcRHQEH1bIXz8XtHfQYP0FQbOqlSibCKr0qjlNPrhWNwDtEXyiBc7vb0NhBc0Vv8F6bUA6O8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604416630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xX3PJZ/vpF37kgHozJbvLL9WXGA1QJlGImPglV7fUf4=; b=JaqbOkTn3wjAQZcOEMF88B2IBiaB6OBcCxPGKyh4GUHa3wovFA+/qhDU817iLTdJ+m6fCGy6ZwRwbnPHmhXu9PfbJNvK9W1f/E10zmDZG1+9ioJkp+bD/OmRQmEFJPQNMVhZRfzdLLqNywPzinWZmdbo6+7HFIFTZzTASb3zglY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604416630484171.71399153534662; Tue, 3 Nov 2020 07:17:10 -0800 (PST) Received: from localhost ([::1]:46352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZy3Z-0003kL-Pq for importer@patchew.org; Tue, 03 Nov 2020 10:17:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZy1V-0002ES-Uo for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kZy1S-0002vY-RM for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:15:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-D_8eCKaSPsW-USEbPWdJHQ-1; Tue, 03 Nov 2020 10:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33E9E80B72B for ; Tue, 3 Nov 2020 15:14:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7FDC10016DA; Tue, 3 Nov 2020 15:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604416497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xX3PJZ/vpF37kgHozJbvLL9WXGA1QJlGImPglV7fUf4=; b=BTw8nn+CnWqA4eMK3AkbTFielxSlXYSEoCnqYHXdbwG7Babk8heSJPOfht+dcbJ34CnLIL K857es918SNPXyIyl0Jk10bXWiUjZKu5lBx6xc1weipIoSyWGmj3aKVb51cAy1/T8QbkTz HGaoDf98YgcB/7z9h2OQm4xK1MLdF+w= X-MC-Unique: D_8eCKaSPsW-USEbPWdJHQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 4/4] qemu-option: warn for short-form boolean options Date: Tue, 3 Nov 2020 10:14:52 -0500 Message-Id: <20201103151452.416784-5-pbonzini@redhat.com> In-Reply-To: <20201103151452.416784-1-pbonzini@redhat.com> References: <20201103151452.416784-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Options such as "server" or "nowait", that are commonly found in -chardev, are sugar for "server=3Don" and "wait=3Doff". This is quite surprising and also does not have any notion of typing attached. It is even possible to do "-device e1000,noid" and get a device with "id=3Doff". Deprecate all this, except for -chardev and -spice where it is in wide use. Signed-off-by: Paolo Bonzini --- chardev/char.c | 1 + docs/system/deprecated.rst | 7 +++++++ include/qemu/option.h | 1 + tests/test-qemu-opts.c | 1 + ui/spice-core.c | 1 + util/qemu-option.c | 22 +++++++++++++++------- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 78553125d3..108da615df 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -829,6 +829,7 @@ Chardev *qemu_chr_find(const char *name) =20 QemuOptsList qemu_chardev_opts =3D { .name =3D "chardev", + .allow_flag_options =3D true, /* server, nowait, etc. */ .implied_opt_name =3D "backend", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), .desc =3D { diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 32a0e620db..0e7edf7e56 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -146,6 +146,13 @@ Drives with interface types other than ``if=3Dnone`` a= re for onboard devices. It is possible to use drives the board doesn't pick up with -device. This usage is now deprecated. Use ``if=3Dnone`` instead. =20 +Short-form boolean options (since 5.2) +'''''''''''''''''''''''''''''''''''''' + +Boolean options such as ``share=3Don``/``share=3Doff`` can be written +in short form as ``share`` and ``noshare``. This is deprecated +for all command-line options except ``-chardev` and ``-spice``, for +which the short form was in wide use. =20 QEMU Machine Protocol (QMP) commands ------------------------------------ diff --git a/include/qemu/option.h b/include/qemu/option.h index ac69352e0e..046ac06a1f 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -65,6 +65,7 @@ struct QemuOptsList { const char *name; const char *implied_opt_name; bool merge_lists; /* Merge multiple uses of option into a single list= ? */ + bool allow_flag_options; /* Whether to warn for short-form boolean opt= ions */ QTAILQ_HEAD(, QemuOpts) head; QemuOptDesc desc[]; }; diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 297ffe79dd..a74c475773 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -77,6 +77,7 @@ static QemuOptsList opts_list_02 =3D { static QemuOptsList opts_list_03 =3D { .name =3D "opts_list_03", .implied_opt_name =3D "implied", + .allow_flag_options =3D true, .head =3D QTAILQ_HEAD_INITIALIZER(opts_list_03.head), .desc =3D { /* no elements =3D> accept any params */ diff --git a/ui/spice-core.c b/ui/spice-core.c index eea52f5389..08f834fa41 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -397,6 +397,7 @@ static SpiceChannelList *qmp_query_spice_channels(void) =20 static QemuOptsList qemu_spice_opts =3D { .name =3D "spice", + .allow_flag_options =3D true, /* disable-agent-file-xfer, sasl, unix, = etc. */ .head =3D QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), .merge_lists =3D true, .desc =3D { diff --git a/util/qemu-option.c b/util/qemu-option.c index 5824b7afe2..8b6050fbf7 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -779,16 +779,19 @@ void qemu_opts_print(QemuOpts *opts, const char *sepa= rator) =20 static const char *get_opt_name_value(const char *params, const char *firstname, + bool warn_on_flag, bool *help_wanted, char **name, char **value) { const char *p; + const char *prefix =3D ""; size_t len; =20 len =3D strcspn(params, "=3D,"); if (params[len] !=3D '=3D') { if (help_wanted && starts_with_help_option(params) =3D=3D len) { *help_wanted =3D true; + warn_on_flag =3D false; } /* found "foo,more" */ if (firstname) { @@ -801,9 +804,14 @@ static const char *get_opt_name_value(const char *para= ms, if (strncmp(*name, "no", 2) =3D=3D 0) { memmove(*name, *name + 2, strlen(*name + 2) + 1); *value =3D g_strdup("off"); + prefix =3D "no"; } else { *value =3D g_strdup("on"); } + if (warn_on_flag) { + error_report("short-form boolean option '%s%s' deprecated"= , prefix, *name); + error_printf("Please use %s=3D%s instead\n", *name, *value= ); + } } } else { /* found "foo=3Dbar,more" */ @@ -822,14 +830,14 @@ static const char *get_opt_name_value(const char *par= ams, =20 static bool opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, bool prepend, - bool *help_wanted, Error **errp) + bool warn_on_flag, bool *help_wanted, Error **er= rp) { char *option, *value; const char *p; QemuOpt *opt; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, firstname, help_wanted, &option, &valu= e); + p =3D get_opt_name_value(p, firstname, warn_on_flag, help_wanted, = &option, &value); if (help_wanted && *help_wanted) { return false; } @@ -858,7 +866,7 @@ static char *opts_parse_id(const char *params) char *name, *value; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, NULL, NULL, &name, &value); + p =3D get_opt_name_value(p, NULL, false, NULL, &name, &value); if (!strcmp(name, "id")) { g_free(name); return value; @@ -877,7 +885,7 @@ bool has_help_option(const char *params) bool ret =3D false; =20 for (p =3D params; *p;) { - p =3D get_opt_name_value(p, NULL, &ret, &name, &value); + p =3D get_opt_name_value(p, NULL, false, &ret, &name, &value); g_free(name); g_free(value); if (ret) { @@ -897,7 +905,7 @@ 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, NULL, errp= ); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, @@ -925,8 +933,8 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, return NULL; } =20 - if (!opts_do_parse(opts, params, firstname, defaults, help_wanted, - errp)) { + if (!opts_do_parse(opts, params, firstname, defaults, + !list->allow_flag_options, help_wanted, errp)) { qemu_opts_del(opts); return NULL; } --=20 2.26.2