void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
                               int64_t bps_wr,
                               int64_t iops,
                               int64_t iops_rd,
                               int64_t iops_wr,
                               bool has_bps_max,
                               int64_t bps_max,
                               bool has_bps_rd_max,
                               int64_t bps_rd_max,
                               bool has_bps_wr_max,
                               int64_t bps_wr_max,
                               bool has_iops_max,
                               int64_t iops_max,
                               bool has_iops_rd_max,
                               int64_t iops_rd_max,
                               bool has_iops_wr_max,
                               int64_t iops_wr_max,
                               bool has_iops_size,
                               int64_t iops_size, Error **errp)
{
    ThrottleConfig cfg;
    BlockDriverState *bs;
    AioContext *aio_context;
    bs = bdrv_find(device);
    if (!bs) {
        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
        return;
    }
    memset(&cfg, 0, sizeof(cfg));
    cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
    cfg.buckets[THROTTLE_BPS_READ].avg  = bps_rd;
    cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
    cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
    cfg.buckets[THROTTLE_OPS_READ].avg  = iops_rd;
    cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
    if (has_bps_max) {
        cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
    }
    if (has_bps_rd_max) {
        cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
    }
    if (has_bps_wr_max) {
        cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
    }
    if (has_iops_max) {
        cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
    }
    if (has_iops_rd_max) {
        cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
    }
    if (has_iops_wr_max) {
        cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
    }
    if (has_iops_size) {
        cfg.op_size = iops_size;
    }
    if (!check_throttle_config(&cfg, errp)) {
        return;
    }
    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)) {
        bdrv_io_limits_disable(bs);
    }
    if (bs->io_limits_enabled) {
        bdrv_set_io_limits(bs, &cfg);
    }
}
void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
                               int64_t bps_wr,
                               int64_t iops,
                               int64_t iops_rd,
                               int64_t iops_wr,
                               bool has_bps_max,
                               int64_t bps_max,
                               bool has_bps_rd_max,
                               int64_t bps_rd_max,
                               bool has_bps_wr_max,
                               int64_t bps_wr_max,
                               bool has_iops_max,
                               int64_t iops_max,
                               bool has_iops_rd_max,
                               int64_t iops_rd_max,
                               bool has_iops_wr_max,
                               int64_t iops_wr_max,
                               bool has_iops_size,
                               int64_t iops_size, Error **errp)
{
    ThrottleConfig cfg;
    BlockDriverState *bs;
    AioContext *aio_context;
    bs = bdrv_find(device);
    if (!bs) {
        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
        return;
    }
    memset(&cfg, 0, sizeof(cfg));
    cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
    cfg.buckets[THROTTLE_BPS_READ].avg  = bps_rd;
    cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
    cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
    cfg.buckets[THROTTLE_OPS_READ].avg  = iops_rd;
    cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
    if (has_bps_max) {
        cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
    }
    if (has_bps_rd_max) {
        cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
    }
    if (has_bps_wr_max) {
        cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
    }
    if (has_iops_max) {
        cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
    }
    if (has_iops_rd_max) {
        cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
    }
    if (has_iops_wr_max) {
        cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
    }
    if (has_iops_size) {
        cfg.op_size = iops_size;
    }
    if (!check_throttle_config(&cfg, errp)) {
        return;
    }
    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)) {
        bdrv_io_limits_disable(bs);
    }
    if (bs->io_limits_enabled) {
        bdrv_set_io_limits(bs, &cfg);
    }
}
void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,
                               int64_t VAR_3,
                               int64_t VAR_4,
                               int64_t VAR_5,
                               int64_t VAR_6,
                               bool VAR_7,
                               int64_t VAR_8,
                               bool VAR_9,
                               int64_t VAR_10,
                               bool VAR_11,
                               int64_t VAR_12,
                               bool VAR_13,
                               int64_t VAR_14,
                               bool VAR_15,
                               int64_t VAR_16,
                               bool VAR_17,
                               int64_t VAR_18,
                               bool VAR_19,
                               int64_t VAR_20, Error **VAR_21)
{
    ThrottleConfig cfg;
    BlockDriverState *bs;
    AioContext *aio_context;
    bs = bdrv_find(VAR_0);
    if (!bs) {
        error_set(VAR_21, QERR_DEVICE_NOT_FOUND, VAR_0);
        return;
    }
    memset(&cfg, 0, sizeof(cfg));
    cfg.buckets[THROTTLE_BPS_TOTAL].avg = VAR_1;
    cfg.buckets[THROTTLE_BPS_READ].avg  = VAR_2;
    cfg.buckets[THROTTLE_BPS_WRITE].avg = VAR_3;
    cfg.buckets[THROTTLE_OPS_TOTAL].avg = VAR_4;
    cfg.buckets[THROTTLE_OPS_READ].avg  = VAR_5;
    cfg.buckets[THROTTLE_OPS_WRITE].avg = VAR_6;
    if (VAR_7) {
        cfg.buckets[THROTTLE_BPS_TOTAL].max = VAR_8;
    }
    if (VAR_9) {
        cfg.buckets[THROTTLE_BPS_READ].max = VAR_10;
    }
    if (VAR_11) {
        cfg.buckets[THROTTLE_BPS_WRITE].max = VAR_12;
    }
    if (VAR_13) {
        cfg.buckets[THROTTLE_OPS_TOTAL].max = VAR_14;
    }
    if (VAR_15) {
        cfg.buckets[THROTTLE_OPS_READ].max = VAR_16;
    }
    if (VAR_17) {
        cfg.buckets[THROTTLE_OPS_WRITE].max = VAR_18;
    }
    if (VAR_19) {
        cfg.op_size = VAR_20;
    }
    if (!check_throttle_config(&cfg, VAR_21)) {
        return;
    }
    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)) {
        bdrv_io_limits_disable(bs);
    }
    if (bs->io_limits_enabled) {
        bdrv_set_io_limits(bs, &cfg);
    }
}
void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,
int64_t VAR_3,
int64_t VAR_4,
int64_t VAR_5,
int64_t VAR_6,
bool VAR_7,
int64_t VAR_8,
bool VAR_9,
int64_t VAR_10,
bool VAR_11,
int64_t VAR_12,
bool VAR_13,
int64_t VAR_14,
bool VAR_15,
int64_t VAR_16,
bool VAR_17,
int64_t VAR_18,
bool VAR_19,
int64_t VAR_20, Error **VAR_21)
{ ThrottleConfig cfg; BlockDriverState *bs; AioContext *aio_context; bs = bdrv_find(VAR_0); if (!bs) { error_set(VAR_21, QERR_DEVICE_NOT_FOUND, VAR_0); return; } memset(&cfg, 0, sizeof(cfg)); cfg.buckets[THROTTLE_BPS_TOTAL].avg = VAR_1; cfg.buckets[THROTTLE_BPS_READ].avg  = VAR_2; cfg.buckets[THROTTLE_BPS_WRITE].avg = VAR_3; cfg.buckets[THROTTLE_OPS_TOTAL].avg = VAR_4; cfg.buckets[THROTTLE_OPS_READ].avg  = VAR_5; cfg.buckets[THROTTLE_OPS_WRITE].avg = VAR_6; if (VAR_7) { cfg.buckets[THROTTLE_BPS_TOTAL].max = VAR_8; } if (VAR_9) { cfg.buckets[THROTTLE_BPS_READ].max = VAR_10; } if (VAR_11) { cfg.buckets[THROTTLE_BPS_WRITE].max = VAR_12; } if (VAR_13) { cfg.buckets[THROTTLE_OPS_TOTAL].max = VAR_14; } if (VAR_15) { cfg.buckets[THROTTLE_OPS_READ].max = VAR_16; } if (VAR_17) { cfg.buckets[THROTTLE_OPS_WRITE].max = VAR_18; } if (VAR_19) { cfg.op_size = VAR_20; } if (!check_throttle_config(&cfg, VAR_21)) { return; } 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)) { bdrv_io_limits_disable(bs); } if (bs->io_limits_enabled) { bdrv_set_io_limits(bs, &cfg); } }