From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117743462397.2996977222981; Mon, 7 Aug 2017 07:55:43 -0700 (PDT) Received: from localhost ([::1]:37735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejRW-0006ce-2s for importer@patchew.org; Mon, 07 Aug 2017 10:55:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIq-00075K-Q6 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIb-0003jr-MT for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIO-0003UE-UD; Mon, 07 Aug 2017 10:46:17 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 15BDB6148D; Mon, 7 Aug 2017 14:46:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA0FB7FE8F; Mon, 7 Aug 2017 14:46:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0BA8C113864E; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15BDB6148D Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:05 +0200 Message-Id: <1502117160-24655-2-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 Aug 2017 14:46:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 01/56] qobject: Touch up comments to say @param instead of 'param' 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qobject/qdict.c | 68 ++++++++++++++++++++++++++++-------------------------= ---- qobject/qlist.c | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/qobject/qdict.c b/qobject/qdict.c index 576018e..d795079 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -116,13 +116,13 @@ static QDictEntry *qdict_find(const QDict *qdict, /** * qdict_put_obj(): Put a new QObject into the dictionary * - * Insert the pair 'key:value' into 'qdict', if 'key' already exists - * its 'value' will be replaced. + * Insert the pair @key:@value into @qdict, if @key already exists + * its value will be replaced. * * This is done by freeing the reference to the stored QObject and * storing the new one in the same entry. * - * NOTE: ownership of 'value' is transferred to the QDict + * NOTE: ownership of @value is transferred to the QDict */ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) { @@ -144,10 +144,10 @@ void qdict_put_obj(QDict *qdict, const char *key, QOb= ject *value) } =20 /** - * qdict_get(): Lookup for a given 'key' + * qdict_get(): Lookup for a given @key * - * Return a weak reference to the QObject associated with 'key' if - * 'key' is present in the dictionary, NULL otherwise. + * Return a weak reference to the QObject associated with @key if + * @key is present in the dictionary, NULL otherwise. */ QObject *qdict_get(const QDict *qdict, const char *key) { @@ -158,9 +158,9 @@ QObject *qdict_get(const QDict *qdict, const char *key) } =20 /** - * qdict_haskey(): Check if 'key' exists + * qdict_haskey(): Check if @key exists * - * Return 1 if 'key' exists in the dict, 0 otherwise + * Return 1 if @key exists in the dict, 0 otherwise */ int qdict_haskey(const QDict *qdict, const char *key) { @@ -177,11 +177,11 @@ size_t qdict_size(const QDict *qdict) } =20 /** - * qdict_get_double(): Get an number mapped by 'key' + * qdict_get_double(): Get an number mapped by @key * - * This function assumes that 'key' exists and it stores a QNum. + * This function assumes that @key exists and it stores a QNum. * - * Return number mapped by 'key'. + * Return number mapped by @key. */ double qdict_get_double(const QDict *qdict, const char *key) { @@ -189,12 +189,12 @@ double qdict_get_double(const QDict *qdict, const cha= r *key) } =20 /** - * qdict_get_int(): Get an integer mapped by 'key' + * qdict_get_int(): Get an integer mapped by @key * - * This function assumes that 'key' exists and it stores a + * This function assumes that @key exists and it stores a * QNum representable as int. * - * Return integer mapped by 'key'. + * Return integer mapped by @key. */ int64_t qdict_get_int(const QDict *qdict, const char *key) { @@ -202,12 +202,12 @@ int64_t qdict_get_int(const QDict *qdict, const char = *key) } =20 /** - * qdict_get_bool(): Get a bool mapped by 'key' + * qdict_get_bool(): Get a bool mapped by @key * - * This function assumes that 'key' exists and it stores a + * This function assumes that @key exists and it stores a * QBool object. * - * Return bool mapped by 'key'. + * Return bool mapped by @key. */ bool qdict_get_bool(const QDict *qdict, const char *key) { @@ -232,12 +232,12 @@ QDict *qdict_get_qdict(const QDict *qdict, const char= *key) =20 /** * qdict_get_str(): Get a pointer to the stored string mapped - * by 'key' + * by @key * - * This function assumes that 'key' exists and it stores a + * This function assumes that @key exists and it stores a * QString object. * - * Return pointer to the string mapped by 'key'. + * Return pointer to the string mapped by @key. */ const char *qdict_get_str(const QDict *qdict, const char *key) { @@ -245,11 +245,11 @@ const char *qdict_get_str(const QDict *qdict, const c= har *key) } =20 /** - * qdict_get_try_int(): Try to get integer mapped by 'key' + * qdict_get_try_int(): Try to get integer mapped by @key * - * Return integer mapped by 'key', if it is not present in the + * Return integer mapped by @key, if it is not present in the * dictionary or if the stored object is not a QNum representing an - * integer, 'def_value' will be returned. + * integer, @def_value will be returned. */ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) @@ -265,11 +265,11 @@ int64_t qdict_get_try_int(const QDict *qdict, const c= har *key, } =20 /** - * qdict_get_try_bool(): Try to get a bool mapped by 'key' + * qdict_get_try_bool(): Try to get a bool mapped by @key * - * Return bool mapped by 'key', if it is not present in the + * Return bool mapped by @key, if it is not present in the * dictionary or if the stored object is not of QBool type - * 'def_value' will be returned. + * @def_value will be returned. */ bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_valu= e) { @@ -280,9 +280,9 @@ bool qdict_get_try_bool(const QDict *qdict, const char = *key, bool def_value) =20 /** * qdict_get_try_str(): Try to get a pointer to the stored string - * mapped by 'key' + * mapped by @key * - * Return a pointer to the string mapped by 'key', if it is not present + * Return a pointer to the string mapped by @key, if it is not present * in the dictionary or if the stored object is not of QString type * NULL will be returned. */ @@ -427,8 +427,8 @@ void qdict_destroy_obj(QObject *obj) } =20 /** - * qdict_copy_default(): If no entry mapped by 'key' exists in 'dst' yet, = the - * value of 'key' in 'src' is copied there (and the refcount increased + * qdict_copy_default(): If no entry mapped by @key exists in @dst yet, the + * value of @key in @src is copied there (and the refcount increased * accordingly). */ void qdict_copy_default(QDict *dst, QDict *src, const char *key) @@ -447,8 +447,8 @@ void qdict_copy_default(QDict *dst, QDict *src, const c= har *key) } =20 /** - * qdict_set_default_str(): If no entry mapped by 'key' exists in 'dst' ye= t, a - * new QString initialised by 'val' is put there. + * qdict_set_default_str(): If no entry mapped by @key exists in @dst yet,= a + * new QString initialised by @val is put there. */ void qdict_set_default_str(QDict *dst, const char *key, const char *val) { @@ -667,8 +667,8 @@ void qdict_array_split(QDict *src, QList **dst) * 'foo.0.bar' -> prefix=3D'foo' and suffix=3D'0.bar' * 'foo..0.bar' -> prefix=3D'foo.0' and suffix=3D'bar' * - * The '..' sequence will be unescaped in the returned 'prefix' - * string. The 'suffix' string will be left in escaped format, so it + * The '..' sequence will be unescaped in the returned @prefix + * string. The @suffix string will be left in escaped format, so it * can be fed back into the qdict_split_flat_key() key as the input * later. * diff --git a/qobject/qlist.c b/qobject/qlist.c index 86b60cb..f11dc5b 100644 --- a/qobject/qlist.c +++ b/qobject/qlist.c @@ -52,7 +52,7 @@ QList *qlist_copy(QList *src) /** * qlist_append_obj(): Append an QObject into QList * - * NOTE: ownership of 'value' is transferred to the QList + * NOTE: ownership of @value is transferred to the QList */ void qlist_append_obj(QList *qlist, QObject *value) { --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118188499786.4569141504792; Mon, 7 Aug 2017 08:03:08 -0700 (PDT) Received: from localhost ([::1]:37774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejYh-0005NL-90 for importer@patchew.org; Mon, 07 Aug 2017 11:03:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ1-0007K1-RH for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIl-0003s6-Pm for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIT-0003Xg-PU; Mon, 07 Aug 2017 10:46:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0A26356C9; Mon, 7 Aug 2017 14:46:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B09956A307; Mon, 7 Aug 2017 14:46:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0F770113864F; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0A26356C9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:06 +0200 Message-Id: <1502117160-24655-3-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 02/56] qdict: New helpers to put and get unsigned 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- include/qapi/qmp/qdict.h | 5 +++++ qobject/qdict.c | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 363e431..3b52481 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -56,6 +56,8 @@ void qdict_destroy_obj(QObject *obj); /* Helpers for int, bool, and string */ #define qdict_put_int(qdict, key, value) \ qdict_put(qdict, key, qnum_from_int(value)) +#define qdict_put_uint(qdict, key, value) \ + qdict_put(qdict, key, qnum_from_uint(value)) #define qdict_put_bool(qdict, key, value) \ qdict_put(qdict, key, qbool_from_bool(value)) #define qdict_put_str(qdict, key, value) \ @@ -64,12 +66,15 @@ void qdict_destroy_obj(QObject *obj); /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key); +uint64_t qdict_get_uint(const QDict *qdict, const char *key); bool qdict_get_bool(const QDict *qdict, const char *key); QList *qdict_get_qlist(const QDict *qdict, const char *key); QDict *qdict_get_qdict(const QDict *qdict, const char *key); const char *qdict_get_str(const QDict *qdict, const char *key); int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value); +uint64_t qdict_get_try_uint(const QDict *qdict, const char *key, + uint64_t def_value); bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_valu= e); const char *qdict_get_try_str(const QDict *qdict, const char *key); =20 diff --git a/qobject/qdict.c b/qobject/qdict.c index d795079..be919b9 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -189,10 +189,9 @@ double qdict_get_double(const QDict *qdict, const char= *key) } =20 /** - * qdict_get_int(): Get an integer mapped by @key + * qdict_get_int(): Get a signed integer mapped by @key * - * This function assumes that @key exists and it stores a - * QNum representable as int. + * @qdict must map @key to an integer QNum that fits into int64_t. * * Return integer mapped by @key. */ @@ -202,6 +201,18 @@ int64_t qdict_get_int(const QDict *qdict, const char *= key) } =20 /** + * qdict_get_uint(): Get an unsigned integer mapped by 'key' + * + * @qdict must map @key to an integer QNum that fits into uint64_t. + * + * Return integer mapped by 'key'. + */ +uint64_t qdict_get_uint(const QDict *qdict, const char *key) +{ + return qnum_get_uint(qobject_to_qnum(qdict_get(qdict, key))); +} + +/** * qdict_get_bool(): Get a bool mapped by @key * * This function assumes that @key exists and it stores a @@ -245,11 +256,10 @@ const char *qdict_get_str(const QDict *qdict, const c= har *key) } =20 /** - * qdict_get_try_int(): Try to get integer mapped by @key + * qdict_get_try_int(): Try to get signed integer mapped by @key * - * Return integer mapped by @key, if it is not present in the - * dictionary or if the stored object is not a QNum representing an - * integer, @def_value will be returned. + * If @qdict maps @key to an integer QNum that fits into int64_t, + * return it. Else return @def_value. */ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) @@ -265,6 +275,25 @@ int64_t qdict_get_try_int(const QDict *qdict, const ch= ar *key, } =20 /** + * qdict_get_try_uint(): Try to get unsigned integer mapped by 'key' + * + * If @qdict maps @key to an integer QNum that fits into uint64_t, + * return it. Else return @def_value. + */ +uint64_t qdict_get_try_uint(const QDict *qdict, const char *key, + uint64_t def_value) +{ + QNum *qnum =3D qobject_to_qnum(qdict_get(qdict, key)); + uint64_t val; + + if (!qnum || !qnum_get_try_uint(qnum, &val)) { + return def_value; + } + + return val; +} + +/** * qdict_get_try_bool(): Try to get a bool mapped by @key * * Return bool mapped by @key, if it is not present in the --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117588190391.80124371571935; Mon, 7 Aug 2017 07:53:08 -0700 (PDT) Received: from localhost ([::1]:37720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejP0-0004Kh-Uk for importer@patchew.org; Mon, 07 Aug 2017 10:53:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIj-0006ws-Ln for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIY-0003fo-Pv for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIN-0003Ow-Kk; Mon, 07 Aug 2017 10:46:15 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9179AC047B71; Mon, 7 Aug 2017 14:46:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B05B98FBE1; Mon, 7 Aug 2017 14:46:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 134241138656; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9179AC047B71 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:07 +0200 Message-Id: <1502117160-24655-4-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 Aug 2017 14:46:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 03/56] monitor: Rewrite comment describing HMP .args_type 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- monitor.c | 75 +++++++++++++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/monitor.c b/monitor.c index e0f8801..8b54ba1 100644 --- a/monitor.c +++ b/monitor.c @@ -85,37 +85,56 @@ #endif =20 /* - * Supported types: + * Command handlers (mon_cmd_t member @cmd) receive actual arguments + * in a QDict, which is built by the HMP core according to mon_cmd_t + * member @args_type. It's a list of NAME:TYPE separated by comma. * - * 'F' filename - * 'B' block device name - * 's' string (accept optional quote) - * 'S' it just appends the rest of the string (accept optional qu= ote) - * 'O' option string of the form NAME=3DVALUE,... - * parsed according to QemuOptsList given by its name - * Example: 'device:O' uses qemu_device_opts. - * Restriction: only lists with empty desc are supported - * TODO lift the restriction - * 'i' 32 bit integer - * 'l' target long (32 or 64 bit) - * 'M' Non-negative target long (32 or 64 bit), in user mode the - * value is multiplied by 2^20 (think Mebibyte) - * 'o' octets (aka bytes) - * user mode accepts an optional E, e, P, p, T, t, G, g, M, m, - * K, k suffix, which multiplies the value by 2^60 for suffix= es E - * and e, 2^50 for suffixes P and p, 2^40 for suffixes T and = t, - * 2^30 for suffixes G and g, 2^20 for M and m, 2^10 for K an= d k - * 'T' double - * user mode accepts an optional ms, us, ns suffix, - * which divides the value by 1e3, 1e6, 1e9, respectively - * '/' optional gdb-like print format (like "/10x") + * TYPEs that put a string value with key NAME into the QDict: + * 's' Argument is enclosed in '"' or delimited by whitespace. In + * the former case, escapes \n \r \\ \' and \" are recognized. + * 'F' File name, like 's' except for completion. + * 'B' BlockBackend name, like 's' except for completion. + * 'S' Argument is the remainder of the line, less leading + * whitespace. + * - * '?' optional type (for all types, except '/') - * '.' other form of optional type (for 'i' and 'l') - * 'b' boolean - * user mode accepts "on" or "off" - * '-' optional parameter (eg. '-f') + * TYPEs that put an int64_t value with key NAME: + * 'l' Argument is an expression (QEMU pocket calculator). + * 'i' Like 'l' except value must fit into 32 bit unsigned. + * 'M' Like 'l' except value must not be negative and is multiplied + * by 2^20 (think "mebibyte"). * + * TYPEs that put an uint64_t value with key NAME: + * 'o' Argument is a size (think "octets"). Without suffix the + * value is multiplied by 2^20 (mebibytes), with suffix E or e + * by 2^60 (exbibytes), with P or p by 2^50 (pebibytes), with T + * or t by 2^40 (tebibytes), with G or g by 2^30 (gibibytes), + * with M or m by 2^10 (mebibytes), with K or k by 2^10 + * (kibibytes). + * + * TYPEs that put a double value with key NAME: + * 'T' Argument is a time in seconds. With optional ms, us, ns + * suffix, the value divided by 1e3, 1e6, 1e9 respectively. + * + * TYPEs that put a bool value with key NAME: + * 'b' Argument is either "on" (true) or "off" (false). + * '-' CHAR + * Argument is either "-CHAR" (true) or absent (false). + * + * TYPEs that put multiple values: + * 'O' Option string of the form NAME=3DVALUE,... parsed according to + * the QemuOptsList given by its name. + * Example: 'device:O' uses qemu_device_opts. + * Restriction: only lists with empty desc are supported. + * Puts all the NAME=3DVALUE. + * '/' Gdb-like print format (like "/10x"), always optional. + * Puts keys "count", "format", "size", all int. + * + * Modifier character following the type string: + * '?' Argument is optional, nothing is put when it is absent + * (all types except 'O', '/', 'b'). + * '.' Argument is optional, must be preceded by '.' if present + * (only types 'i', 'l', 'M') */ =20 typedef struct mon_cmd_t { --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117559016289.1103052789143; Mon, 7 Aug 2017 07:52:39 -0700 (PDT) Received: from localhost ([::1]:37718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejOX-0003tB-R7 for importer@patchew.org; Mon, 07 Aug 2017 10:52:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIj-0006wl-IF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIY-0003fS-Ke for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIO-0003TK-0P; Mon, 07 Aug 2017 10:46:16 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id D60E97DCC4; Mon, 7 Aug 2017 14:46:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1B4E7FE8D; Mon, 7 Aug 2017 14:46:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 16F8111386C7; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D60E97DCC4 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:08 +0200 Message-Id: <1502117160-24655-5-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 14:46:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 04/56] char: Make ringbuf-read size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). ringbuf-read parameter @size is 'int' (int64_t). qmp_ringbuf_read() rejects negative values, then implicitly converts to size_t. Change the parameter to 'size' and drop the check for negative values. ringbuf-read now accepts size values between 2^63 and 2^64-1. It accepts negative values as before, because that's how the QObject input visitor works for backward compatibility. The HMP command's size parameter remains uint32_t, as HMP args_type strings can't do uint64_t byte counts: 'l' is signed, and 'o' multiplies by 2^20. Signed-off-by: Markus Armbruster --- chardev/char-ringbuf.c | 11 +++-------- qapi-schema.json | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/chardev/char-ringbuf.c b/chardev/char-ringbuf.c index df52b04..a9205ea 100644 --- a/chardev/char-ringbuf.c +++ b/chardev/char-ringbuf.c @@ -65,10 +65,10 @@ static int ringbuf_chr_write(Chardev *chr, const uint8_= t *buf, int len) return len; } =20 -static int ringbuf_chr_read(Chardev *chr, uint8_t *buf, int len) +static int ringbuf_chr_read(Chardev *chr, uint8_t *buf, size_t len) { RingBufChardev *d =3D RINGBUF_CHARDEV(chr); - int i; + size_t i; =20 qemu_mutex_lock(&chr->chr_write_lock); for (i =3D 0; i < len && d->cons !=3D d->prod; i++) { @@ -151,7 +151,7 @@ void qmp_ringbuf_write(const char *device, const char *= data, } } =20 -char *qmp_ringbuf_read(const char *device, int64_t size, +char *qmp_ringbuf_read(const char *device, uint64_t size, bool has_format, enum DataFormat format, Error **errp) { @@ -171,11 +171,6 @@ char *qmp_ringbuf_read(const char *device, int64_t siz= e, return NULL; } =20 - if (size <=3D 0) { - error_setg(errp, "size must be greater than zero"); - return NULL; - } - count =3D ringbuf_count(chr); size =3D size > count ? count : size; read_data =3D g_malloc(size + 1); diff --git a/qapi-schema.json b/qapi-schema.json index febe70e..18ec301 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -543,7 +543,7 @@ # ## { 'command': 'ringbuf-read', - 'data': {'device': 'str', 'size': 'int', '*format': 'DataFormat'}, + 'data': {'device': 'str', 'size': 'size', '*format': 'DataFormat'}, 'returns': 'str' } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117416182838.0155258458615; Mon, 7 Aug 2017 07:50:16 -0700 (PDT) Received: from localhost ([::1]:37706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejME-0001Ye-GI for importer@patchew.org; Mon, 07 Aug 2017 10:50:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIh-0006uh-Kk for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIY-0003eY-4o for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIN-0003QG-Qv; Mon, 07 Aug 2017 10:46:15 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43B57356E3; Mon, 7 Aug 2017 14:46:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E89108F363; Mon, 7 Aug 2017 14:46:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1A17211386C8; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 43B57356E3 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:09 +0200 Message-Id: <1502117160-24655-6-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 05/56] char: Make ringbuf size unsigned in QAPI 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). ChardevRingbuf member @size is 'int' (int64_t). Doesn't really matter, as its users chardev-add and chardev-change manually reject sizes that aren't powers of two. Change the ChardevRingbuf member to 'size' anyway. Signed-off-by: Markus Armbruster --- qapi-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index 18ec301..f4a71df 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5106,7 +5106,7 @@ # # Since: 1.5 ## -{ 'struct': 'ChardevRingbuf', 'data': { '*size' : 'int' }, +{ 'struct': 'ChardevRingbuf', 'data': { '*size' : 'size' }, 'base': 'ChardevCommon' } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118415396292.79956454047465; Mon, 7 Aug 2017 08:06:55 -0700 (PDT) Received: from localhost ([::1]:37792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejcL-00004y-Sm for importer@patchew.org; Mon, 07 Aug 2017 11:06:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ2-0007L2-Q8 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIn-0003tO-LQ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIU-0003YQ-D9; Mon, 07 Aug 2017 10:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 470658046A; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC1DF5C269; Mon, 7 Aug 2017 14:46:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1DB9211386C9; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 470658046A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:10 +0200 Message-Id: <1502117160-24655-7-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 06/56] char: Don't truncate -chardev and HMP chardev-add ringbuf 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu_chr_parse_ringbuf() initializes the new ChardevRingbuf's @size to the value of qemu_opt_get_size(). Except it first truncates the value from uint64_t to int. Fix that, so you can waste your RAM on multi-gigabyte ring buffers. Signed-off-by: Markus Armbruster --- chardev/char-ringbuf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/chardev/char-ringbuf.c b/chardev/char-ringbuf.c index a9205ea..9275ae9 100644 --- a/chardev/char-ringbuf.c +++ b/chardev/char-ringbuf.c @@ -198,18 +198,14 @@ char *qmp_ringbuf_read(const char *device, uint64_t s= ize, static void qemu_chr_parse_ringbuf(QemuOpts *opts, ChardevBackend *backend, Error **errp) { - int val; ChardevRingbuf *ringbuf; =20 backend->type =3D CHARDEV_BACKEND_KIND_RINGBUF; ringbuf =3D backend->u.ringbuf.data =3D g_new0(ChardevRingbuf, 1); qemu_chr_parse_common(opts, qapi_ChardevRingbuf_base(ringbuf)); =20 - val =3D qemu_opt_get_size(opts, "size", 0); - if (val !=3D 0) { - ringbuf->has_size =3D true; - ringbuf->size =3D val; - } + ringbuf->size =3D qemu_opt_get_size(opts, "size", 0); + ringbuf->has_size =3D ringbuf->size !=3D 0; } =20 static void char_ringbuf_class_init(ObjectClass *oc, void *data) --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118889127850.3890191435561; Mon, 7 Aug 2017 08:14:49 -0700 (PDT) Received: from localhost ([::1]:37824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejjz-0007ui-Sv for importer@patchew.org; Mon, 07 Aug 2017 11:14:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ6-0007Pp-HO for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIr-0003vv-5G for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003Zq-D9; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 510D2633; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC0E8707C0; Mon, 7 Aug 2017 14:46:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 216B711386CA; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 510D2633 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:11 +0200 Message-Id: <1502117160-24655-8-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 07/56] cpus: Make memsave, pmemsave sizes, addresses unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes, virtual and physical addresses should use QAPI type 'size' (uint64_t). memsave, pmemsave parameters @val, @size are 'int' (int64_t). qmp_memsave() and qmp_pmemsave() implicitly convert to target_ulong or hwaddr. Change the parameters to 'size'. Both commands now accept size and address values between 2^63 and 2^64-1. They accept negative values as before, because that's how the QObject input visitor works for backward compatibility. The HMP commands' size parameters remain uint32_t, as HMP args_type strings can't do uint64_t byte counts: 'l' is signed, and 'o' multiplies by 2^20. Their address parameters remain int64_t for the same reason. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- cpus.c | 6 +++--- qapi-schema.json | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cpus.c b/cpus.c index 9bed61e..8c5ee05 100644 --- a/cpus.c +++ b/cpus.c @@ -1947,14 +1947,14 @@ CpuInfoList *qmp_query_cpus(Error **errp) return head; } =20 -void qmp_memsave(int64_t addr, int64_t size, const char *filename, +void qmp_memsave(uint64_t addr, uint64_t size, const char *filename, bool has_cpu, int64_t cpu_index, Error **errp) { FILE *f; uint32_t l; CPUState *cpu; uint8_t buf[1024]; - int64_t orig_addr =3D addr, orig_size =3D size; + uint64_t orig_addr =3D addr, orig_size =3D size; =20 if (!has_cpu) { cpu_index =3D 0; @@ -1994,7 +1994,7 @@ exit: fclose(f); } =20 -void qmp_pmemsave(int64_t addr, int64_t size, const char *filename, +void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename, Error **errp) { FILE *f; diff --git a/qapi-schema.json b/qapi-schema.json index f4a71df..80458fa 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2460,7 +2460,8 @@ # ## { 'command': 'memsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': '= int'} } + 'data': {'val': 'size', 'size': 'size', 'filename': 'str', + '*cpu-index': 'int'} } =20 ## # @pmemsave: @@ -2489,7 +2490,7 @@ # ## { 'command': 'pmemsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } + 'data': {'val': 'size', 'size': 'size', 'filename': 'str'} } =20 ## # @cont: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118576200510.75547891407075; Mon, 7 Aug 2017 08:09:36 -0700 (PDT) Received: from localhost ([::1]:37800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejew-0002TN-Rm for importer@patchew.org; Mon, 07 Aug 2017 11:09:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ5-0007Nq-1v for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIp-0003ug-HT for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIU-0003YH-5g; Mon, 07 Aug 2017 10:46:22 -0400 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 27BDE83F3D; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED17094C6D; Mon, 7 Aug 2017 14:46:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2480711386CC; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 27BDE83F3D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:12 +0200 Message-Id: <1502117160-24655-9-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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.27]); Mon, 07 Aug 2017 14:46:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 08/56] dump: Make sizes and addresses unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes, virtual and physical addresses should use QAPI type 'size' (uint64_t). dump-guest-memory parameters @begin, @length are 'int' (int64_t). They get implicitly converted to unsigned types somewhere down in the bowels of the dump machinery. DumpQueryResult members @completed and @total are also 'int', and also implicitly converted. Change these dump-guest-memory parameters and DumpQueryResult members to 'size'. dump-guest-memory now accepts size and address values between 2^63 and 2^64-1. They accept negative values as before, because that's how the QObject input visitor works for backward compatibility. query-dump and DUMP_COMPLETED now report sizes above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info dump". Drop a few redundant initializers and an incorrect, disabled debug print while there. Parameters of HMP's dump-guest-memory remain uint32_t, as HMP args_type strings can't do uint64_t byte counts: 'l' is signed, and 'o' multiplies by 2^20. Signed-off-by: Markus Armbruster --- dump.c | 26 ++++++++++++-------------- hmp.c | 2 +- include/sysemu/dump.h | 8 ++++---- include/sysemu/memory_mapping.h | 4 ++-- memory_mapping.c | 4 ++-- qapi-schema.json | 6 +++--- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/dump.c b/dump.c index d9090a2..452f20f 100644 --- a/dump.c +++ b/dump.c @@ -331,7 +331,7 @@ static void write_elf_section(DumpState *s, int type, E= rror **errp) } } =20 -static void write_data(DumpState *s, void *buf, int length, Error **errp) +static void write_data(DumpState *s, void *buf, size_t length, Error **err= p) { int ret; =20 @@ -345,9 +345,9 @@ static void write_data(DumpState *s, void *buf, int len= gth, Error **errp) =20 /* write the memory to vmcore. 1 page per I/O. */ static void write_memory(DumpState *s, GuestPhysBlock *block, ram_addr_t s= tart, - int64_t size, Error **errp) + uint64_t size, Error **errp) { - int64_t i; + uint64_t i; Error *local_err =3D NULL; =20 for (i =3D 0; i < size / s->dump_info.page_size; i++) { @@ -378,7 +378,7 @@ static void get_offset_range(hwaddr phys_addr, { GuestPhysBlock *block; hwaddr offset =3D s->memory_offset; - int64_t size_in_block, start; + uint64_t size_in_block, start; =20 /* When the memory is not stored into vmcore, offset will be -1 */ *p_offset =3D -1; @@ -602,7 +602,7 @@ static int get_next_block(DumpState *s, GuestPhysBlock = *block) static void dump_iterate(DumpState *s, Error **errp) { GuestPhysBlock *block; - int64_t size; + uint64_t size; Error *local_err =3D NULL; =20 do { @@ -1466,10 +1466,10 @@ bool dump_in_progress(void) =20 /* calculate total size of memory to be dumped (taking filter into * acoount.) */ -static int64_t dump_calculate_size(DumpState *s) +static uint64_t dump_calculate_size(DumpState *s) { GuestPhysBlock *block; - int64_t size =3D 0, total =3D 0, left =3D 0, right =3D 0; + uint64_t total =3D 0, size, left, right; =20 QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { if (s->has_filter) { @@ -1490,7 +1490,7 @@ static int64_t dump_calculate_size(DumpState *s) =20 static void dump_init(DumpState *s, int fd, bool has_format, DumpGuestMemoryFormat format, bool paging, bool has_= filter, - int64_t begin, int64_t length, Error **errp) + uint64_t begin, uint64_t length, Error **errp) { CPUState *cpu; int nr_cpus; @@ -1532,9 +1532,6 @@ static void dump_init(DumpState *s, int fd, bool has_= format, guest_phys_blocks_init(&s->guest_phys_blocks); guest_phys_blocks_append(&s->guest_phys_blocks); s->total_size =3D dump_calculate_size(s); -#ifdef DEBUG_DUMP_GUEST_MEMORY - fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size); -#endif =20 s->start =3D get_start_block(s); if (s->start =3D=3D -1) { @@ -1667,7 +1664,7 @@ cleanup: static void dump_process(DumpState *s, Error **errp) { Error *local_err =3D NULL; - DumpQueryResult *result =3D NULL; + DumpQueryResult *result; =20 if (s->has_format && s->format !=3D DUMP_GUEST_MEMORY_FORMAT_ELF) { create_kdump_vmcore(s, &local_err); @@ -1706,6 +1703,7 @@ DumpQueryResult *qmp_query_dump(Error **errp) { DumpQueryResult *result =3D g_new(DumpQueryResult, 1); DumpState *state =3D &dump_state_global; + result->status =3D atomic_read(&state->status); /* make sure we are reading status and written_size in order */ smp_rmb(); @@ -1716,8 +1714,8 @@ DumpQueryResult *qmp_query_dump(Error **errp) =20 void qmp_dump_guest_memory(bool paging, const char *file, bool has_detach, bool detach, - bool has_begin, int64_t begin, bool has_length, - int64_t length, bool has_format, + bool has_begin, uint64_t begin, bool has_length, + uint64_t length, bool has_format, DumpGuestMemoryFormat format, Error **errp) { const char *p; diff --git a/hmp.c b/hmp.c index fd80dce..8257dd0 100644 --- a/hmp.c +++ b/hmp.c @@ -2797,12 +2797,12 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const Q= Dict *qdict) void hmp_info_dump(Monitor *mon, const QDict *qdict) { DumpQueryResult *result =3D qmp_query_dump(NULL); + double percent; =20 assert(result && result->status < DUMP_STATUS__MAX); monitor_printf(mon, "Status: %s\n", DumpStatus_lookup[result->status]); =20 if (result->status =3D=3D DUMP_STATUS_ACTIVE) { - float percent =3D 0; assert(result->total !=3D 0); percent =3D 100.0 * result->completed / result->total; monitor_printf(mon, "Finished: %.2f %%\n", percent); diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 2672a15..52024d6 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -165,8 +165,8 @@ typedef struct DumpState { GuestPhysBlock *next_block; ram_addr_t start; bool has_filter; - int64_t begin; - int64_t length; + uint64_t begin; + uint64_t length; =20 uint8_t *note_buf; /* buffer for notes */ size_t note_buf_offset; /* the writing place in note_buf */ @@ -184,11 +184,11 @@ typedef struct DumpState { DumpGuestMemoryFormat format; /* valid only if has_format =3D=3D true = */ QemuThread dump_thread; /* thread for detached dump */ =20 - int64_t total_size; /* total memory size (in bytes) to + uint64_t total_size; /* total memory size (in bytes) to * be dumped. When filter is * enabled, this will only count * those to be written. */ - int64_t written_size; /* written memory size (in bytes), + uint64_t written_size; /* written memory size (in bytes), * this could be used to calculate * how much work we have * finished. */ diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mappin= g.h index 706152d..47d6252 100644 --- a/include/sysemu/memory_mapping.h +++ b/include/sysemu/memory_mapping.h @@ -79,7 +79,7 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *lis= t, void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list, const GuestPhysBlockList *guest_phys_blo= cks); =20 -void memory_mapping_filter(MemoryMappingList *list, int64_t begin, - int64_t length); +void memory_mapping_filter(MemoryMappingList *list, uint64_t begin, + uint64_t length); =20 #endif diff --git a/memory_mapping.c b/memory_mapping.c index a5d3855..a4fbdca 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -328,8 +328,8 @@ void qemu_get_guest_simple_memory_mapping(MemoryMapping= List *list, } } =20 -void memory_mapping_filter(MemoryMappingList *list, int64_t begin, - int64_t length) +void memory_mapping_filter(MemoryMappingList *list, uint64_t begin, + uint64_t length) { MemoryMapping *cur, *next; =20 diff --git a/qapi-schema.json b/qapi-schema.json index 80458fa..3ad2bc0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3439,7 +3439,7 @@ ## { 'command': 'dump-guest-memory', 'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool', - '*begin': 'int', '*length': 'int', + '*begin': 'size', '*length': 'size', '*format': 'DumpGuestMemoryFormat'} } =20 ## @@ -3475,8 +3475,8 @@ ## { 'struct': 'DumpQueryResult', 'data': { 'status': 'DumpStatus', - 'completed': 'int', - 'total': 'int' } } + 'completed': 'size', + 'total': 'size' } } =20 ## # @query-dump: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117394359952.6529005035701; Mon, 7 Aug 2017 07:49:54 -0700 (PDT) Received: from localhost ([::1]:37704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejLs-0001Ey-J0 for importer@patchew.org; Mon, 07 Aug 2017 10:49:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIj-0006wc-DB for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIY-0003fh-OB for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIO-0003TW-7u; Mon, 07 Aug 2017 10:46:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21641356EC; Mon, 7 Aug 2017 14:46:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C1E08F37A; Mon, 7 Aug 2017 14:46:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2803511386CD; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21641356EC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:13 +0200 Message-Id: <1502117160-24655-10-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 09/56] balloon: Make balloon size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). balloon parameter @value is 'int' (int64_t). qmp_balloon() implicitly converts to ram_addr_t, i.e. uint64_t. BALLOON_CHANGE parameter @actual and BalloonInfo member @actual are also 'int'. virtio_balloon_set_config() and virtio_balloon_stat() implicitly convert from ram_addr_t. Change all three to 'size', and adjust the code using them. balloon now accepts size values between 2^63 and 2^64-1. It accepts negative values as before, because that's how the QObject input visitor works for backward compatibility. Doing the same for HMP's balloon deserves its own commit (the next one). BALLOON_CHANGE and query-balloon now report sizes above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info balloon". Signed-off-by: Markus Armbruster --- balloon.c | 2 +- hmp.c | 2 +- qapi-schema.json | 4 ++-- qapi/event.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/balloon.c b/balloon.c index 1d720ff..2ecca76 100644 --- a/balloon.c +++ b/balloon.c @@ -102,7 +102,7 @@ BalloonInfo *qmp_query_balloon(Error **errp) return info; } =20 -void qmp_balloon(int64_t target, Error **errp) +void qmp_balloon(uint64_t target, Error **errp) { if (!have_balloon(errp)) { return; diff --git a/hmp.c b/hmp.c index 8257dd0..4556045 100644 --- a/hmp.c +++ b/hmp.c @@ -781,7 +781,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict) return; } =20 - monitor_printf(mon, "balloon: actual=3D%" PRId64 "\n", info->actual >>= 20); + monitor_printf(mon, "balloon: actual=3D%" PRIu64 "\n", info->actual >>= 20); =20 qapi_free_BalloonInfo(info); } diff --git a/qapi-schema.json b/qapi-schema.json index 3ad2bc0..23eb60d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2003,7 +2003,7 @@ # Since: 0.14.0 # ## -{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } } +{ 'struct': 'BalloonInfo', 'data': {'actual': 'size' } } =20 ## # @query-balloon: @@ -2603,7 +2603,7 @@ # <- { "return": {} } # ## -{ 'command': 'balloon', 'data': {'value': 'int'} } +{ 'command': 'balloon', 'data': {'value': 'size'} } =20 ## # @Abort: diff --git a/qapi/event.json b/qapi/event.json index 6d22b02..9dfc70b 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -488,7 +488,7 @@ # ## { 'event': 'BALLOON_CHANGE', - 'data': { 'actual': 'int' } } + 'data': { 'actual': 'size' } } =20 ## # @GUEST_PANICKED: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118736361755.5178633972151; Mon, 7 Aug 2017 08:12:16 -0700 (PDT) Received: from localhost ([::1]:37814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejhW-00058m-Pj for importer@patchew.org; Mon, 07 Aug 2017 11:12:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ5-0007Oo-OV for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIq-0003vV-HT for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003Zt-EV; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 500468046F; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E4D4707AC; Mon, 7 Aug 2017 14:46:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2B33C11386CF; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 500468046F Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:14 +0200 Message-Id: <1502117160-24655-11-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The previous commit made it unsigned in QMP. Switch HMP's args_type from 'M' to 'o'. Loses support for expressions (QEMU pocket calculator), gains support for units other than mebibytes. Negative values are no longer accepted and interpreted modulo 2^64. Instead, values between 2^63 and 2^64-1 are now accepted. Signed-off-by: Markus Armbruster --- hmp-commands.hx | 2 +- hmp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 1941e19..46ce79c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1433,7 +1433,7 @@ ETEXI =20 { .name =3D "balloon", - .args_type =3D "value:M", + .args_type =3D "value:o", .params =3D "target", .help =3D "request VM to change its memory allocation (in MB= )", .cmd =3D hmp_balloon, diff --git a/hmp.c b/hmp.c index 4556045..1932a11 100644 --- a/hmp.c +++ b/hmp.c @@ -781,7 +781,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict) return; } =20 - monitor_printf(mon, "balloon: actual=3D%" PRIu64 "\n", info->actual >>= 20); + monitor_printf(mon, "balloon: actual=3D%" PRId64 "\n", info->actual >>= 20); =20 qapi_free_BalloonInfo(info); } @@ -1178,7 +1178,7 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdic= t) =20 void hmp_balloon(Monitor *mon, const QDict *qdict) { - int64_t value =3D qdict_get_int(qdict, "value"); + uint64_t value =3D qdict_get_uint(qdict, "value"); Error *err =3D NULL; =20 qmp_balloon(value, &err); --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117573325471.462070871828; Mon, 7 Aug 2017 07:52:53 -0700 (PDT) Received: from localhost ([::1]:37719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejOk-00045y-5k for importer@patchew.org; Mon, 07 Aug 2017 10:52:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIt-00079J-Uz for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIe-0003mN-GF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIR-0003VU-35; Mon, 07 Aug 2017 10:46:19 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 018DA72FDD; Mon, 7 Aug 2017 14:46:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 413C17FE83; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2EF5111386D0; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 018DA72FDD Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:15 +0200 Message-Id: <1502117160-24655-12-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 07 Aug 2017 14:46:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 11/56] monitor: Drop unused HMP .args_type 'M' 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The previous commit switched balloon from 'M' to 'o', rendering 'M' unused. It was never used for anything else. Drop it. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- monitor.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/monitor.c b/monitor.c index 8b54ba1..3b2757e 100644 --- a/monitor.c +++ b/monitor.c @@ -101,8 +101,6 @@ * TYPEs that put an int64_t value with key NAME: * 'l' Argument is an expression (QEMU pocket calculator). * 'i' Like 'l' except value must fit into 32 bit unsigned. - * 'M' Like 'l' except value must not be negative and is multiplied - * by 2^20 (think "mebibyte"). * * TYPEs that put an uint64_t value with key NAME: * 'o' Argument is a size (think "octets"). Without suffix the @@ -134,7 +132,7 @@ * '?' Argument is optional, nothing is put when it is absent * (all types except 'O', '/', 'b'). * '.' Argument is optional, must be preceded by '.' if present - * (only types 'i', 'l', 'M') + * (only types 'i', 'l') */ =20 typedef struct mon_cmd_t { @@ -2913,7 +2911,6 @@ static QDict *monitor_parse_arguments(Monitor *mon, break; case 'i': case 'l': - case 'M': { int64_t val; =20 @@ -2944,12 +2941,6 @@ static QDict *monitor_parse_arguments(Monitor *mon, monitor_printf(mon, "\'%s\' has failed: ", cmd->name); monitor_printf(mon, "integer is for 32-bit values\n"); goto fail; - } else if (c =3D=3D 'M') { - if (val < 0) { - monitor_printf(mon, "enter a positive value\n"); - goto fail; - } - val <<=3D 20; } qdict_put_int(qdict, key, val); } --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15021190469391002.1534431274304; Mon, 7 Aug 2017 08:17:26 -0700 (PDT) Received: from localhost ([::1]:37839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejmX-00021t-Ja for importer@patchew.org; Mon, 07 Aug 2017 11:17:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ6-0007Ps-Ix for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIr-0003wM-HV for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50180) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003Zy-IM; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F3AAC047B62; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37E428FBE0; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 31FA311386D1; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F3AAC047B62 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:16 +0200 Message-Id: <1502117160-24655-13-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 12/56] pc-dimm: Make size and address unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes and addresses should use QAPI type 'size' (uint64_t). PCDIMMDeviceInfo members @addr and @size are 'int' (int64_t). qmp_pc_dimm_device_list() implicitly converts from uint64_t. Change these PCDIMMDeviceInfo members to 'size'. query-memory-devices now reports sizes and addresses above 2^63-1 correctly instead of their (negative) two's complement. HMP's "info memory-devices" already reported them correctly, because it printed the signed integers with PRIx64 and PRIu32. Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov --- qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 23eb60d..6aa6be9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -6057,8 +6057,8 @@ ## { 'struct': 'PCDIMMDeviceInfo', 'data': { '*id': 'str', - 'addr': 'int', - 'size': 'int', + 'addr': 'size', + 'size': 'size', 'slot': 'int', 'node': 'int', 'memdev': 'str', --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117408323447.37274090801986; Mon, 7 Aug 2017 07:50:08 -0700 (PDT) Received: from localhost ([::1]:37705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejM7-0001RH-3c for importer@patchew.org; Mon, 07 Aug 2017 10:50:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIs-00077m-O1 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejId-0003le-LK for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56050) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIR-0003VS-31; Mon, 07 Aug 2017 10:46:19 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id F1F49356F6; Mon, 7 Aug 2017 14:46:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72EC47F479; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 35C1A11386D2; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F1F49356F6 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:17 +0200 Message-Id: <1502117160-24655-14-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 13/56] pci: Make PCI addresses and sizes unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes and addresses should use QAPI type 'size' (uint64_t). PciMemoryRegion members @address and @size are 'int' (int64_t). qmp_query_pci_regions() implicitly converts from pcibus_t, i.e. uint64_t. Change these PciMemoryRegion members to 'size'. query-pci now reports sizes and addresses above 2^63-1 correctly instead of their (negative) two's complement. HMP's "info pci" already reported them correctly, because it implicitly converted back to uint64_t. Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum --- qapi-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index 6aa6be9..c8cceb9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2062,7 +2062,7 @@ # Since: 0.14.0 ## { 'struct': 'PciMemoryRegion', - 'data': {'bar': 'int', 'type': 'str', 'address': 'int', 'size': 'int', + 'data': {'bar': 'int', 'type': 'str', 'address': 'size', 'size': 'size', '*prefetch': 'bool', '*mem_type_64': 'bool' } } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119885869834.6518503769031; Mon, 7 Aug 2017 08:31:25 -0700 (PDT) Received: from localhost ([::1]:37919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dek04-0006RT-LJ for importer@patchew.org; Mon, 07 Aug 2017 11:31:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJH-0007cD-W6 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ1-00045T-U7 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fb-Cz; Mon, 07 Aug 2017 10:46:27 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 23BD4A8A6; Mon, 7 Aug 2017 14:46:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6515F90C71; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 399F711386D3; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 23BD4A8A6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:18 +0200 Message-Id: <1502117160-24655-15-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 14/56] migration: Fix migrate-set-cache-size error reporting 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qmp_migrate_set_cache_size() calls xbzrle_cache_resize() to do the actual work, which in turn calls cache_init() to resize the cache. If cache_init() fails, xbzrle_cache_resize() reports that error with error_report() and fails. qmp_migrate_set_cache_size() detects the failure and reports "Parameter 'cache size' expects is smaller than page size" with error_setg(). The first error is accurate, the second is bogus. With HMP, we get both. With QMP, we get the accurate one on stderr, and the bogus one via QMP. Fix by making xbzrle_cache_resize() use error_setg() instead of error_report(). Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela --- migration/migration.c | 4 +--- migration/ram.c | 9 +++++++-- migration/ram.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c3fe0ed..3ce68f3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1298,10 +1298,8 @@ void qmp_migrate_set_cache_size(int64_t value, Error= **errp) return; } =20 - new_size =3D xbzrle_cache_resize(value); + new_size =3D xbzrle_cache_resize(value, errp); if (new_size < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "is smaller than page size"); return; } =20 diff --git a/migration/ram.c b/migration/ram.c index e18b3e2..e9ab858 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -29,6 +29,7 @@ #include "cpu.h" #include #include "qapi-event.h" +#include "qapi/qmp/qerror.h" #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" @@ -110,15 +111,19 @@ static void XBZRLE_cache_unlock(void) * hence changes to the cache are protected by XBZRLE.lock(). * * Returns the new_size or negative in case of error. + * Returns the the new cache size on success, -1 on error. * * @new_size: new cache size + * @errp: return location for an Error */ -int64_t xbzrle_cache_resize(int64_t new_size) +int64_t xbzrle_cache_resize(int64_t new_size, Error **errp) { PageCache *new_cache; int64_t ret; =20 if (new_size < TARGET_PAGE_SIZE) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "is smaller than page size"); return -1; } =20 @@ -131,7 +136,7 @@ int64_t xbzrle_cache_resize(int64_t new_size) new_cache =3D cache_init(new_size / TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); if (!new_cache) { - error_report("Error creating cache"); + error_setg(errp, "Error creating cache"); ret =3D -1; goto out; } diff --git a/migration/ram.h b/migration/ram.h index c081fde..97842bf 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -35,7 +35,7 @@ extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; =20 -int64_t xbzrle_cache_resize(int64_t new_size); +int64_t xbzrle_cache_resize(int64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117457197920.5581023585037; Mon, 7 Aug 2017 07:50:57 -0700 (PDT) Received: from localhost ([::1]:37712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejMt-0002VW-N3 for importer@patchew.org; Mon, 07 Aug 2017 10:50:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ5-0007Np-1X for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIp-0003uN-7A for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54832) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIU-0003YG-6C; Mon, 07 Aug 2017 10:46:22 -0400 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 2A7A8DB93D; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C4C194C74; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3CEDB11386D5; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A7A8DB93D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:19 +0200 Message-Id: <1502117160-24655-16-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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.38]); Mon, 07 Aug 2017 14:46:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 15/56] migration: Make XBZRLE cache size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). migrate-set-cache-size parameter @value is 'int' (int64_t). qmp_migrate_set_cache_size() ensures it fits into size_t. page_cache.c implicitly converts the signed size to unsigned types (it can't quite decide whether to use uint64_t or size_t for cache offsets, but that's not something I can tackle now). XBZRLECacheStats member @cache-size and query-migrate-cache-size's result are also 'int'. Change the migrate-set-cache-size parameter and the XBZRLECacheStats members to 'size', fix up hmp_migrate_set_cache_size(), and tweak a few variable types to reduce implicit conversions. migrate-set-cache-size now accepts size values between 2^63 and 2^64-1. It accepts negative values as before, because that's how the QObject input visitor works for backward compatibility. So does HMP's migrate_set_cache_size. query-migrate and query-migrate-cache-size now report cache sizes above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info migrate_cache_size". HMP's "info migrate" already reported the cache size correctly, because it printed the signed integer with PRIu32. Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela --- hmp.c | 4 ++-- migration/migration.c | 10 +++++----- migration/migration.h | 4 ++-- migration/page_cache.c | 20 +++++++++----------- migration/page_cache.h | 2 +- migration/ram.c | 5 ++--- migration/ram.h | 2 +- qapi-schema.json | 6 +++--- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/hmp.c b/hmp.c index 1932a11..184fb8b 100644 --- a/hmp.c +++ b/hmp.c @@ -344,7 +344,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) =20 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict) { - monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n", + monitor_printf(mon, "xbzrel cache size: %" PRIu64 " kbytes\n", qmp_query_migrate_cache_size(NULL) >> 10); } =20 @@ -1504,7 +1504,7 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDi= ct *qdict) =20 void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) { - int64_t value =3D qdict_get_int(qdict, "value"); + uint64_t value =3D qdict_get_uint(qdict, "value"); Error *err =3D NULL; =20 qmp_migrate_set_cache_size(value, &err); diff --git a/migration/migration.c b/migration/migration.c index 3ce68f3..2d7f3a2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1279,13 +1279,13 @@ void qmp_migrate_cancel(Error **errp) migrate_fd_cancel(migrate_get_current()); } =20 -void qmp_migrate_set_cache_size(int64_t value, Error **errp) +void qmp_migrate_set_cache_size(uint64_t value, Error **errp) { MigrationState *s =3D migrate_get_current(); - int64_t new_size; + ssize_t new_size; =20 /* Check for truncation */ - if (value !=3D (size_t)value) { + if (value !=3D (ssize_t)value) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", "exceeding address space"); return; @@ -1306,7 +1306,7 @@ void qmp_migrate_set_cache_size(int64_t value, Error = **errp) s->xbzrle_cache_size =3D new_size; } =20 -int64_t qmp_query_migrate_cache_size(Error **errp) +uint64_t qmp_query_migrate_cache_size(Error **errp) { return migrate_xbzrle_cache_size(); } @@ -1431,7 +1431,7 @@ int migrate_use_xbzrle(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE]; } =20 -int64_t migrate_xbzrle_cache_size(void) +size_t migrate_xbzrle_cache_size(void) { MigrationState *s; =20 diff --git a/migration/migration.h b/migration/migration.h index 148c9fa..e4708e1 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -106,7 +106,7 @@ struct MigrationState int64_t downtime; int64_t expected_downtime; bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; - int64_t xbzrle_cache_size; + size_t xbzrle_cache_size; int64_t setup_time; =20 /* Flag set once the migration has been asked to enter postcopy */ @@ -172,7 +172,7 @@ bool migrate_zero_blocks(void); bool migrate_auto_converge(void); =20 int migrate_use_xbzrle(void); -int64_t migrate_xbzrle_cache_size(void); +size_t migrate_xbzrle_cache_size(void); bool migrate_colo_enabled(void); =20 bool migrate_use_block(void); diff --git a/migration/page_cache.c b/migration/page_cache.c index ba984c4..226ea72 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -40,18 +40,17 @@ struct CacheItem { struct PageCache { CacheItem *page_cache; unsigned int page_size; - int64_t max_num_items; + uint64_t max_num_items; uint64_t max_item_age; - int64_t num_items; + uint64_t num_items; }; =20 -PageCache *cache_init(int64_t num_pages, unsigned int page_size) +PageCache *cache_init(uint64_t num_pages, unsigned page_size) { - int64_t i; - + uint64_t i; PageCache *cache; =20 - if (num_pages <=3D 0) { + if (!num_pages) { DPRINTF("invalid number of pages\n"); return NULL; } @@ -65,18 +64,17 @@ PageCache *cache_init(int64_t num_pages, unsigned int p= age_size) /* round down to the nearest power of 2 */ if (!is_power_of_2(num_pages)) { num_pages =3D pow2floor(num_pages); - DPRINTF("rounding down to %" PRId64 "\n", num_pages); + DPRINTF("rounding down to %zd\n", num_pages); } cache->page_size =3D page_size; cache->num_items =3D 0; cache->max_item_age =3D 0; cache->max_num_items =3D num_pages; =20 - DPRINTF("Setting cache buckets to %" PRId64 "\n", cache->max_num_items= ); + DPRINTF("Setting cache buckets to %zd\n", cache->max_num_items); =20 /* We prefer not to abort if there is no memory */ - cache->page_cache =3D g_try_malloc((cache->max_num_items) * - sizeof(*cache->page_cache)); + cache->page_cache =3D g_try_new(CacheItem, cache->max_num_items); if (!cache->page_cache) { DPRINTF("Failed to allocate cache->page_cache\n"); g_free(cache); @@ -94,7 +92,7 @@ PageCache *cache_init(int64_t num_pages, unsigned int pag= e_size) =20 void cache_fini(PageCache *cache) { - int64_t i; + uint64_t i; =20 g_assert(cache); g_assert(cache->page_cache); diff --git a/migration/page_cache.h b/migration/page_cache.h index 4fadd0c..b9afce3 100644 --- a/migration/page_cache.h +++ b/migration/page_cache.h @@ -28,7 +28,7 @@ typedef struct PageCache PageCache; * @num_pages: cache maximal number of cached pages * @page_size: cache page size */ -PageCache *cache_init(int64_t num_pages, unsigned int page_size); +PageCache *cache_init(uint64_t num_pages, unsigned page_size); =20 /** * cache_fini: free all cache resources diff --git a/migration/ram.c b/migration/ram.c index e9ab858..ce38be4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -110,16 +110,15 @@ static void XBZRLE_cache_unlock(void) * migration may be using the cache and might finish during this call, * hence changes to the cache are protected by XBZRLE.lock(). * - * Returns the new_size or negative in case of error. * Returns the the new cache size on success, -1 on error. * * @new_size: new cache size * @errp: return location for an Error */ -int64_t xbzrle_cache_resize(int64_t new_size, Error **errp) +ssize_t xbzrle_cache_resize(size_t new_size, Error **errp) { PageCache *new_cache; - int64_t ret; + ssize_t ret; =20 if (new_size < TARGET_PAGE_SIZE) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", diff --git a/migration/ram.h b/migration/ram.h index 97842bf..7c4187d 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -35,7 +35,7 @@ extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; =20 -int64_t xbzrle_cache_resize(int64_t new_size, Error **errp); +ssize_t xbzrle_cache_resize(size_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 diff --git a/qapi-schema.json b/qapi-schema.json index c8cceb9..ecabff6 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -646,7 +646,7 @@ # Since: 1.2 ## { 'struct': 'XBZRLECacheStats', - 'data': {'cache-size': 'int', 'bytes': 'int', 'pages': 'int', + 'data': {'cache-size': 'size', 'bytes': 'int', 'pages': 'int', 'cache-miss': 'int', 'cache-miss-rate': 'number', 'overflow': 'int' } } =20 @@ -2875,7 +2875,7 @@ # <- { "return": {} } # ## -{ 'command': 'migrate-set-cache-size', 'data': {'value': 'int'} } +{ 'command': 'migrate-set-cache-size', 'data': {'value': 'size'} } =20 ## # @query-migrate-cache-size: @@ -2892,7 +2892,7 @@ # <- { "return": 67108864 } # ## -{ 'command': 'query-migrate-cache-size', 'returns': 'int' } +{ 'command': 'query-migrate-cache-size', 'returns': 'size' } =20 ## # @ObjectPropertyInfo: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150211773845881.97537985542294; Mon, 7 Aug 2017 07:55:38 -0700 (PDT) Received: from localhost ([::1]:37734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejRP-0006SV-Qg for importer@patchew.org; Mon, 07 Aug 2017 10:55:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIt-00079E-Tl for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIe-0003mD-DQ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54726) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIQ-0003VQ-TG; Mon, 07 Aug 2017 10:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E32472FD8; Mon, 7 Aug 2017 14:46:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B1218FC1C; Mon, 7 Aug 2017 14:46:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4035411386D6; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E32472FD8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:20 +0200 Message-Id: <1502117160-24655-17-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 07 Aug 2017 14:46:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 16/56] migration: Make XBZRLE transferred size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). XBZRLECacheStats member @bytes is 'int' (int64_t). save_xbzrle_page() computes the byte count increment in size_t, implicitly converts it to int, then adds that to @bytes. Change the XBZRLECacheStats member to 'size' and clean up save_xbzrle_page(). query-migrate now reports transferred sizes above 2^63-1 correctly instead of their (negative) two's complement. HMP's "info migrate" already reported them correctly, because it printed the signed integer with PRIu64. Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela --- migration/ram.c | 3 ++- qapi-schema.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ce38be4..5c247f8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -461,7 +461,8 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **cur= rent_data, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, bool last_stage) { - int encoded_len =3D 0, bytes_xbzrle; + int encoded_len; + size_t bytes_xbzrle; uint8_t *prev_cached_page; =20 if (!cache_is_cached(XBZRLE.cache, current_addr, diff --git a/qapi-schema.json b/qapi-schema.json index ecabff6..4a3d07e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -646,7 +646,7 @@ # Since: 1.2 ## { 'struct': 'XBZRLECacheStats', - 'data': {'cache-size': 'size', 'bytes': 'int', 'pages': 'int', + 'data': {'cache-size': 'size', 'bytes': 'size', 'pages': 'int', 'cache-miss': 'int', 'cache-miss-rate': 'number', 'overflow': 'int' } } =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15021179038501019.1506867358837; Mon, 7 Aug 2017 07:58:23 -0700 (PDT) Received: from localhost ([::1]:37752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejU6-0000qA-Eo for importer@patchew.org; Mon, 07 Aug 2017 10:58:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIu-00079h-6J for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIf-0003mi-0e for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIR-0003Vb-7y; Mon, 07 Aug 2017 10:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 333FD7F415; Mon, 7 Aug 2017 14:46:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1C41600C4; Mon, 7 Aug 2017 14:46:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4350011386D7; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 333FD7F415 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:21 +0200 Message-Id: <1502117160-24655-18-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 17/56] migration: Make MigrationStats sizes unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). MigrationStats members @transferred, @remaining, @total, @normal-bytes, @page-size are 'int' (int64_t). populate_ram_info(), populate_disk_info() and and many places that update them in global variable @ram_counters implicitly convert from unsigned types. Change these MigrationStats members to 'size'. query-migrate now reports them correctly above 2^63-1 instead of their (negative) two's complement. HMP's "info migrate" already reported them correctly, because it printed the signed integer with PRIu64. Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela --- qapi-schema.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 4a3d07e..2eee676 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -620,11 +620,11 @@ # Since: 0.14.0 ## { 'struct': 'MigrationStats', - 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' , + 'data': {'transferred': 'size', 'remaining': 'size', 'total': 'size' , 'duplicate': 'int', 'skipped': 'int', 'normal': 'int', - 'normal-bytes': 'int', 'dirty-pages-rate' : 'int', + 'normal-bytes': 'size', 'dirty-pages-rate' : 'int', 'mbps' : 'number', 'dirty-sync-count' : 'int', - 'postcopy-requests' : 'int', 'page-size' : 'int' } } + 'postcopy-requests' : 'int', 'page-size' : 'size' } } =20 ## # @XBZRLECacheStats: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118229811646.8162335096416; Mon, 7 Aug 2017 08:03:49 -0700 (PDT) Received: from localhost ([::1]:37776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejZM-0005vK-HE for importer@patchew.org; Mon, 07 Aug 2017 11:03:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ4-0007Mx-6C for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIo-0003tn-5N for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58032) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIU-0003YK-7p; Mon, 07 Aug 2017 10:46:22 -0400 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 2A62E7F40C; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E510795212; Mon, 7 Aug 2017 14:46:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 46BE911386D8; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A62E7F40C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:22 +0200 Message-Id: <1502117160-24655-19-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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]); Mon, 07 Aug 2017 14:46:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 18/56] migration: Make parameter max-bandwidth unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte rates should use QAPI type 'size' (uint64_t). migrate_set_speed's parameter @value and member @max-bandwidth of MigrationParameters and MigrateSetParameters are 'int' (int64_t). Change them all to 'size'. migrate_set_speed and migrate-set-parameters now accept bandwidth values between 2^63 and SIZE_MAX (commonly 2^64-1). They accept negative values as before, because that's how the QObject input visitor works for backward compatibility. So does HMP's migrate_set_speed, except it continues to reject negative values. query-migrate-parameters now reports bandwidth values above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info migrate_params". Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela --- hmp.c | 2 +- migration/migration.c | 9 ++++----- qapi-schema.json | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hmp.c b/hmp.c index 184fb8b..9bcdcb3 100644 --- a/hmp.c +++ b/hmp.c @@ -322,7 +322,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME], params->tls_hostname); assert(params->has_max_bandwidth); - monitor_printf(mon, "%s: %" PRId64 " bytes/second\n", + monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n", MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH], params->max_bandwidth); assert(params->has_downtime_limit); diff --git a/migration/migration.c b/migration/migration.c index 2d7f3a2..0b47371 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -716,8 +716,7 @@ static bool migrate_params_check(MigrationParameters *p= arams, Error **errp) return false; } =20 - if (params->has_max_bandwidth && - (params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) { + if (params->has_max_bandwidth && params->max_bandwidth > SIZE_MAX) { error_setg(errp, "Parameter 'max_bandwidth' expects an integer in = the" " range of 0 to %zu bytes/second", SIZE_MAX); return false; @@ -1311,7 +1310,7 @@ uint64_t qmp_query_migrate_cache_size(Error **errp) return migrate_xbzrle_cache_size(); } =20 -void qmp_migrate_set_speed(int64_t value, Error **errp) +void qmp_migrate_set_speed(uint64_t value, Error **errp) { MigrateSetParameters p =3D { .has_max_bandwidth =3D true, @@ -2179,8 +2178,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-cpu-throttle-increment", MigrationState, parameters.cpu_throttle_increment, DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT), - DEFINE_PROP_INT64("x-max-bandwidth", MigrationState, - parameters.max_bandwidth, MAX_THROTTLE), + DEFINE_PROP_UINT64("x-max-bandwidth", MigrationState, + parameters.max_bandwidth, MAX_THROTTLE), DEFINE_PROP_INT64("x-downtime-limit", MigrationState, parameters.downtime_limit, DEFAULT_MIGRATE_SET_DOWNTIME), diff --git a/qapi-schema.json b/qapi-schema.json index 2eee676..c18e574 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1116,7 +1116,7 @@ '*cpu-throttle-increment': 'int', '*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', - '*max-bandwidth': 'int', + '*max-bandwidth': 'size', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', '*block-incremental': 'bool' } } @@ -1200,7 +1200,7 @@ '*cpu-throttle-increment': 'int', '*tls-creds': 'str', '*tls-hostname': 'str', - '*max-bandwidth': 'int', + '*max-bandwidth': 'size', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', '*block-incremental': 'bool' } } @@ -2852,7 +2852,7 @@ # <- { "return": {} } # ## -{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} } +{ 'command': 'migrate_set_speed', 'data': {'value': 'size'} } =20 ## # @migrate-set-cache-size: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118066318430.2030571226609; Mon, 7 Aug 2017 08:01:06 -0700 (PDT) Received: from localhost ([::1]:37766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejWi-0003iB-1a for importer@patchew.org; Mon, 07 Aug 2017 11:01:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIw-0007Bh-3S for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIg-0003o5-PB for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIS-0003WZ-8X; Mon, 07 Aug 2017 10:46:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C2C9806A1; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B581E8F363; Mon, 7 Aug 2017 14:46:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4A45F11386DB; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0C2C9806A1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:23 +0200 Message-Id: <1502117160-24655-20-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 19/56] block: Make snapshot VM state size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). SnapshotInfo member @vm-state-size is 'int' (int64_t). QEMUSnapshotInfo member @vm_state_size is uint64_t. bdrv_query_snapshot_info_list(), bdrv_image_info_dump(), qmp_blockdev_snapshot_delete_internal_sync() convert implicitly between the two. Change the SnapshotInfo member to 'size'. query-named-block-nodes, query-block and blockdev-snapshot-delete-internal-sync now report VM state sizes above 2^63-1 correctly instead of their (negative) two's complement. HMP's "info snapshots" and "info block" still report negative values, because bdrv_snapshot_dump() passes the size to get_human_readable_size(), which is still signed. To be fixed soon. Same for "qemu-img snapshot -l" and "qemu-img info". Signed-off-by: Markus Armbruster --- qapi/block-core.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 27790f3..ecfeecd 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -28,7 +28,7 @@ # ## { 'struct': 'SnapshotInfo', - 'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int', + 'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'size', 'date-sec': 'int', 'date-nsec': 'int', 'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } } =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119562868266.2033822692623; Mon, 7 Aug 2017 08:26:02 -0700 (PDT) Received: from localhost ([::1]:37891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejup-0001Zw-Qj for importer@patchew.org; Mon, 07 Aug 2017 11:25:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJJ-0007fB-Iq for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ4-000477-5I for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37446) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fx-HX; Mon, 07 Aug 2017 10:46:27 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 61717BDD0; Mon, 7 Aug 2017 14:46:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5BBF90C75; Mon, 7 Aug 2017 14:46:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4D59A11386DF; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 61717BDD0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:24 +0200 Message-Id: <1502117160-24655-21-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 20/56] block: Make ImageInfo sizes unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). ImageInfo members @virtual-size, @actual-size, @cluster-size are 'int' (int64_t). bdrv_query_image_info() gets their values from bdrv_getlength(), bdrv_get_allocated_file_size(), bdrv_get_info(), all signed. It ensures the former two are non-negative, but doesn't bother with cluster-size. vmdk_get_extent_info() initializes virtual-size and cluster-size from signed #sectors * BDRV_SECTOR_SIZE without checking for overflow. Perhaps we should be more careful with sizes overflowing into signs, but that's not something I can tackle now. Change these ImageInfo members to 'size'. query-named-block-nodes and query-block would now report image sizes above 2^63-1 correctly instead of their (negative) two's complement, if such values were possible (they aren't; the block layer uses int64_t internally). So would HMP's "info block", except for the ones it formats with get_human_readable_size(), which is still signed. To be fixed next. Same for "qemu-img info". Signed-off-by: Markus Armbruster --- block/qapi.c | 15 ++++++++++----- qapi/block-core.json | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 5f1a71f..1c6123c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -235,7 +235,7 @@ void bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, Error **errp) { - int64_t size; + int64_t size, allocated_size; const char *backing_filename; BlockDriverInfo bdi; int ret; @@ -251,12 +251,16 @@ void bdrv_query_image_info(BlockDriverState *bs, goto out; } =20 + allocated_size =3D bdrv_get_allocated_file_size(bs); + info =3D g_new0(ImageInfo, 1); info->filename =3D g_strdup(bs->filename); info->format =3D g_strdup(bdrv_get_format_name(bs)); info->virtual_size =3D size; - info->actual_size =3D bdrv_get_allocated_file_size(bs); - info->has_actual_size =3D info->actual_size >=3D 0; + if (allocated_size >=3D 0) { + info->actual_size =3D allocated_size; + info->has_actual_size =3D true; + } if (bdrv_is_encrypted(bs)) { info->encrypted =3D true; info->has_encrypted =3D true; @@ -727,6 +731,7 @@ void bdrv_image_info_dump(fprintf_function func_fprintf= , void *f, ImageInfo *info) { char size_buf[128], dsize_buf[128]; + if (!info->has_actual_size) { snprintf(dsize_buf, sizeof(dsize_buf), "unavailable"); } else { @@ -737,7 +742,7 @@ void bdrv_image_info_dump(fprintf_function func_fprintf= , void *f, func_fprintf(f, "image: %s\n" "file format: %s\n" - "virtual size: %s (%" PRId64 " bytes)\n" + "virtual size: %s (%" PRIu64 " bytes)\n" "disk size: %s\n", info->filename, info->format, size_buf, info->virtual_size, @@ -748,7 +753,7 @@ void bdrv_image_info_dump(fprintf_function func_fprintf= , void *f, } =20 if (info->has_cluster_size) { - func_fprintf(f, "cluster_size: %" PRId64 "\n", + func_fprintf(f, "cluster_size: %" PRIu64 "\n", info->cluster_size); } =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index ecfeecd..02e12f7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -156,8 +156,9 @@ ## { 'struct': 'ImageInfo', 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool', - '*actual-size': 'int', 'virtual-size': 'int', - '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'b= ool', + '*actual-size': 'size', 'virtual-size': 'size', + '*cluster-size': 'size', + '*encrypted': 'bool', '*compressed': 'bool', '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo= '], '*backing-image': 'ImageInfo', --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117896861108.58718559137913; Mon, 7 Aug 2017 07:58:16 -0700 (PDT) Received: from localhost ([::1]:37751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejTz-0000kH-N2 for importer@patchew.org; Mon, 07 Aug 2017 10:58:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejIy-0007Ew-Np for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIi-0003pe-V7 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIT-0003X8-2W; Mon, 07 Aug 2017 10:46:21 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id DA28E7F40C; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 476DC7F479; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 50E4D11385EE; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DA28E7F40C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:25 +0200 Message-Id: <1502117160-24655-22-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 21/56] block: Clean up get_human_readable_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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" get_human_readable_size() formats all negative numbers as if they were small. The previous two commits changed all callers to pass unsigned arguments. Change the parameter type to from int64_t to uint64_t. Also change the buffer size parameter from int (ahem!) to size_t. Signed-off-by: Markus Armbruster --- block/qapi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 1c6123c..0f6620e 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -566,10 +566,11 @@ BlockStatsList *qmp_query_blockstats(bool has_query_n= odes, =20 #define NB_SUFFIXES 4 =20 -static char *get_human_readable_size(char *buf, int buf_size, int64_t size) +static char *get_human_readable_size(char *buf, size_t buf_size, + uint64_t size) { static const char suffixes[NB_SUFFIXES] =3D {'K', 'M', 'G', 'T'}; - int64_t base; + uint64_t base; int i; =20 if (size <=3D 999) { --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118237895559.4364477648215; Mon, 7 Aug 2017 08:03:57 -0700 (PDT) Received: from localhost ([::1]:37777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejZU-00061x-Ky for importer@patchew.org; Mon, 07 Aug 2017 11:03:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ0-0007IJ-Vw for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIl-0003rp-HF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIT-0003Xs-SR; Mon, 07 Aug 2017 10:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96D026148C; Mon, 7 Aug 2017 14:46:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CDD64D72A; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 53EF611385FB; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 96D026148C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:26 +0200 Message-Id: <1502117160-24655-23-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 Aug 2017 14:46:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 22/56] block: Mix up signed and unsigned less in bdrv_img_create() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" @size is declared int64_t. It's set in two places. The second one assigns the (signed) value of bdrv_getlength(), then errors out if its negative. The first one assigns qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0), i.e. an uint64_t value. What if it exceeds INT64_MAX? Is that even possible? Turns out it is: $ qemu-img create -o size=3D9223372036854775808 foo.img On closer examination, the code still works as long as converting from uint64_t to int64_t and back doesn't change the value. Implementation-defined behavior, but sane implementations behave. Things actually break elsewhere for such sizes, e.g. file-posix.c's raw_create(). Clean this up. Signed-off-by: Markus Armbruster --- block.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ce9cce7..04cce0d 100644 --- a/block.c +++ b/block.c @@ -4309,7 +4309,8 @@ void bdrv_img_create(const char *filename, const char= *fmt, QemuOptsList *create_opts =3D NULL; QemuOpts *opts =3D NULL; const char *backing_fmt, *backing_file; - int64_t size; + uint64_t size; + int64_t backing_size; BlockDriver *drv, *proto_drv; Error *local_err =3D NULL; int ret =3D 0; @@ -4414,7 +4415,7 @@ void bdrv_img_create(const char *filename, const char= *fmt, bs =3D bdrv_open(full_backing, NULL, backing_options, back_flags, &local_err); g_free(full_backing); - if (!bs && size !=3D -1) { + if (!bs && size !=3D UINT64_MAX) { /* Couldn't open BS, but we have a size, so it's nonfatal */ warn_reportf_err(local_err, "Could not verify backing image. " @@ -4426,22 +4427,24 @@ void bdrv_img_create(const char *filename, const ch= ar *fmt, "Could not open backing image to determine s= ize.\n"); goto out; } else { - if (size =3D=3D -1) { + if (size =3D=3D UINT64_MAX) { /* Opened BS, have no size */ - size =3D bdrv_getlength(bs); - if (size < 0) { - error_setg_errno(errp, -size, "Could not get size of '= %s'", + backing_size =3D bdrv_getlength(bs); + if (backing_size < 0) { + error_setg_errno(errp, -backing_size, + "Could not get size of '%s'", backing_file); bdrv_unref(bs); goto out; } + size =3D backing_size; qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abo= rt); } bdrv_unref(bs); } } /* (backing_file && !(flags & BDRV_O_NO_BACKING)) */ =20 - if (size =3D=3D -1) { + if (size =3D=3D UINT64_MAX) { error_setg(errp, "Image creation needs a size parameter"); goto out; } --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118366680447.38219855356294; Mon, 7 Aug 2017 08:06:06 -0700 (PDT) Received: from localhost ([::1]:37789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejbY-0007nB-U1 for importer@patchew.org; Mon, 07 Aug 2017 11:06:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ4-0007NN-Jv for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIq-0003vG-ET for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003Zs-DD; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5059F8047E; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E1B3707BA; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 57B461138600; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5059F8047E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:27 +0200 Message-Id: <1502117160-24655-24-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 23/56] option: Fix type of qemu_opt_set_number() parameter @val 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Parameter @val is int64_t. It's assigned to opt->value.uint, which is uint64_t, because that's what QemuOpts integers are. Screwed up when the function was added in commit b83c18e. Change @val to uint64_t. Signed-off-by: Markus Armbruster --- include/qemu/option.h | 2 +- util/qemu-option.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index f7338db..d812da4 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -92,7 +92,7 @@ void qemu_opt_set(QemuOpts *opts, const char *name, const= char *value, Error **errp); void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val, Error **errp); -void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val, +void qemu_opt_set_number(QemuOpts *opts, const char *name, uint64_t val, Error **errp); typedef int (*qemu_opt_loopfunc)(void *opaque, const char *name, const char *value, diff --git a/util/qemu-option.c b/util/qemu-option.c index 9b1dc80..ca4f737 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -579,7 +579,7 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name= , bool val, QTAILQ_INSERT_TAIL(&opts->head, opt, next); } =20 -void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val, +void qemu_opt_set_number(QemuOpts *opts, const char *name, uint64_t val, Error **errp) { QemuOpt *opt; --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118057624713.7618806341616; Mon, 7 Aug 2017 08:00:57 -0700 (PDT) Received: from localhost ([::1]:37765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejWZ-0003bE-Tq for importer@patchew.org; Mon, 07 Aug 2017 11:00:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ4-0007NE-Gg for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIq-0003vN-Gb for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58114) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003Zu-DZ; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51ABF7F408; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FC16707BB; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5A95F1138603; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51ABF7F408 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:28 +0200 Message-Id: <1502117160-24655-25-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 24/56] block/qcow2: Change align_offset() to operate on uint64_t 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" align_offset() mixes different widths, and its callers pass both signed and unsigned values. It's best to stick to unsigned when twiddling bits. Signed-off-by: Markus Armbruster --- block/qcow2.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 96a8d43..0d7043e 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -468,10 +468,9 @@ static inline int offset_to_l2_index(BDRVQcow2State *s= , int64_t offset) return (offset >> s->cluster_bits) & (s->l2_size - 1); } =20 -static inline int64_t align_offset(int64_t offset, int n) +static inline uint64_t align_offset(uint64_t offset, uint64_t n) { - offset =3D (offset + n - 1) & ~(n - 1); - return offset; + return (offset + n - 1) & ~(n - 1); } =20 static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s) --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117957464628.6743180520195; Mon, 7 Aug 2017 07:59:17 -0700 (PDT) Received: from localhost ([::1]:37754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejUy-0001c8-7U for importer@patchew.org; Mon, 07 Aug 2017 10:59:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ1-0007JL-GE for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIl-0003ry-Je for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:46:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIU-0003YU-DG; Mon, 07 Aug 2017 10:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57E407F409; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 905BE68D41; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5E4711138605; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57E407F409 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:29 +0200 Message-Id: <1502117160-24655-26-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 25/56] block/qcow2: Change qcow2_calc_prealloc_size() to uint64_t 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Change parameter @total_size and return value to uint64_t. Callers mix uint64_t and int64_t. Thus, the commit reduces, but does not eliminate implicit conversions. qcow2_create2() passes a (presumably non-negative) int64_t argument, then passes the result through a local variable to qemu_opt_set_number(). Change the local variable to uint64_t to avoid pointless conversions. qcow2_measure() passes a uint64_t argument, then assigns the result to int64_t (which the next commit will change to uint64_t). Signed-off-by: Markus Armbruster --- block/qcow2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index d7c600b..d96d1f6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2613,13 +2613,13 @@ int64_t qcow2_refcount_metadata_size(int64_t cluste= rs, size_t cluster_size, * Returns: Total number of bytes required for the fully allocated image * (including metadata). */ -static int64_t qcow2_calc_prealloc_size(int64_t total_size, - size_t cluster_size, - int refcount_order) +static uint64_t qcow2_calc_prealloc_size(uint64_t total_size, + size_t cluster_size, + int refcount_order) { - int64_t meta_size =3D 0; + uint64_t meta_size =3D 0; uint64_t nl1e, nl2e; - int64_t aligned_total_size =3D align_offset(total_size, cluster_size); + uint64_t aligned_total_size =3D align_offset(total_size, cluster_size); =20 /* header: 1 cluster */ meta_size +=3D cluster_size; @@ -2729,7 +2729,7 @@ static int qcow2_create2(const char *filename, int64_= t total_size, int ret; =20 if (prealloc =3D=3D PREALLOC_MODE_FULL || prealloc =3D=3D PREALLOC_MOD= E_FALLOC) { - int64_t prealloc_size =3D + uint64_t prealloc_size =3D qcow2_calc_prealloc_size(total_size, cluster_size, refcount_or= der); qemu_opt_set_number(opts, BLOCK_OPT_SIZE, prealloc_size, &error_ab= ort); qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_lookup[preallo= c], --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118880699960.3323055507819; Mon, 7 Aug 2017 08:14:40 -0700 (PDT) Received: from localhost ([::1]:37822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejjr-0007kl-Ck for importer@patchew.org; Mon, 07 Aug 2017 11:14:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ6-0007Q7-UI for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIr-0003wb-PU for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003a2-Jt; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59692806B1; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E9A3707C3; Mon, 7 Aug 2017 14:46:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 617951138608; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 59692806B1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:30 +0200 Message-Id: <1502117160-24655-27-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 26/56] block: Make BlockMeasureInfo sizes unsigned in QAPI 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). BlockMeasureInfo members @required and @fully-allocated are 'int' (int64_t). qcow2_measure() computes their values from qcow2_calc_prealloc_size(), @virtual_size and @required, all uint64_t (the former only since the previous commit). raw_measure() computes them either from bdrv_getlength() or from qemu_opt_get_size_del(). The former is int64_t, but we error out if it's negative. The latter is uint64_t. Change these BlockMeasureInfo members to 'size'. qemu-img now reports them correctly above 2^63-1 instead of their (negative) two's complement. Signed-off-by: Markus Armbruster --- block/raw-format.c | 10 ++++++---- qapi/block-core.json | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block/raw-format.c b/block/raw-format.c index 142649e..6b73d5b 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -316,14 +316,16 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, = BlockDriverState *in_bs, Error **errp) { BlockMeasureInfo *info; - int64_t required; + int64_t size; + uint64_t required; =20 if (in_bs) { - required =3D bdrv_getlength(in_bs); - if (required < 0) { - error_setg_errno(errp, -required, "Unable to get image size"); + size =3D bdrv_getlength(in_bs); + if (size < 0) { + error_setg_errno(errp, -size, "Unable to get image size"); return NULL; } + required =3D size; } else { required =3D ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, = 0), BDRV_SECTOR_SIZE); diff --git a/qapi/block-core.json b/qapi/block-core.json index 02e12f7..bc8e5b6 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -485,7 +485,7 @@ # Since: 2.10 ## { 'struct': 'BlockMeasureInfo', - 'data': {'required': 'int', 'fully-allocated': 'int'} } + 'data': {'required': 'size', 'fully-allocated': 'size'} } =20 ## # @query-block: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119039862128.02461671709898; Mon, 7 Aug 2017 08:17:19 -0700 (PDT) Received: from localhost ([::1]:37838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejmP-0001uA-Cd for importer@patchew.org; Mon, 07 Aug 2017 11:17:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJA-0007Rb-1F for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIu-0003yO-8z for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58180) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003aD-Pf; Mon, 07 Aug 2017 10:46:24 -0400 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 BCB3F8124A; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64DA195200; Mon, 7 Aug 2017 14:46:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 655EB113860B; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCB3F8124A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:31 +0200 Message-Id: <1502117160-24655-28-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 27/56] block/dirty-bitmap: Clean up signed vs. unsigned dirty counts 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" hbitmap_count() returns uint64_t. Clean up test-hbitmap.c to check its value with g_assert_cmpuint() instead of g_assert_cmpint(). bdrv_get_dirty_count() and bdrv_get_meta_dirty_count() return its value converted to int64_t. Clean them up to return it unadulterated. This moves the implicit conversion to some callers, so clean them up, too. mirror_run() assigns the value of bdrv_get_meta_dirty_count() to a local int64_t variable. Change it to uint64_t. Signedness still gets mixed up in the computation of s->common.len, but messing with that is more than I can handle right now. get_remaining_dirty() tallies bdrv_get_dirty_count() values in int64_t. Its caller block_save_pending() converts it back to uint64_t. Change get_remaining_dirty() to uint64_t. Signed-off-by: Markus Armbruster Reviewed-by: John Snow --- block/dirty-bitmap.c | 4 ++-- block/mirror.c | 4 ++-- block/trace-events | 8 ++++---- include/block/dirty-bitmap.h | 4 ++-- migration/block.c | 4 ++-- tests/test-hbitmap.c | 16 +++++++++------- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 30462d4..5b1699c 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -681,12 +681,12 @@ void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *iter, i= nt64_t sector_num) hbitmap_iter_init(&iter->hbi, iter->hbi.hb, sector_num); } =20 -int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap) +uint64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap) { return hbitmap_count(bitmap->bitmap); } =20 -int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap) +uint64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap) { return hbitmap_count(bitmap->meta); } diff --git a/block/mirror.c b/block/mirror.c index c9a6a3c..14c34e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -798,8 +798,8 @@ static void coroutine_fn mirror_run(void *opaque) assert(!s->dbi); s->dbi =3D bdrv_dirty_iter_new(s->dirty_bitmap, 0); for (;;) { - uint64_t delay_ns =3D 0; - int64_t cnt, delta; + uint64_t cnt, delay_ns =3D 0; + int64_t delta; bool should_complete; =20 if (s->ret < 0) { diff --git a/block/trace-events b/block/trace-events index 071a8d7..464a11f 100644 --- a/block/trace-events +++ b/block/trace-events @@ -24,13 +24,13 @@ commit_start(void *bs, void *base, void *top, void *s) = "bs %p base %p top %p s % =20 # block/mirror.c mirror_start(void *bs, void *s, void *opaque) "bs %p s %p opaque %p" -mirror_restart_iter(void *s, int64_t cnt) "s %p dirty count %"PRId64 +mirror_restart_iter(void *s, uint64_t cnt) "s %p dirty count %" PRIu64 mirror_before_flush(void *s) "s %p" -mirror_before_drain(void *s, int64_t cnt) "s %p dirty count %"PRId64 -mirror_before_sleep(void *s, int64_t cnt, int synced, uint64_t delay_ns) "= s %p dirty count %"PRId64" synced %d delay %"PRIu64"ns" +mirror_before_drain(void *s, uint64_t cnt) "s %p dirty count %" PRIu64 +mirror_before_sleep(void *s, uint64_t cnt, int synced, uint64_t delay_ns) = "s %p dirty count %" PRIu64 " synced %d delay %" PRIu64 "ns" mirror_one_iteration(void *s, int64_t offset, uint64_t bytes) "s %p offset= %" PRId64 " bytes %" PRIu64 mirror_iteration_done(void *s, int64_t offset, uint64_t bytes, int ret) "s= %p offset %" PRId64 " bytes %" PRIu64 " ret %d" -mirror_yield(void *s, int64_t cnt, int buf_free_count, int in_flight) "s %= p dirty count %"PRId64" free buffers %d in_flight %d" +mirror_yield(void *s, uint64_t cnt, int buf_free_count, int in_flight) "s = %p dirty count %" PRIu64 " free buffers %d in_flight %d" mirror_yield_in_flight(void *s, int64_t offset, int in_flight) "s %p offse= t %" PRId64 " in_flight %d" =20 # block/backup.c diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index a79a58d..d7e0f61 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -91,8 +91,8 @@ void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitm= ap, int64_t cur_sector, int64_t nr_sectors= ); int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter); void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num); -int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap); -int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap); +uint64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap); +uint64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap); void bdrv_dirty_bitmap_truncate(BlockDriverState *bs); bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap); bool bdrv_has_readonly_bitmaps(BlockDriverState *bs); diff --git a/migration/block.c b/migration/block.c index 9171f60..59b7551 100644 --- a/migration/block.c +++ b/migration/block.c @@ -656,10 +656,10 @@ static int flush_blks(QEMUFile *f) =20 /* Called with iothread lock taken. */ =20 -static int64_t get_remaining_dirty(void) +static uint64_t get_remaining_dirty(void) { BlkMigDevState *bmds; - int64_t dirty =3D 0; + uint64_t dirty =3D 0; =20 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { aio_context_acquire(blk_get_aio_context(bmds->blk)); diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c index 1acb353..f816827 100644 --- a/tests/test-hbitmap.c +++ b/tests/test-hbitmap.c @@ -70,7 +70,8 @@ static void hbitmap_test_check(TestHBitmapData *data, } =20 if (first =3D=3D 0) { - g_assert_cmpint(count << data->granularity, =3D=3D, hbitmap_count(= data->hb)); + g_assert_cmpuint(count << data->granularity, + =3D=3D, hbitmap_count(data->hb)); } } =20 @@ -222,7 +223,7 @@ static void hbitmap_test_check_get(TestHBitmapData *dat= a) count +=3D hbitmap_get(data->hb, i); g_assert_cmpint(hbitmap_get(data->hb, i), =3D=3D, val !=3D 0); } - g_assert_cmpint(count, =3D=3D, hbitmap_count(data->hb)); + g_assert_cmpuint(count, =3D=3D, hbitmap_count(data->hb)); } =20 static void test_hbitmap_zero(TestHBitmapData *data, @@ -416,15 +417,15 @@ static void test_hbitmap_granularity(TestHBitmapData = *data, /* Note that hbitmap_test_check has to be invoked manually in this tes= t. */ hbitmap_test_init(data, L1, 1); hbitmap_test_set(data, 0, 1); - g_assert_cmpint(hbitmap_count(data->hb), =3D=3D, 2); + g_assert_cmpuint(hbitmap_count(data->hb), =3D=3D, 2); hbitmap_test_check(data, 0); hbitmap_test_set(data, 2, 1); - g_assert_cmpint(hbitmap_count(data->hb), =3D=3D, 4); + g_assert_cmpuint(hbitmap_count(data->hb), =3D=3D, 4); hbitmap_test_check(data, 0); hbitmap_test_set(data, 0, 3); - g_assert_cmpint(hbitmap_count(data->hb), =3D=3D, 4); + g_assert_cmpuint(hbitmap_count(data->hb), =3D=3D, 4); hbitmap_test_reset(data, 0, 1); - g_assert_cmpint(hbitmap_count(data->hb), =3D=3D, 2); + g_assert_cmpuint(hbitmap_count(data->hb), =3D=3D, 2); } =20 static void test_hbitmap_iter_granularity(TestHBitmapData *data, @@ -494,7 +495,8 @@ static void hbitmap_test_check_boundary_bits(TestHBitma= pData *data) */ g_assert(hbitmap_get(data->hb, 0)); g_assert(hbitmap_get(data->hb, size - 1)); - g_assert_cmpint(2 << data->granularity, =3D=3D, hbitmap_count(data= ->hb)); + g_assert_cmpuint(2ull << data->granularity, + =3D=3D, hbitmap_count(data->hb)); } } =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119759489972.4164332795312; Mon, 7 Aug 2017 08:29:19 -0700 (PDT) Received: from localhost ([::1]:37902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejy2-0004JB-3w for importer@patchew.org; Mon, 07 Aug 2017 11:29:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007Y7-QH for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIw-000411-S5 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIW-0003ax-8Q; Mon, 07 Aug 2017 10:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00B02C058EA8; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F1A4600C4; Mon, 7 Aug 2017 14:46:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 68CB4113860C; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 00B02C058EA8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:32 +0200 Message-Id: <1502117160-24655-29-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 07 Aug 2017 14:46:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 28/56] block: Widen dirty bitmap granularity to uint64_t for safety 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block dirty bitmaps represent granularity in bytes as uint32_t. It must be a power of two and a multiple of BDRV_SECTOR_SIZE. The trouble with uint32_t is computations like this one in mirror_do_read(): uint64_t max_bytes; max_bytes =3D s->granularity * s->max_iov; The operands of * are uint32_t and int, so the product is computed in uint32_t (assuming 32 bit int), then zero-extended to uint64_t. Since granularity is generally combined with 64 bit file offsets, it's best to make it 64 bits, too. Less opportunity to screw up. Signed-off-by: Markus Armbruster --- block.c | 2 +- block/backup.c | 2 +- block/dirty-bitmap.c | 19 +++++++------------ block/mirror.c | 6 +++--- block/qcow2-bitmap.c | 18 +++++++++--------- block/qcow2.h | 2 +- blockdev.c | 6 +++--- include/block/block.h | 2 +- include/block/block_int.h | 4 ++-- include/block/dirty-bitmap.h | 7 +++---- qapi/block-core.json | 8 ++++---- 11 files changed, 35 insertions(+), 41 deletions(-) diff --git a/block.c b/block.c index 04cce0d..fe4b089 100644 --- a/block.c +++ b/block.c @@ -4922,7 +4922,7 @@ void bdrv_del_child(BlockDriverState *parent_bs, Bdrv= Child *child, Error **errp) } =20 bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *nam= e, - uint32_t granularity, Error **errp) + uint64_t granularity, Error **errp) { BlockDriver *drv =3D bs->drv; =20 diff --git a/block/backup.c b/block/backup.c index 504a089..a37c944 100644 --- a/block/backup.c +++ b/block/backup.c @@ -363,7 +363,7 @@ static int coroutine_fn backup_run_incremental(BackupBl= ockJob *job) bool error_is_read; int ret =3D 0; int clusters_per_iter; - uint32_t granularity; + uint64_t granularity; int64_t offset; int64_t cluster; int64_t end; diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 5b1699c..c0b5952 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -109,13 +109,13 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bit= map) =20 /* Called with BQL taken. */ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, - uint32_t granularity, + uint64_t granularity, const char *name, Error **errp) { int64_t bitmap_size; BdrvDirtyBitmap *bitmap; - uint32_t sector_granularity; + uint64_t sector_granularity; =20 assert((granularity & (granularity - 1)) =3D=3D 0); =20 @@ -133,7 +133,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverSt= ate *bs, } bitmap =3D g_new0(BdrvDirtyBitmap, 1); bitmap->mutex =3D &bs->dirty_bitmap_mutex; - bitmap->bitmap =3D hbitmap_alloc(bitmap_size, ctz32(sector_granularity= )); + bitmap->bitmap =3D hbitmap_alloc(bitmap_size, ctz64(sector_granularity= )); bitmap->size =3D bitmap_size; bitmap->name =3D g_strdup(name); bitmap->disabled =3D false; @@ -178,7 +178,7 @@ int bdrv_dirty_bitmap_get_meta_locked(BlockDriverState = *bs, int nb_sectors) { uint64_t i; - int sectors_per_bit =3D 1 << hbitmap_granularity(bitmap->meta); + uint64_t sectors_per_bit =3D 1ull << hbitmap_granularity(bitmap->meta); =20 /* To optimize: we can make hbitmap to internally check the range in a * coarse level, or at least do it word by word. */ @@ -491,10 +491,10 @@ int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvD= irtyBitmap *bitmap, * but clamped between [4K, 64K]. Defaults to 64K in the case that there * is no cluster size information available. */ -uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs) +uint64_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs) { BlockDriverInfo bdi; - uint32_t granularity; + uint64_t granularity; =20 if (bdrv_get_info(bs, &bdi) >=3D 0 && bdi.cluster_size > 0) { granularity =3D MAX(4096, bdi.cluster_size); @@ -506,16 +506,11 @@ uint32_t bdrv_get_default_bitmap_granularity(BlockDri= verState *bs) return granularity; } =20 -uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap) +uint64_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap) { return BDRV_SECTOR_SIZE << hbitmap_granularity(bitmap->bitmap); } =20 -uint32_t bdrv_dirty_bitmap_meta_granularity(BdrvDirtyBitmap *bitmap) -{ - return BDRV_SECTOR_SIZE << hbitmap_granularity(bitmap->meta); -} - BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap, uint64_t first_sector) { diff --git a/block/mirror.c b/block/mirror.c index 14c34e9..37a8744 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -53,7 +53,7 @@ typedef struct MirrorBlockJob { BlockdevOnError on_source_error, on_target_error; bool synced; bool should_complete; - int64_t granularity; + uint64_t granularity; size_t buf_size; int64_t bdev_length; unsigned long *cow_bitmap; @@ -1124,7 +1124,7 @@ static BlockDriver bdrv_mirror_top =3D { static void mirror_start_job(const char *job_id, BlockDriverState *bs, int creation_flags, BlockDriverState *target, const char *replaces, int64_t speed, - uint32_t granularity, int64_t buf_size, + uint64_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -1287,7 +1287,7 @@ fail: =20 void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - int64_t speed, uint32_t granularity, int64_t buf_size, + int64_t speed, uint64_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index e8d3bdb..356772c 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -147,11 +147,11 @@ static int check_table_entry(uint64_t entry, int clus= ter_size) =20 static int check_constraints_on_bitmap(BlockDriverState *bs, const char *name, - uint32_t granularity, + uint64_t granularity, Error **errp) { BDRVQcow2State *s =3D bs->opaque; - int granularity_bits =3D ctz32(granularity); + int granularity_bits =3D ctz64(granularity); int64_t len =3D bdrv_getlength(bs); =20 assert(granularity > 0); @@ -274,10 +274,10 @@ static int free_bitmap_clusters(BlockDriverState *bs,= Qcow2BitmapTable *tb) static uint64_t sectors_covered_by_bitmap_cluster(const BDRVQcow2State *s, const BdrvDirtyBitmap *b= itmap) { - uint32_t sector_granularity =3D + uint64_t sector_granularity =3D bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; =20 - return (uint64_t)sector_granularity * (s->cluster_size << 3); + return sector_granularity * (s->cluster_size << 3); } =20 /* load_bitmap_data @@ -342,7 +342,7 @@ static BdrvDirtyBitmap *load_bitmap(BlockDriverState *b= s, { int ret; uint64_t *bitmap_table =3D NULL; - uint32_t granularity; + uint64_t granularity; BdrvDirtyBitmap *bitmap =3D NULL; =20 if (bm->flags & BME_FLAG_IN_USE) { @@ -358,7 +358,7 @@ static BdrvDirtyBitmap *load_bitmap(BlockDriverState *b= s, goto fail; } =20 - granularity =3D 1U << bm->granularity_bits; + granularity =3D 1ULL << bm->granularity_bits; bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, bm->name, errp); if (bitmap =3D=3D NULL) { goto fail; @@ -1321,7 +1321,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriver= State *bs, Error **errp) bitmap =3D bdrv_dirty_bitmap_next(bs, bitmap)) { const char *name =3D bdrv_dirty_bitmap_name(bitmap); - uint32_t granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + uint64_t granularity =3D bdrv_dirty_bitmap_granularity(bitmap); Qcow2Bitmap *bm; =20 if (!bdrv_dirty_bitmap_get_persistance(bitmap) || @@ -1364,7 +1364,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriver= State *bs, Error **errp) QSIMPLEQ_INSERT_TAIL(&drop_tables, tb, entry); } bm->flags =3D bdrv_dirty_bitmap_get_autoload(bitmap) ? BME_FLAG_AU= TO : 0; - bm->granularity_bits =3D ctz32(bdrv_dirty_bitmap_granularity(bitma= p)); + bm->granularity_bits =3D ctz64(bdrv_dirty_bitmap_granularity(bitma= p)); bm->dirty_bitmap =3D bitmap; } =20 @@ -1436,7 +1436,7 @@ int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Err= or **errp) =20 bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, - uint32_t granularity, + uint64_t granularity, Error **errp) { BDRVQcow2State *s =3D bs->opaque; diff --git a/block/qcow2.h b/block/qcow2.h index 0d7043e..6a7ca09 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -659,7 +659,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverSt= ate *bs, Error **errp); int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp); bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, - uint32_t granularity, + uint64_t granularity, Error **errp); void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, diff --git a/blockdev.c b/blockdev.c index 02cd69b..960c5be 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2708,7 +2708,7 @@ out: } =20 void qmp_block_dirty_bitmap_add(const char *node, const char *name, - bool has_granularity, uint32_t granularity, + bool has_granularity, uint64_t granularity, bool has_persistent, bool persistent, bool has_autoload, bool autoload, Error **errp) @@ -3401,7 +3401,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, enum MirrorSyncMode sync, BlockMirrorBackingMode backing_mode, bool has_speed, int64_t speed, - bool has_granularity, uint32_t granular= ity, + bool has_granularity, uint64_t granular= ity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, @@ -3617,7 +3617,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char = *job_id, bool has_replaces, const char *replaces, MirrorSyncMode sync, bool has_speed, int64_t speed, - bool has_granularity, uint32_t granularity, + bool has_granularity, uint64_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, diff --git a/include/block/block.h b/include/block/block.h index 34770bb..3a4e980 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -620,6 +620,6 @@ void bdrv_add_child(BlockDriverState *parent, BlockDriv= erState *child, void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **er= rp); =20 bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *nam= e, - uint32_t granularity, Error **errp); + uint64_t granularity, Error **errp); =20 #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index d4f4ea7..c09076e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -392,7 +392,7 @@ struct BlockDriver { int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp); bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs, const char *name, - uint32_t granularity, + uint64_t granularity, Error **errp); void (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs, const char *name, @@ -896,7 +896,7 @@ void commit_active_start(const char *job_id, BlockDrive= rState *bs, */ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - int64_t speed, uint32_t granularity, int64_t buf_size, + int64_t speed, uint64_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index d7e0f61..9058cef 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -5,7 +5,7 @@ #include "qemu/hbitmap.h" =20 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, - uint32_t granularity, + uint64_t granularity, const char *name, Error **errp); void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap, @@ -32,9 +32,8 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState= *bs, void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap); void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap); BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); -uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); -uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap); -uint32_t bdrv_dirty_bitmap_meta_granularity(BdrvDirtyBitmap *bitmap); +uint64_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); +uint64_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap); const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap); diff --git a/qapi/block-core.json b/qapi/block-core.json index bc8e5b6..1c4a08d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -418,7 +418,7 @@ # Since: 1.3 ## { 'struct': 'BlockDirtyInfo', - 'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32', + 'data': {'*name': 'str', 'count': 'int', 'granularity': 'size', 'status': 'DirtyBitmapStatus'} } =20 ## @@ -1532,7 +1532,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', - '*speed': 'int', '*granularity': 'uint32', + '*speed': 'int', '*granularity': 'size', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*unmap': 'bool' } } @@ -1571,7 +1571,7 @@ # Since: 2.4 ## { 'struct': 'BlockDirtyBitmapAdd', - 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', + 'data': { 'node': 'str', 'name': 'str', '*granularity': 'size', '*persistent': 'bool', '*autoload': 'bool' } } =20 ## @@ -1731,7 +1731,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', - '*speed': 'int', '*granularity': 'uint32', + '*speed': 'int', '*granularity': 'size', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*filter-node-name': 'str' } } --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118683670341.2478060551048; Mon, 7 Aug 2017 08:11:23 -0700 (PDT) Received: from localhost ([::1]:37810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejge-0004Gn-HF for importer@patchew.org; Mon, 07 Aug 2017 11:11:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ8-0007RR-WF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIs-0003xG-SM for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003aG-Tt; Mon, 07 Aug 2017 10:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1FA5806A2; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BD038FBE1; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6BE5F113860F; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A1FA5806A2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:33 +0200 Message-Id: <1502117160-24655-30-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 29/56] block: Make BlockDirtyInfo byte count unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte counts should use QAPI type 'size' (uint64_t). BlockDirtyInfo member @count is 'int' (int64_t). bdrv_query_dirty_bitmaps() computes @count from bdrv_get_dirty_count() in uint64_t, then implicitly converts to int64_t. Before the commit before previous, the conversion was in bdrv_get_dirty_count() instead. Change member @count to 'size'. query-block now reports @count values above 2^63-1 correctly instead of their (negative) two's complement. Signed-off-by: Markus Armbruster Reviewed-by: John Snow --- qapi/block-core.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1c4a08d..60e1b6f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -418,7 +418,7 @@ # Since: 1.3 ## { 'struct': 'BlockDirtyInfo', - 'data': {'*name': 'str', 'count': 'int', 'granularity': 'size', + 'data': {'*name': 'str', 'count': 'size', 'granularity': 'size', 'status': 'DirtyBitmapStatus'} } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118995341296.8877359577393; Mon, 7 Aug 2017 08:16:35 -0700 (PDT) Received: from localhost ([::1]:37834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejlh-0001If-Ln for importer@patchew.org; Mon, 07 Aug 2017 11:16:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJB-0007U0-LF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIv-000405-Vq for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003cW-6U; Mon, 07 Aug 2017 10:46:25 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 1EC457F3E4; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FF427F479; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 70ED01138611; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1EC457F3E4 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:34 +0200 Message-Id: <1502117160-24655-31-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 30/56] block: Make write thresholds unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets should use QAPI type 'size' (uint64_t). block-set-write-threshold parameter @write-threshold is 'int' (int64_t). qmp_block_set_write_threshold() passes it on to bdrv_write_threshold_set(), implicitly converting to uint64_t. BLOCK_WRITE_THRESHOLD parameters @write-threshold, @amount-exceeded are 'int'. before_write_notify() gets them from BlockDriverState member write_threshold_offset and bdrv_write_threshold_exceeded(), implicitly converting from uint64_t. BlockDeviceInfo members @write_threshold is 'int'. bdrv_block_device_info() gets it from bdrv_write_threshold_get(), implicitly converting from uint64_t. Change them all to 'size'. Drop a redundant initializer while there. block-set-write-threshold now accepts file offsets between 2^63 and 2^64-1. It accepts negative values as before, because that's how the QObject input visitor works for backward compatibility. There is no matching HMP command. BLOCK_WRITE_THRESHOLD, query-block and query-named-block-nodes now report write threshold values above 2^63-1 correctly instead of their (negative) two's complement. HMP's info block does not report write thresholds. Signed-off-by: Markus Armbruster --- block/write-threshold.c | 2 +- qapi/block-core.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/write-threshold.c b/block/write-threshold.c index 0bd1a01..c4572d9 100644 --- a/block/write-threshold.c +++ b/block/write-threshold.c @@ -56,7 +56,7 @@ static int coroutine_fn before_write_notify(NotifierWithR= eturn *notifier, { BdrvTrackedRequest *req =3D opaque; BlockDriverState *bs =3D req->bs; - uint64_t amount =3D 0; + uint64_t amount; =20 amount =3D bdrv_write_threshold_exceeded(bs, req); if (amount > 0) { diff --git a/qapi/block-core.json b/qapi/block-core.json index 60e1b6f..9e96590 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -366,7 +366,7 @@ '*bps_wr_max_length': 'int', '*iops_max_length': 'int', '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheI= nfo', - 'write_threshold': 'int' } } + 'write_threshold': 'size' } } =20 ## # @BlockDeviceIoStatus: @@ -3748,8 +3748,8 @@ ## { 'event': 'BLOCK_WRITE_THRESHOLD', 'data': { 'node-name': 'str', - 'amount-exceeded': 'uint64', - 'write-threshold': 'uint64' } } + 'amount-exceeded': 'size', + 'write-threshold': 'size' } } =20 ## # @block-set-write-threshold: @@ -3779,7 +3779,7 @@ # ## { 'command': 'block-set-write-threshold', - 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } + 'data': { 'node-name': 'str', 'write-threshold': 'size' } } =20 ## # @x-blockdev-change: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117946654367.79501919078734; Mon, 7 Aug 2017 07:59:06 -0700 (PDT) Received: from localhost ([::1]:37753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejUn-0001RN-Bo for importer@patchew.org; Mon, 07 Aug 2017 10:59:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJA-0007SH-IC for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIu-0003yz-Md for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63730) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIW-0003aT-72; Mon, 07 Aug 2017 10:46:24 -0400 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 DFA3A61493; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E045C9520F; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7351B1138614; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DFA3A61493 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:35 +0200 Message-Id: <1502117160-24655-32-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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]); Mon, 07 Aug 2017 14:46:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 31/56] block: Make throttle byte rates and sizes unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes and byte rates should use QAPI type 'size' (uint64_t). BlockIOThrottle and BlockDeviceInfo members @bps, @bps_rd, @bps_wr, @bps_max, @bps_rd_max, @bps_wr_max, @iops_size are 'int' (int64_t). qmp_block_set_io_throttle() and bdrv_block_device_info() copy @bps, @bps_rd, @bps_wr to / from LeakyBucket member @avg (implicit conversion to / from double), @bps_max, @bps_rd_max, @bps_wr_max to / from LeakyBucket member @max (implicit conversion to / from double), and @iops_size to / from ThrottleConfig member op_size (implicit conversion to / from uint64_t). Change these BlockIOThrottle and BlockDeviceInfo members to 'size'. block_set_io_throttle now accepts sizes and rates between 2^63 and 2^64-1. It accepts negative values as before, because that's how the QObject input visitor works for backward compatibility. Doing the same for HMP's block_set_io_throttle deserves its own commit (the next one). query-block and query-named-block-nodes now report sizes and rates above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info block". Signed-off-by: Markus Armbruster Reviewed-by: Alberto Garcia --- hmp.c | 12 ++++++------ qapi/block-core.json | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hmp.c b/hmp.c index 9bcdcb3..3253674 100644 --- a/hmp.c +++ b/hmp.c @@ -468,17 +468,17 @@ static void print_block_info(Monitor *mon, BlockInfo = *info, if (inserted->bps || inserted->bps_rd || inserted->bps_wr || inserted->iops || inserted->iops_rd || inserted->iops_wr) { - monitor_printf(mon, " I/O throttling: bps=3D%" PRId64 - " bps_rd=3D%" PRId64 " bps_wr=3D%" PRId64 - " bps_max=3D%" PRId64 - " bps_rd_max=3D%" PRId64 - " bps_wr_max=3D%" PRId64 + monitor_printf(mon, " I/O throttling: bps=3D%" PRIu64 + " bps_rd=3D%" PRIu64 " bps_wr=3D%" PRIu64 + " bps_max=3D%" PRIu64 + " bps_rd_max=3D%" PRIu64 + " bps_wr_max=3D%" PRIu64 " iops=3D%" PRId64 " iops_rd=3D%" PRId64 " iops_wr=3D%" PRId64 " iops_max=3D%" PRId64 " iops_rd_max=3D%" PRId64 " iops_wr_max=3D%" PRId64 - " iops_size=3D%" PRId64 + " iops_size=3D%" PRIu64 " group=3D%s\n", inserted->bps, inserted->bps_rd, diff --git a/qapi/block-core.json b/qapi/block-core.json index 9e96590..1e26cb0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -356,16 +356,16 @@ '*backing_file': 'str', 'backing_file_depth': 'int', 'encrypted': 'bool', 'encryption_key_missing': 'bool', 'detect_zeroes': 'BlockdevDetectZeroesOptions', - 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', + 'bps': 'size', 'bps_rd': 'size', 'bps_wr': 'size', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', 'image': 'ImageInfo', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', + '*bps_max': 'size', '*bps_rd_max': 'size', + '*bps_wr_max': 'size', '*iops_max': 'int', '*iops_rd_max': 'int', '*iops_wr_max': 'int', '*bps_max_length': 'int', '*bps_rd_max_length': 'int', '*bps_wr_max_length': 'int', '*iops_max_length': 'int', '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheI= nfo', + '*iops_size': 'size', '*group': 'str', 'cache': 'BlockdevCache= Info', 'write_threshold': 'size' } } =20 ## @@ -1866,15 +1866,15 @@ # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', - 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': '= int', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int', + 'data': { '*device': 'str', '*id': 'str', + 'bps': 'size', 'bps_rd': 'size', 'bps_wr': 'size', + 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', + '*bps_max': 'size', '*bps_rd_max': 'size', '*bps_wr_max': 'siz= e', + '*iops_max': 'int', '*iops_rd_max': 'int', '*iops_wr_max': 'in= t', '*bps_max_length': 'int', '*bps_rd_max_length': 'int', '*bps_wr_max_length': 'int', '*iops_max_length': 'int', '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + '*iops_size': 'size', '*group': 'str' } } =20 ## # @block-stream: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118527163968.2159817435668; Mon, 7 Aug 2017 08:08:47 -0700 (PDT) Received: from localhost ([::1]:37797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deje9-0001l0-NB for importer@patchew.org; Mon, 07 Aug 2017 11:08:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ7-0007R4-Oq for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIs-0003x0-K4 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIV-0003aA-OW; Mon, 07 Aug 2017 10:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A90EDC047B74; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBA3C8F37A; Mon, 7 Aug 2017 14:46:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 771971138615; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A90EDC047B74 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:36 +0200 Message-Id: <1502117160-24655-33-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 Aug 2017 14:46:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 32/56] hmp: Make block_set_io_throttle's arguments unsigned 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The previous commit made them unsigned in QMP. Switch HMP's args_type from 'l' to 'o'. Loses support for expressions (QEMU pocket calculator), gains support for unit suffixes. Negative values are no longer accepted and interpreted modulo 2^64. Instead, values between 2^63 and 2^64-1 are now accepted. Signed-off-by: Markus Armbruster --- hmp-commands.hx | 2 +- hmp.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 46ce79c..bc3c066 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1668,7 +1668,7 @@ ETEXI =20 { .name =3D "block_set_io_throttle", - .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l= ,iops_wr:l", + .args_type =3D "device:B,bps:o,bps_rd:o,bps_wr:o,iops:l,iops_rd:l= ,iops_wr:l", .params =3D "device bps bps_rd bps_wr iops iops_rd iops_wr", .help =3D "change I/O throttle limits for a block drive", .cmd =3D hmp_block_set_io_throttle, diff --git a/hmp.c b/hmp.c index 3253674..599e816 100644 --- a/hmp.c +++ b/hmp.c @@ -1764,9 +1764,9 @@ void hmp_block_set_io_throttle(Monitor *mon, const QD= ict *qdict) BlockIOThrottle throttle =3D { .has_device =3D true, .device =3D (char *) qdict_get_str(qdict, "device"), - .bps =3D qdict_get_int(qdict, "bps"), - .bps_rd =3D qdict_get_int(qdict, "bps_rd"), - .bps_wr =3D qdict_get_int(qdict, "bps_wr"), + .bps =3D qdict_get_uint(qdict, "bps"), + .bps_rd =3D qdict_get_uint(qdict, "bps_rd"), + .bps_wr =3D qdict_get_uint(qdict, "bps_wr"), .iops =3D qdict_get_int(qdict, "iops"), .iops_rd =3D qdict_get_int(qdict, "iops_rd"), .iops_wr =3D qdict_get_int(qdict, "iops_wr"), --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150211845927245.71928418273728; Mon, 7 Aug 2017 08:07:39 -0700 (PDT) Received: from localhost ([::1]:37794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejd3-0000iX-QZ for importer@patchew.org; Mon, 07 Aug 2017 11:07:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJB-0007UY-SH for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIw-00040b-JY for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54580) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003cm-B5; Mon, 07 Aug 2017 10:46:25 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 30D6E806A0; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 175F97FE8E; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7A5B81138618; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 30D6E806A0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:37 +0200 Message-Id: <1502117160-24655-34-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 33/56] block: Make block_resize size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sizes should use QAPI type 'size' (uint64_t). block_resize parameter @size is 'int' (int64_t). qmp_block_resize() ensures it's non-negative before it passes it on to blk_truncate(). Change parameter @size to 'size', and update the range check accordingly. Just cleanup; block_resize accepts the same size values as before. Signed-off-by: Markus Armbruster --- blockdev.c | 7 ++++--- qapi/block-core.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 960c5be..98dbe51 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2916,7 +2916,7 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) =20 void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, - int64_t size, Error **errp) + uint64_t size, Error **errp) { Error *local_err =3D NULL; BlockBackend *blk =3D NULL; @@ -2940,8 +2940,9 @@ void qmp_block_resize(bool has_device, const char *de= vice, goto out; } =20 - if (size < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"= ); + if (size > INT64_MAX) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", + "a size less than 8EiB"); goto out; } =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 1e26cb0..2e0d53c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1009,7 +1009,7 @@ ## { 'command': 'block_resize', 'data': { '*device': 'str', '*node-name': 'str', - 'size': 'int' }} + 'size': 'size' }} =20 ## # @NewImageMode: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118777130356.24465883600817; Mon, 7 Aug 2017 08:12:57 -0700 (PDT) Received: from localhost ([::1]:37817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejiB-0005qE-Mp for importer@patchew.org; Mon, 07 Aug 2017 11:12:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJG-0007aP-Kc for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ1-00044b-9e for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fY-Bt; Mon, 07 Aug 2017 10:46:27 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 2859680480; Mon, 7 Aug 2017 14:46:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16DCC91532; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7E38411385D0; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2859680480 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:38 +0200 Message-Id: <1502117160-24655-35-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 34/56] block: Make BlockDeviceStats sizes, offsets unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte counts and file offsets should use QAPI type 'size' (uint64_t). BlockDeviceStats members @rd_bytes, @wr_bytes and @wr_highest_offset are 'int' (int64_t). bdrv_query_blk_stats() gets them from BlockAcctStats member nr_bytes[] and stat64_get(), implicitly converting from uint64_t. Change all three to 'size'. query-blockstats now report byte counts and file offsets above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info blockstats". Signed-off-by: Markus Armbruster --- hmp.c | 4 ++-- qapi/block-core.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index 599e816..ecacb7f 100644 --- a/hmp.c +++ b/hmp.c @@ -577,8 +577,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdi= ct) } =20 monitor_printf(mon, "%s:", stats->value->device); - monitor_printf(mon, " rd_bytes=3D%" PRId64 - " wr_bytes=3D%" PRId64 + monitor_printf(mon, " rd_bytes=3D%" PRIu64 + " wr_bytes=3D%" PRIu64 " rd_operations=3D%" PRId64 " wr_operations=3D%" PRId64 " flush_operations=3D%" PRId64 diff --git a/qapi/block-core.json b/qapi/block-core.json index 2e0d53c..1d68669 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -704,10 +704,10 @@ # Since: 0.14.0 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int', + 'data': {'rd_bytes': 'size', 'wr_bytes': 'size', 'rd_operations': 'int', 'wr_operations': 'int', 'flush_operations': 'int', 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int', + 'rd_total_time_ns': 'int', 'wr_highest_offset': 'size', 'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', 'failed_flush_operations': 'int', 'invalid_rd_operations': 'int= ', --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117787509900.7591893656985; Mon, 7 Aug 2017 07:56:27 -0700 (PDT) Received: from localhost ([::1]:37737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejSE-0007O7-3s for importer@patchew.org; Mon, 07 Aug 2017 10:56:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ9-0007RX-Lw for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIu-0003y7-2z for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIW-0003aN-4C; Mon, 07 Aug 2017 10:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0222E356E2; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77A8568D96; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 81E6911385DC; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0222E356E2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:39 +0200 Message-Id: <1502117160-24655-36-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 35/56] blockjob: Lift speed sign conversion into block_job_set_speed() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The BlockJob abstraction takes int64_t speed. The underlying RateLimit abstraction takes uint64_t. We convert from int64_t to uint64_t in the BlockJobDriver speed_set() methods. They all reject negative speed. Lift this check and conversion up into the method's caller block_job_set_speed(). I'm going to lift it further until it falls off the top. Improve the error message while there. Signed-off-by: Markus Armbruster --- block/backup.c | 6 +----- block/commit.c | 6 +----- block/mirror.c | 6 +----- block/stream.c | 6 +----- blockjob.c | 7 +++++++ include/block/blockjob.h | 2 +- include/block/blockjob_int.h | 2 +- 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/block/backup.c b/block/backup.c index a37c944..b76143d 100644 --- a/block/backup.c +++ b/block/backup.c @@ -188,14 +188,10 @@ static int coroutine_fn backup_before_write_notify( return backup_do_cow(job, req->offset, req->bytes, NULL, true); } =20 -static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) +static void backup_set_speed(BlockJob *job, uint64_t speed, Error **errp) { BackupBlockJob *s =3D container_of(job, BackupBlockJob, common); =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return; - } ratelimit_set_speed(&s->limit, speed, SLICE_TIME); } =20 diff --git a/block/commit.c b/block/commit.c index c7857c3..5dc1c73 100644 --- a/block/commit.c +++ b/block/commit.c @@ -220,14 +220,10 @@ out: block_job_defer_to_main_loop(&s->common, commit_complete, data); } =20 -static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp) +static void commit_set_speed(BlockJob *job, uint64_t speed, Error **errp) { CommitBlockJob *s =3D container_of(job, CommitBlockJob, common); =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return; - } ratelimit_set_speed(&s->limit, speed, SLICE_TIME); } =20 diff --git a/block/mirror.c b/block/mirror.c index 37a8744..7959a7f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -928,14 +928,10 @@ immediate_exit: block_job_defer_to_main_loop(&s->common, mirror_exit, data); } =20 -static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp) +static void mirror_set_speed(BlockJob *job, uint64_t speed, Error **errp) { MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return; - } ratelimit_set_speed(&s->limit, speed, SLICE_TIME); } =20 diff --git a/block/stream.c b/block/stream.c index e6f7234..11b6673 100644 --- a/block/stream.c +++ b/block/stream.c @@ -207,14 +207,10 @@ out: block_job_defer_to_main_loop(&s->common, stream_complete, data); } =20 -static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp) +static void stream_set_speed(BlockJob *job, uint64_t speed, Error **errp) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common); =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return; - } ratelimit_set_speed(&s->limit, speed, SLICE_TIME); } =20 diff --git a/blockjob.c b/blockjob.c index 70a7818..7f77b7e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -460,6 +460,13 @@ void block_job_set_speed(BlockJob *job, int64_t speed,= Error **errp) error_setg(errp, QERR_UNSUPPORTED); return; } + + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + job->driver->set_speed(job, speed, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 67c0968..bf5314b 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -110,7 +110,7 @@ typedef struct BlockJob { int64_t len; =20 /** Speed that was set with @block_job_set_speed. */ - int64_t speed; + uint64_t speed; =20 /** The completion function that will be called when the job completes= . */ BlockCompletionFunc *cb; diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index f13ad05..2d10794 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -42,7 +42,7 @@ struct BlockJobDriver { BlockJobType job_type; =20 /** Optional callback for job types that support setting a speed limit= */ - void (*set_speed)(BlockJob *job, int64_t speed, Error **errp); + void (*set_speed)(BlockJob *job, uint64_t speed, Error **errp); =20 /** Mandatory: Entrypoint for the Coroutine. */ CoroutineEntry *start; --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118406317715.414933238967; Mon, 7 Aug 2017 08:06:46 -0700 (PDT) Received: from localhost ([::1]:37791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejcC-0008NV-Sr for importer@patchew.org; Mon, 07 Aug 2017 11:06:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJ9-0007RS-5P for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIt-0003xw-VQ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIW-0003aO-3F; Mon, 07 Aug 2017 10:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E27928125F; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76F2C8F363; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 84F171138553; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E27928125F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:40 +0200 Message-Id: <1502117160-24655-37-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 36/56] blockjob: Drop unused parameter @errp of method set_speed() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- block/backup.c | 2 +- block/commit.c | 2 +- block/mirror.c | 2 +- block/stream.c | 2 +- blockjob.c | 9 +-------- include/block/blockjob_int.h | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/block/backup.c b/block/backup.c index b76143d..359e526 100644 --- a/block/backup.c +++ b/block/backup.c @@ -188,7 +188,7 @@ static int coroutine_fn backup_before_write_notify( return backup_do_cow(job, req->offset, req->bytes, NULL, true); } =20 -static void backup_set_speed(BlockJob *job, uint64_t speed, Error **errp) +static void backup_set_speed(BlockJob *job, uint64_t speed) { BackupBlockJob *s =3D container_of(job, BackupBlockJob, common); =20 diff --git a/block/commit.c b/block/commit.c index 5dc1c73..ae9191d 100644 --- a/block/commit.c +++ b/block/commit.c @@ -220,7 +220,7 @@ out: block_job_defer_to_main_loop(&s->common, commit_complete, data); } =20 -static void commit_set_speed(BlockJob *job, uint64_t speed, Error **errp) +static void commit_set_speed(BlockJob *job, uint64_t speed) { CommitBlockJob *s =3D container_of(job, CommitBlockJob, common); =20 diff --git a/block/mirror.c b/block/mirror.c index 7959a7f..6c3b446 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -928,7 +928,7 @@ immediate_exit: block_job_defer_to_main_loop(&s->common, mirror_exit, data); } =20 -static void mirror_set_speed(BlockJob *job, uint64_t speed, Error **errp) +static void mirror_set_speed(BlockJob *job, uint64_t speed) { MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); =20 diff --git a/block/stream.c b/block/stream.c index 11b6673..9a145f2 100644 --- a/block/stream.c +++ b/block/stream.c @@ -207,7 +207,7 @@ out: block_job_defer_to_main_loop(&s->common, stream_complete, data); } =20 -static void stream_set_speed(BlockJob *job, uint64_t speed, Error **errp) +static void stream_set_speed(BlockJob *job, uint64_t speed) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common); =20 diff --git a/blockjob.c b/blockjob.c index 7f77b7e..e653eef 100644 --- a/blockjob.c +++ b/blockjob.c @@ -454,8 +454,6 @@ static void block_job_completed_txn_success(BlockJob *j= ob) =20 void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { - Error *local_err =3D NULL; - if (!job->driver->set_speed) { error_setg(errp, QERR_UNSUPPORTED); return; @@ -467,12 +465,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed,= Error **errp) return; } =20 - job->driver->set_speed(job, speed, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - + job->driver->set_speed(job, speed); job->speed =3D speed; } =20 diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index 2d10794..dadfd8c 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -42,7 +42,7 @@ struct BlockJobDriver { BlockJobType job_type; =20 /** Optional callback for job types that support setting a speed limit= */ - void (*set_speed)(BlockJob *job, uint64_t speed, Error **errp); + void (*set_speed)(BlockJob *job, uint64_t speed); =20 /** Mandatory: Entrypoint for the Coroutine. */ CoroutineEntry *start; --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502117620813949.6569734648273; Mon, 7 Aug 2017 07:53:40 -0700 (PDT) Received: from localhost ([::1]:37721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejPX-0004o7-L3 for importer@patchew.org; Mon, 07 Aug 2017 10:53:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJA-0007Rd-3k for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIu-0003ym-GP for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003ce-6x; Mon, 07 Aug 2017 10:46:25 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 22D3A78EB2; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F7A17FE80; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 88A7E113855A; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 22D3A78EB2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:41 +0200 Message-Id: <1502117160-24655-38-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 37/56] blockjob: Make BlockJobInfo and event speed unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte rates should use QAPI type 'size' (uint64_t). BlockJobInfo member @speed and parameter @speed of events BLOCK_JOB_COMPLETED, BLOCK_JOB_CANCELLED, BLOCK_JOB_READY are 'int' (int64_t). block_job_query(), block_job_event_completed(), block_job_event_cancelled(), block_job_event_ready() all get it from BlockJob member @speed, implicitly converting from uint64_t (since the commit before previous). The conversion is safe, because block_job_set_speed() won't set speeds above INT_MAX. Change the BlockJobInfo member and the event parameters to 'size', for QAPI/QMP consistency. Signed-off-by: Markus Armbruster --- hmp.c | 4 ++-- qapi/block-core.json | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index ecacb7f..fae974e 100644 --- a/hmp.c +++ b/hmp.c @@ -967,7 +967,7 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdi= ct) while (list) { if (strcmp(list->value->type, "stream") =3D=3D 0) { monitor_printf(mon, "Streaming device %s: Completed %" PRId64 - " of %" PRId64 " bytes, speed limit %" PRId64 + " of %" PRId64 " bytes, speed limit %" PRIu64 " bytes/s\n", list->value->device, list->value->offset, @@ -975,7 +975,7 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdi= ct) list->value->speed); } else { monitor_printf(mon, "Type %s, device %s: Completed %" PRId64 - " of %" PRId64 " bytes, speed limit %" PRId64 + " of %" PRId64 " bytes, speed limit %" PRIu64 " bytes/s\n", list->value->type, list->value->device, diff --git a/qapi/block-core.json b/qapi/block-core.json index 1d68669..ceaab43 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -956,7 +956,8 @@ ## { 'struct': 'BlockJobInfo', 'data': {'type': 'str', 'device': 'str', 'len': 'int', - 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'in= t', + 'offset': 'int', 'busy': 'bool', 'paused': 'bool', + 'speed': 'size', 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} } =20 ## @@ -3607,7 +3608,7 @@ 'device': 'str', 'len' : 'int', 'offset': 'int', - 'speed' : 'int', + 'speed' : 'size', '*error': 'str' } } =20 ## @@ -3643,7 +3644,7 @@ 'device': 'str', 'len' : 'int', 'offset': 'int', - 'speed' : 'int' } } + 'speed' : 'size' } } =20 ## # @BLOCK_JOB_ERROR: @@ -3708,7 +3709,7 @@ 'device': 'str', 'len' : 'int', 'offset': 'int', - 'speed' : 'int' } } + 'speed' : 'size' } } =20 ## # @PreallocMode: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119812100920.3636150019095; Mon, 7 Aug 2017 08:30:12 -0700 (PDT) Received: from localhost ([::1]:37905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejys-00054B-Pm for importer@patchew.org; Mon, 07 Aug 2017 11:30:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJK-0007g2-1H for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ4-00047k-Lg for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIa-0003i7-Sb; Mon, 07 Aug 2017 10:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDA8A356DC; Mon, 7 Aug 2017 14:46:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E57969282; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8BA7F113855B; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CDA8A356DC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:42 +0200 Message-Id: <1502117160-24655-39-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 38/56] blockjob: Lift speed sign conversion out of block_job_set_speed() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The BlockJob abstraction takes int64_t speed. The underlying RateLimit abstraction takes uint64_t. We convert from int64_t to uint64_t in block_job_set_speed(). It rejects negative speed. Lift this check and conversion up into its callers qmp_block_job_set_speed() and block_job_create(). I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- blockdev.c | 6 ++++++ blockjob.c | 14 +++++++------- include/block/blockjob.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/blockdev.c b/blockdev.c index 98dbe51..f9afc32 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3697,6 +3697,12 @@ void qmp_block_job_set_speed(const char *device, int= 64_t speed, Error **errp) return; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + block_job_set_speed(job, speed, errp); aio_context_release(aio_context); } diff --git a/blockjob.c b/blockjob.c index e653eef..998ffef 100644 --- a/blockjob.c +++ b/blockjob.c @@ -452,19 +452,13 @@ static void block_job_completed_txn_success(BlockJob = *job) } } =20 -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +void block_job_set_speed(BlockJob *job, uint64_t speed, Error **errp) { if (!job->driver->set_speed) { error_setg(errp, QERR_UNSUPPORTED); return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - job->driver->set_speed(job, speed); job->speed =3D speed; } @@ -647,6 +641,12 @@ void *block_job_create(const char *job_id, const Block= JobDriver *driver, } } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return NULL; + } + blk =3D blk_new(perm, shared_perm); ret =3D blk_insert_bs(blk, bs, errp); if (ret < 0) { diff --git a/include/block/blockjob.h b/include/block/blockjob.h index bf5314b..5eb1537 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -198,7 +198,7 @@ void block_job_remove_all_bdrv(BlockJob *job); * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. */ -void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); +void block_job_set_speed(BlockJob *job, uint64_t speed, Error **errp); =20 /** * block_job_start: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118286584633.7134714588647; Mon, 7 Aug 2017 08:04:46 -0700 (PDT) Received: from localhost ([::1]:37780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejaH-0006f9-94 for importer@patchew.org; Mon, 07 Aug 2017 11:04:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJB-0007UI-QB for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIv-0003zu-MQ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIW-0003bq-P3; Mon, 07 Aug 2017 10:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 923DE806C3; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1FAC69297; Mon, 7 Aug 2017 14:46:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8FE3F11384C6; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 923DE806C3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:43 +0200 Message-Id: <1502117160-24655-40-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 39/56] blockjob: Lift speed sign conversion out of block_job_create() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" block_job_create() takes int64_t speed. The underlying RateLimit abstraction takes uint64_t. block_job_create() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of block_job_create() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/backup.c | 5 +++++ block/commit.c | 6 ++++++ block/mirror.c | 6 ++++++ block/stream.c | 6 ++++++ blockjob.c | 8 +------- include/block/blockjob_int.h | 2 +- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/block/backup.c b/block/backup.c index 359e526..3a97836 100644 --- a/block/backup.c +++ b/block/backup.c @@ -577,6 +577,11 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, return NULL; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER, "speed"); + return NULL; + } + if (sync_mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " diff --git a/block/commit.c b/block/commit.c index ae9191d..86d780e 100644 --- a/block/commit.c +++ b/block/commit.c @@ -309,6 +309,12 @@ void commit_start(const char *job_id, BlockDriverState= *bs, return; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + s =3D block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL, speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { diff --git a/block/mirror.c b/block/mirror.c index 6c3b446..af54163 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1139,6 +1139,12 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, Error *local_err =3D NULL; int ret; =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + if (granularity =3D=3D 0) { granularity =3D bdrv_get_default_bitmap_granularity(target); } diff --git a/block/stream.c b/block/stream.c index 9a145f2..fefcdb9 100644 --- a/block/stream.c +++ b/block/stream.c @@ -237,6 +237,12 @@ void stream_start(const char *job_id, BlockDriverState= *bs, } } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + /* Prevent concurrent jobs trying to modify the graph structure here, = we * already have our own plans. Also don't allow resize as the image si= ze is * queried only at the job start and then cached. */ diff --git a/blockjob.c b/blockjob.c index 998ffef..335099e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -604,7 +604,7 @@ static void block_job_event_completed(BlockJob *job, co= nst char *msg) =20 void *block_job_create(const char *job_id, const BlockJobDriver *driver, BlockDriverState *bs, uint64_t perm, - uint64_t shared_perm, int64_t speed, int flags, + uint64_t shared_perm, uint64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp) { BlockBackend *blk; @@ -641,12 +641,6 @@ void *block_job_create(const char *job_id, const Block= JobDriver *driver, } } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return NULL; - } - blk =3D blk_new(perm, shared_perm); ret =3D blk_insert_bs(blk, bs, errp); if (ret < 0) { diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index dadfd8c..33472ba 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -133,7 +133,7 @@ struct BlockJobDriver { */ void *block_job_create(const char *job_id, const BlockJobDriver *driver, BlockDriverState *bs, uint64_t perm, - uint64_t shared_perm, int64_t speed, int flags, + uint64_t shared_perm, uint64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp= ); =20 /** --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150211921414323.303602570009502; Mon, 7 Aug 2017 08:20:14 -0700 (PDT) Received: from localhost ([::1]:37849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejpE-0004Rt-Ra for importer@patchew.org; Mon, 07 Aug 2017 11:20:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007XJ-3L for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIy-00041v-0i for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33082) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIY-0003dL-2h; Mon, 07 Aug 2017 10:46:26 -0400 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 6555261486; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE9A195200; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9371011384DB; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6555261486 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:44 +0200 Message-Id: <1502117160-24655-41-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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]); Mon, 07 Aug 2017 14:46:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 40/56] blockjob: Lift speed sign conversion out of backup_job_create() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" backup_job_create() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. backup_job_create() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of backup_job_create() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/backup.c | 7 +------ blockdev.c | 12 ++++++++++++ include/block/block_int.h | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/block/backup.c b/block/backup.c index 3a97836..eddc17a 100644 --- a/block/backup.c +++ b/block/backup.c @@ -529,7 +529,7 @@ static const BlockJobDriver backup_job_driver =3D { }; =20 BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, + BlockDriverState *target, uint64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, BlockdevOnError on_source_error, @@ -577,11 +577,6 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, return NULL; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return NULL; - } - if (sync_mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " diff --git a/blockdev.c b/blockdev.c index f9afc32..1deea49 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3210,6 +3210,12 @@ static BlockJob *do_drive_backup(DriveBackup *backup= , BlockJobTxn *txn, return NULL; } =20 + if (backup->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return NULL; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3353,6 +3359,12 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup,= BlockJobTxn *txn, return NULL; } =20 + if (backup->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return NULL; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index c09076e..19639c0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -923,7 +923,7 @@ void mirror_start(const char *job_id, BlockDriverState = *bs, * until the job is cancelled or manually completed. */ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, + BlockDriverState *target, uint64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119948172612.6017706588818; Mon, 7 Aug 2017 08:32:28 -0700 (PDT) Received: from localhost ([::1]:37921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dek14-0007Ay-Lj for importer@patchew.org; Mon, 07 Aug 2017 11:32:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJK-0007gc-H6 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ4-00047z-Ov for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIa-0003iF-V8; Mon, 07 Aug 2017 10:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DADCE13AA0; Mon, 7 Aug 2017 14:46:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A85CF68D96; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 968C111384DC; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DADCE13AA0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:45 +0200 Message-Id: <1502117160-24655-42-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 07 Aug 2017 14:46:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 41/56] blockjob: Lift speed sign conversion out of mirror_start_job() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mirror_start_job() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. mirror_start_job() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of mirror_start_job() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/mirror.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index af54163..27b4c7f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1119,7 +1119,7 @@ static BlockDriver bdrv_mirror_top =3D { =20 static void mirror_start_job(const char *job_id, BlockDriverState *bs, int creation_flags, BlockDriverState *target, - const char *replaces, int64_t speed, + const char *replaces, uint64_t speed, uint64_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, @@ -1139,12 +1139,6 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, Error *local_err =3D NULL; int ret; =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - if (granularity =3D=3D 0) { granularity =3D bdrv_get_default_bitmap_granularity(target); } @@ -1298,6 +1292,11 @@ void mirror_start(const char *job_id, BlockDriverSta= te *bs, bool is_none_mode; BlockDriverState *base; =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } if (mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(errp, "Sync mode 'incremental' not supported"); return; @@ -1323,6 +1322,12 @@ void commit_active_start(const char *job_id, BlockDr= iverState *bs, =20 orig_base_flags =3D bdrv_get_flags(base); =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + if (bdrv_reopen(base, bs->open_flags, errp)) { return; } --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119632830514.7720851920805; Mon, 7 Aug 2017 08:27:12 -0700 (PDT) Received: from localhost ([::1]:37895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejvz-0002XG-I2 for importer@patchew.org; Mon, 07 Aug 2017 11:27:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJF-0007Z2-IB for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ0-00043x-Jo for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIY-0003eu-VB; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8FAD80474; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A65F28F37F; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9A36411384DD; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C8FAD80474 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:46 +0200 Message-Id: <1502117160-24655-43-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 42/56] blockjob: Lift speed sign conversion out of stream_start() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" stream_start() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. stream_start() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of stream_start() into its caller. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/stream.c | 8 +------- blockdev.c | 6 ++++++ include/block/block_int.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/block/stream.c b/block/stream.c index fefcdb9..16acb1e 100644 --- a/block/stream.c +++ b/block/stream.c @@ -223,7 +223,7 @@ static const BlockJobDriver stream_job_driver =3D { =20 void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, - int64_t speed, BlockdevOnError on_error, Error **errp) + uint64_t speed, BlockdevOnError on_error, Error **errp) { StreamBlockJob *s; BlockDriverState *iter; @@ -237,12 +237,6 @@ void stream_start(const char *job_id, BlockDriverState= *bs, } } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - /* Prevent concurrent jobs trying to modify the graph structure here, = we * already have our own plans. Also don't allow resize as the image si= ze is * queried only at the job start and then cached. */ diff --git a/blockdev.c b/blockdev.c index 1deea49..4d9a665 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2989,6 +2989,12 @@ void qmp_block_stream(bool has_job_id, const char *j= ob_id, const char *device, return; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index 19639c0..695d7b3 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -821,7 +821,7 @@ int is_windows_drive(const char *filename); */ void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, - int64_t speed, BlockdevOnError on_error, Error **errp); + uint64_t speed, BlockdevOnError on_error, Error **errp); =20 /** * commit_start: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118112369646.7321406199279; Mon, 7 Aug 2017 08:01:52 -0700 (PDT) Received: from localhost ([::1]:37771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejXS-0004N6-RO for importer@patchew.org; Mon, 07 Aug 2017 11:01:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJB-0007Tc-DZ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIv-0003zm-GM for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35384) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003cY-5z; Mon, 07 Aug 2017 10:46:25 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 22D0378EA4; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A95177FE83; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9D4AA11384DE; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 22D0378EA4 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:47 +0200 Message-Id: <1502117160-24655-44-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 43/56] blockjob: Lift speed sign conversion out of mirror_start() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mirror_start() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. mirror_start() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of mirror_start() into its caller. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/mirror.c | 7 +------ blockdev.c | 5 +++++ include/block/block_int.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 27b4c7f..af0c989 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1283,7 +1283,7 @@ fail: =20 void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - int64_t speed, uint64_t granularity, int64_t buf_size, + uint64_t speed, uint64_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -1292,11 +1292,6 @@ void mirror_start(const char *job_id, BlockDriverSta= te *bs, bool is_none_mode; BlockDriverState *base; =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } if (mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(errp, "Sync mode 'incremental' not supported"); return; diff --git a/blockdev.c b/blockdev.c index 4d9a665..06f87e3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3454,6 +3454,11 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, filter_node_name =3D NULL; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } if (granularity !=3D 0 && (granularity < 512 || granularity > 1048576 = * 64)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); diff --git a/include/block/block_int.h b/include/block/block_int.h index 695d7b3..3ff5536 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -896,7 +896,7 @@ void commit_active_start(const char *job_id, BlockDrive= rState *bs, */ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - int64_t speed, uint64_t granularity, int64_t buf_size, + uint64_t speed, uint64_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118844382533.1928555883147; Mon, 7 Aug 2017 08:14:04 -0700 (PDT) Received: from localhost ([::1]:37820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejjE-00071P-Rb for importer@patchew.org; Mon, 07 Aug 2017 11:14:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJA-0007Ss-VX for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIv-0003zd-Ej for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003cR-6p; Mon, 07 Aug 2017 10:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19A15356EA; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7840707A4; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A114F1133042; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 19A15356EA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:48 +0200 Message-Id: <1502117160-24655-45-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 44/56] blockjob: Lift speed sign conversion out of blockdev_mirror_common() 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" blockdev_mirror_common() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. blockdev_mirror_common() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of blockdev_mirror_common() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- blockdev.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 06f87e3..13df88b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3419,7 +3419,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, BlockMirrorBackingMode backing_mode, - bool has_speed, int64_t speed, + bool has_speed, uint64_t speed, bool has_granularity, uint64_t granular= ity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, @@ -3454,11 +3454,6 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, filter_node_name =3D NULL; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } if (granularity !=3D 0 && (granularity < 512 || granularity > 1048576 = * 64)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); @@ -3508,6 +3503,12 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) return; } =20 + if (arg->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3667,6 +3668,12 @@ void qmp_blockdev_mirror(bool has_job_id, const char= *job_id, return; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118565586224.96671928345665; Mon, 7 Aug 2017 08:09:25 -0700 (PDT) Received: from localhost ([::1]:37799 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejem-0002KK-8u for importer@patchew.org; Mon, 07 Aug 2017 11:09:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJC-0007WA-Vl for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIw-00040u-Rw for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35418) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003d0-Jf; Mon, 07 Aug 2017 10:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D0AB78EBE; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F30BA707A7; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A3FB41133045; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D0AB78EBE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:49 +0200 Message-Id: <1502117160-24655-46-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 45/56] blockjob: Lift speed sign conversion out of commit_start() etc. 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" commit_start() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. commit_start() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of commit_start() and commit_active_start() into their caller qmp_block_commit(). I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster --- block/commit.c | 9 ++------- block/mirror.c | 8 +------- blockdev.c | 6 ++++++ include/block/block_int.h | 5 +++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/block/commit.c b/block/commit.c index 86d780e..f61421f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -282,7 +282,8 @@ static BlockDriver bdrv_commit_top =3D { }; =20 void commit_start(const char *job_id, BlockDriverState *bs, - BlockDriverState *base, BlockDriverState *top, int64_t s= peed, + BlockDriverState *base, BlockDriverState *top, + uint64_t speed, BlockdevOnError on_error, const char *backing_file_str, const char *filter_node_name, Error **errp) { @@ -309,12 +310,6 @@ void commit_start(const char *job_id, BlockDriverState= *bs, return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - s =3D block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL, speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { diff --git a/block/mirror.c b/block/mirror.c index af0c989..f1adda5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1307,7 +1307,7 @@ void mirror_start(const char *job_id, BlockDriverStat= e *bs, =20 void commit_active_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, int creation_flags, - int64_t speed, BlockdevOnError on_error, + uint64_t speed, BlockdevOnError on_error, const char *filter_node_name, BlockCompletionFunc *cb, void *opaque, bool auto_complete, Error **errp) @@ -1317,12 +1317,6 @@ void commit_active_start(const char *job_id, BlockDr= iverState *bs, =20 orig_base_flags =3D bdrv_get_flags(base); =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - if (bdrv_reopen(base, bs->open_flags, errp)) { return; } diff --git a/blockdev.c b/blockdev.c index 13df88b..e679f5d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3102,6 +3102,12 @@ void qmp_block_commit(bool has_job_id, const char *j= ob_id, const char *device, return; } =20 + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + goto out; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index 3ff5536..75116e5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -840,7 +840,8 @@ void stream_start(const char *job_id, BlockDriverState = *bs, * */ void commit_start(const char *job_id, BlockDriverState *bs, - BlockDriverState *base, BlockDriverState *top, int64_t s= peed, + BlockDriverState *base, BlockDriverState *top, + uint64_t speed, BlockdevOnError on_error, const char *backing_file_str, const char *filter_node_name, Error **errp); /** @@ -864,7 +865,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, */ void commit_active_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, int creation_flags, - int64_t speed, BlockdevOnError on_error, + uint64_t speed, BlockdevOnError on_error, const char *filter_node_name, BlockCompletionFunc *cb, void *opaque, bool auto_complete, Error **errp); --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119478202429.4012204539655; Mon, 7 Aug 2017 08:24:38 -0700 (PDT) Received: from localhost ([::1]:37881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejtU-0008S8-RC for importer@patchew.org; Mon, 07 Aug 2017 11:24:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJK-0007gE-6L for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ3-00046i-GS for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44110) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fZ-Dy; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DCEDC0587C6; Mon, 7 Aug 2017 14:46:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F26648F36A; Mon, 7 Aug 2017 14:46:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A822E1133047; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0DCEDC0587C6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:50 +0200 Message-Id: <1502117160-24655-47-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 46/56] blockjob: Make job commands' speed parameter unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte rates should use QAPI type 'size' (uint64_t). drive-backup, blockdev-backup, block-commit, drive-mirror, blockdev-mirror, block-stream and block-job-set-speed parameter @size is 'int' (int64_t). Their QMP command handlers all ensure it's non-negative before they pass it on to the next lower layer, which expects uint64_t. Change these @speed parameters to 'size', and drop the range checks. You can now set rate limits between 2^63 and 2^64-1. Good luck finding hardware where that actually limits. Negative values are accepted and interpreted modulo 2^64, because that's how the QObject input visitor works for backward compatibility. Drop the tests for negative size. Signed-off-by: Markus Armbruster --- blockdev.c | 50 ++++--------------------------------------= ---- qapi/block-core.json | 14 ++++++------- tests/qemu-iotests/030 | 16 --------------- tests/qemu-iotests/030.out | 4 ++-- tests/qemu-iotests/041 | 18 ----------------- tests/qemu-iotests/041.out | 4 ++-- tests/qemu-iotests/055 | 26 ------------------------ tests/qemu-iotests/055.out | 4 ++-- 8 files changed, 17 insertions(+), 119 deletions(-) diff --git a/blockdev.c b/blockdev.c index e679f5d..7feed7a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2970,7 +2970,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, bool has_base, const char *base, bool has_base_node, const char *base_node, bool has_backing_file, const char *backing_file, - bool has_speed, int64_t speed, + bool has_speed, uint64_t speed, bool has_on_error, BlockdevOnError on_error, Error **errp) { @@ -2989,12 +2989,6 @@ void qmp_block_stream(bool has_job_id, const char *j= ob_id, const char *device, return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3063,7 +3057,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, bool has_base, const char *base, bool has_top, const char *top, bool has_backing_file, const char *backing_file, - bool has_speed, int64_t speed, + bool has_speed, uint64_t speed, bool has_filter_node_name, const char *filter_node_n= ame, Error **errp) { @@ -3102,12 +3096,6 @@ void qmp_block_commit(bool has_job_id, const char *j= ob_id, const char *device, return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - goto out; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3222,12 +3210,6 @@ static BlockJob *do_drive_backup(DriveBackup *backup= , BlockJobTxn *txn, return NULL; } =20 - if (backup->speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return NULL; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3371,12 +3353,6 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup,= BlockJobTxn *txn, return NULL; } =20 - if (backup->speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return NULL; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3509,12 +3485,6 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) return; } =20 - if (arg->speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3647,7 +3617,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char = *job_id, const char *device, const char *target, bool has_replaces, const char *replaces, MirrorSyncMode sync, - bool has_speed, int64_t speed, + bool has_speed, uint64_t speed, bool has_granularity, uint64_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, @@ -3674,12 +3644,6 @@ void qmp_blockdev_mirror(bool has_job_id, const char= *job_id, return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 @@ -3724,7 +3688,7 @@ static BlockJob *find_block_job(const char *id, AioCo= ntext **aio_context, return job; } =20 -void qmp_block_job_set_speed(const char *device, int64_t speed, Error **er= rp) +void qmp_block_job_set_speed(const char *device, uint64_t speed, Error **e= rrp) { AioContext *aio_context; BlockJob *job =3D find_block_job(device, &aio_context, errp); @@ -3733,12 +3697,6 @@ void qmp_block_job_set_speed(const char *device, int= 64_t speed, Error **errp) return; } =20 - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - block_job_set_speed(job, speed, errp); aio_context_release(aio_context); } diff --git a/qapi/block-core.json b/qapi/block-core.json index ceaab43..9e9f2d8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1117,7 +1117,7 @@ { 'struct': 'DriveBackup', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImage= Mode', - '*speed': 'int', '*bitmap': 'str', '*compress': 'bool', + '*speed': 'size', '*bitmap': 'str', '*compress': 'bool', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } =20 @@ -1158,7 +1158,7 @@ { 'struct': 'BlockdevBackup', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', 'sync': 'MirrorSyncMode', - '*speed': 'int', + '*speed': 'size', '*compress': 'bool', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } @@ -1329,7 +1329,7 @@ ## { 'command': 'block-commit', 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'st= r', - '*backing-file': 'str', '*speed': 'int', + '*backing-file': 'str', '*speed': 'size', '*filter-node-name': 'str' } } =20 ## @@ -1533,7 +1533,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', - '*speed': 'int', '*granularity': 'size', + '*speed': 'size', '*granularity': 'size', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*unmap': 'bool' } } @@ -1732,7 +1732,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', - '*speed': 'int', '*granularity': 'size', + '*speed': 'size', '*granularity': 'size', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*filter-node-name': 'str' } } @@ -1949,7 +1949,7 @@ ## { 'command': 'block-stream', 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', - '*base-node': 'str', '*backing-file': 'str', '*speed': 'int', + '*base-node': 'str', '*backing-file': 'str', '*speed': 'size', '*on-error': 'BlockdevOnError' } } =20 ## @@ -1974,7 +1974,7 @@ # Since: 1.1 ## { 'command': 'block-job-set-speed', - 'data': { 'device': 'str', 'speed': 'int' } } + 'data': { 'device': 'str', 'speed': 'size' } } =20 ## # @block-job-cancel: diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index d745cb4..7fc365b 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -788,21 +788,5 @@ class TestSetSpeed(iotests.QMPTestCase): =20 self.cancel_and_wait(resume=3DTrue) =20 - def test_set_speed_invalid(self): - self.assert_no_active_block_jobs() - - result =3D self.vm.qmp('block-stream', device=3D'drive0', speed=3D= -1) - self.assert_qmp(result, 'error/class', 'GenericError') - - self.assert_no_active_block_jobs() - - result =3D self.vm.qmp('block-stream', device=3D'drive0') - self.assert_qmp(result, 'return', {}) - - result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D-1) - self.assert_qmp(result, 'error/class', 'GenericError') - - self.cancel_and_wait() - if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed']) diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index 391c857..84bfd63 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -....................... +...................... ---------------------------------------------------------------------- -Ran 23 tests +Ran 22 tests =20 OK diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index a860a31..6c2dd50 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -701,24 +701,6 @@ class TestSetSpeed(iotests.QMPTestCase): =20 self.wait_ready_and_cancel() =20 - def test_set_speed_invalid(self): - self.assert_no_active_block_jobs() - - result =3D self.vm.qmp('drive-mirror', device=3D'drive0', sync=3D'= full', - target=3Dtarget_img, speed=3D-1) - self.assert_qmp(result, 'error/class', 'GenericError') - - self.assert_no_active_block_jobs() - - result =3D self.vm.qmp('drive-mirror', device=3D'drive0', sync=3D'= full', - target=3Dtarget_img) - self.assert_qmp(result, 'return', {}) - - result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D-1) - self.assert_qmp(result, 'error/class', 'GenericError') - - self.wait_ready_and_cancel() - class TestUnbackedSource(iotests.QMPTestCase): image_len =3D 2 * 1024 * 1024 # MB =20 diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index c28b392..1eb95f3 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -..........................................................................= ........... +..........................................................................= .......... ---------------------------------------------------------------------- -Ran 85 tests +Ran 84 tests =20 OK diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index e1206ca..c703fbb 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -220,32 +220,6 @@ class TestSetSpeed(iotests.QMPTestCase): def test_set_speed_blockdev_backup(self): self.do_test_set_speed('blockdev-backup', 'drive1') =20 - def do_test_set_speed_invalid(self, cmd, target): - self.assert_no_active_block_jobs() - - result =3D self.vm.qmp(cmd, device=3D'drive0', - target=3Dtarget, sync=3D'full', speed=3D-1) - self.assert_qmp(result, 'error/class', 'GenericError') - - self.assert_no_active_block_jobs() - - self.vm.pause_drive('drive0') - result =3D self.vm.qmp(cmd, device=3D'drive0', - target=3Dtarget, sync=3D'full') - self.assert_qmp(result, 'return', {}) - - result =3D self.vm.qmp('block-job-set-speed', device=3D'drive0', s= peed=3D-1) - self.assert_qmp(result, 'error/class', 'GenericError') - - event =3D self.cancel_and_wait(resume=3DTrue) - self.assert_qmp(event, 'data/type', 'backup') - - def test_set_speed_invalid_drive_backup(self): - self.do_test_set_speed_invalid('drive-backup', target_img) - - def test_set_speed_invalid_blockdev_backup(self): - self.do_test_set_speed_invalid('blockdev-backup', 'drive1') - class TestSingleTransaction(iotests.QMPTestCase): def setUp(self): qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(= image_len)) diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out index 5ce2f9a..af8dac1 100644 --- a/tests/qemu-iotests/055.out +++ b/tests/qemu-iotests/055.out @@ -1,5 +1,5 @@ -.............................. +............................ ---------------------------------------------------------------------- -Ran 30 tests +Ran 28 tests =20 OK --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119429949689.4470543272298; Mon, 7 Aug 2017 08:23:49 -0700 (PDT) Received: from localhost ([::1]:37879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejsi-0007r9-Oz for importer@patchew.org; Mon, 07 Aug 2017 11:23:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJJ-0007dd-7d for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ2-00045x-Hi for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fs-G8; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39220806A2; Mon, 7 Aug 2017 14:46:26 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C5268FBE2; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id ABAA61133049; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 39220806A2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:51 +0200 Message-Id: <1502117160-24655-48-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 47/56] blockjob: Make BlockJobInfo and event offsets unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets should use QAPI type 'size' (uint64_t). BlockJobInfo members @len, offset and parameters @len, @offset of events BLOCK_JOB_COMPLETED, BLOCK_JOB_CANCELLED, BLOCK_JOB_READY are 'int' (int64_t). block_job_query(), block_job_event_completed(), block_job_event_cancelled(), block_job_event_ready() get them from BlockJob members @len and @offset, which are int64_t, but should never be negative. Change the BlockJobInfo members and the event parameters to 'size', for QAPI/QMP consistency. Signed-off-by: Markus Armbruster --- hmp.c | 8 ++++---- qapi/block-core.json | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index fae974e..867c50b 100644 --- a/hmp.c +++ b/hmp.c @@ -966,16 +966,16 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *q= dict) =20 while (list) { if (strcmp(list->value->type, "stream") =3D=3D 0) { - monitor_printf(mon, "Streaming device %s: Completed %" PRId64 - " of %" PRId64 " bytes, speed limit %" PRIu64 + monitor_printf(mon, "Streaming device %s: Completed %" PRIu64 + " of %" PRIu64 " bytes, speed limit %" PRIu64 " bytes/s\n", list->value->device, list->value->offset, list->value->len, list->value->speed); } else { - monitor_printf(mon, "Type %s, device %s: Completed %" PRId64 - " of %" PRId64 " bytes, speed limit %" PRIu64 + monitor_printf(mon, "Type %s, device %s: Completed %" PRIu64 + " of %" PRIu64 " bytes, speed limit %" PRIu64 " bytes/s\n", list->value->type, list->value->device, diff --git a/qapi/block-core.json b/qapi/block-core.json index 9e9f2d8..b8442f3 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -955,8 +955,8 @@ # Since: 1.1 ## { 'struct': 'BlockJobInfo', - 'data': {'type': 'str', 'device': 'str', 'len': 'int', - 'offset': 'int', 'busy': 'bool', 'paused': 'bool', + 'data': {'type': 'str', 'device': 'str', 'len': 'size', + 'offset': 'size', 'busy': 'bool', 'paused': 'bool', 'speed': 'size', 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} } =20 @@ -3606,8 +3606,8 @@ { 'event': 'BLOCK_JOB_COMPLETED', 'data': { 'type' : 'BlockJobType', 'device': 'str', - 'len' : 'int', - 'offset': 'int', + 'len' : 'size', + 'offset': 'size', 'speed' : 'size', '*error': 'str' } } =20 @@ -3642,8 +3642,8 @@ { 'event': 'BLOCK_JOB_CANCELLED', 'data': { 'type' : 'BlockJobType', 'device': 'str', - 'len' : 'int', - 'offset': 'int', + 'len' : 'size', + 'offset': 'size', 'speed' : 'size' } } =20 ## @@ -3707,8 +3707,8 @@ { 'event': 'BLOCK_JOB_READY', 'data': { 'type' : 'BlockJobType', 'device': 'str', - 'len' : 'int', - 'offset': 'int', + 'len' : 'size', + 'offset': 'size', 'speed' : 'size' } } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118616867351.35691622951765; Mon, 7 Aug 2017 08:10:16 -0700 (PDT) Received: from localhost ([::1]:37802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejfb-000374-F4 for importer@patchew.org; Mon, 07 Aug 2017 11:10:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007YI-Vi for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIz-00042s-B2 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIY-0003dw-5e; Mon, 07 Aug 2017 10:46:26 -0400 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 03D3CDB946; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C9AD9521A; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AEB181133050; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03D3CDB946 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:52 +0200 Message-Id: <1502117160-24655-49-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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.38]); Mon, 07 Aug 2017 14:46:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 48/56] block: Make mirror buffer size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte counts should use QAPI type 'size' (uint64_t). Parameter @buf-size of drive-mirror and blockdev-mirror is 'int' (int64_t). The underlying MirrorBlockJob abstraction takes size_t. mirror_start_job() converts from int64_t to size_t, rejecting negative sizes (but not values exceeding SIZE_MAX). Change the two parameters to 'size', and lift the (fixed) check and the conversion into blockdev_mirror_common(). Signed-off-by: Markus Armbruster --- block/mirror.c | 11 +++-------- blockdev.c | 9 +++++++-- include/block/block_int.h | 2 +- qapi/block-core.json | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index f1adda5..f9a5416 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -333,7 +333,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlo= ckJob *s) int nb_chunks =3D 1; int sectors_per_chunk =3D s->granularity >> BDRV_SECTOR_BITS; bool write_zeroes_ok =3D bdrv_can_write_zeroes_with_unmap(blk_bs(s->ta= rget)); - int max_io_bytes =3D MAX(s->buf_size / MAX_IN_FLIGHT, MAX_IO_BYTES); + unsigned max_io_bytes =3D MAX(s->buf_size / MAX_IN_FLIGHT, MAX_IO_BYTE= S); =20 bdrv_dirty_bitmap_lock(s->dirty_bitmap); offset =3D bdrv_dirty_iter_next(s->dbi) * BDRV_SECTOR_SIZE; @@ -1120,7 +1120,7 @@ static BlockDriver bdrv_mirror_top =3D { static void mirror_start_job(const char *job_id, BlockDriverState *bs, int creation_flags, BlockDriverState *target, const char *replaces, uint64_t speed, - uint64_t granularity, int64_t buf_size, + uint64_t granularity, size_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -1147,11 +1147,6 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, /* Granularity must be large enough for sector-based dirty bitmap */ assert(granularity >=3D BDRV_SECTOR_SIZE); =20 - if (buf_size < 0) { - error_setg(errp, "Invalid parameter 'buf-size'"); - return; - } - if (buf_size =3D=3D 0) { buf_size =3D DEFAULT_MIRROR_BUF_SIZE; } @@ -1283,7 +1278,7 @@ fail: =20 void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - uint64_t speed, uint64_t granularity, int64_t buf_size, + uint64_t speed, uint64_t granularity, size_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/blockdev.c b/blockdev.c index 7feed7a..ba1a960 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3403,7 +3403,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, BlockMirrorBackingMode backing_mode, bool has_speed, uint64_t speed, bool has_granularity, uint64_t granular= ity, - bool has_buf_size, int64_t buf_size, + bool has_buf_size, uint64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, @@ -3447,6 +3447,11 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, return; } =20 + if (buf_size > SIZE_MAX) { + error_setg(errp, "Parameter 'buf-size' is too large"); + return; + } + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { return; } @@ -3619,7 +3624,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char = *job_id, MirrorSyncMode sync, bool has_speed, uint64_t speed, bool has_granularity, uint64_t granularity, - bool has_buf_size, int64_t buf_size, + bool has_buf_size, uint64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, diff --git a/include/block/block_int.h b/include/block/block_int.h index 75116e5..8bde408 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -897,7 +897,7 @@ void commit_active_start(const char *job_id, BlockDrive= rState *bs, */ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, - uint64_t speed, uint64_t granularity, int64_t buf_size, + uint64_t speed, uint64_t granularity, size_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/qapi/block-core.json b/qapi/block-core.json index b8442f3..51caee9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1534,7 +1534,7 @@ '*format': 'str', '*node-name': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', '*speed': 'size', '*granularity': 'size', - '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', + '*buf-size': 'size', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*unmap': 'bool' } } =20 @@ -1733,7 +1733,7 @@ '*replaces': 'str', 'sync': 'MirrorSyncMode', '*speed': 'size', '*granularity': 'size', - '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', + '*buf-size': 'size', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*filter-node-name': 'str' } } =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119367840744.4721276384655; Mon, 7 Aug 2017 08:22:47 -0700 (PDT) Received: from localhost ([::1]:37871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejri-00071f-BZ for importer@patchew.org; Mon, 07 Aug 2017 11:22:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007XH-1o for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIx-00041d-NI for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIY-0003dQ-0M; Mon, 07 Aug 2017 10:46:26 -0400 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 E5DD578EAA; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 636479520F; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B20C01133052; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E5DD578EAA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:53 +0200 Message-Id: <1502117160-24655-50-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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.27]); Mon, 07 Aug 2017 14:46:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 49/56] block: Make ImageCheck file offset unsigned in QAPI 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets should use QAPI type 'size' (uint64_t). ImageCheck member @image-end-offset is 'int' (int64_t). collect_image_check() gets it from BdrvCheckResult member @image_end_offset (also int64_t, should never be negative). Change the ImageCheck member to 'size', for QAPI/QMP consistency. Signed-off-by: Markus Armbruster --- qapi/block-core.json | 2 +- qemu-img.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 51caee9..3c6d448 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -208,7 +208,7 @@ ## { 'struct': 'ImageCheck', 'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int', - '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'i= nt', + '*image-end-offset': 'size', '*corruptions': 'int', '*leaks': '= int', '*corruptions-fixed': 'int', '*leaks-fixed': 'int', '*total-clusters': 'int', '*allocated-clusters': 'int', '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } } diff --git a/qemu-img.c b/qemu-img.c index f4d5f0d..3ae5fe3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -604,7 +604,7 @@ static void dump_human_image_check(ImageCheck *check, b= ool quiet) =20 if (check->image_end_offset) { qprintf(quiet, - "Image end offset: %" PRId64 "\n", check->image_end_offset= ); + "Image end offset: %" PRIu64 "\n", check->image_end_offset= ); } } =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119208700657.5580792446614; Mon, 7 Aug 2017 08:20:08 -0700 (PDT) Received: from localhost ([::1]:37848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejp9-0004NM-6L for importer@patchew.org; Mon, 07 Aug 2017 11:20:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJD-0007Wl-I6 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIw-000416-Sa for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIX-0003dG-Rz; Mon, 07 Aug 2017 10:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A48B578EBF; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 576AF707AC; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B53EB1133071; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A48B578EBF Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:54 +0200 Message-Id: <1502117160-24655-51-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Aug 2017 14:46:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 50/56] block: Make BLOCK_IMAGE_CORRUPTED offset, size unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets should use QAPI type 'size' (uint64_t). BLOCK_IMAGE_CORRUPTED parameters @offset and @size are 'int' (int64_t). qcow2_signal_corruption() passes non-negative int64_t values. Change the event parameters to 'size', for QAPI/QMP consistency. Signed-off-by: Markus Armbruster --- qapi/block-core.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 3c6d448..64b84a5 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3520,8 +3520,8 @@ 'data': { 'device' : 'str', '*node-name' : 'str', 'msg' : 'str', - '*offset' : 'int', - '*size' : 'int', + '*offset' : 'size', + '*size' : 'size', 'fatal' : 'bool' } } =20 ## --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119688105905.3016653709824; Mon, 7 Aug 2017 08:28:08 -0700 (PDT) Received: from localhost ([::1]:37898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejws-0003KG-Kt for importer@patchew.org; Mon, 07 Aug 2017 11:28:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJJ-0007fj-QP for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ4-00047P-C9 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIa-0003iA-VA; Mon, 07 Aug 2017 10:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB387806BD; Mon, 7 Aug 2017 14:46:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 587856A307; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B8E8F1133074; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB387806BD Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:55 +0200 Message-Id: <1502117160-24655-52-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Aug 2017 14:46:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 51/56] block/nfs: Fix for readahead-size, page-cache-size > INT64_MAX 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" nfs_client_open() implicitly converts the uint64_t value of qemu_opt_get_number() to int64_t, then clamps it to range. The clamping is broken for negative values. Fix by making NFSClient members @readahead and @pagecache uint64_t. Signed-off-by: Markus Armbruster --- block/nfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index d8db419..2776788 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -58,7 +58,8 @@ typedef struct NFSClient { bool cache_used; NFSServer *server; char *path; - int64_t uid, gid, tcp_syncnt, readahead, pagecache, debug; + int64_t uid, gid, tcp_syncnt, debug; + uint64_t readahead, pagecache; } NFSClient; =20 typedef struct NFSRPC { @@ -856,10 +857,10 @@ static void nfs_refresh_filename(BlockDriverState *bs= , QDict *options) qdict_put_int(opts, "tcp-syn-cnt", client->tcp_syncnt); } if (client->readahead) { - qdict_put_int(opts, "readahead-size", client->readahead); + qdict_put_uint(opts, "readahead-size", client->readahead); } if (client->pagecache) { - qdict_put_int(opts, "page-cache-size", client->pagecache); + qdict_put_uint(opts, "page-cache-size", client->pagecache); } if (client->debug) { qdict_put_int(opts, "debug", client->debug); --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502118723856788.0776780233438; Mon, 7 Aug 2017 08:12:03 -0700 (PDT) Received: from localhost ([::1]:37813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejhK-0004wr-H5 for importer@patchew.org; Mon, 07 Aug 2017 11:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007YG-Uj for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIz-00043I-Mb for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIY-0003et-VF; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF8BDA790; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC1388F363; Mon, 7 Aug 2017 14:46:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BBD671133000; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF8BDA790 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:56 +0200 Message-Id: <1502117160-24655-53-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 52/56] block/nfs: Reject negative readahead-size, page-cache-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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The nfs block driver uses QEMU_OPT_NUMBER for these sizes. All other block drivers use QEMU_OPT_SIZE. Both are uint64_t, but QEMU_OPT_SIZE rejects negative numbers, while QEMU_OPT_NUMBER interprets them modulo 2^64. Switch the nfs block driver to QEMU_OPT_SIZE. Signed-off-by: Markus Armbruster --- block/nfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index 2776788..0ed3e7c 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -394,12 +394,12 @@ static QemuOptsList runtime_opts =3D { }, { .name =3D "readahead-size", - .type =3D QEMU_OPT_NUMBER, + .type =3D QEMU_OPT_SIZE, .help =3D "Set the readahead size in bytes", }, { .name =3D "page-cache-size", - .type =3D QEMU_OPT_NUMBER, + .type =3D QEMU_OPT_SIZE, .help =3D "Set the pagecache size in bytes", }, { @@ -557,7 +557,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict= *options, "if cache.direct =3D on"); goto fail; } - client->readahead =3D qemu_opt_get_number(opts, "readahead-size", = 0); + client->readahead =3D qemu_opt_get_size(opts, "readahead-size", 0); if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) { warn_report("Truncating NFS readahead size to %d", QEMU_NFS_MAX_READAHEAD_SIZE); @@ -578,7 +578,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict= *options, "if cache.direct =3D on"); goto fail; } - client->pagecache =3D qemu_opt_get_number(opts, "page-cache-size",= 0); + client->pagecache =3D qemu_opt_get_size(opts, "page-cache-size", 0= ); if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) { warn_report("Truncating NFS pagecache size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE); --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119333648504.9901711238773; Mon, 7 Aug 2017 08:22:13 -0700 (PDT) Received: from localhost ([::1]:37864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejrA-0006T6-4v for importer@patchew.org; Mon, 07 Aug 2017 11:22:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJJ-0007fG-K4 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ4-00047H-9J for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35608) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIa-0003hH-9X; Mon, 07 Aug 2017 10:46:28 -0400 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 36C1478EA2; Mon, 7 Aug 2017 14:46:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DBF09520C; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BF71E1133001; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 36C1478EA2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:57 +0200 Message-Id: <1502117160-24655-54-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> 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.27]); Mon, 07 Aug 2017 14:46:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 53/56] block: Make blockdev-add byte counts unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets, sizes and alignments should use QAPI type 'size' (uint64_t). blockdev-add parameters are 'int' (int64_t): BlockdevOptionsNull member @size; BlockdevOptionsQcow2 members @cache-size, @l2-cache-size, @refcount-cache-size; BlockdevOptionsNfs members @readahead-size, @page-cache-size; BlockdevOptionsCurlBase member @readahead; BlockdevOptionsRaw members @offset, @size. The block drivers get their values with qemu_opt_get_size(), which returns uint64_t. They store them in uint64_t variables, except for the null driver, which stores in BDRVNullState member int64_t length. Change these BlockdevOptionsFOO members to 'size'. Change BDRVNullState member length to uint64_t. This moves the implicit conversion to int64_t from null_file_open() to null_getlength(). No worse than before. blockdev-add and -blockdev now accept values between 2^63 and 2^64-1. They accept negative values as before, because that's how the QObject input visitor works for backward compatibility. Values above 2^63 are unlikely to actually work; the block subsystem isn't prepared for them. Again, no worse than before. Aside: we call the same thing @readahead-size in one place, and @readahead in another place. Sad. Signed-off-by: Markus Armbruster --- block/null.c | 2 +- qapi/block-core.json | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/block/null.c b/block/null.c index 876f909..2ab0e70 100644 --- a/block/null.c +++ b/block/null.c @@ -20,7 +20,7 @@ #define NULL_OPT_ZEROES "read-zeroes" =20 typedef struct { - int64_t length; + uint64_t length; int64_t latency_ns; bool read_zeroes; } BDRVNullState; diff --git a/qapi/block-core.json b/qapi/block-core.json index 64b84a5..3482f8c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2189,7 +2189,7 @@ # Since: 2.9 ## { 'struct': 'BlockdevOptionsNull', - 'data': { '*size': 'int', '*latency-ns': 'uint64' } } + 'data': { '*size': 'size', '*latency-ns': 'uint64' } } =20 ## # @BlockdevOptionsVVFAT: @@ -2421,9 +2421,9 @@ '*pass-discard-snapshot': 'bool', '*pass-discard-other': 'bool', '*overlap-check': 'Qcow2OverlapChecks', - '*cache-size': 'int', - '*l2-cache-size': 'int', - '*refcount-cache-size': 'int', + '*cache-size': 'size', + '*l2-cache-size': 'size', + '*refcount-cache-size': 'size', '*cache-clean-interval': 'int', '*encrypt': 'BlockdevQcow2Encryption' } } =20 @@ -2568,9 +2568,9 @@ { 'struct': 'BlockdevOptionsBlkdebug', 'data': { 'image': 'BlockdevRef', '*config': 'str', - '*align': 'int', '*max-transfer': 'int32', - '*opt-write-zero': 'int32', '*max-write-zero': 'int32', - '*opt-discard': 'int32', '*max-discard': 'int32', + '*align': 'size', '*max-transfer': 'size', + '*opt-write-zero': 'size', '*max-write-zero': 'size', + '*opt-discard': 'size', '*max-discard': 'size', '*inject-error': ['BlkdebugInjectErrorOptions'], '*set-state': ['BlkdebugSetStateOptions'] } } =20 @@ -2862,8 +2862,8 @@ '*user': 'int', '*group': 'int', '*tcp-syn-count': 'int', - '*readahead-size': 'int', - '*page-cache-size': 'int', + '*readahead-size': 'size', + '*page-cache-size': 'size', '*debug': 'int' } } =20 ## @@ -2893,7 +2893,7 @@ ## { 'struct': 'BlockdevOptionsCurlBase', 'data': { 'url': 'str', - '*readahead': 'int', + '*readahead': 'size', '*timeout': 'int', '*username': 'str', '*password-secret': 'str', @@ -3001,7 +3001,7 @@ ## { 'struct': 'BlockdevOptionsRaw', 'base': 'BlockdevOptionsGenericFormat', - 'data': { '*offset': 'int', '*size': 'int' } } + 'data': { '*offset': 'size', '*size': 'size' } } =20 ## # @BlockdevOptionsVxHS: --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119165020568.2324280445844; Mon, 7 Aug 2017 08:19:25 -0700 (PDT) Received: from localhost ([::1]:37844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejoR-0003iZ-LN for importer@patchew.org; Mon, 07 Aug 2017 11:19:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJF-0007ZI-Mz for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ0-00044D-T4 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003fH-5q; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFED17F40F; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90D88707B9; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C28771133003; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EFED17F40F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:58 +0200 Message-Id: <1502117160-24655-55-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 54/56] qemu-img: blk_getlength() can fail, fix img_map() to check 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- qemu-img.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 3ae5fe3..cf3ef3e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2838,6 +2838,10 @@ static int img_map(int argc, char **argv) } =20 length =3D blk_getlength(blk); + if (length < 0) { + error_report("Couldn't get length of image '%s': %s", + filename, strerror(-length)); + } while (curr.start + curr.length < length) { int64_t nsectors_left; int64_t sector_num; --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502120046638274.7256050051891; Mon, 7 Aug 2017 08:34:06 -0700 (PDT) Received: from localhost ([::1]:37933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dek2e-0008Mo-1Z for importer@patchew.org; Mon, 07 Aug 2017 11:34:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJL-0007iD-VJ for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejJ6-000494-31 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIb-0003iv-Jt; Mon, 07 Aug 2017 10:46:29 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 87125356F3; Mon, 7 Aug 2017 14:46:28 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 905487FE88; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C66B11133008; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87125356F3 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:45:59 +0200 Message-Id: <1502117160-24655-56-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Aug 2017 14:46:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 55/56] block: Make MapEntry offsets and size unsigned in QAPI 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" File offsets and sizes use QAPI type 'size' (uint64_t). MapEntry members @start, @length and @offset are 'int' (int64_t). get_block_status() sets @start and @length to unsigned long long values, and @offset to a non-negative int64_t value. Change these MapEntry members to 'size'. "qemu-img map" now reports them correctly above 2^63-1 instead of their (negative) two's complement. Signed-off-by: Markus Armbruster --- qapi/block-core.json | 4 ++-- qemu-img.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 3482f8c..6f62723 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -236,8 +236,8 @@ # ## { 'struct': 'MapEntry', - 'data': {'start': 'int', 'length': 'int', 'data': 'bool', - 'zero': 'bool', 'depth': 'int', '*offset': 'int', + 'data': {'start': 'size', 'length': 'size', 'data': 'bool', + 'zero': 'bool', 'depth': 'int', '*offset': 'size', '*filename': 'str' } } =20 ## diff --git a/qemu-img.c b/qemu-img.c index cf3ef3e..1c783c7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2655,14 +2655,14 @@ static void dump_map_entry(OutputFormat output_form= at, MapEntry *e, } break; case OFORMAT_JSON: - printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64"," + printf("%s{ \"start\": %" PRIu64 ", \"length\": %" PRIu64 "," " \"depth\": %"PRId64", \"zero\": %s, \"data\": %s", (e->start =3D=3D 0 ? "[" : ",\n"), e->start, e->length, e->depth, e->zero ? "true" : "false", e->data ? "true" : "false"); if (e->has_offset) { - printf(", \"offset\": %"PRId64"", e->offset); + printf(", \"offset\": %" PRIu64, e->offset); } putchar('}'); =20 --=20 2.7.5 From nobody Thu May 2 03:59:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502119507425376.6202319038931; Mon, 7 Aug 2017 08:25:07 -0700 (PDT) Received: from localhost ([::1]:37883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejtw-0000SX-Hp for importer@patchew.org; Mon, 07 Aug 2017 11:25:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dejJE-0007Y9-Qz for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dejIz-000435-Jn for qemu-devel@nongnu.org; Mon, 07 Aug 2017 10:47:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dejIZ-0003f4-1c; Mon, 07 Aug 2017 10:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF96A8047E; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 901608FBF5; Mon, 7 Aug 2017 14:46:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C9839113300D; Mon, 7 Aug 2017 16:46:00 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF96A8047E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 16:46:00 +0200 Message-Id: <1502117160-24655-57-git-send-email-armbru@redhat.com> In-Reply-To: <1502117160-24655-1-git-send-email-armbru@redhat.com> References: <1502117160-24655-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Aug 2017 14:46:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 56/56] crypto: Make QCryptoBlockInfoLUKS offsets unsigned in QAPI/QMP 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, famz@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Byte offsets should use QAPI type 'size' (uint64_t). QCryptoBlockInfoLUKS member @payload-offset and QCryptoBlockInfoLUKSSlot member @key-offset are 'int' (int64_t). qcrypto_block_luks_get_info() gets the former QCryptoBlock member @payload_offset, implicitly converting from uint64_t, and computes the latter from QCryptoBlockLUKSKeySlot member @key_offset, implicitly converting from long long. Change both offsets to 'size'. query-block and query-named-block-nodes now report @payload-offset values above 2^63-1 correctly instead of their (negative) two's complement. Should never occur in practice. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrange --- qapi/crypto.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 6b6fde3..57a10cb 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -266,7 +266,7 @@ 'data': {'active': 'bool', '*iters': 'int', '*stripes': 'int', - 'key-offset': 'int' } } + 'key-offset': 'size' } } =20 =20 ## @@ -292,7 +292,7 @@ 'ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgorithm', 'hash-alg': 'QCryptoHashAlgorithm', - 'payload-offset': 'int', + 'payload-offset': 'size', 'master-key-iters': 'int', 'uuid': 'str', 'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }} --=20 2.7.5