qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v9 00/15] blockdev: BlockBackend and media
@ 2015-11-06 15:27 Max Reitz
  2015-11-06 15:27 ` [Qemu-devel] [PATCH v9 11/15] qmp: Introduce blockdev-change-medium Max Reitz
  0 siblings, 1 reply; 3+ messages in thread
From: Max Reitz @ 2015-11-06 15:27 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, qemu-devel, Max Reitz

Patch 11 of the last series broke the OS X build due to ui/cocoa.m
directly referencing qmp_change_blockdev() (which was an internal
function not directly mapped to any QMP command before, now it becomes
an "external" function and is renamed qmp_blockdev_change_medium()).
This v9 consists only of that patch, because the rest is completely
unchanged from v8.

Unfortunately, neither am I rich enough nor do I have the immediate
intention of buying Apple hardware any time soon anyway, so I have no
way of verifying that this changed version builds on OS X. I would
appreciate help with that.

Oh, and if anybody ever asks me again why it might be a bad idea to put
management code into the GUI layer of one specific operating system...


git-backport-diff against v8:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/15:[----] [--] 'block: Add blk_remove_bs()'
002/15:[----] [--] 'block: Make bdrv_states public'
003/15:[----] [--] 'block: Add functions for inheriting a BBRS'
004/15:[----] [--] 'blockdev: Add blockdev-open-tray'
005/15:[----] [--] 'blockdev: Add blockdev-close-tray'
006/15:[----] [--] 'blockdev: Add blockdev-remove-medium'
007/15:[----] [--] 'blockdev: Add blockdev-insert-medium'
008/15:[----] [--] 'blockdev: Implement eject with basic operations'
009/15:[----] [--] 'blockdev: Implement change with basic operations'
010/15:[----] [--] 'block: Inquire tray state before tray-moved events'
011/15:[0010] [FC] 'qmp: Introduce blockdev-change-medium'
012/15:[----] [--] 'hmp: Use blockdev-change-medium for change command'
013/15:[----] [--] 'blockdev: read-only-mode for blockdev-change-medium'
014/15:[----] [--] 'hmp: Add read-only-mode option to change command'
015/15:[----] [--] 'iotests: Add test for change-related QMP commands'


Max Reitz (15):
  block: Add blk_remove_bs()
  block: Make bdrv_states public
  block: Add functions for inheriting a BBRS
  blockdev: Add blockdev-open-tray
  blockdev: Add blockdev-close-tray
  blockdev: Add blockdev-remove-medium
  blockdev: Add blockdev-insert-medium
  blockdev: Implement eject with basic operations
  blockdev: Implement change with basic operations
  block: Inquire tray state before tray-moved events
  qmp: Introduce blockdev-change-medium
  hmp: Use blockdev-change-medium for change command
  blockdev: read-only-mode for blockdev-change-medium
  hmp: Add read-only-mode option to change command
  iotests: Add test for change-related QMP commands

 block.c                        |   3 +-
 block/block-backend.c          |  56 +++-
 blockdev.c                     | 286 ++++++++++++----
 hmp-commands.hx                |  20 +-
 hmp.c                          |  47 ++-
 include/block/block_int.h      |   2 +
 include/sysemu/block-backend.h |   3 +
 include/sysemu/blockdev.h      |   2 -
 qapi-schema.json               |   6 +-
 qapi/block-core.json           | 126 ++++++++
 qmp-commands.hx                | 218 +++++++++++++
 qmp.c                          |   3 +-
 tests/qemu-iotests/118         | 720 +++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/118.out     |   5 +
 tests/qemu-iotests/group       |   1 +
 ui/cocoa.m                     |  10 +-
 16 files changed, 1402 insertions(+), 106 deletions(-)
 create mode 100755 tests/qemu-iotests/118
 create mode 100644 tests/qemu-iotests/118.out

-- 
2.6.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH v9 11/15] qmp: Introduce blockdev-change-medium
  2015-11-06 15:27 [Qemu-devel] [PATCH v9 00/15] blockdev: BlockBackend and media Max Reitz
@ 2015-11-06 15:27 ` Max Reitz
  2015-11-10 12:48   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Max Reitz @ 2015-11-06 15:27 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, qemu-devel, Max Reitz

Introduce a new QMP command 'blockdev-change-medium' which is intended
to replace the 'change' command for block devices. The existing function
qmp_change_blockdev() is accordingly renamed to
qmp_blockdev_change_medium().

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 blockdev.c                |  7 ++++---
 include/sysemu/blockdev.h |  2 --
 qapi-schema.json          |  6 ++++--
 qapi/block-core.json      | 23 +++++++++++++++++++++++
 qmp-commands.hx           | 31 +++++++++++++++++++++++++++++++
 qmp.c                     |  2 +-
 ui/cocoa.m                | 10 ++++++----
 7 files changed, 69 insertions(+), 12 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index df93173..dec6169 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2133,8 +2133,9 @@ void qmp_blockdev_insert_medium(const char *device, const char *node_name,
     qmp_blockdev_insert_anon_medium(device, bs, errp);
 }
 
-void qmp_change_blockdev(const char *device, const char *filename,
-                         const char *format, Error **errp)
+void qmp_blockdev_change_medium(const char *device, const char *filename,
+                                bool has_format, const char *format,
+                                Error **errp)
 {
     BlockBackend *blk;
     BlockDriverState *medium_bs = NULL;
@@ -2155,7 +2156,7 @@ void qmp_change_blockdev(const char *device, const char *filename,
 
     bdrv_flags = blk_get_open_flags_from_root_state(blk);
 
-    if (format) {
+    if (has_format) {
         options = qdict_new();
         qdict_put(options, "driver", qstring_from_str(format));
     }
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index a00be94..b06a060 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -63,8 +63,6 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type);
 
 /* device-hotplug */
 
-void qmp_change_blockdev(const char *device, const char *filename,
-                         const char *format, Error **errp);
 void hmp_commit(Monitor *mon, const QDict *qdict);
 void hmp_drive_del(Monitor *mon, const QDict *qdict);
 #endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 702b7b5..058b8ec 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1842,8 +1842,10 @@
 #          device's password.  The behavior of reads and writes to the block
 #          device between when these calls are executed is undefined.
 #
-# Notes:  It is strongly recommended that this interface is not used especially
-#         for changing block devices.
+# Notes:  This interface is deprecated, and it is strongly recommended that you
+#         avoid using it.  For changing block devices, use
+#         blockdev-change-medium; for changing VNC parameters, use
+#         change-vnc-password.
 #
 # Since: 0.14.0
 ##
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 5c4fc72..e9fa649 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1959,6 +1959,29 @@
 
 
 ##
+# @blockdev-change-medium:
+#
+# Changes the medium inserted into a block device by ejecting the current medium
+# and loading a new image file which is inserted as the new medium (this command
+# combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium
+# and blockdev-close-tray).
+#
+# @device:          block device name
+#
+# @filename:        filename of the new image to be loaded
+#
+# @format:          #optional, format to open the new image with (defaults to
+#                   the probed format)
+#
+# Since: 2.5
+##
+{ 'command': 'blockdev-change-medium',
+  'data': { 'device': 'str',
+            'filename': 'str',
+            '*format': 'str' } }
+
+
+##
 # @BlockErrorAction
 #
 # An enumeration of action that has been taken when a DISK I/O occurs
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 1dfa809..d6e4d7e 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -4163,6 +4163,37 @@ Example:
 EQMP
 
     {
+        .name       = "blockdev-change-medium",
+        .args_type  = "device:B,filename:F,format:s?",
+        .mhandler.cmd_new = qmp_marshal_blockdev_change_medium,
+    },
+
+SQMP
+blockdev-change-medium
+----------------------
+
+Changes the medium inserted into a block device by ejecting the current medium
+and loading a new image file which is inserted as the new medium.
+
+Arguments:
+
+- "device": device name (json-string)
+- "filename": filename of the new image (json-string)
+- "format": format of the new image (json-string, optional)
+
+Examples:
+
+1. Change a removable medium
+
+-> { "execute": "blockdev-change-medium",
+             "arguments": { "device": "ide1-cd0",
+                            "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
+                            "format": "raw" } }
+<- { "return": {} }
+
+EQMP
+
+    {
         .name       = "query-memdev",
         .args_type  = "",
         .mhandler.cmd_new = qmp_marshal_query_memdev,
diff --git a/qmp.c b/qmp.c
index ff54e5a..4e44f98 100644
--- a/qmp.c
+++ b/qmp.c
@@ -414,7 +414,7 @@ void qmp_change(const char *device, const char *target,
     if (strcmp(device, "vnc") == 0) {
         qmp_change_vnc(target, has_arg, arg, errp);
     } else {
-        qmp_change_blockdev(device, target, arg, errp);
+        qmp_blockdev_change_medium(device, target, has_arg, arg, errp);
     }
 }
 
diff --git a/ui/cocoa.m b/ui/cocoa.m
index c0d6bb2..2d8e4e2 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1113,10 +1113,12 @@ QemuCocoaView *cocoaView;
         }
 
         Error *err = NULL;
-        qmp_change_blockdev([drive cStringUsingEncoding: NSASCIIStringEncoding],
-                            [file cStringUsingEncoding: NSASCIIStringEncoding],
-                            "raw",
-                            &err);
+        qmp_blockdev_change_medium([drive cStringUsingEncoding:
+                                          NSASCIIStringEncoding],
+                                   [file cStringUsingEncoding:
+                                         NSASCIIStringEncoding],
+                                   true, "raw",
+                                   &err);
         handleAnyDeviceErrors(err);
     }
 }
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v9 11/15] qmp: Introduce blockdev-change-medium
  2015-11-06 15:27 ` [Qemu-devel] [PATCH v9 11/15] qmp: Introduce blockdev-change-medium Max Reitz
@ 2015-11-10 12:48   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2015-11-10 12:48 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel, qemu-block

Am 06.11.2015 um 16:27 hat Max Reitz geschrieben:
> Introduce a new QMP command 'blockdev-change-medium' which is intended
> to replace the 'change' command for block devices. The existing function
> qmp_change_blockdev() is accordingly renamed to
> qmp_blockdev_change_medium().
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Thanks, updated the queued patch with this one.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-10 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-06 15:27 [Qemu-devel] [PATCH v9 00/15] blockdev: BlockBackend and media Max Reitz
2015-11-06 15:27 ` [Qemu-devel] [PATCH v9 11/15] qmp: Introduce blockdev-change-medium Max Reitz
2015-11-10 12:48   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).