From nobody Thu May 2 21:24:10 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.zoho.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 1492768031699480.99598691645576; Fri, 21 Apr 2017 02:47:11 -0700 (PDT) Received: from localhost ([::1]:58251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V9i-0002AB-6i for importer@patchew.org; Fri, 21 Apr 2017 05:47:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V68-0007u3-Nx for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V67-0000Vg-Ka for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V67-0000Vb-ER for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43: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 2C41A34157B; Fri, 21 Apr 2017 09:43:26 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DB177EF4E; Fri, 21 Apr 2017 09:43:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C41A34157B 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2C41A34157B From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:11 +0100 Message-Id: <20170421094316.19361-2-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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]); Fri, 21 Apr 2017 09:43: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] [PULL for-2.9 1/6] qemu-options: explain disk I/O throttling options 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: Peter Maydell , Alberto Garcia , Stefan Hajnoczi 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 disk I/O throttling options have been listed for a long time but never explained on the QEMU man page. Suggested-by: Nini Gu Cc: Alberto Garcia Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Message-id: 20170301115026.22621-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- qemu-options.hx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 99af8ed..9171bd5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -635,6 +635,30 @@ file sectors into the image file. conversion of plain zero writes by the OS to driver specific optimized zero write commands. You may even choose "unmap" if @var{discard} is set to "unmap" to allow a zero write to be converted to an UNMAP operation. +@item bps=3D@var{b},bps_rd=3D@var{r},bps_wr=3D@var{w} +Specify bandwidth throttling limits in bytes per second, either for all re= quest +types or for reads or writes only. Small values can lead to timeouts or h= angs +inside the guest. A safe minimum for disks is 2 MB/s. +@item bps_max=3D@var{bm},bps_rd_max=3D@var{rm},bps_wr_max=3D@var{wm} +Specify bursts in bytes per second, either for all request types or for re= ads +or writes only. Bursts allow the guest I/O to spike above the limit +temporarily. +@item iops=3D@var{i},iops_rd=3D@var{r},iops_wr=3D@var{w} +Specify request rate limits in requests per second, either for all request +types or for reads or writes only. +@item iops_max=3D@var{bm},iops_rd_max=3D@var{rm},iops_wr_max=3D@var{wm} +Specify bursts in requests per second, either for all request types or for= reads +or writes only. Bursts allow the guest I/O to spike above the limit +temporarily. +@item iops_size=3D@var{is} +Let every @var{is} bytes of a request count as a new request for iops +throttling purposes. Use this option to prevent guests from circumventing= iops +limits by sending fewer but larger requests. +@item group=3D@var{g} +Join a throttling quota group with given name @var{g}. All drives that are +members of the same group are accounted for together. Use this option to +prevent guests from circumventing throttling limits by using many small di= sks +instead of a single larger disk. @end table =20 By default, the @option{cache=3Dwriteback} mode is used. It will report da= ta --=20 2.9.3 From nobody Thu May 2 21:24:10 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.zoho.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 1492767900194468.3094149584773; Fri, 21 Apr 2017 02:45:00 -0700 (PDT) Received: from localhost ([::1]:58239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V7a-0000OZ-Nf for importer@patchew.org; Fri, 21 Apr 2017 05:44:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V6C-0007wi-A9 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V6B-0000W5-Ak for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58042) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V6B-0000W1-4Z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:31 -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 1212116F8A3; Fri, 21 Apr 2017 09:43:30 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A6C27FBD9; Fri, 21 Apr 2017 09:43:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1212116F8A3 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1212116F8A3 From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:12 +0100 Message-Id: <20170421094316.19361-3-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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.30]); Fri, 21 Apr 2017 09:43:30 +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] [PULL for-2.9 2/6] throttle: do not use invalid config in test 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: Peter Maydell , Stefan Hajnoczi 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 (burst) max parameter cannot be smaller than the avg parameter. There is a test case that uses avg =3D 56, max =3D 1 and gets away with it because no input validation is performed by the test case. This patch switches to valid test input parameters. Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-id: 20170301115026.22621-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/test-throttle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index bd7c501..089e937 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -205,8 +205,8 @@ static void test_config_functions(void) orig_cfg.buckets[THROTTLE_OPS_READ].avg =3D 69; orig_cfg.buckets[THROTTLE_OPS_WRITE].avg =3D 23; =20 - orig_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; /* should be corrected= */ - orig_cfg.buckets[THROTTLE_BPS_READ].max =3D 1; /* should not be corre= cted */ + orig_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; /* should be correcte= d */ + orig_cfg.buckets[THROTTLE_BPS_READ].max =3D 56; /* should not be corr= ected */ orig_cfg.buckets[THROTTLE_BPS_WRITE].max =3D 120; =20 orig_cfg.buckets[THROTTLE_OPS_TOTAL].max =3D 150; @@ -246,8 +246,8 @@ static void test_config_functions(void) g_assert(final_cfg.buckets[THROTTLE_OPS_READ].avg =3D=3D 69); g_assert(final_cfg.buckets[THROTTLE_OPS_WRITE].avg =3D=3D 23); =20 - g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D=3D 15.3);/* fix= ed */ - g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max =3D=3D 1); /* not= fixed */ + g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D=3D 15.3); /* fi= xed */ + g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max =3D=3D 56); /* no= t fixed */ g_assert(final_cfg.buckets[THROTTLE_BPS_WRITE].max =3D=3D 120); =20 g_assert(final_cfg.buckets[THROTTLE_OPS_TOTAL].max =3D=3D 150); --=20 2.9.3 From nobody Thu May 2 21:24:10 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.zoho.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 149276804834581.50073764536671; Fri, 21 Apr 2017 02:47:28 -0700 (PDT) Received: from localhost ([::1]:58252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V9y-0002Qf-RQ for importer@patchew.org; Fri, 21 Apr 2017 05:47:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V6I-000823-B0 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V6D-0000Wj-FC for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V6D-0000Wb-5Z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:33 -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 1999F683EE; Fri, 21 Apr 2017 09:43:32 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 945CA7FBC8; Fri, 21 Apr 2017 09:43:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1999F683EE 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1999F683EE From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:13 +0100 Message-Id: <20170421094316.19361-4-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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.38]); Fri, 21 Apr 2017 09:43:32 +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] [PULL for-2.9 3/6] throttle: make throttle_config(throttle_get_config()) symmetric 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: Peter Maydell , Stefan Hajnoczi 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" Throttling has a weird property that throttle_get_config() does not always return the same throttling settings that were given with throttle_config(). In other words, the set and get functions aren't symmetric. If .max is 0 then the throttling code assigns a default value of .avg / 10 in throttle_config(). This is an implementation detail of the throttling algorithm. When throttle_get_config() is called the .max value returned should still be 0. Users are exposed to this quirk via "info block" or "query-block" monitor commands. This has caused confusion because it looks like a bug when an unexpected value is reported. This patch hides the .max value adjustment in throttle_get_config() and updates test-throttle.c appropriately. Reported-by: Nini Gu Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-id: 20170301115026.22621-4-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/test-throttle.c | 8 ++++---- util/throttle.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 089e937..a9201b1 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -205,8 +205,8 @@ static void test_config_functions(void) orig_cfg.buckets[THROTTLE_OPS_READ].avg =3D 69; orig_cfg.buckets[THROTTLE_OPS_WRITE].avg =3D 23; =20 - orig_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; /* should be correcte= d */ - orig_cfg.buckets[THROTTLE_BPS_READ].max =3D 56; /* should not be corr= ected */ + orig_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; + orig_cfg.buckets[THROTTLE_BPS_READ].max =3D 56; orig_cfg.buckets[THROTTLE_BPS_WRITE].max =3D 120; =20 orig_cfg.buckets[THROTTLE_OPS_TOTAL].max =3D 150; @@ -246,8 +246,8 @@ static void test_config_functions(void) g_assert(final_cfg.buckets[THROTTLE_OPS_READ].avg =3D=3D 69); g_assert(final_cfg.buckets[THROTTLE_OPS_WRITE].avg =3D=3D 23); =20 - g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D=3D 15.3); /* fi= xed */ - g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max =3D=3D 56); /* no= t fixed */ + g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max =3D=3D 0); + g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max =3D=3D 56); g_assert(final_cfg.buckets[THROTTLE_BPS_WRITE].max =3D=3D 120); =20 g_assert(final_cfg.buckets[THROTTLE_OPS_TOTAL].max =3D=3D 150); diff --git a/util/throttle.c b/util/throttle.c index 3817d9b..3570ed2 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -380,6 +380,14 @@ static void throttle_fix_bucket(LeakyBucket *bkt) } } =20 +/* undo internal bucket parameter changes (see throttle_fix_bucket()) */ +static void throttle_unfix_bucket(LeakyBucket *bkt) +{ + if (bkt->max < bkt->avg) { + bkt->max =3D 0; + } +} + /* take care of canceling a timer */ static void throttle_cancel_timer(QEMUTimer *timer) { @@ -420,7 +428,13 @@ void throttle_config(ThrottleState *ts, */ void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg) { + int i; + *cfg =3D ts->cfg; + + for (i =3D 0; i < BUCKETS_COUNT; i++) { + throttle_unfix_bucket(&cfg->buckets[i]); + } } =20 =20 --=20 2.9.3 From nobody Thu May 2 21:24:10 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.zoho.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 1492768064167843.9160079165581; Fri, 21 Apr 2017 02:47:44 -0700 (PDT) Received: from localhost ([::1]:58253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1VAE-0002fx-QJ for importer@patchew.org; Fri, 21 Apr 2017 05:47:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V6J-00083K-Uj for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V6I-0000YK-JS for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58208) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V6I-0000YA-AO for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:38 -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 31C8516F8A0; Fri, 21 Apr 2017 09:43:36 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A4F75C8BB; Fri, 21 Apr 2017 09:43:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31C8516F8A0 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 31C8516F8A0 From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:14 +0100 Message-Id: <20170421094316.19361-5-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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]); Fri, 21 Apr 2017 09:43:36 +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] [PULL for-2.9 4/6] migration/block: use blk_pwrite_zeroes for each zero cluster 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: Peter Maydell , Stefan Hajnoczi , Lidong Chen 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" From: Lidong Chen BLOCK_SIZE is (1 << 20), qcow2 cluster size is 65536 by default, this may cause the qcow2 file size to be bigger after migration. This patch checks each cluster, using blk_pwrite_zeroes for each zero cluster. [Initialize cluster_size to BLOCK_SIZE to prevent a gcc uninitialized variable compiler warning. In reality we always initialize cluster_size in a conditional but gcc doesn't know that. --Stefan] Reviewed-by: Stefan Hajnoczi Signed-off-by: Lidong Chen Message-id: 1492050868-16200-1-git-send-email-lidongchen@tencent.com Signed-off-by: Stefan Hajnoczi --- migration/block.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 7734ff7..060087f 100644 --- a/migration/block.c +++ b/migration/block.c @@ -885,6 +885,8 @@ static int block_load(QEMUFile *f, void *opaque, int ve= rsion_id) int64_t total_sectors =3D 0; int nr_sectors; int ret; + BlockDriverInfo bdi; + int cluster_size =3D BLOCK_SIZE; =20 do { addr =3D qemu_get_be64(f); @@ -919,6 +921,15 @@ static int block_load(QEMUFile *f, void *opaque, int v= ersion_id) error_report_err(local_err); return -EINVAL; } + + ret =3D bdrv_get_info(blk_bs(blk), &bdi); + if (ret =3D=3D 0 && bdi.cluster_size > 0 && + bdi.cluster_size <=3D BLOCK_SIZE && + BLOCK_SIZE % bdi.cluster_size =3D=3D 0) { + cluster_size =3D bdi.cluster_size; + } else { + cluster_size =3D BLOCK_SIZE; + } } =20 if (total_sectors - addr < BDRV_SECTORS_PER_DIRTY_CHUNK) { @@ -932,10 +943,30 @@ static int block_load(QEMUFile *f, void *opaque, int = version_id) nr_sectors * BDRV_SECTOR_SIZE, BDRV_REQ_MAY_UNMAP); } else { + int i; + int64_t cur_addr; + uint8_t *cur_buf; + buf =3D g_malloc(BLOCK_SIZE); qemu_get_buffer(f, buf, BLOCK_SIZE); - ret =3D blk_pwrite(blk, addr * BDRV_SECTOR_SIZE, buf, - nr_sectors * BDRV_SECTOR_SIZE, 0); + for (i =3D 0; i < BLOCK_SIZE / cluster_size; i++) { + cur_addr =3D addr * BDRV_SECTOR_SIZE + i * cluster_siz= e; + cur_buf =3D buf + i * cluster_size; + + if ((!block_mig_state.zero_blocks || + cluster_size < BLOCK_SIZE) && + buffer_is_zero(cur_buf, cluster_size)) { + ret =3D blk_pwrite_zeroes(blk, cur_addr, + cluster_size, + BDRV_REQ_MAY_UNMAP); + } else { + ret =3D blk_pwrite(blk, cur_addr, cur_buf, + cluster_size, 0); + } + if (ret < 0) { + break; + } + } g_free(buf); } =20 --=20 2.9.3 From nobody Thu May 2 21:24:10 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.zoho.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 1492768167769460.2101601799984; Fri, 21 Apr 2017 02:49:27 -0700 (PDT) Received: from localhost ([::1]:58261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1VBu-0003z7-9w for importer@patchew.org; Fri, 21 Apr 2017 05:49:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V6M-00085v-Pb for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V6L-0000Yv-KL for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V6L-0000Yk-Ea for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:41 -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 49BC68C54F; Fri, 21 Apr 2017 09:43:40 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD89F81C10; Fri, 21 Apr 2017 09:43:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49BC68C54F 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49BC68C54F From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:15 +0100 Message-Id: <20170421094316.19361-6-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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]); Fri, 21 Apr 2017 09:43:40 +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] [PULL for-2.9 5/6] MAINTAINERS: update Wen's email address 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: Peter Maydell , Changlong Xie , Stefan Hajnoczi 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" From: Changlong Xie So he can get CC'ed on future patches and bugs for this feature Signed-off-by: Changlong Xie Message-id: 1492484893-23435-1-git-send-email-xiecl.fnst@cn.fujitsu.com Signed-off-by: Stefan Hajnoczi --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c60235e..5638992 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1817,7 +1817,7 @@ S: Supported F: tests/image-fuzzer/ =20 Replication -M: Wen Congyang +M: Wen Congyang M: Changlong Xie S: Supported F: replication* --=20 2.9.3 From nobody Thu May 2 21:24:10 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.zoho.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 1492768237002311.6624665166304; Fri, 21 Apr 2017 02:50:37 -0700 (PDT) Received: from localhost ([::1]:58271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1VD1-0004h0-69 for importer@patchew.org; Fri, 21 Apr 2017 05:50:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1V6T-0008BC-OQ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1V6P-0000ZS-Kr for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51082) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1V6P-0000ZM-FH for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:43:45 -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 634FEC067C1E; Fri, 21 Apr 2017 09:43:44 +0000 (UTC) Received: from localhost (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id A04371840A; Fri, 21 Apr 2017 09:43:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 634FEC067C1E 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=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 634FEC067C1E From: Stefan Hajnoczi To: Date: Fri, 21 Apr 2017 10:43:16 +0100 Message-Id: <20170421094316.19361-7-stefanha@redhat.com> In-Reply-To: <20170421094316.19361-1-stefanha@redhat.com> References: <20170421094316.19361-1-stefanha@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.32]); Fri, 21 Apr 2017 09:43:44 +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] [PULL for-2.9 6/6] MAINTAINERS: update my email address 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: Peter Maydell , Xie Changlong , Stefan Hajnoczi , Zhang Chen 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" From: Zhang Chen I'm leaving my job at Fujitsu, this email address will stop working this week. Update it to one that I will have access to later. Signed-off-by: Xie Changlong Message-id: 1492758767-19716-1-git-send-email-xiecl.fnst@cn.fujitsu.com Signed-off-by: Stefan Hajnoczi --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 5638992..cae3b09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1818,7 +1818,7 @@ F: tests/image-fuzzer/ =20 Replication M: Wen Congyang -M: Changlong Xie +M: Xie Changlong S: Supported F: replication* F: block/replication.c --=20 2.9.3