From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547148057393786.4235717910785; Thu, 10 Jan 2019 11:20:57 -0800 (PST) Received: from localhost ([127.0.0.1]:60054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfsk-00066d-Q0 for importer@patchew.org; Thu, 10 Jan 2019 14:20:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfrB-00050C-5R for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfrA-0008Pg-1t for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60766) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfr7-0008MQ-BV; Thu, 10 Jan 2019 14:19:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F3E08E664; Thu, 10 Jan 2019 19:19:04 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id E470760C67; Thu, 10 Jan 2019 19:19:03 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:18:55 -0600 Message-Id: <20190110191901.5082-2-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 10 Jan 2019 19:19:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/6] qemu-option: Allow integer defaults X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lbloch@janustech.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Set the framework up for declaring integer options with an integer default, instead of our current insane approach of requiring the default value to be given as a string (which then has to be reparsed at every use that wants a number). git grep '[^.]def_value_str' says that we have done a good job of NOT abusing the internal field outside of the implementation in qemu-option.c; therefore, it is not too hard to audit that all code can either handle the new integer defaults correctly or abort because a caller violated constraints. Sadly, we DO have a constraint that qemu_opt_get() should not be called on an option that has an integer type, because we have no where to stash a cached const char * result; but callers that want an integer should be using qemu_opt_get_number() and friends anyways. Signed-off-by: Eric Blake Acked-by: Kevin Wolf --- include/qemu/option.h | 12 ++++++++ util/qemu-option.c | 69 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index 844587cab39..46b80d5a6e1 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -46,6 +46,18 @@ typedef struct QemuOptDesc { const char *name; enum QemuOptType type; const char *help; + /* + * For QEMU_OPT_STRING: Leave def_value_int 0, and set def_value_str + * to a default value or leave NULL for no default. + * + * For other types: Initialize at most non-zero def_value_int or a + * parseable def_value_str for a default (must use a string for an + * explicit default of 0, although an implicit default generally + * works). If setting def_value_int, calling qemu_opt_get() on + * that option will abort(); instead, call qemu_opt_get_del() or a + * typed getter. + */ + uint64_t def_value_int; const char *def_value_str; } QemuOptDesc; diff --git a/util/qemu-option.c b/util/qemu-option.c index de42e2a406a..06c4e8102a8 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -321,7 +321,8 @@ const char *qemu_opt_get(QemuOpts *opts, const char *na= me) opt =3D qemu_opt_find(opts, name); if (!opt) { const QemuOptDesc *desc =3D find_desc_by_name(opts->list->desc, na= me); - if (desc && desc->def_value_str) { + if (desc) { + assert(!desc->def_value_int); return desc->def_value_str; } } @@ -364,8 +365,22 @@ char *qemu_opt_get_del(QemuOpts *opts, const char *nam= e) opt =3D qemu_opt_find(opts, name); if (!opt) { desc =3D find_desc_by_name(opts->list->desc, name); - if (desc && desc->def_value_str) { - str =3D g_strdup(desc->def_value_str); + if (desc) { + if (desc->def_value_str) { + str =3D g_strdup(desc->def_value_str); + } else if (desc->def_value_int) { + switch (desc->type) { + case QEMU_OPT_BOOL: + str =3D g_strdup("on"); + break; + case QEMU_OPT_NUMBER: + case QEMU_OPT_SIZE: + str =3D g_strdup_printf("%" PRId64, desc->def_value_in= t); + break; + default: + abort(); + } + } } return str; } @@ -400,8 +415,15 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, c= onst char *name, opt =3D qemu_opt_find(opts, name); if (opt =3D=3D NULL) { const QemuOptDesc *desc =3D find_desc_by_name(opts->list->desc, na= me); - if (desc && desc->def_value_str) { - parse_option_bool(name, desc->def_value_str, &ret, &error_abor= t); + if (desc) { + if (desc->def_value_int) { + assert(desc->type !=3D QEMU_OPT_STRING); + return true; + } + if (desc->def_value_str) { + parse_option_bool(name, desc->def_value_str, &ret, + &error_abort); + } } return ret; } @@ -436,8 +458,15 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts *o= pts, const char *name, opt =3D qemu_opt_find(opts, name); if (opt =3D=3D NULL) { const QemuOptDesc *desc =3D find_desc_by_name(opts->list->desc, na= me); - if (desc && desc->def_value_str) { - parse_option_number(name, desc->def_value_str, &ret, &error_ab= ort); + if (desc) { + if (desc->def_value_int) { + assert(desc->type !=3D QEMU_OPT_STRING); + return desc->def_value_int; + } + if (desc->def_value_str) { + parse_option_number(name, desc->def_value_str, &ret, + &error_abort); + } } return ret; } @@ -473,8 +502,15 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts *opt= s, const char *name, opt =3D qemu_opt_find(opts, name); if (opt =3D=3D NULL) { const QemuOptDesc *desc =3D find_desc_by_name(opts->list->desc, na= me); - if (desc && desc->def_value_str) { - parse_option_size(name, desc->def_value_str, &ret, &error_abor= t); + if (desc) { + if (desc->def_value_int) { + assert(desc->type !=3D QEMU_OPT_STRING); + return desc->def_value_int; + } + if (desc->def_value_str) { + parse_option_size(name, desc->def_value_str, &ret, + &error_abort); + } } return ret; } @@ -787,9 +823,23 @@ void qemu_opts_print(QemuOpts *opts, const char *separ= ator) } for (; desc && desc->name; desc++) { const char *value; + char *tmp =3D NULL; opt =3D qemu_opt_find(opts, desc->name); value =3D opt ? opt->str : desc->def_value_str; + if (!value && desc->def_value_int) { + switch (desc->type) { + case QEMU_OPT_BOOL: + value =3D tmp =3D g_strdup("on"); + break; + case QEMU_OPT_NUMBER: + case QEMU_OPT_SIZE: + value =3D tmp =3D g_strdup_printf("%" PRId64, desc->def_va= lue_int); + break; + default: + abort(); + } + } if (!value) { continue; } @@ -803,6 +853,7 @@ void qemu_opts_print(QemuOpts *opts, const char *separa= tor) printf("%s%s=3D%s", sep, desc->name, value); } sep =3D separator; + g_free(tmp); } } --=20 2.20.1 From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547148358206759.9160109199045; Thu, 10 Jan 2019 11:25:58 -0800 (PST) Received: from localhost ([127.0.0.1]:33244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfxl-0001H5-1P for importer@patchew.org; Thu, 10 Jan 2019 14:25:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfrH-00059O-HI for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfrG-0008WK-N3 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfrE-0008Sh-43; Thu, 10 Jan 2019 14:19:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5977B4FCD9; Thu, 10 Jan 2019 19:19:11 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99DFF4148; Thu, 10 Jan 2019 19:19:04 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:18:56 -0600 Message-Id: <20190110191901.5082-3-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 10 Jan 2019 19:19:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/6] block: Take advantage of QemuOpt default integers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, Stefan Weil , Jeff Cody , armbru@redhat.com, Max Reitz , lbloch@janustech.com, Stefan Hajnoczi , "Denis V. Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of defining an integer to a default string value (where we have to be careful how we spelled the integer because of the use of stringify), populate a default integer value instead. Drop a useless stringify(0); a missing default is just as easy to interpret as 0 as an explicit string 0. Signed-off-by: Eric Blake Acked-by: Kevin Wolf --- block/parallels.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index cc9445879d7..a7593310332 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -96,7 +96,7 @@ static QemuOptsList parallels_create_opts =3D { .name =3D BLOCK_OPT_CLUSTER_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "Parallels image cluster size", - .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE), + .def_value_int =3D DEFAULT_CLUSTER_SIZE, }, { /* end of list */ } } diff --git a/block/qcow2.c b/block/qcow2.c index 4897abae5e8..c9b76a9ea93 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4892,7 +4892,7 @@ static QemuOptsList qcow2_create_opts =3D { .name =3D BLOCK_OPT_CLUSTER_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "qcow2 cluster size", - .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) + .def_value_int =3D DEFAULT_CLUSTER_SIZE, }, { .name =3D BLOCK_OPT_PREALLOC, diff --git a/block/qed.c b/block/qed.c index 9377c0b7ad8..9db36c39066 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1651,7 +1651,7 @@ static QemuOptsList qed_create_opts =3D { .name =3D BLOCK_OPT_CLUSTER_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "Cluster size (in bytes)", - .def_value_str =3D stringify(QED_DEFAULT_CLUSTER_SIZE) + .def_value_int =3D QED_DEFAULT_CLUSTER_SIZE, }, { .name =3D BLOCK_OPT_TABLE_SIZE, diff --git a/block/vdi.c b/block/vdi.c index 2380daa583e..65659c9b179 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -985,7 +985,7 @@ static QemuOptsList vdi_create_opts =3D { .name =3D BLOCK_OPT_CLUSTER_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "VDI cluster (block) size", - .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) + .def_value_int =3D DEFAULT_CLUSTER_SIZE, }, #endif #if defined(CONFIG_VDI_STATIC_IMAGE) diff --git a/block/vhdx.c b/block/vhdx.c index b785aef4b7b..54bf6805fc6 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2085,13 +2085,12 @@ static QemuOptsList vhdx_create_opts =3D { { .name =3D VHDX_BLOCK_OPT_LOG_SIZE, .type =3D QEMU_OPT_SIZE, - .def_value_str =3D stringify(DEFAULT_LOG_SIZE), + .def_value_int =3D DEFAULT_LOG_SIZE, .help =3D "Log size; min 1MB." }, { .name =3D VHDX_BLOCK_OPT_BLOCK_SIZE, .type =3D QEMU_OPT_SIZE, - .def_value_str =3D stringify(0), .help =3D "Block Size; min 1MB, max 256MB. " \ "0 means auto-calculate based on image size." }, --=20 2.20.1 From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154714828083940.44129187725878; Thu, 10 Jan 2019 11:24:40 -0800 (PST) Received: from localhost ([127.0.0.1]:32872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfwV-0000L8-PT for importer@patchew.org; Thu, 10 Jan 2019 14:24:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfrH-00059H-B6 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfrG-0008WE-MK for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34238) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfrE-0008TZ-SO; Thu, 10 Jan 2019 14:19:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18255C0C8BA7; Thu, 10 Jan 2019 19:19:12 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 713E260C67; Thu, 10 Jan 2019 19:19:11 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:18:57 -0600 Message-Id: <20190110191901.5082-4-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 10 Jan 2019 19:19:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/6] Revert "vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, Stefan Weil , armbru@redhat.com, Max Reitz , lbloch@janustech.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This reverts commit 3dd5b8f4718c6ca1eadb16dd67a8cad76455ddb0. Now that we can express QemuOpts values as an integer, we don't have to be careful about how we spell our macro. Acked-by: Kevin Wolf --- block/vdi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/vdi.c b/block/vdi.c index 65659c9b179..180a45b70f6 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -85,7 +85,7 @@ #define BLOCK_OPT_STATIC "static" #define SECTOR_SIZE 512 -#define DEFAULT_CLUSTER_SIZE S_1MiB +#define DEFAULT_CLUSTER_SIZE (1 * MiB) #if defined(CONFIG_VDI_DEBUG) #define VDI_DEBUG 1 @@ -432,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, goto fail; } else if (header.block_size !=3D DEFAULT_CLUSTER_SIZE) { error_setg(errp, "unsupported VDI image (block size %" PRIu32 - " is not %" PRIu32 ")", + " is not %" PRIu64 ")", header.block_size, DEFAULT_CLUSTER_SIZE); ret =3D -ENOTSUP; goto fail; --=20 2.20.1 From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547148458157926.7203840853157; Thu, 10 Jan 2019 11:27:38 -0800 (PST) Received: from localhost ([127.0.0.1]:33684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfzI-000298-MC for importer@patchew.org; Thu, 10 Jan 2019 14:27:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfra-0005Yo-3D for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfrX-0000JL-OZ for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfrI-00005j-4D; Thu, 10 Jan 2019 14:19:16 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C18EC07457B; Thu, 10 Jan 2019 19:19:15 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A32660C67; Thu, 10 Jan 2019 19:19:12 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:18:58 -0600 Message-Id: <20190110191901.5082-5-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 10 Jan 2019 19:19:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 4/6] qemu: Prefer '(x * MiB)' over 'S_xiB' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lbloch@janustech.com, armbru@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that QemuOpts can accept true integer defaults, we no longer have to be careful about the spelling of our default macros because we are no longer applying stringify() to any of the macros. Although it is slightly more verbose to call out an integer times a scale, it avoids the need to have a list of S_*iB macros that were used in commit b6a95c6d. Signed-off-by: Eric Blake Acked-by: Kevin Wolf --- block/qcow2.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index a98d24500b2..d8db6622774 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -50,11 +50,11 @@ /* 8 MB refcount table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_REFTABLE_SIZE S_8MiB +#define QCOW_MAX_REFTABLE_SIZE (8 * MiB) /* 32 MB L1 table is enough for 2 PB images at 64k cluster size * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */ -#define QCOW_MAX_L1_SIZE S_32MiB +#define QCOW_MAX_L1_SIZE (32 * MiB) /* Allow for an average of 1k per snapshot table entry, should be plenty of * space for snapshot names and IDs */ @@ -81,15 +81,15 @@ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ #ifdef CONFIG_LINUX -#define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB +#define DEFAULT_L2_CACHE_MAX_SIZE (32 * MiB) #define DEFAULT_CACHE_CLEAN_INTERVAL 600 /* seconds */ #else -#define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB +#define DEFAULT_L2_CACHE_MAX_SIZE (8 * MiB) /* Cache clean interval is currently available only on Linux, so must be 0= */ #define DEFAULT_CACHE_CLEAN_INTERVAL 0 #endif -#define DEFAULT_CLUSTER_SIZE S_64KiB +#define DEFAULT_CLUSTER_SIZE (64 * KiB) #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts" #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request" --=20 2.20.1 From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547148072210319.47417326492655; Thu, 10 Jan 2019 11:21:12 -0800 (PST) Received: from localhost ([127.0.0.1]:60154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghft7-0006Lw-5X for importer@patchew.org; Thu, 10 Jan 2019 14:21:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfrd-0005bS-S8 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfrc-0000TN-Uf for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfrX-00006e-Qs; Thu, 10 Jan 2019 14:19:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16A01A1F68; Thu, 10 Jan 2019 19:19:16 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D64767178; Thu, 10 Jan 2019 19:19:15 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:18:59 -0600 Message-Id: <20190110191901.5082-6-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 10 Jan 2019 19:19:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 5/6] Revert "include: Add a comment to explain the origin of sizes' lookup table" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lbloch@janustech.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This reverts commit 1240ac558d348f6c7a5752b1a57c1da58e4efe3e. The table itself is about to be reverted, now that it has no clients. Signed-off-by: Eric Blake Acked-by: Kevin Wolf --- include/qemu/units.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/include/qemu/units.h b/include/qemu/units.h index 1c959d182e8..68a77586504 100644 --- a/include/qemu/units.h +++ b/include/qemu/units.h @@ -17,24 +17,6 @@ #define PiB (INT64_C(1) << 50) #define EiB (INT64_C(1) << 60) -/* - * The following lookup table is intended to be used when a literal string= of - * the number of bytes is required (for example if it needs to be stringif= ied). - * It can also be used for generic shortcuts of power-of-two sizes. - * This table is generated using the AWK script below: - * - * BEGIN { - * suffix=3D"KMGTPE"; - * for(i=3D10; i<64; i++) { - * val=3D2**i; - * s=3Dsubstr(suffix, int(i/10), 1); - * n=3D2**(i%10); - * pad=3D21-int(log(n)/log(10)); - * printf("#define S_%d%siB %*d\n", n, s, pad, val); - * } - * } - */ - #define S_1KiB 1024 #define S_2KiB 2048 #define S_4KiB 4096 --=20 2.20.1 From nobody Sat Apr 20 15:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547148203151249.8165030317407; Thu, 10 Jan 2019 11:23:23 -0800 (PST) Received: from localhost ([127.0.0.1]:60715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfvG-0007ls-6h for importer@patchew.org; Thu, 10 Jan 2019 14:23:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghfrf-0005ch-6Q for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghfre-0000V8-As for qemu-devel@nongnu.org; Thu, 10 Jan 2019 14:19:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghfra-00007D-4q; Thu, 10 Jan 2019 14:19:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB802C074F0D; Thu, 10 Jan 2019 19:19:16 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-216.phx2.redhat.com [10.3.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 389234148; Thu, 10 Jan 2019 19:19:16 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:19:00 -0600 Message-Id: <20190110191901.5082-7-eblake@redhat.com> In-Reply-To: <20190110191901.5082-1-eblake@redhat.com> References: <20190110191901.5082-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 10 Jan 2019 19:19:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 6/6] Revert "include: Add a lookup table of sizes" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lbloch@janustech.com, armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This reverts commit 540b8492618ebbe98e7462bd7d31361b8cb10a05. Now that QemuOpts can accept default values as integers, there are no more clients of the S_*iB macros, and no longer a reason to have a list of macros that contain a specific spelling of special values merely for the sake of stringify(), when it is a lot nicer to just compute integers in the first place using ordinary arithmetic and our smaller list of xiB scaling macros. Signed-off-by: Eric Blake Acked-by: Kevin Wolf --- include/qemu/units.h | 55 -------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/include/qemu/units.h b/include/qemu/units.h index 68a77586504..692db3fbb26 100644 --- a/include/qemu/units.h +++ b/include/qemu/units.h @@ -17,59 +17,4 @@ #define PiB (INT64_C(1) << 50) #define EiB (INT64_C(1) << 60) -#define S_1KiB 1024 -#define S_2KiB 2048 -#define S_4KiB 4096 -#define S_8KiB 8192 -#define S_16KiB 16384 -#define S_32KiB 32768 -#define S_64KiB 65536 -#define S_128KiB 131072 -#define S_256KiB 262144 -#define S_512KiB 524288 -#define S_1MiB 1048576 -#define S_2MiB 2097152 -#define S_4MiB 4194304 -#define S_8MiB 8388608 -#define S_16MiB 16777216 -#define S_32MiB 33554432 -#define S_64MiB 67108864 -#define S_128MiB 134217728 -#define S_256MiB 268435456 -#define S_512MiB 536870912 -#define S_1GiB 1073741824 -#define S_2GiB 2147483648 -#define S_4GiB 4294967296 -#define S_8GiB 8589934592 -#define S_16GiB 17179869184 -#define S_32GiB 34359738368 -#define S_64GiB 68719476736 -#define S_128GiB 137438953472 -#define S_256GiB 274877906944 -#define S_512GiB 549755813888 -#define S_1TiB 1099511627776 -#define S_2TiB 2199023255552 -#define S_4TiB 4398046511104 -#define S_8TiB 8796093022208 -#define S_16TiB 17592186044416 -#define S_32TiB 35184372088832 -#define S_64TiB 70368744177664 -#define S_128TiB 140737488355328 -#define S_256TiB 281474976710656 -#define S_512TiB 562949953421312 -#define S_1PiB 1125899906842624 -#define S_2PiB 2251799813685248 -#define S_4PiB 4503599627370496 -#define S_8PiB 9007199254740992 -#define S_16PiB 18014398509481984 -#define S_32PiB 36028797018963968 -#define S_64PiB 72057594037927936 -#define S_128PiB 144115188075855872 -#define S_256PiB 288230376151711744 -#define S_512PiB 576460752303423488 -#define S_1EiB 1152921504606846976 -#define S_2EiB 2305843009213693952 -#define S_4EiB 4611686018427387904 -#define S_8EiB 9223372036854775808 - #endif --=20 2.20.1