Patchwork [1/4] QMP, Introduce set-global-dirty-log command.

login
register
mail settings
Submitter Anthony PERARD
Date July 17, 2012, 1:30 p.m.
Message ID <1342531805-29894-2-git-send-email-anthony.perard@citrix.com>
Download mbox | patch
Permalink /patch/171429/
State New
Headers show

Comments

Anthony PERARD - July 17, 2012, 1:30 p.m.
This command is used during a migration of a guest under Xen. It calls
memory_global_dirty_log_start or memory_global_dirty_log_stop according to the
argument pass to the command.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 qapi-schema.json |   13 +++++++++++++
 qmp-commands.hx  |   24 ++++++++++++++++++++++++
 xen-all.c        |   15 +++++++++++++++
 xen-stub.c       |    5 +++++
 4 files changed, 57 insertions(+), 0 deletions(-)
Eric Blake - July 17, 2012, 1:57 p.m.
On 07/17/2012 07:30 AM, Anthony PERARD wrote:

In the subject, s/set-global/xen-&/, so that searching git log for the
full monitor command name will hit this commit.

> This command is used during a migration of a guest under Xen. It calls
> memory_global_dirty_log_start or memory_global_dirty_log_stop according to the
> argument pass to the command.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
>  qapi-schema.json |   13 +++++++++++++
>  qmp-commands.hx  |   24 ++++++++++++++++++++++++
>  xen-all.c        |   15 +++++++++++++++
>  xen-stub.c       |    5 +++++
>  4 files changed, 57 insertions(+), 0 deletions(-)
>
Avi Kivity - July 17, 2012, 1:58 p.m.
On 07/17/2012 04:30 PM, Anthony PERARD wrote:
> This command is used during a migration of a guest under Xen. It calls
> memory_global_dirty_log_start or memory_global_dirty_log_stop according to the
> argument pass to the command.

Is the command truly needed?  Can't it come from the xen library you
link to?
Stefano Stabellini - July 17, 2012, 5:58 p.m.
On Tue, 17 Jul 2012, Avi Kivity wrote:
> On 07/17/2012 04:30 PM, Anthony PERARD wrote:
> > This command is used during a migration of a guest under Xen. It calls
> > memory_global_dirty_log_start or memory_global_dirty_log_stop according to the
> > argument pass to the command.
> 
> Is the command truly needed?  Can't it come from the xen library you
> link to?

I thought that a while ago we decided to use QMP rather than xenstore to
issue Xen commands to QEMU.
The only xenstore stuff left are the PV protocols and few parameters.

Of course we could use xenstore to issue commands again, but it goes
against the last year and an half of development :-)
Avi Kivity - July 18, 2012, 8:30 a.m.
On 07/17/2012 08:58 PM, Stefano Stabellini wrote:
> On Tue, 17 Jul 2012, Avi Kivity wrote:
>> On 07/17/2012 04:30 PM, Anthony PERARD wrote:
>> > This command is used during a migration of a guest under Xen. It calls
>> > memory_global_dirty_log_start or memory_global_dirty_log_stop according to the
>> > argument pass to the command.
>> 
>> Is the command truly needed?  Can't it come from the xen library you
>> link to?
> 
> I thought that a while ago we decided to use QMP rather than xenstore to
> issue Xen commands to QEMU.
> The only xenstore stuff left are the PV protocols and few parameters.
> 
> Of course we could use xenstore to issue commands again, but it goes
> against the last year and an half of development :-)

This particular command is weird.  You enable dirty logging via an
external interface, but all output goes through the internal interface.
 It doesn't make much sense.

But let's not reopen the issue, if it was decided to go with qmp command
for those things then so be it.

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index 1ab5dbd..e8d17b5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1765,6 +1765,19 @@ 
 { 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} }
 
 ##
+# @xen-set-global-dirty-log
+#
+# Enable or disable the global dirty log mode.
+#
+# @enable: true to enable, false to disable.
+#
+# Returns: nothing
+#
+# Since: 1.2
+##
+{ 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
+
+##
 # @device_del:
 #
 # Remove a device from a guest
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 2e1a38e..c92decd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -468,6 +468,30 @@  Example:
 EQMP
 
     {
+        .name       = "xen-set-global-dirty-log",
+        .args_type  = "enable:b",
+        .mhandler.cmd_new = qmp_marshal_input_xen_set_global_dirty_log,
+    },
+
+SQMP
+xen-set-global-dirty-log
+-------
+
+Enable or disable the global dirty log mode.
+
+Arguments:
+
+- "enable": Enable it or disable it.
+
+Example:
+
+-> { "execute": "xen-set-global-dirty-log",
+     "arguments": { "enable": true } }
+<- { "return": {} }
+
+EQMP
+
+    {
         .name       = "migrate",
         .args_type  = "detach:-d,blk:-b,inc:-i,uri:s",
         .mhandler.cmd_new = qmp_marshal_input_migrate,
diff --git a/xen-all.c b/xen-all.c
index 59f2323..8995d43 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -14,6 +14,7 @@ 
 #include "hw/pc.h"
 #include "hw/xen_common.h"
 #include "hw/xen_backend.h"
+#include "qmp-commands.h"
 
 #include "range.h"
 #include "xen-mapcache.h"
@@ -36,6 +37,7 @@ 
 
 static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi;
 static MemoryRegion *framebuffer;
+static bool xen_in_migration;
 
 /* Compatibility with older version */
 #if __XEN_LATEST_INTERFACE_VERSION__ < 0x0003020a
@@ -552,10 +554,14 @@  static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section)
 
 static void xen_log_global_start(MemoryListener *listener)
 {
+    if (xen_enabled()) {
+        xen_in_migration = true;
+    }
 }
 
 static void xen_log_global_stop(MemoryListener *listener)
 {
+    xen_in_migration = false;
 }
 
 static void xen_eventfd_add(MemoryListener *listener,
@@ -586,6 +592,15 @@  static MemoryListener xen_memory_listener = {
     .priority = 10,
 };
 
+void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
+{
+    if (enable) {
+        memory_global_dirty_log_start();
+    } else {
+        memory_global_dirty_log_stop();
+    }
+}
+
 /* VCPU Operations, MMIO, IO ring ... */
 
 static void xen_reset_vcpu(void *opaque)
diff --git a/xen-stub.c b/xen-stub.c
index 8ff2b79..5e66ba8 100644
--- a/xen-stub.c
+++ b/xen-stub.c
@@ -11,6 +11,7 @@ 
 #include "qemu-common.h"
 #include "hw/xen.h"
 #include "memory.h"
+#include "qmp-commands.h"
 
 void xenstore_store_pv_console_info(int i, CharDriverState *chr)
 {
@@ -54,3 +55,7 @@  int xen_init(void)
 void xen_register_framebuffer(MemoryRegion *mr)
 {
 }
+
+void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
+{
+}