[libvirt] [PATCHv2 08/15] blockjob: expose qemu commands for mirrored storage migration

Eric Blake eblake at redhat.com
Fri Apr 6 15:58:40 UTC 2012


On 04/05/2012 10:36 PM, Eric Blake wrote:
> The new block copy storage migration sequence requires both the
> 'drive-mirror' action in 'transaction' (present if the 'drive-mirror'
> standalone monitor command also exists) and the 'drive-reopen' monitor
> command (it would be nice if that were also part of a 'transaction',
> but the initial qemu implementation has it standalone only).
> 
> As of this[1] qemu email, both commands have been proposed but not yet
> incorporated into the tree, so there is a risk that qemu 1.1 will
> not have these commands, or will have something subtly different.
> [1]https://lists.gnu.org/archive/html/qemu-devel/2012-03/msg01524.html
> 

Another tweak that I will need for implementing REUSE_EXT - for an
existing file, it should be okay to let qemu probe the existing file for
its type, rather than requiring libvirt to probe the type and always
pass a string to qemu.  I specifically added the COPY_RAW flag as a way
to force libvirt to pass "raw" and prevent a format probe.  Also, when
there is no existing destination, the assumption is that the destination
should be the same format as the source, but we may have let qemu probe
the source file, in which case we have no format string to pass along.
Normally, probing is suspicious - any raw file can pretend to be any
other file type, but since there is a mechanism to specifically
recognize raw files, I think probing is okay in other situations.

So I'm squashing this in:

diff --git i/src/qemu/qemu_monitor.h w/src/qemu/qemu_monitor.h
index 0aa74be..a432b6f 100644
--- i/src/qemu/qemu_monitor.h
+++ w/src/qemu/qemu_monitor.h
@@ -523,16 +523,14 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                            const char *file,
                            const char *format,
                            int mode)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
-    ATTRIBUTE_NONNULL(5);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr actions)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 int qemuMonitorDriveReopen(qemuMonitorPtr mon,
                            const char *device,
                            const char *file,
                            const char *format)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-    ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

 int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                 const char *cmd,
diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
index d61c91b..bb080e5 100644
--- i/src/qemu/qemu_monitor_json.c
+++ w/src/qemu/qemu_monitor_json.c
@@ -3206,9 +3206,9 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon
ATTRIBUTE_UNUSED,
                                         "drive-mirror",
                                         "s:device", device,
                                         "s:target", file,
-                                        "s:format", format,
                                         "s:mode",

qemuMonitorDriveMirrorTypeToString(mode),
+                                        format ? "s:format" : NULL, format,
                                         NULL);
     if (!cmd)
         return -1;
@@ -3271,7 +3271,7 @@ qemuMonitorJSONDriveReopen(qemuMonitorPtr mon,
const char *device,
     cmd = qemuMonitorJSONMakeCommand("drive-reopen",
                                      "s:device", device,
                                      "s:new-image-file", file,
-                                     "s:format", format,
+                                     format ? "s:format" : NULL, format,
                                      NULL);
     if (!cmd)
         return -1;
diff --git i/src/qemu/qemu_monitor_json.h w/src/qemu/qemu_monitor_json.h
index ffd8e64..136c0f3 100644
--- i/src/qemu/qemu_monitor_json.h
+++ w/src/qemu/qemu_monitor_json.h
@@ -239,16 +239,14 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
                                const char *file,
                                const char *format,
                                int mode)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
-    ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 int qemuMonitorJSONDriveReopen(qemuMonitorPtr mon,
                                const char *device,
                                const char *file,
                                const char *format)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-    ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

 int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
                                     const char *cmd_str,


-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120406/fbb73e0a/attachment-0001.sig>


More information about the libvir-list mailing list