From nobody Sun Feb 8 19:39:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613480281441261.3050630459519; Tue, 16 Feb 2021 04:58:01 -0800 (PST) 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-594-egx8AYcXNkWVVVK0jnNTSw-1; Tue, 16 Feb 2021 07:57:58 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F8261020C21; Tue, 16 Feb 2021 12:57:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE6BE5D9CD; Tue, 16 Feb 2021 12:57:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A47D418095CD; Tue, 16 Feb 2021 12:57:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11GCvo9j002362 for ; Tue, 16 Feb 2021 07:57:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 59CAC60C6B; Tue, 16 Feb 2021 12:57:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-215.ams2.redhat.com [10.36.112.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6165E60C62; Tue, 16 Feb 2021 12:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613480280; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9JhrP8W260Q5jqEDoyzu7vMkE+Od5hqV2tEM+fYTLPI=; b=Gv8EptvykcOI13HCHtEWku+WjxILMTRBYpd6RWuUxzJPtvAxZYop9QNIXLEQdTbHqAzoud lH53uLjAW4L0tvz7AM3LRi28T9NWiUuClEWsjOOlXx16FKb81UkXt6B5yKXY2VewsmXuO1 +XEzs/OjSXodA4lMcRpP9VYlU/0tdWg= X-MC-Unique: egx8AYcXNkWVVVK0jnNTSw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] qemu: remove support for generating yes|no boolean options Date: Tue, 16 Feb 2021 12:57:05 +0000 Message-Id: <20210216125705.275788-6-berrange@redhat.com> In-Reply-To: <20210216125705.275788-1-berrange@redhat.com> References: <20210216125705.275788-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) All callers are now using the on|off syntax, so yes|no is a unreachable code path. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virqemu.c | 50 +++++++++++++------------------------ src/util/virqemu.h | 10 +++----- tests/qemucommandutiltest.c | 10 ++++---- 3 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 5b0dc25bc1..57ee42dd16 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -37,7 +37,6 @@ struct virQEMUCommandLineJSONIteratorData { const char *prefix; virBufferPtr buf; const char *skipKey; - bool onOff; virQEMUBuildCommandLineJSONArrayFormatFunc arrayFunc; }; =20 @@ -47,7 +46,6 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, virJSONValuePtr value, virBufferPtr buf, const char *skipKey, - bool onOff, virQEMUBuildCommandLineJSONArrayFormatF= unc arrayFunc, bool nested); =20 @@ -57,8 +55,7 @@ int virQEMUBuildCommandLineJSONArrayBitmap(const char *key, virJSONValuePtr array, virBufferPtr buf, - const char *skipKey G_GNUC_UNUSED, - bool onOff G_GNUC_UNUSED) + const char *skipKey G_GNUC_UNUSED) { ssize_t pos =3D -1; ssize_t end; @@ -87,8 +84,7 @@ int virQEMUBuildCommandLineJSONArrayNumbered(const char *key, virJSONValuePtr array, virBufferPtr buf, - const char *skipKey, - bool onOff) + const char *skipKey) { virJSONValuePtr member; size_t i; @@ -99,7 +95,7 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key, member =3D virJSONValueArrayGet((virJSONValuePtr) array, i); prefix =3D g_strdup_printf("%s.%zu", key, i); =20 - if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKe= y, onOff, + if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKe= y, virQEMUBuildCommandLineJSON= ArrayNumbered, true) < 0) return 0; @@ -125,8 +121,7 @@ static int virQEMUBuildCommandLineJSONArrayObjectsStr(const char *key, virJSONValuePtr array, virBufferPtr buf, - const char *skipKey G_GNUC_UNUS= ED, - bool onOff G_GNUC_UNUSED) + const char *skipKey G_GNUC_UNUS= ED) { g_auto(virBuffer) tmp =3D VIR_BUFFER_INITIALIZER; size_t i; @@ -163,11 +158,11 @@ virQEMUBuildCommandLineJSONIterate(const char *key, tmpkey =3D g_strdup_printf("%s.%s", data->prefix, key); =20 return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf, - data->skipKey, data->onO= ff, + data->skipKey, data->arrayFunc, false); } else { return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, - data->skipKey, data->onO= ff, + data->skipKey, data->arrayFunc, false); } } @@ -178,11 +173,10 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, virJSONValuePtr value, virBufferPtr buf, const char *skipKey, - bool onOff, virQEMUBuildCommandLineJSONArrayFormatF= unc arrayFunc, bool nested) { - struct virQEMUCommandLineJSONIteratorData data =3D { key, buf, skipKey= , onOff, arrayFunc }; + struct virQEMUCommandLineJSONIteratorData data =3D { key, buf, skipKey= , arrayFunc }; virJSONType type =3D virJSONValueGetType(value); virJSONValuePtr elem; bool tmp; @@ -207,18 +201,10 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, =20 case VIR_JSON_TYPE_BOOLEAN: virJSONValueGetBoolean(value, &tmp); - if (onOff) { - if (tmp) - virBufferAsprintf(buf, "%s=3Don,", key); - else - virBufferAsprintf(buf, "%s=3Doff,", key); - } else { - if (tmp) - virBufferAsprintf(buf, "%s=3Dyes,", key); - else - virBufferAsprintf(buf, "%s=3Dno,", key); - } - + if (tmp) + virBufferAsprintf(buf, "%s=3Don,", key); + else + virBufferAsprintf(buf, "%s=3Doff,", key); break; =20 case VIR_JSON_TYPE_ARRAY: @@ -229,7 +215,7 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, return -1; } =20 - if (!arrayFunc || arrayFunc(key, value, buf, skipKey, onOff) < 0) { + if (!arrayFunc || arrayFunc(key, value, buf, skipKey) < 0) { /* fallback, treat the array as a non-bitmap, adding the key * for each member */ for (i =3D 0; i < virJSONValueArraySize(value); i++) { @@ -237,7 +223,7 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, =20 /* recurse to avoid duplicating code */ if (virQEMUBuildCommandLineJSONRecurse(key, elem, buf, ski= pKey, - onOff, arrayFunc, t= rue) < 0) + arrayFunc, true) < = 0) return -1; } } @@ -265,7 +251,6 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, * @value: json object containing the value * @buf: otuput buffer * @skipKey: name of key that will be handled separately by caller - * @onOff: Use 'on' and 'off' for boolean values rather than 'yes' and 'no' * @arrayFunc: array formatter function to allow for different syntax * * Formats JSON value object into command line parameters suitable for use= with @@ -277,10 +262,9 @@ int virQEMUBuildCommandLineJSON(virJSONValuePtr value, virBufferPtr buf, const char *skipKey, - bool onOff, virQEMUBuildCommandLineJSONArrayFormatFunc arr= ay) { - if (virQEMUBuildCommandLineJSONRecurse(NULL, value, buf, skipKey, onOf= f, array, false) < 0) + if (virQEMUBuildCommandLineJSONRecurse(NULL, value, buf, skipKey, arra= y, false) < 0) return -1; =20 virBufferTrim(buf, ","); @@ -311,7 +295,7 @@ virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr p= rops, =20 virBufferAsprintf(&buf, "%s,", type); =20 - if (virQEMUBuildCommandLineJSON(props, &buf, "type", true, + if (virQEMUBuildCommandLineJSON(props, &buf, "type", virQEMUBuildCommandLineJSONArrayObject= sStr) < 0) return NULL; =20 @@ -336,7 +320,7 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBuffer= Ptr buf, =20 if (props) { virBufferAddLit(buf, ","); - if (virQEMUBuildCommandLineJSON(props, buf, NULL, true, + if (virQEMUBuildCommandLineJSON(props, buf, NULL, virQEMUBuildCommandLineJSONArrayBitmap) < = 0) return -1; } @@ -362,7 +346,7 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr sr= cdef) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, true, + if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, virQEMUBuildCommandLineJSONArrayNumber= ed) < 0) return NULL; =20 diff --git a/src/util/virqemu.h b/src/util/virqemu.h index b81efc765f..849b7df0c2 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -29,23 +29,19 @@ typedef int (*virQEMUBuildCommandLineJSONArrayFormatFunc)(const char *key, virJSONValuePtr = array, virBufferPtr buf, - const char *skip= Key, - bool onOff); + const char *skip= Key); int virQEMUBuildCommandLineJSONArrayBitmap(const char *key, virJSONValuePtr array, virBufferPtr buf, - const char *skipKey, - bool onOff); + const char *skipKey); int virQEMUBuildCommandLineJSONArrayNumbered(const char *key, virJSONValuePtr array, virBufferPtr buf, - const char *skipKey, - bool onOff); + const char *skipKey); =20 int virQEMUBuildCommandLineJSON(virJSONValuePtr value, virBufferPtr buf, const char *skipKey, - bool onOff, virQEMUBuildCommandLineJSONArrayFormatFunc= array); =20 char * diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index 305f59e76b..6291c3b787 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -47,7 +47,7 @@ testQemuCommandBuildFromJSON(const void *opaque) return -1; } =20 - if (virQEMUBuildCommandLineJSON(val, &buf, NULL, false, data->arrayfun= c) < 0) { + if (virQEMUBuildCommandLineJSON(val, &buf, NULL, data->arrayfunc) < 0)= { fprintf(stderr, "\nvirQEMUBuildCommandlineJSON failed process JSON:\n%s\n", data->props); @@ -99,8 +99,8 @@ mymain(void) DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qwer\"}", "string=3Dqw= er"); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"string\":\"qw,e,r\"}", "string=3D= qw,,e,,r"); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"number\":1234}", "number=3D1234"); - DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=3Dyes"= ); - DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=3Dno"= ); + DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true}", "boolean=3Don"); + DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":false}", "boolean=3Doff= "); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"bitmap\":[]}", NULL); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"bitmap\":[0]}", "bitmap=3D0"); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"bitmap\":[1,3,5]}", @@ -113,14 +113,14 @@ mymain(void) DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"array\":[\"bleah\",\"qwerty\",1]}= ", "array=3Dbleah,array=3Dqwerty,array= =3D1"); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"boolean\":true,\"hyphen-name\":12= 34,\"some_string\":\"bleah\"}", - "boolean=3Dyes,hyphen-name=3D1234,som= e_string=3Dbleah"); + "boolean=3Don,hyphen-name=3D1234,some= _string=3Dbleah"); DO_TEST_COMMAND_OBJECT_FROM_JSON("{\"nest\": {\"boolean\":true," "\"hyphen-name\":1234," "\"some_string\":\"bleah\= "," "\"bleah\":\"bl,eah\"" "}" "}", - "nest.boolean=3Dyes,nest.hyphen-name= =3D1234," + "nest.boolean=3Don,nest.hyphen-name= =3D1234," "nest.some_string=3Dbleah,nest.bleah= =3Dbl,,eah"); DO_TEST_COMMAND_DRIVE_FROM_JSON("{\"driver\":\"gluster\"," "\"volume\":\"test\"," --=20 2.29.2