aboutsummaryrefslogtreecommitdiff
path: root/block/qapi-sysemu.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/qapi-sysemu.c')
-rw-r--r--block/qapi-sysemu.c73
1 files changed, 25 insertions, 48 deletions
diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c
index 680c7ee342..0c7a1423de 100644
--- a/block/qapi-sysemu.c
+++ b/block/qapi-sysemu.c
@@ -116,8 +116,8 @@ static int do_open_tray(const char *blk_name, const char *qdev_id,
return 0;
}
-void qmp_blockdev_open_tray(bool has_device, const char *device,
- bool has_id, const char *id,
+void qmp_blockdev_open_tray(const char *device,
+ const char *id,
bool has_force, bool force,
Error **errp)
{
@@ -127,9 +127,7 @@ void qmp_blockdev_open_tray(bool has_device, const char *device,
if (!has_force) {
force = false;
}
- rc = do_open_tray(has_device ? device : NULL,
- has_id ? id : NULL,
- force, &local_err);
+ rc = do_open_tray(device, id, force, &local_err);
if (rc && rc != -ENOSYS && rc != -EINPROGRESS) {
error_propagate(errp, local_err);
return;
@@ -137,16 +135,13 @@ void qmp_blockdev_open_tray(bool has_device, const char *device,
error_free(local_err);
}
-void qmp_blockdev_close_tray(bool has_device, const char *device,
- bool has_id, const char *id,
+void qmp_blockdev_close_tray(const char *device,
+ const char *id,
Error **errp)
{
BlockBackend *blk;
Error *local_err = NULL;
- device = has_device ? device : NULL;
- id = has_id ? id : NULL;
-
blk = qmp_get_blk(device, id, errp);
if (!blk) {
return;
@@ -173,17 +168,14 @@ void qmp_blockdev_close_tray(bool has_device, const char *device,
}
}
-static void blockdev_remove_medium(bool has_device, const char *device,
- bool has_id, const char *id, Error **errp)
+static void blockdev_remove_medium(const char *device, const char *id,
+ Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
AioContext *aio_context;
bool has_attached_device;
- device = has_device ? device : NULL;
- id = has_id ? id : NULL;
-
blk = qmp_get_blk(device, id, errp);
if (!blk) {
return;
@@ -232,7 +224,7 @@ out:
void qmp_blockdev_remove_medium(const char *id, Error **errp)
{
- blockdev_remove_medium(false, NULL, true, id, errp);
+ blockdev_remove_medium(NULL, id, errp);
}
static void qmp_blockdev_insert_anon_medium(BlockBackend *blk,
@@ -280,16 +272,13 @@ static void qmp_blockdev_insert_anon_medium(BlockBackend *blk,
}
}
-static void blockdev_insert_medium(bool has_device, const char *device,
- bool has_id, const char *id,
+static void blockdev_insert_medium(const char *device, const char *id,
const char *node_name, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
- blk = qmp_get_blk(has_device ? device : NULL,
- has_id ? id : NULL,
- errp);
+ blk = qmp_get_blk(device, id, errp);
if (!blk) {
return;
}
@@ -311,13 +300,13 @@ static void blockdev_insert_medium(bool has_device, const char *device,
void qmp_blockdev_insert_medium(const char *id, const char *node_name,
Error **errp)
{
- blockdev_insert_medium(false, NULL, true, id, node_name, errp);
+ blockdev_insert_medium(NULL, id, node_name, errp);
}
-void qmp_blockdev_change_medium(bool has_device, const char *device,
- bool has_id, const char *id,
+void qmp_blockdev_change_medium(const char *device,
+ const char *id,
const char *filename,
- bool has_format, const char *format,
+ const char *format,
bool has_force, bool force,
bool has_read_only,
BlockdevChangeReadOnlyMode read_only,
@@ -331,9 +320,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
QDict *options = NULL;
Error *err = NULL;
- blk = qmp_get_blk(has_device ? device : NULL,
- has_id ? id : NULL,
- errp);
+ blk = qmp_get_blk(device, id, errp);
if (!blk) {
goto fail;
}
@@ -370,7 +357,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
detect_zeroes = blk_get_detect_zeroes_from_root_state(blk);
qdict_put_str(options, "detect-zeroes", detect_zeroes ? "on" : "off");
- if (has_format) {
+ if (format) {
qdict_put_str(options, "driver", format);
}
@@ -379,9 +366,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
goto fail;
}
- rc = do_open_tray(has_device ? device : NULL,
- has_id ? id : NULL,
- force, &err);
+ rc = do_open_tray(device, id, force, &err);
if (rc && rc != -ENOSYS) {
error_propagate(errp, err);
goto fail;
@@ -389,7 +374,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
error_free(err);
err = NULL;
- blockdev_remove_medium(has_device, device, has_id, id, &err);
+ blockdev_remove_medium(device, id, &err);
if (err) {
error_propagate(errp, err);
goto fail;
@@ -401,7 +386,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
goto fail;
}
- qmp_blockdev_close_tray(has_device, device, has_id, id, errp);
+ qmp_blockdev_close_tray(device, id, errp);
fail:
/* If the medium has been inserted, the device has its own reference, so
@@ -410,8 +395,7 @@ fail:
bdrv_unref(medium_bs);
}
-void qmp_eject(bool has_device, const char *device,
- bool has_id, const char *id,
+void qmp_eject(const char *device, const char *id,
bool has_force, bool force, Error **errp)
{
Error *local_err = NULL;
@@ -421,16 +405,14 @@ void qmp_eject(bool has_device, const char *device,
force = false;
}
- rc = do_open_tray(has_device ? device : NULL,
- has_id ? id : NULL,
- force, &local_err);
+ rc = do_open_tray(device, id, force, &local_err);
if (rc && rc != -ENOSYS) {
error_propagate(errp, local_err);
return;
}
error_free(local_err);
- blockdev_remove_medium(has_device, device, has_id, id, errp);
+ blockdev_remove_medium(device, id, errp);
}
/* throttling disk I/O limits */
@@ -441,9 +423,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
BlockBackend *blk;
AioContext *aio_context;
- blk = qmp_get_blk(arg->has_device ? arg->device : NULL,
- arg->has_id ? arg->id : NULL,
- errp);
+ blk = qmp_get_blk(arg->device, arg->id, errp);
if (!blk) {
return;
}
@@ -516,11 +496,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
/* Enable I/O limits if they're not enabled yet, otherwise
* just update the throttling group. */
if (!blk_get_public(blk)->throttle_group_member.throttle_state) {
- blk_io_limits_enable(blk,
- arg->has_group ? arg->group :
- arg->has_device ? arg->device :
- arg->id);
- } else if (arg->has_group) {
+ blk_io_limits_enable(blk, arg->group ?: arg->device ?: arg->id);
+ } else if (arg->group) {
blk_io_limits_update_group(blk, arg->group);
}
/* Set the new throttling configuration */