aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-04 12:12:28 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-04 12:12:28 +0100
commit335c738c440e8a283e10660d38bf82532b439cf8 (patch)
treefe8b39f6bacc47192af94962f9e3a7a2b5d1670b
parent1edbc90d9991dcf2196114bf1d7ac2a75b996f3a (diff)
downloadxen-335c738c440e8a283e10660d38bf82532b439cf8.tar.gz
xen-335c738c440e8a283e10660d38bf82532b439cf8.tar.bz2
xen-335c738c440e8a283e10660d38bf82532b439cf8.zip
Change the global suspend event channel lock file to a per-domain lock file
This allows multiple guests to be migrated or protected by Remus simultaneously. Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> Acked-by: Brendan Cully <brendan@cs.ubc.ca>
-rw-r--r--tools/libxc/xc_suspend.c29
-rw-r--r--tools/libxc/xenguest.h2
-rw-r--r--tools/libxl/libxl_dom.c2
-rw-r--r--tools/python/xen/lowlevel/checkpoint/libcheckpoint.c2
-rw-r--r--tools/xcutils/xc_save.c2
5 files changed, 22 insertions, 15 deletions
diff --git a/tools/libxc/xc_suspend.c b/tools/libxc/xc_suspend.c
index a9999b38ed..a334e821c1 100644
--- a/tools/libxc/xc_suspend.c
+++ b/tools/libxc/xc_suspend.c
@@ -7,18 +7,22 @@
#include "xc_private.h"
#include "xenguest.h"
-#define SUSPEND_LOCK_FILE "/var/lib/xen/suspend_evtchn_lock.d"
-static int lock_suspend_event(void)
+#define SUSPEND_LOCK_FILE "/var/lib/xen/suspend_evtchn"
+static int lock_suspend_event(int domid)
{
int fd, rc;
mode_t mask;
char buf[128];
+ char suspend_file[256];
+ snprintf(suspend_file, sizeof(suspend_file), "%s_%d_lock.d",
+ SUSPEND_LOCK_FILE, domid);
mask = umask(022);
- fd = open(SUSPEND_LOCK_FILE, O_CREAT | O_EXCL | O_RDWR, 0666);
+ fd = open(suspend_file, O_CREAT | O_EXCL | O_RDWR, 0666);
if (fd < 0)
{
- ERROR("Can't create lock file for suspend event channel\n");
+ ERROR("Can't create lock file for suspend event channel %s\n",
+ suspend_file);
return -EINVAL;
}
umask(mask);
@@ -30,12 +34,15 @@ static int lock_suspend_event(void)
return rc;
}
-static int unlock_suspend_event(void)
+static int unlock_suspend_event(int domid)
{
int fd, pid, n;
char buf[128];
+ char suspend_file[256];
- fd = open(SUSPEND_LOCK_FILE, O_RDWR);
+ snprintf(suspend_file, sizeof(suspend_file), "%s_%d_lock.d",
+ SUSPEND_LOCK_FILE, domid);
+ fd = open(suspend_file, O_RDWR);
if (fd < 0)
return -EINVAL;
@@ -50,7 +57,7 @@ static int unlock_suspend_event(void)
/* We are the owner, so we can simply delete the file */
if (pid == getpid())
{
- unlink(SUSPEND_LOCK_FILE);
+ unlink(suspend_file);
return 0;
}
}
@@ -77,19 +84,19 @@ int xc_await_suspend(int xce, int suspend_evtchn)
return 0;
}
-int xc_suspend_evtchn_release(int xce, int suspend_evtchn)
+int xc_suspend_evtchn_release(int xce, int domid, int suspend_evtchn)
{
if (suspend_evtchn >= 0)
xc_evtchn_unbind(xce, suspend_evtchn);
- return unlock_suspend_event();
+ return unlock_suspend_event(domid);
}
int xc_suspend_evtchn_init(int xc, int xce, int domid, int port)
{
int rc, suspend_evtchn = -1;
- if (lock_suspend_event())
+ if (lock_suspend_event(domid))
return -EINVAL;
suspend_evtchn = xc_evtchn_bind_interdomain(xce, domid, port);
@@ -111,7 +118,7 @@ int xc_suspend_evtchn_init(int xc, int xce, int domid, int port)
cleanup:
if (suspend_evtchn != -1)
- xc_suspend_evtchn_release(xce, suspend_evtchn);
+ xc_suspend_evtchn_release(xce, domid, suspend_evtchn);
return -1;
}
diff --git a/tools/libxc/xenguest.h b/tools/libxc/xenguest.h
index 851f76985c..d1d86b2c1c 100644
--- a/tools/libxc/xenguest.h
+++ b/tools/libxc/xenguest.h
@@ -157,7 +157,7 @@ int xc_hvm_build_mem(int xc_handle,
const char *image_buffer,
unsigned long image_size);
-int xc_suspend_evtchn_release(int xce, int suspend_evtchn);
+int xc_suspend_evtchn_release(int xce, int domid, int suspend_evtchn);
int xc_suspend_evtchn_init(int xc, int xce, int domid, int port);
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 75691d2f2d..89ba8b9a34 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -326,7 +326,7 @@ int core_suspend(struct libxl_ctx *ctx, uint32_t domid, int fd,
&core_suspend_switch_qemu_logdirty);
if (si.suspend_eventchn > 0)
- xc_suspend_evtchn_release(si.xce, si.suspend_eventchn);
+ xc_suspend_evtchn_release(si.xce, domid, si.suspend_eventchn);
if (si.xce > 0)
xc_evtchn_close(si.xce);
diff --git a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
index 459141fcb9..d84fa831d0 100644
--- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
+++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
@@ -360,7 +360,7 @@ static void release_suspend_evtchn(checkpoint_state *s)
{
/* TODO: teach xen to clean up if port is unbound */
if (s->xce >= 0 && s->suspend_evtchn >= 0) {
- xc_suspend_evtchn_release(s->xce, s->suspend_evtchn);
+ xc_suspend_evtchn_release(s->xce, s->domid, s->suspend_evtchn);
s->suspend_evtchn = -1;
}
}
diff --git a/tools/xcutils/xc_save.c b/tools/xcutils/xc_save.c
index 55e4b1d4ef..02570bda45 100644
--- a/tools/xcutils/xc_save.c
+++ b/tools/xcutils/xc_save.c
@@ -210,7 +210,7 @@ main(int argc, char **argv)
&switch_qemu_logdirty);
if (si.suspend_evtchn > 0)
- xc_suspend_evtchn_release(si.xce, si.suspend_evtchn);
+ xc_suspend_evtchn_release(si.xce, si.domid, si.suspend_evtchn);
if (si.xce > 0)
xc_evtchn_close(si.xce);