From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZxRV-00019j-7k for qemu-devel@nongnu.org; Mon, 23 Mar 2015 04:10:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZxRR-0002Sr-6m for qemu-devel@nongnu.org; Mon, 23 Mar 2015 04:10:37 -0400 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:36206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZxRQ-0002Sk-Qv for qemu-devel@nongnu.org; Mon, 23 Mar 2015 04:10:33 -0400 Received: by wgra20 with SMTP id a20so139265142wgr.3 for ; Mon, 23 Mar 2015 01:10:31 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <550FCA73.7080901@redhat.com> Date: Mon, 23 Mar 2015 09:10:27 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1427088255-29885-1-git-send-email-famz@redhat.com> In-Reply-To: <1427088255-29885-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] block: Switch to host monotonic clock for IO throttling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , berto@igalia.com, Stefan Hajnoczi On 23/03/2015 06:24, Fam Zheng wrote: > Currently, throttle timers won't make any progress when VCPU is not > running, which would stall the request queue in utils, qtest, vm > suspending, and live migration without special handling. > > For example in bdrv_drain_all, all requests are resumed immediately > without taking throttling limit into account. This means whenever it is > called, IO throttling goes ineffective (examples: system reset, > migration and many block job operations.). > > This might be some loophole that guest could exploit. > > If we use the host clock, we can later just trust the nested poll when > waiting for requests. > > Note that for qemu-iotests case 093, which sets up qtest when running > QEMU, we still use vm clock so the script can control the clock stepping > in order to be deterministic. > > Signed-off-by: Fam Zheng Reviewed-by: Paolo Bonzini > --- > v2: Don't break qemu-iotests 093. > --- > block.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/block.c b/block.c > index 0fe97de..89a1d5b 100644 > --- a/block.c > +++ b/block.c > @@ -30,6 +30,7 @@ > #include "qapi/qmp/qjson.h" > #include "sysemu/block-backend.h" > #include "sysemu/sysemu.h" > +#include "sysemu/qtest.h" > #include "qemu/notify.h" > #include "block/coroutine.h" > #include "block/qapi.h" > @@ -181,10 +182,16 @@ static void bdrv_throttle_write_timer_cb(void *opaque) > /* should be called before bdrv_set_io_limits if a limit is set */ > void bdrv_io_limits_enable(BlockDriverState *bs) > { > + int clock_type = QEMU_CLOCK_REALTIME; > + > + if (qtest_enabled()) { > + /* For testing block IO throttling only */ > + clock_type = QEMU_CLOCK_VIRTUAL; > + } > assert(!bs->io_limits_enabled); > throttle_init(&bs->throttle_state, > bdrv_get_aio_context(bs), > - QEMU_CLOCK_VIRTUAL, > + clock_type, > bdrv_throttle_read_timer_cb, > bdrv_throttle_write_timer_cb, > bs); >