]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Accept device model name for eject
authorKevin Wolf <kwolf@redhat.com>
Tue, 20 Sep 2016 11:38:46 +0000 (13:38 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 23 Sep 2016 11:40:45 +0000 (13:40 +0200)
In order to remove the need for BlockBackend names in the external API,
we want to allow qdev device names in all device related commands.

This converts eject to accept a qdev device name.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c
docs/qmp-commands.txt
hmp.c
qapi/block.json
ui/cocoa.m

index a007b22f804612fdb0e728271c8725e47afd5964..3d92724d0f50924b73e19a6b854af8196d170e09 100644 (file)
@@ -2265,7 +2265,9 @@ exit:
     block_job_txn_unref(block_job_txn);
 }
 
-void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
+void qmp_eject(bool has_device, const char *device,
+               bool has_id, const char *id,
+               bool has_force, bool force, Error **errp)
 {
     Error *local_err = NULL;
     int rc;
@@ -2274,14 +2276,16 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
         force = false;
     }
 
-    rc = do_open_tray(device, NULL, force, &local_err);
+    rc = do_open_tray(has_device ? device : NULL,
+                      has_id ? id : NULL,
+                      force, &local_err);
     if (rc && rc != -ENOSYS) {
         error_propagate(errp, local_err);
         return;
     }
     error_free(local_err);
 
-    qmp_x_blockdev_remove_medium(true, device, false, NULL, errp);
+    qmp_x_blockdev_remove_medium(has_device, device, has_id, id, errp);
 }
 
 void qmp_block_passwd(bool has_device, const char *device,
index e77bf2f1dd0f80d8f51fa1a5b6ea1b3ef40dd83b..9024ef282386495051218129088d4df37025384d 100644 (file)
@@ -72,12 +72,14 @@ Eject a removable medium.
 
 Arguments:
 
-- force: force ejection (json-bool, optional)
-- device: device name (json-string)
+- "force": force ejection (json-bool, optional)
+- "device": block device name (deprecated, use @id instead)
+            (json-string, optional)
+- "id": the name or QOM path of the guest device (json-string, optional)
 
 Example:
 
--> { "execute": "eject", "arguments": { "device": "ide1-cd0" } }
+-> { "execute": "eject", "arguments": { "id": "ide0-1-0" } }
 <- { "return": {} }
 
 Note: The "force" argument defaults to false.
diff --git a/hmp.c b/hmp.c
index 0a16aefc2ac12d06037953de4a2e61d46ca0f173..09827b3ec40e5d85f0f03a24bdf5a53419942f86 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -1376,7 +1376,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict)
     const char *device = qdict_get_str(qdict, "device");
     Error *err = NULL;
 
-    qmp_eject(device, true, force, &err);
+    qmp_eject(true, device, false, NULL, true, force, &err);
     hmp_handle_error(mon, &err);
 }
 
index 8b08bd2fd0bf213f0c40ed12ecca9cbd01b4f449..c896bd1d3bbbb2f29165d50cb8b9f87ffdea12fe 100644 (file)
 #
 # Ejects a device from a removable drive.
 #
-# @device:  The name of the device
+# @device:  #optional Block device name (deprecated, use @id instead)
+#
+# @id:      #optional The name or QOM path of the guest device (since: 2.8)
 #
 # @force:   @optional If true, eject regardless of whether the drive is locked.
 #           If not specified, the default value is false.
 #
 # Since: 0.14.0
 ##
-{ 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
+{ 'command': 'eject',
+  'data': { '*device': 'str',
+            '*id': 'str',
+            '*force': 'bool' } }
 
 ##
 # @nbd-server-start:
index 52d9c54b6de5c2e30cca48673287380b25de8bd9..a847737b686e363c731b6291a357acc02b17f6f5 100644 (file)
@@ -1085,7 +1085,8 @@ QemuCocoaView *cocoaView;
     }
 
     Error *err = NULL;
-    qmp_eject([drive cStringUsingEncoding: NSASCIIStringEncoding], false, false, &err);
+    qmp_eject(true, [drive cStringUsingEncoding: NSASCIIStringEncoding],
+              false, NULL, false, false, &err);
     handleAnyDeviceErrors(err);
 }