From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8WFy-0006Tn-5u for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:36:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8WFm-0003Zb-K0 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:36:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8WFm-0003Yz-5h for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:36:34 -0500 Date: Wed, 29 Jan 2014 15:36:30 +0100 From: Stefan Hajnoczi Message-ID: <20140129143630.GG23531@stefanha-thinkpad.muc.redhat.com> References: <1390984843-2101-1-git-send-email-famz@redhat.com> <1390984843-2101-5-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1390984843-2101-5-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: Add 080 for IO throttling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org On Wed, Jan 29, 2014 at 04:40:43PM +0800, Fam Zheng wrote: > This case utilizes qemu-io command "aio_{read,write} -a -q" to verify > the effectiveness of IO throttling options. > > The "-a" option will cause qemu-io requests to be accounted. > > It's implemented by driving the vm timer from qtest protocol, so the > throttling timers are signaled with determinied time duration. Then we s/determinied/determined/ > +class ThrottleTestCase(iotests.QMPTestCase): > + image_len = 80 * 1024 * 1024 # MB > + > + def blockstats(self, device): > + result = self.vm.qmp("query-blockstats") > + for r in result['return']: > + if r['device'] == device: > + stat = r['stats'] > + return stat['rd_bytes'], stat['rd_operations'], stat['wr_bytes'], stat['wr_operations'] > + raise Exception("Device not found for blockstats: %s" % device) > + > + def setUp(self): > + qemu_img('create', '-f', iotests.imgfmt, test_img, "1G") > + #self.vm = iotests.VM().add_drive(test_img, "bps=1024,bps_max=1") Commented out line? > + self.vm = iotests.VM().add_drive(test_img) > + self.vm.launch() > + > + def tearDown(self): > + self.vm.shutdown() > + os.remove(test_img) > + > + def do_test_throttle(self, seconds=10, **limits): > + def check_limit(limit, num): > + # IO throttling algorithm is discrete, allow 10% error so the test > + # is more deterministic > + return limit == 0 or num < seconds * limit * 1.1 > + > + nsec_per_sec = 1000000000 > + > + limits['bps_max'] = 1 > + limits['iops_max'] = 1 I *think* this trick is to force throttling not to allow bursts? Maybe a comment would be good to clarify. IIRC when max is 0, burst behavior is different. > + ns += seconds * nsec_per_sec > + self.vm.qtest_cmd("clock_step %d" % ns) > + # wait for a while to let requests take off > + time.sleep(1) sleep() is evil but I'm not sure there is a better way either... :(