qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: Add 080 for IO throttling


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: Add 080 for IO throttling
Date: Wed, 29 Jan 2014 15:36:30 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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... :(



reply via email to

[Prev in Thread] Current Thread [Next in Thread]