From nobody Sun Oct 5 19:22:46 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=1615305164; cv=none; d=zohomail.com; s=zohoarc; b=LlvLnxudv4ewJ88tLxTkWSaQGUlZuHtRCSb8kaCmTfEP3JPo69tBdl40PuUVjXPRKWP66z1GienSsQu1kMUK9XNbP2G0VB52F+F2QmYQzRXoVVg6edvdsGykwCQcuy2vhqt+wortCZ+3+bU/qIsv/6HhyTjDvR/pZAaumfXY6kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615305164; 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=JUIP1hLD9IuDyzpzwwpjqZJWzFhUHjnXHR+4nt8i9Rs=; b=KzEoYPavFNE88MzQblH85rP92QeW82ZwIJXi7hXfDxLyA+lgVGqkjT2V4jX56tTw+oTFgNjjMj3mncuCky7AOYnVh8EvQcJy4hBshHNQax8HZZ4Tgg9zzQI4yBUTl9exEDhMJlvZ+8NWcFr+ujQw3cukGROg759DVeuIKQZeWEE= 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 1615305164527774.9066549356398; Tue, 9 Mar 2021 07:52:44 -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-267-PPrjg4DuM6CCFnub5nEXwA-1; Tue, 09 Mar 2021 10:52:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F5EA26860; Tue, 9 Mar 2021 15:52:34 +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 83C835D720; Tue, 9 Mar 2021 15:52:33 +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 60C4C1809C86; Tue, 9 Mar 2021 15:52:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 129FqHFi028389 for ; Tue, 9 Mar 2021 10:52:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id E99091F4; Tue, 9 Mar 2021 15:52:17 +0000 (UTC) Received: from blue.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FEEE19C46; Tue, 9 Mar 2021 15:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615305163; 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=JUIP1hLD9IuDyzpzwwpjqZJWzFhUHjnXHR+4nt8i9Rs=; b=NMLpEyQm4/7Np53LLC3cuP9O2RQq4mcSD+2vVw9b+mzrezWnVemeH/sKFWi4ETpTyeZryN pX30udjKlOHKmlcTO7n9gv0nV8zYRFYsJ5da5hzvw78PgNmXUAM6OX+Lqn/D3COFm9frWJ TtBCGn12GjMIvEs9W7RthbdFpi3Tr2w= X-MC-Unique: PPrjg4DuM6CCFnub5nEXwA-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 05/17] utils: Deprecate hex-with-suffix sizes Date: Tue, 9 Mar 2021 09:51:50 -0600 Message-Id: <20210309155202.1312571-6-eblake@redhat.com> In-Reply-To: <20210309155202.1312571-1-eblake@redhat.com> References: <20210309155202.1312571-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: "reviewer:Incompatible changes" 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.15 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) 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 Message-Id: <20210211204438.1184395-4-eblake@redhat.com> Reviewed-by: Daniel P. Berrang=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 cfabe6984677..ecff6bf8c633 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -166,6 +166,14 @@ Using ``-M kernel-irqchip=3Doff`` with x86 machine typ= es that include a local APIC is deprecated. The ``split`` setting is supported, as is using ``-M kernel-irqchip=3Doff`` with the ISA PC machine type. +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 189a184859c0..d89a40a8c325 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