xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: xen devel <xen-devel@lists.xen.org>
Cc: Ian Campbell <Ian.Campbell@citrix.com>,
	Wen Congyang <wency@cn.fujitsu.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Jiang Yunhong <yunhong.jiang@intel.com>,
	Dong Eddie <eddie.dong@intel.com>,
	Yang Hongyang <yanghy@cn.fujitsu.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [RFC Patch 04/25] don't touch remus in remus_device
Date: Fri, 18 Jul 2014 19:38:49 +0800	[thread overview]
Message-ID: <1405683551-12579-5-git-send-email-wency@cn.fujitsu.com> (raw)
In-Reply-To: <1405683551-12579-1-git-send-email-wency@cn.fujitsu.com>

remus device is an abstract layer to do checkpoint.
COLO can also use it to do checkpoint. But there is
still some codes in remus device which touch remus:
1. netbufscript is for remus, move it to domain_suspend_state
2. diskbuf: not a suitable name for checkpoint. Use
   enabled_device_kinds to instead of it.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 tools/libxl/libxl.c              |  9 ++++++---
 tools/libxl/libxl_internal.h     | 19 ++++++++++++-------
 tools/libxl/libxl_netbuffer.c    |  7 +++++--
 tools/libxl/libxl_remus_device.c |  4 ++--
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index cd038d1..94087ff 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -832,10 +832,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         }
 
         if (info->netbufscript) {
-            rds->netbufscript =
+            dss->netbufscript =
                 libxl__strdup(gc, info->netbufscript);
         } else {
-            rds->netbufscript =
+            dss->netbufscript =
                 GCSPRINTF("%s/remus-netbuf-setup",
                 libxl__xen_script_dir_path());
         }
@@ -844,9 +844,12 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     rds->ao = ao;
     rds->egc = egc;
     rds->domid = domid;
-    rds->diskbuf = info->diskbuf;
     rds->callback = libxl__remus_setup_done;
     rds->ops = remus_ops;
+    if (info->diskbuf)
+        rds->enabled_device_kinds |= LIBXL__REMUS_DEVICE_DISK;
+    if (info->netbuf)
+        rds->enabled_device_kinds |= LIBXL__REMUS_DEVICE_NIC;
 
     /* Point of no return */
     libxl__remus_devices_setup(egc, rds);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 441a51f..e327604 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -2505,8 +2505,8 @@ typedef struct libxl__save_helper_state {
  */
 
 typedef enum libxl__remus_device_kind {
-    LIBXL__REMUS_DEVICE_NIC,
-    LIBXL__REMUS_DEVICE_DISK,
+    LIBXL__REMUS_DEVICE_NIC = (1 << 0),
+    LIBXL__REMUS_DEVICE_DISK= (1 << 1),
 } libxl__remus_device_kind;
 
 typedef struct libxl__remus_device libxl__remus_device;
@@ -2581,8 +2581,7 @@ struct libxl__remus_device_state {
     libxl__remus_callback *callback;
     /* the last ops must be NULL */
     const libxl__remus_device_subkind_ops **ops;
-    const char *netbufscript;
-    bool diskbuf;
+    int enabled_device_kinds;
 
     /* private */
     /* devices that have been set up */
@@ -2692,9 +2691,15 @@ struct libxl__domain_suspend_state {
     libxl__ev_xswatch guest_watch;
     libxl__ev_time guest_timeout;
     const char *dm_savefile;
-    libxl__remus_device_state rds;
-    libxl__ev_time checkpoint_timeout; /* used for Remus checkpoint */
-    int interval; /* checkpoint interval (for Remus) */
+    /* for Remus */
+    struct {
+        libxl__remus_device_state rds;
+        const char *netbufscript;
+        /* used for Remus checkpoint */
+        libxl__ev_time checkpoint_timeout;
+        /* checkpoint interval */
+        int interval;
+    };
     libxl__save_helper_state shs;
     libxl__logdirty_switch logdirty;
     void (*callback_common_done)(libxl__egc*,
diff --git a/tools/libxl/libxl_netbuffer.c b/tools/libxl/libxl_netbuffer.c
index 39025f4..2387563 100644
--- a/tools/libxl/libxl_netbuffer.c
+++ b/tools/libxl/libxl_netbuffer.c
@@ -28,6 +28,7 @@
 struct libxl__remus_netbuf_state {
     libxl__ao *ao;
     uint32_t domid;
+    const char *netbufscript;
 
     struct nl_sock *nlsock;
     struct nl_cache *qdisc_cache;
@@ -51,6 +52,7 @@ static int nic_init(libxl__remus_device_state *rds)
 {
     int rc, ret;
     libxl__remus_netbuf_state *ns;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
 
     STATE_AO_GC(rds->ao);
 
@@ -83,6 +85,7 @@ static int nic_init(libxl__remus_device_state *rds)
 
     ns->ao = rds->ao;
     ns->domid = rds->domid;
+    ns->netbufscript = dss->netbufscript;
 
     rc = 0;
 
@@ -258,7 +261,7 @@ static void setup_async_exec(libxl__remus_device *dev, char *op)
 
     /* Convenience aliases */
     libxl__remus_netbuf_state *ns = CTX->rns;
-    char *const script = libxl__strdup(gc, dev->rds->netbufscript);
+    char *const script = libxl__strdup(gc, ns->netbufscript);
     const uint32_t domid = ns->domid;
     const int dev_id = remus_nic->devid;
     const char *const vif = remus_nic->vif;
@@ -381,7 +384,7 @@ static void netbuf_setup_script_cb(libxl__egc *egc,
 
     if (hotplug_error) {
         LOG(ERROR, "netbuf script %s setup failed for vif %s: %s",
-            dev->rds->netbufscript, vif, hotplug_error);
+            CTX->rns->netbufscript, vif, hotplug_error);
         rc = ERROR_FAIL;
         goto out;
     }
diff --git a/tools/libxl/libxl_remus_device.c b/tools/libxl/libxl_remus_device.c
index c9df7f0..2acf3bb 100644
--- a/tools/libxl/libxl_remus_device.c
+++ b/tools/libxl/libxl_remus_device.c
@@ -86,10 +86,10 @@ void libxl__remus_devices_setup(libxl__egc *egc, libxl__remus_device_state *rds)
     rds->num_nics = 0;
     rds->num_disks = 0;
 
-    if (rds->netbufscript)
+    if (rds->enabled_device_kinds & LIBXL__REMUS_DEVICE_NIC)
         rds->nics = libxl_device_nic_list(CTX, rds->domid, &rds->num_nics);
 
-    if (rds->diskbuf)
+    if (rds->enabled_device_kinds & LIBXL__REMUS_DEVICE_NIC)
         rds->disks = libxl_device_disk_list(CTX, rds->domid, &rds->num_disks);
 
     if (rds->num_nics == 0 && rds->num_disks == 0)
-- 
1.9.3

  parent reply	other threads:[~2014-07-18 11:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 11:38 [RFC Patch 00/25] COarse-grain LOck-stepping Virtual Machines for Non-stop Service Wen Congyang
2014-07-18 11:38 ` [RFC Patch 01/25] copy the correct page to memory Wen Congyang
2014-07-18 11:38 ` [RFC Patch 02/25] csum the correct page Wen Congyang
2014-07-18 11:38 ` [RFC Patch 03/25] don't zero out ioreq page Wen Congyang
2014-07-18 11:38 ` Wen Congyang [this message]
2014-07-18 11:38 ` [RFC Patch 05/25] rename remus device to checkpoint device Wen Congyang
2014-07-18 11:38 ` [RFC Patch 06/25] adjust the indentation Wen Congyang
2014-07-18 11:38 ` [RFC Patch 07/25] Refactor domain_suspend_callback_common() Wen Congyang
2014-07-18 11:38 ` [RFC Patch 08/25] Update libxl__domain_resume() for colo Wen Congyang
2014-07-18 11:38 ` [RFC Patch 09/25] Update libxl__domain_suspend_common_switch_qemu_logdirty() " Wen Congyang
2014-07-18 11:38 ` [RFC Patch 10/25] Introduce a new internal API libxl__domain_unpause() Wen Congyang
2014-07-18 11:38 ` [RFC Patch 11/25] Update libxl__domain_unpause() to support qemu-xen Wen Congyang
2014-07-18 11:38 ` [RFC Patch 12/25] support to resume uncooperative HVM guests Wen Congyang
2014-07-18 11:38 ` [RFC Patch 13/25] update datecopier to support sending data only Wen Congyang
2014-07-18 11:38 ` [RFC Patch 14/25] introduce a new API to aync read data from fd Wen Congyang
2014-07-18 11:39 ` [RFC Patch 15/25] Update libxl_save_msgs_gen.pl to support return data from xl to xc Wen Congyang
2014-07-18 11:39 ` [RFC Patch 16/25] Allow slave sends data to master Wen Congyang
2014-07-18 11:39 ` [RFC Patch 17/25] secondary vm suspend/resume/checkpoint code Wen Congyang
2014-07-18 11:39 ` [RFC Patch 18/25] primary vm suspend/get_dirty_pfn/resume/checkpoint code Wen Congyang
2014-07-18 11:39 ` [RFC Patch 19/25] xc_domain_save: flush cache before calling callbacks->postcopy() in colo mode Wen Congyang
2014-07-18 11:39 ` [RFC Patch 20/25] COLO: xc related codes Wen Congyang
2014-07-18 11:39 ` [RFC Patch 21/25] send store mfn and console mfn to xl before resuming secondary vm Wen Congyang
2014-07-18 11:39 ` [RFC Patch 22/25] implement the cmdline for COLO Wen Congyang
2014-07-18 11:39 ` [RFC Patch 23/25] HACK: do checkpoint per 20ms Wen Congyang
2014-07-18 11:39 ` [RFC Patch 24/25] fix vm entry fail Wen Congyang
2014-07-24 10:40   ` Tim Deegan
2014-07-25  5:39     ` Wen Congyang
2014-08-07  6:52     ` Wen Congyang
2014-07-18 11:39 ` [RFC Patch 25/25] sync mmu before resuming secondary vm Wen Congyang
2014-07-24 10:59   ` Tim Deegan
2014-07-25  5:46     ` Wen Congyang
2014-08-07  7:46     ` Wen Congyang
2014-07-18 11:39 ` [RFC Patch 26/25] Introduce "xen-load-devices-state" Wen Congyang
2014-07-18 11:43 ` [RFC Patch 00/25] COarse-grain LOck-stepping Virtual Machines for Non-stop Service Wen Congyang
2014-07-18 14:18 ` Andrew Cooper
2014-07-18 14:30   ` Wen Congyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405683551-12579-5-git-send-email-wency@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yanghy@cn.fujitsu.com \
    --cc=yunhong.jiang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).