xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen
       [not found] <alpine.DEB.2.10.1606131143110.2878@sstabellini-ThinkPad-X260>
@ 2016-06-13 10:57 ` Stefano Stabellini
  2016-06-13 10:57   ` [PULL 2/2] Introduce "xen-load-devices-state" Stefano Stabellini
  2016-06-13 11:48 ` [PULL 0/2] xen-20160613-tag Jan Beulich
  2016-06-13 12:04 ` Peter Maydell
  2 siblings, 1 reply; 6+ messages in thread
From: Stefano Stabellini @ 2016-06-13 10:57 UTC (permalink / raw)
  To: peter.maydell; +Cc: anthony.perard, sstabellini, qemu-devel, xen-devel

From: Anthony PERARD <anthony.perard@citrix.com>

Since f615f39 (exec: remove ram_addr argument from
qemu_ram_block_from_host), migration under Xen is likely to fail, with a
SEGV of QEMU. But the commit only reveal a bug with the calculation of
the offset value in qemu_ram_block_from_host().

This patch calculates the offset from the ram_addr as
qemu_ram_addr_from_host() will later calculate the ram_addr from the
offset.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index a9d465b..4f3818c 100644
--- a/exec.c
+++ b/exec.c
@@ -1935,7 +1935,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
         ram_addr = xen_ram_addr_from_mapcache(ptr);
         block = qemu_get_ram_block(ram_addr);
         if (block) {
-            *offset = (host - block->host);
+            *offset = ram_addr - block->offset;
         }
         rcu_read_unlock();
         return block;
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* [PULL 2/2] Introduce "xen-load-devices-state"
  2016-06-13 10:57 ` [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen Stefano Stabellini
@ 2016-06-13 10:57   ` Stefano Stabellini
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2016-06-13 10:57 UTC (permalink / raw)
  To: peter.maydell
  Cc: Changlong Xie, Wen Congyang, qemu-devel, xen-devel, sstabellini,
	anthony.perard

From: Wen Congyang <wency@cn.fujitsu.com>

Introduce a "xen-load-devices-state" QAPI command that can be used to
load the state of all devices, but not the RAM or the block devices of
the VM.

We only have hmp commands savevm/loadvm, and qmp commands
xen-save-devices-state.

We use this new command for COLO:
1. suspend both primary vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm

In such case, we need to update all devices' state in any time.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
 migration/savevm.c | 37 +++++++++++++++++++++++++++++++++++++
 qapi-schema.json   | 14 ++++++++++++++
 qmp-commands.hx    | 27 +++++++++++++++++++++++++++
 3 files changed, 78 insertions(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index 6c21231..ae2ef8b 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -31,6 +31,7 @@
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
+#include "hw/xen/xen.h"
 #include "net/net.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
@@ -1754,6 +1755,12 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
         return -EINVAL;
     }
 
+    /* Validate if it is a device's state */
+    if (xen_enabled() && se->is_ram) {
+        error_report("loadvm: %s RAM loading not allowed on Xen", idstr);
+        return -EINVAL;
+    }
+
     /* Add entry */
     le = g_malloc0(sizeof(*le));
 
@@ -2064,6 +2071,36 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     }
 }
 
+void qmp_xen_load_devices_state(const char *filename, Error **errp)
+{
+    QEMUFile *f;
+    QIOChannelFile *ioc;
+    int ret;
+
+    /* Guest must be paused before loading the device state; the RAM state
+     * will already have been loaded by xc
+     */
+    if (runstate_is_running()) {
+        error_setg(errp, "Cannot update device state while vm is running");
+        return;
+    }
+    vm_stop(RUN_STATE_RESTORE_VM);
+
+    ioc = qio_channel_file_new_path(filename, O_RDONLY | O_BINARY, 0, errp);
+    if (!ioc) {
+        return;
+    }
+    f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
+
+    migration_incoming_state_new(f);
+    ret = qemu_loadvm_state(f);
+    qemu_fclose(f);
+    if (ret < 0) {
+        error_setg(errp, QERR_IO_ERROR);
+    }
+    migration_incoming_state_destroy();
+}
+
 int load_vmstate(const char *name)
 {
     BlockDriverState *bs, *bs_vm_state;
diff --git a/qapi-schema.json b/qapi-schema.json
index 8483bdf..48c3a6f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4201,6 +4201,20 @@
   'data': [ 'none', 'record', 'play' ] }
 
 ##
+# @xen-load-devices-state:
+#
+# Load the state of all devices from file. The RAM and the block devices
+# of the VM are not loaded by this command.
+#
+# @filename: the file to load the state of the devices from as binary
+# data. See xen-save-devices-state.txt for a description of the binary
+# format.
+#
+# Since: 2.7
+##
+{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
+
+##
 # @GICCapability:
 #
 # The struct describes capability for a specific GIC (Generic
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 28801a2..780e7f2 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -587,6 +587,33 @@ Example:
 EQMP
 
     {
+        .name       = "xen-load-devices-state",
+        .args_type  = "filename:F",
+        .mhandler.cmd_new = qmp_marshal_xen_load_devices_state,
+    },
+
+SQMP
+xen-load-devices-state
+----------------------
+
+Load the state of all devices from file. The RAM and the block devices
+of the VM are not loaded by this command.
+
+Arguments:
+
+- "filename": the file to load the state of the devices from as binary
+data. See xen-save-devices-state.txt for a description of the binary
+format.
+
+Example:
+
+-> { "execute": "xen-load-devices-state",
+     "arguments": { "filename": "/tmp/resume" } }
+<- { "return": {} }
+
+EQMP
+
+    {
         .name       = "xen-set-global-dirty-log",
         .args_type  = "enable:b",
         .mhandler.cmd_new = qmp_marshal_xen_set_global_dirty_log,
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PULL 0/2] xen-20160613-tag
       [not found] <alpine.DEB.2.10.1606131143110.2878@sstabellini-ThinkPad-X260>
  2016-06-13 10:57 ` [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen Stefano Stabellini
@ 2016-06-13 11:48 ` Jan Beulich
  2016-06-13 13:42   ` Stefano Stabellini
  2016-06-13 12:04 ` Peter Maydell
  2 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2016-06-13 11:48 UTC (permalink / raw)
  To: sstabellini; +Cc: anthony.perard, peter.maydell, qemu-devel, xen-devel

>>> On 13.06.16 at 12:54, <sstabellini@kernel.org> wrote:
> The following changes since commit a93c1bdf0bd4689287094ddb2aae3dc907da3535:
> 
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20160610-1' into 
> staging (2016-06-10 15:47:17 +0100)
> 
> are available in the git repository at:
> 
> 
>   git://xenbits.xen.org/people/sstabellini/qemu-dm.git tags/xen-20160613-tag
> 
> for you to fetch changes up to 88c16567d2cd23da328787187910b013ee43ebca:
> 
>   Introduce "xen-load-devices-state" (2016-06-13 11:50:53 +0100)
> 
> ----------------------------------------------------------------
> Xen 2016/06/13
> 
> ----------------------------------------------------------------
> Anthony PERARD (1):
>       exec: Fix qemu_ram_block_from_host for Xen
> 
> Wen Congyang (1):
>       Introduce "xen-load-devices-state"

May I ask what the disposition of "xen/blkif: avoid double access to
any shared ring request fields" is? I don't think I've seen a pull req,
and it doesn't appear to be in master.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PULL 0/2] xen-20160613-tag
       [not found] <alpine.DEB.2.10.1606131143110.2878@sstabellini-ThinkPad-X260>
  2016-06-13 10:57 ` [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen Stefano Stabellini
  2016-06-13 11:48 ` [PULL 0/2] xen-20160613-tag Jan Beulich
@ 2016-06-13 12:04 ` Peter Maydell
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-06-13 12:04 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: Anthony PERARD, QEMU Developers, xen-devel

On 13 June 2016 at 11:54, Stefano Stabellini <sstabellini@kernel.org> wrote:
> The following changes since commit a93c1bdf0bd4689287094ddb2aae3dc907da3535:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20160610-1' into staging (2016-06-10 15:47:17 +0100)
>
> are available in the git repository at:
>
>
>   git://xenbits.xen.org/people/sstabellini/qemu-dm.git tags/xen-20160613-tag
>
> for you to fetch changes up to 88c16567d2cd23da328787187910b013ee43ebca:
>
>   Introduce "xen-load-devices-state" (2016-06-13 11:50:53 +0100)
>
> ----------------------------------------------------------------
> Xen 2016/06/13
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PULL 0/2] xen-20160613-tag
  2016-06-13 11:48 ` [PULL 0/2] xen-20160613-tag Jan Beulich
@ 2016-06-13 13:42   ` Stefano Stabellini
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2016-06-13 13:42 UTC (permalink / raw)
  To: Jan Beulich
  Cc: anthony.perard, peter.maydell, sstabellini, qemu-devel, xen-devel

On Mon, 13 Jun 2016, Jan Beulich wrote:
> May I ask what the disposition of "xen/blkif: avoid double access to
> any shared ring request fields" is? I don't think I've seen a pull req,
> and it doesn't appear to be in master.

I miscategorized it, sorry. It is going to be in the next pull request.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* [PULL 0/2] xen-20160613-tag
@ 2016-06-13 10:54 Stefano Stabellini
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2016-06-13 10:54 UTC (permalink / raw)
  To: peter.maydell; +Cc: anthony.perard, sstabellini, qemu-devel, xen-devel

The following changes since commit a93c1bdf0bd4689287094ddb2aae3dc907da3535:

  Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20160610-1' into staging (2016-06-10 15:47:17 +0100)

are available in the git repository at:


  git://xenbits.xen.org/people/sstabellini/qemu-dm.git tags/xen-20160613-tag

for you to fetch changes up to 88c16567d2cd23da328787187910b013ee43ebca:

  Introduce "xen-load-devices-state" (2016-06-13 11:50:53 +0100)

----------------------------------------------------------------
Xen 2016/06/13

----------------------------------------------------------------
Anthony PERARD (1):
      exec: Fix qemu_ram_block_from_host for Xen

Wen Congyang (1):
      Introduce "xen-load-devices-state"

 exec.c             |  2 +-
 migration/savevm.c | 37 +++++++++++++++++++++++++++++++++++++
 qapi-schema.json   | 14 ++++++++++++++
 qmp-commands.hx    | 27 +++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 1 deletion(-)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-06-13 13:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <alpine.DEB.2.10.1606131143110.2878@sstabellini-ThinkPad-X260>
2016-06-13 10:57 ` [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen Stefano Stabellini
2016-06-13 10:57   ` [PULL 2/2] Introduce "xen-load-devices-state" Stefano Stabellini
2016-06-13 11:48 ` [PULL 0/2] xen-20160613-tag Jan Beulich
2016-06-13 13:42   ` Stefano Stabellini
2016-06-13 12:04 ` Peter Maydell
2016-06-13 10:54 Stefano Stabellini

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).