@@ -326,6 +326,11 @@
# @read-only-mode: change the read-only mode of the device; defaults
# to 'retain'
#
+# @force: if false (the default), an eject request through blockdev-open-tray
+# will be sent to the guest if it has locked the tray (and the tray
+# will not be opened immediately); if true, the tray will be opened
+# regardless of whether it is locked. (since 7.1)
+#
# Features:
# @deprecated: Member @device is deprecated. Use @id instead.
#
@@ -367,6 +372,7 @@
'*id': 'str',
'filename': 'str',
'*format': 'str',
+ '*force': 'bool',
'*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
@@ -318,6 +318,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
bool has_id, const char *id,
const char *filename,
bool has_format, const char *format,
+ bool has_force, bool force,
bool has_read_only,
BlockdevChangeReadOnlyMode read_only,
Error **errp)
@@ -380,7 +381,7 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
rc = do_open_tray(has_device ? device : NULL,
has_id ? id : NULL,
- false, &err);
+ force, &err);
if (rc && rc != -ENOSYS) {
error_propagate(errp, err);
goto fail;
@@ -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);
}
@@ -202,9 +202,9 @@ ERST
{
.name = "change",
- .args_type = "device:B,target:F,arg:s?,read-only-mode:s?",
- .params = "device filename [format [read-only-mode]]",
- .help = "change a removable medium, optional format",
+ .args_type = "device:B,force:-f,target:F,arg:s?,read-only-mode:s?",
+ .params = "device [-f] filename [format [read-only-mode]]",
+ .help = "change a removable medium, optional format, use -f to force the operation",
.cmd = hmp_change,
},
@@ -212,11 +212,14 @@ SRST
``change`` *device* *setting*
Change the configuration of a device.
- ``change`` *diskdevice* *filename* [*format* [*read-only-mode*]]
+ ``change`` *diskdevice* [-f] *filename* [*format* [*read-only-mode*]]
Change the medium for a removable disk device to point to *filename*. eg::
(qemu) change ide1-cd0 /path/to/some.iso
+ ``-f``
+ forces the operation even if the guest has locked the tray.
+
*format* is optional.
*read-only-mode* may be used to change the read-only status of the device.
@@ -1531,6 +1531,7 @@ - (void)changeDeviceMedia:(id)sender
[file cStringUsingEncoding:
NSASCIIStringEncoding],
true, "raw",
+ true, false,
false, 0,
&err);
});