From nobody Sun Oct 5 19:25:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613076346; cv=none; d=zohomail.com; s=zohoarc; b=Oj10sexw5e8nY+BvSVujs7bIw7BjwjXTOtDzlpr1Sg3OglHf71HoaGHby9pugfFdOIkbkyGO0QZjKHCVaHeCqMmVklyv1Aux8buOgNYmzRaydiNndqpSc28bEfTsiMyTOJhX6vYblOXD7UOJtZ/wmILrkLCCWihKMaFwqoHHpjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613076346; 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=Wx940ZCaWVZE/SPo08+hKc6m3jrEP+FYeAiIba80nYk=; b=QYiYPU3DNr+ywTa9K8q89UqjbgVzrn+NuB1BDH+Fg2nPVq4Ej4ZAHjYxMaE4pyTt1z5Kswhez84qSTSf8u1gNcLEZeMajf8Tzys2WbENsGNUAHbAxx/lXzdH8iTyRS2YXYXuiSpItSuSUhSAL4jiLWsJ/HhC8rC9MnhZC/dRvUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613076346295356.2764660314783; Thu, 11 Feb 2021 12:45:46 -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-195-FlLrJ16oPqqnNCjnkPFpUA-1; Thu, 11 Feb 2021 15:45:42 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 703238749AC; Thu, 11 Feb 2021 20:45:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 705C31A86A; Thu, 11 Feb 2021 20:45:30 +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 B15DC4A7C6; Thu, 11 Feb 2021 20:45:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11BKikOc024221 for ; Thu, 11 Feb 2021 15:44:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFC311002388; Thu, 11 Feb 2021 20:44:46 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-150.phx2.redhat.com [10.3.114.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20A2B10013D7; Thu, 11 Feb 2021 20:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613076345; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Wx940ZCaWVZE/SPo08+hKc6m3jrEP+FYeAiIba80nYk=; b=hSneLWowR2qIjHFtsv/XAk2Gv8ZkLwBCUgN2JyJ9nLjEFBLyp/cuN3uNFuDoR6Zie9J3Yq 8GhKl9fYuQhytbv+BD/UwihbxxskjzgI4FNWJ4TOdGl+NXH/psHEZybOSBgVRNas7DcuhN 7hFeHaMcvySqb56aGFolB7MNhZbf5uY= X-MC-Unique: FlLrJ16oPqqnNCjnkPFpUA-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v2 3/4] utils: Deprecate hex-with-suffix sizes Date: Thu, 11 Feb 2021 14:44:37 -0600 Message-Id: <20210211204438.1184395-4-eblake@redhat.com> In-Reply-To: <20210211204438.1184395-1-eblake@redhat.com> References: <20210211204438.1184395-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: vsementsov@virtuozzo.com, qemu-block@nongnu.org, "reviewer:Incompatible changes" , tao3.xu@intel.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.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Supporting '0x20M' looks odd, particularly since we have a 'B' suffix that is ambiguous for bytes, as well as a less-frequently-used 'E' suffix for extremely large exibytes. In practice, people using hex inputs are specifying values in bytes (and would have written 0x2000000, or possibly relied on default_suffix in the case of qemu_strtosz_MiB), and the use of scaling suffixes makes the most sense for inputs in decimal (where the user would write 32M). But rather than outright dropping support for hex-with-suffix, let's follow our deprecation policy. Sadly, since qemu_strtosz() does not have an Err** parameter, and plumbing that in would be a much larger task, we instead go with just directly emitting the deprecation warning to stderr. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/system/deprecated.rst | 8 ++++++++ util/cutils.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 2fcac7861e07..113c2e933f1b 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -146,6 +146,14 @@ library enabled as a cryptography provider. Neither the ``nettle`` library, or the built-in cryptography provider are supported on FIPS enabled hosts. +hexadecimal sizes with scaling multipliers (since 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Input parameters that take a size value should only use a size suffix +(such as 'k' or 'M') when the base is written in decimal, and not when +the value is hexadecimal. That is, '0x20M' is deprecated, and should +be written either as '32M' or as '0x2000000'. + QEMU Machine Protocol (QMP) commands ------------------------------------ diff --git a/util/cutils.c b/util/cutils.c index 22d27b0fd21b..6a8a175e0d71 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -250,6 +250,9 @@ static int64_t suffix_mul(char suffix, int64_t unit) * fractional portion is truncated to byte * - 0x7fEE - hexadecimal, unit determined by @default_suffix * + * The following cause a deprecation warning, and may be removed in the fu= ture + * - 0xabc{kKmMgGtTpP} - hex with scaling suffix + * * The following are intentionally not supported * - octal, such as 08 * - fractional hex, such as 0x1.8 @@ -272,7 +275,7 @@ static int do_strtosz(const char *nptr, const char **en= d, int retval; const char *endptr, *f; unsigned char c; - bool mul_required =3D false; + bool mul_required =3D false, hex =3D false; uint64_t val; int64_t mul; double fraction =3D 0.0; @@ -298,6 +301,7 @@ static int do_strtosz(const char *nptr, const char **en= d, retval =3D -EINVAL; goto out; } + hex =3D true; } else if (*endptr =3D=3D '.') { /* * Input looks like a fraction. Make sure even 1.k works @@ -320,6 +324,10 @@ static int do_strtosz(const char *nptr, const char **e= nd, c =3D *endptr; mul =3D suffix_mul(c, unit); if (mul > 0) { + if (hex) { + warn_report("Using a multiplier suffix on hex numbers " + "is deprecated: %s", nptr); + } endptr++; } else { mul =3D suffix_mul(default_suffix, unit); --=20 2.30.1