All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: "Ian Pratt" <ian.pratt@citrix.com>,
	ian.jackson@eu.citrix.com,
	"\"柳澤佳里(yanagisawa yoshisato)\""
	<yanagisawa.yoshisato@lab.ntt.co.jp>,
	"Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
	"Keir Fraser" <keir.fraser@eu.citrix.com>
Subject: Re: [RFC][PATCH 13/13] Kemari: use shared region with to flip logdirty_bitmap
Date: Tue, 24 Mar 2009 15:59:38 +0900	[thread overview]
Message-ID: <49C884DA.5030201@lab.ntt.co.jp> (raw)
In-Reply-To: <49B86400.8090601@lab.ntt.co.jp>

This is an updated version of the following patch.  It will receive a
notification of flip change through an event channel.

http://lists.xensource.com/archives/html/xen-devel/2009-03/msg00757.html

Signed-off-by: Yoshisato Yanagisawa <yanagisawa.yoshisato@lab.ntt.co.jp>
Signed-off-by: Yoshi Tamura <tamura.yoshiaki@lab.ntt.co.jp>
---
 xenstore.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/xenstore.c b/xenstore.c
index 928e950..caef5ef 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -33,6 +33,7 @@
 struct xs_handle *xsh = NULL;
 static char *media_filename[MAX_DRIVES+1];
 static QEMUTimer *insert_timer = NULL;
+static int xce = 0;

 #define UWAIT_MAX (30*1000000) /* thirty seconds */
 #define UWAIT     (100000)     /* 1/10th second  */
@@ -301,6 +302,42 @@ const char *xenstore_get_guest_uuid(void)
     return already_computed;
 }

+/* prototype of xenstore_process_logdirty_event */
+void xenstore_process_logdirty_event(void);
+
+static int get_kemari_port(void)
+{
+    static int kemari_port = -1;
+    if (kemari_port > 0)
+        return kemari_port;
+
+    kemari_port = xc_evtchn_bind_unbound_port(xce, DOMID_SELF);
+    return kemari_port;
+}
+
+static void kemari_handler(void *dummy)
+{
+    int port;
+
+    port = xc_evtchn_pending(xce);
+    if (port < 0) {
+        fprintf(logfile, "xc_evtchn_pending failed");
+        return;
+    }
+
+    if (port == get_kemari_port()) {
+        kemari_enabled = 1; /* QEMU will run in kemari mode */
+        xenstore_process_logdirty_event();
+    } else {
+        fprintf(logfile, "unexpected port %d fired", port);
+    }
+
+    if (xc_evtchn_unmask(xce, port) < 0) {
+        fprintf(logfile, "xc_evtchn_unmask failed");
+        return;
+    }
+}
+
 #define DIRECT_PCI_STR_LEN 512
 #define PT_PCI_MSITRANSLATE_DEFAULT 1
 char direct_pci_str[DIRECT_PCI_STR_LEN];
@@ -326,6 +363,12 @@ void xenstore_parse_domain_config(int hvm_domid)

     xenstore_get_guest_uuid();

+    xce = xc_evtchn_open();
+    if (xce < 0) {
+        fprintf(logfile, "Could not open event channel\n");
+        return;
+    }
+
     xsh = xs_daemon_open();
     if (xsh == NULL) {
         fprintf(logfile, "Could not contact xenstore for domain config\n");
@@ -363,6 +406,27 @@ void xenstore_parse_domain_config(int hvm_domid)
             break;
         }
     }
+
+    /* kemari */
+    {
+        int port;
+        char port_string[128];
+        port = get_kemari_port();
+        if (port < 0) {
+            fprintf(stderr, "failed to get kemari port\n");
+            goto out;
+        }
+        snprintf(port_string, sizeof(port_string), "%d", port);
+
+        if (pasprintf(&buf, "/local/domain/%u/kemari/event-channel",
+                hvm_domid) == -1)
+            goto out;
+
+        xs_write(xsh, XBT_NULL, buf, port_string, strlen(port_string));
+        qemu_set_fd_handler2(xc_evtchn_fd(xce),
+            NULL, kemari_handler, NULL, NULL);
+        fprintf(stderr, "Kemari port is enabled: %d\n", port);
+    }

     for (i = 0; i < num; i++) {
 	format = NULL; /* don't know what the format is yet */
@@ -639,6 +703,8 @@ void xenstore_process_logdirty_event(void)
     static char *active_path = NULL;
     static char *next_active_path = NULL;
     static char *seg = NULL;
+    static char *kemari_qemu_info = NULL;
+    static char *qemu_file = NULL;
     unsigned int len;
     int i;

@@ -705,6 +771,8 @@ void xenstore_process_logdirty_event(void)
             seg = NULL;
             return;
         }
+        kemari_qemu_info = seg + logdirty_bitmap_size * 2;
+        asprintf(&qemu_file, "/dev/shm/qemu-save.%d", domid); /* use tmpfs */
 #endif

         /* Remember the paths for the next-active and active entries */
@@ -722,6 +790,30 @@ void xenstore_process_logdirty_event(void)
         }
     }

+#ifndef CONFIG_STUBDOM
+    if (kemari_enabled) {
+        while (kemari_qemu_info[1])
+            xen_rmb();
+
+        /* Switch buffers */
+        i = kemari_qemu_info[0];
+        if (i != 0 && i != 1) {
+            fprintf(logfile, "Log-dirty: bad next-active entry: %d\n", i);
+            exit(1);
+        }
+        logdirty_bitmap = (unsigned long *)(seg + i * logdirty_bitmap_size);
+        kemari_qemu_info[1] = 1;
+        xen_wmb();
+
+        /* Save QEMU status */
+        while (kemari_qemu_info[2])
+            xen_rmb();
+        do_savevm(qemu_file);
+        kemari_qemu_info[2] = 1;
+        xen_wmb();
+        return;
+    }
+#endif /* !CONFIG_STUBDOM */
     fprintf(logfile, "Triggered log-dirty buffer switch\n");

     /* Read the required active buffer from the store */

  reply	other threads:[~2009-03-24  6:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12  1:14 [RFC][PATCH 00/13] Kemari: updated to the 3.4 unstable tree Yoshiaki Tamura
2009-03-12  1:15 ` [RFC][PATCH 01/13] Kemari: add ECS_TAP state to event channel Yoshiaki Tamura
2009-03-12  1:16 ` [RFC][PATCH 02/13] Kemari: core kemari code Yoshiaki Tamura
2009-03-12  1:16 ` [RFC][PATCH 03/13] Kemari: change parameter type of xc_{set, get}_hvm_param Yoshiaki Tamura
2009-03-12  1:17 ` [RFC][PATCH 04/13] Kemari: Kemari controller interface in libxc Yoshiaki Tamura
2009-03-12  1:17 ` [RFC][PATCH 05/13] Kemari: Kemari sender Yoshiaki Tamura
2009-03-24  6:59   ` Yoshiaki Tamura
2009-03-12  1:18 ` [RFC][PATCH 06/13] Kemari: Kemari receiver Yoshiaki Tamura
2009-03-12  1:19 ` [RFC][PATCH 07/13] Kemari: add Kemari support to python Yoshiaki Tamura
2009-03-12  1:19 ` [RFC][PATCH 08/13] Kemari: add dev state "Attached" " Yoshiaki Tamura
2009-03-12  1:20 ` [RFC][PATCH 09/13] Kemari: add XenbusStateAttached to xenbus Yoshiaki Tamura
2009-03-12  1:23 ` [RFC][PATCH 13/13] Kemari: use shared region with to flip logdirty_bitmap Yoshiaki Tamura
2009-03-24  6:59   ` Yoshiaki Tamura [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-03-06  5:47 [RFC][PATCH 00/13] Kemari: VM synchronization mechanism for fault tolerance Yoshiaki Tamura
2009-03-06  6:47 ` [RFC][PATCH 13/13] Kemari: use shared region with to flip logdirty_bitmap Yoshiaki Tamura

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=49C884DA.5030201@lab.ntt.co.jp \
    --to=tamura.yoshiaki@lab.ntt.co.jp \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ian.pratt@citrix.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=yanagisawa.yoshisato@lab.ntt.co.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.