]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: pass block pull backing file to monitor
authorEric Blake <eblake@redhat.com>
Sat, 18 Feb 2012 16:20:01 +0000 (09:20 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 29 Feb 2012 20:44:20 +0000 (13:44 -0700)
This actually wires up the new optional parameter to block_stream:
http://wiki.qemu.org/Features/LiveBlockMigration/ImageStreamingAPI

The error checking is still sparse, since libvirt must not use
qemu-img or header probing on a qcow2 file in use by qemu to
check if the backing file name is valid; so for now, libvirt is
relying on qemu to diagnose an incorrect backing name.  Fixing this
will require libvirt to track the entire backing file chain at the
time qemu is started and keeps it updated with snapshot and pull
operations.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Add
parameter, and update callers.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Update
signature.
* src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Likewise.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update caller.
* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Likewise.

src/qemu/qemu_driver.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index a3ba5337ac32755badfd7574e37fd28672e21caf..c6bdd299f74bd560211162fdc3f2333254b787ee 100644 (file)
@@ -11379,14 +11379,6 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
     if (!device) {
         goto cleanup;
     }
-    /* XXX - add a qemu capability check; if qemu 1.1 or newer, then
-     *  validate and convert non-NULL base into something that can
-     * be passed as optional base argument.  */
-    if (base)  {
-        qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                        _("partial block pull is not supported with this QEMU binary"));
-        goto cleanup;
-    }
 
     if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
@@ -11399,7 +11391,12 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
 
     qemuDomainObjEnterMonitorWithDriver(driver, vm);
     priv = vm->privateData;
-    ret = qemuMonitorBlockJob(priv->mon, device, bandwidth, info, mode);
+    /* XXX - add a qemu capability check, since only qemu 1.1 or newer
+     * supports the base argument.
+     * XXX - libvirt should really be tracking the backing file chain
+     * itself, and validating that base is on the chain, rather than
+     * relying on qemu to do this.  */
+    ret = qemuMonitorBlockJob(priv->mon, device, base, bandwidth, info, mode);
     qemuDomainObjExitMonitorWithDriver(driver, vm);
 
 endjob:
index 4896919064d2fb2f6b3fc7f079cf2d2f7e636d4e..1da73f69d167b01b24083a0b9eb47d352822ee31 100644 (file)
@@ -2712,17 +2712,18 @@ int qemuMonitorScreendump(qemuMonitorPtr mon,
 
 int qemuMonitorBlockJob(qemuMonitorPtr mon,
                         const char *device,
+                        const char *base,
                         unsigned long bandwidth,
                         virDomainBlockJobInfoPtr info,
                         int mode)
 {
     int ret = -1;
 
-    VIR_DEBUG("mon=%p, device=%s, bandwidth=%lu, info=%p, mode=%o",
-              mon, device, bandwidth, info, mode);
+    VIR_DEBUG("mon=%p, device=%s, base=%s, bandwidth=%lu, info=%p, mode=%o",
+              mon, device, NULLSTR(base), bandwidth, info, mode);
 
     if (mon->json)
-        ret = qemuMonitorJSONBlockJob(mon, device, bandwidth, info, mode);
+        ret = qemuMonitorJSONBlockJob(mon, device, base, bandwidth, info, mode);
     else
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
                         _("block jobs require JSON monitor"));
index 9c5a5d3c7d3e88abc092ae80c2d13e4db7f67ace..b1c956c26d4f6d9953c4eb2e255b7ac24b3bbf45 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor.h: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -519,9 +519,11 @@ typedef enum {
 
 int qemuMonitorBlockJob(qemuMonitorPtr mon,
                         const char *device,
+                        const char *back,
                         unsigned long bandwidth,
                         virDomainBlockJobInfoPtr info,
-                        int mode);
+                        int mode)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
 
 int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                             const char *protocol,
index e6e9a8547891563052cc7bb7b86d4ecb5194a863..c0f148bfff90e301c3ffbed4e0c4ea561d9e9701 100644 (file)
@@ -3229,17 +3229,25 @@ static int qemuMonitorJSONGetBlockJobInfo(virJSONValuePtr reply,
 }
 
 
-int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
-                             const char *device,
-                             unsigned long bandwidth,
-                             virDomainBlockJobInfoPtr info,
-                             int mode)
+int
+qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
+                        const char *device,
+                        const char *base,
+                        unsigned long bandwidth,
+                        virDomainBlockJobInfoPtr info,
+                        int mode)
 {
     int ret = -1;
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr reply = NULL;
     const char *cmd_name = NULL;
 
+    if (base && mode != BLOCK_JOB_PULL) {
+        qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("only block pull supports base: %s"), base);
+        return -1;
+    }
+
     if (mode == BLOCK_JOB_ABORT) {
         cmd_name = "block_job_cancel";
         cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device", device, NULL);
@@ -3254,8 +3262,12 @@ int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
                                          NULL);
     } else if (mode == BLOCK_JOB_PULL) {
         cmd_name = "block_stream";
-        cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
-                                         device, NULL);
+        if (base)
+            cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
+                                             device, "s:base", base, NULL);
+        else
+            cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
+                                             device, NULL);
     }
 
     if (!cmd)
index 9c423a0843c754aadfa728f96fce7e70ae9fb9c4..0932a2c0e69344b571deb7b53322d9893c26ce9d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_json.h: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2009, 2011 Red Hat, Inc.
+ * Copyright (C) 2006-2009, 2011-2012 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -246,6 +246,7 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
 
 int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
                             const char *device,
+                            const char *base,
                             unsigned long bandwidth,
                             virDomainBlockJobInfoPtr info,
                             int mode);