block.c (786a4ea82ec9c87e3a895cf41081029b285a5fe5) block.c (de50a20a4cc368d241d67c600f8c0f667186a8b5)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 16 unchanged lines hidden (view full) ---

25#include "qemu-common.h"
26#include "trace.h"
27#include "block/block_int.h"
28#include "block/blockjob.h"
29#include "qemu/module.h"
30#include "qapi/qmp/qjson.h"
31#include "sysemu/block-backend.h"
32#include "sysemu/sysemu.h"
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 16 unchanged lines hidden (view full) ---

25#include "qemu-common.h"
26#include "trace.h"
27#include "block/block_int.h"
28#include "block/blockjob.h"
29#include "qemu/module.h"
30#include "qapi/qmp/qjson.h"
31#include "sysemu/block-backend.h"
32#include "sysemu/sysemu.h"
33#include "sysemu/qtest.h"
33#include "qemu/notify.h"
34#include "block/coroutine.h"
35#include "block/qapi.h"
36#include "qmp-commands.h"
37#include "qemu/timer.h"
38#include "qapi-event.h"
39
40#ifdef CONFIG_BSD

--- 135 unchanged lines hidden (view full) ---

176{
177 BlockDriverState *bs = opaque;
178 qemu_co_enter_next(&bs->throttled_reqs[1]);
179}
180
181/* should be called before bdrv_set_io_limits if a limit is set */
182void bdrv_io_limits_enable(BlockDriverState *bs)
183{
34#include "qemu/notify.h"
35#include "block/coroutine.h"
36#include "block/qapi.h"
37#include "qmp-commands.h"
38#include "qemu/timer.h"
39#include "qapi-event.h"
40
41#ifdef CONFIG_BSD

--- 135 unchanged lines hidden (view full) ---

177{
178 BlockDriverState *bs = opaque;
179 qemu_co_enter_next(&bs->throttled_reqs[1]);
180}
181
182/* should be called before bdrv_set_io_limits if a limit is set */
183void bdrv_io_limits_enable(BlockDriverState *bs)
184{
185 int clock_type = QEMU_CLOCK_REALTIME;
186
187 if (qtest_enabled()) {
188 /* For testing block IO throttling only */
189 clock_type = QEMU_CLOCK_VIRTUAL;
190 }
184 assert(!bs->io_limits_enabled);
185 throttle_init(&bs->throttle_state,
186 bdrv_get_aio_context(bs),
191 assert(!bs->io_limits_enabled);
192 throttle_init(&bs->throttle_state,
193 bdrv_get_aio_context(bs),
187 QEMU_CLOCK_VIRTUAL,
194 clock_type,
188 bdrv_throttle_read_timer_cb,
189 bdrv_throttle_write_timer_cb,
190 bs);
191 bs->io_limits_enabled = true;
192}
193
194/* This function makes an IO wait if needed
195 *

--- 6036 unchanged lines hidden ---
195 bdrv_throttle_read_timer_cb,
196 bdrv_throttle_write_timer_cb,
197 bs);
198 bs->io_limits_enabled = true;
199}
200
201/* This function makes an IO wait if needed
202 *

--- 6036 unchanged lines hidden ---