@@ -1526,6 +1526,13 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,
if (!bs) {
return -ENODEV;
}
+
+ if (bs->throttle_state) {
+ error_setg(errp, "Cannot reference an existing block device for "
+ "which I/O throttling is enabled");
+ return -EINVAL;
+ }
+
bdrv_ref(bs);
*pbs = bs;
return 0;
@@ -2661,6 +2661,13 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
goto out;
}
+ /* The BlockBackend must be the only parent */
+ assert(QLIST_FIRST(&bs->parents));
+ if (QLIST_NEXT(QLIST_FIRST(&bs->parents), next_parent)) {
+ error_setg(errp, "Cannot throttle device with multiple parents");
+ goto out;
+ }
+
throttle_config_init(&cfg);
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;