[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 23/50] blockdev: Catch NULL BDS in block_set_
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 23/50] blockdev: Catch NULL BDS in block_set_io_throttle |
Date: |
Tue, 27 Jan 2015 14:45:56 -0500 |
Split bdrv_find() into blk_by_name() and blk_bs() to separate the
"no medium inserted" case from the "device not found" case.
Signed-off-by: Max Reitz <address@hidden>
---
blockdev.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 5f7eef5..9801a7e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1922,15 +1922,25 @@ void qmp_block_set_io_throttle(const char *device,
int64_t bps, int64_t bps_rd,
int64_t iops_size, Error **errp)
{
ThrottleConfig cfg;
+ BlockBackend *blk;
BlockDriverState *bs;
AioContext *aio_context;
- bs = bdrv_find(device);
- if (!bs) {
+ blk = blk_by_name(device);
+ if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
+ aio_context = blk_get_aio_context(blk);
+ aio_context_acquire(aio_context);
+
+ bs = blk_bs(blk);
+ if (!bs) {
+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ goto out;
+ }
+
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;
@@ -1964,12 +1974,9 @@ void qmp_block_set_io_throttle(const char *device,
int64_t bps, int64_t bps_rd,
}
if (!check_throttle_config(&cfg, errp)) {
- return;
+ goto out;
}
- aio_context = bdrv_get_aio_context(bs);
- aio_context_acquire(aio_context);
-
if (!bs->io_limits_enabled && throttle_enabled(&cfg)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !throttle_enabled(&cfg)) {
@@ -1980,6 +1987,7 @@ void qmp_block_set_io_throttle(const char *device,
int64_t bps, int64_t bps_rd,
bdrv_set_io_limits(bs, &cfg);
}
+out:
aio_context_release(aio_context);
}
--
2.1.0
- [Qemu-devel] [PATCH RESEND 21/50] blockdev: Check BB validity in internal snapshot TA, (continued)
- [Qemu-devel] [PATCH RESEND 21/50] blockdev: Check BB validity in internal snapshot TA, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 25/50] blockdev: Check BB validity in block-commit, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 26/50] blockdev: Check BB validity in drive-backup, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 27/50] blockdev: Check BB validity in blockdev-backup, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 29/50] blockdev: Check BB validity in find_block_job(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 23/50] blockdev: Catch NULL BDS in block_set_io_throttle,
Max Reitz <=
- [Qemu-devel] [PATCH RESEND 30/50] blockdev: Check BB validity in change-backing-file, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 28/50] blockdev: Check BB validity in drive-mirror, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 31/50] block: Add blk_insert_bs(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 32/50] blockdev: Check BB validity in eject and change, Max Reitz, 2015/01/27