From nobody Mon Feb 9 07:55:07 2026 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