From 80dd5aff1b3273e0ee5bec379df62647c0b39c1c Mon Sep 17 00:00:00 2001 From: Denis V. Lunev Date: Wed, 13 Apr 2022 01:18:46 +0300 Subject: block: add 'force' parameter to 'blockdev-change-medium' command 'blockdev-change-medium' is a convinient wrapper for the following sequence of commands: * blockdev-open-tray * blockdev-remove-medium * blockdev-insert-medium * blockdev-close-tray and should be used f.e. to change ISO image inside the CD-ROM tray. Though the guest could lock the tray and some linux guests like CentOS 8.5 actually does that. In this case the execution if this command results in the error like the following: Device 'scsi0-0-1-0' is locked and force was not specified, wait for tray to open and try again. This situation is could be resolved 'blockdev-open-tray' by passing flag 'force' inside. Thus is seems reasonable to add the same capability for 'blockdev-change-medium' too. Signed-off-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy Acked-by: "Dr. David Alan Gilbert" CC: Kevin Wolf CC: Hanna Reitz CC: Eric Blake CC: Markus Armbruster Message-Id: <20220412221846.280723-1-den@openvz.org> Reviewed-by: Daniel P. Berrangé Signed-off-by: Hanna Reitz --- monitor/hmp-cmds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'monitor') diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 634968498b..d8b98bed6c 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1472,6 +1472,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) const char *target = qdict_get_str(qdict, "target"); const char *arg = qdict_get_try_str(qdict, "arg"); const char *read_only = qdict_get_try_str(qdict, "read-only-mode"); + bool force = qdict_get_try_bool(qdict, "force", false); BlockdevChangeReadOnlyMode read_only_mode = 0; Error *err = NULL; @@ -1508,7 +1509,8 @@ void hmp_change(Monitor *mon, const QDict *qdict) } qmp_blockdev_change_medium(true, device, false, NULL, target, - !!arg, arg, !!read_only, read_only_mode, + !!arg, arg, true, force, + !!read_only, read_only_mode, &err); } -- cgit v1.2.3-55-g7522