# HG changeset patch # User rshriram@xxxxxxxxxxxxxxxxxx # Date 1272409464 25200 # Node ID 6d2bca1b77539d1830372887e874b55a6f7781f9 # Parent c87ec146229ab2255ecdf005b862b943b1a5112e 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 diff -r c87ec146229a -r 6d2bca1b7753 tools/libxc/xc_suspend.c --- a/tools/libxc/xc_suspend.c Fri Apr 23 15:04:26 2010 +0100 +++ b/tools/libxc/xc_suspend.c Tue Apr 27 16:04:24 2010 -0700 @@ -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 @@ 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 @@ /* 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 @@ 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 @@ cleanup: if (suspend_evtchn != -1) - xc_suspend_evtchn_release(xce, suspend_evtchn); + xc_suspend_evtchn_release(xce, domid, suspend_evtchn); return -1; } diff -r c87ec146229a -r 6d2bca1b7753 tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h Fri Apr 23 15:04:26 2010 +0100 +++ b/tools/libxc/xenguest.h Tue Apr 27 16:04:24 2010 -0700 @@ -157,7 +157,7 @@ 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 -r c87ec146229a -r 6d2bca1b7753 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri Apr 23 15:04:26 2010 +0100 +++ b/tools/libxl/libxl_dom.c Tue Apr 27 16:04:24 2010 -0700 @@ -326,7 +326,7 @@ &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 -r c87ec146229a -r 6d2bca1b7753 tools/python/xen/lowlevel/checkpoint/libcheckpoint.c --- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Fri Apr 23 15:04:26 2010 +0100 +++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Tue Apr 27 16:04:24 2010 -0700 @@ -360,7 +360,7 @@ { /* 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 -r c87ec146229a -r 6d2bca1b7753 tools/xcutils/xc_save.c --- a/tools/xcutils/xc_save.c Fri Apr 23 15:04:26 2010 +0100 +++ b/tools/xcutils/xc_save.c Tue Apr 27 16:04:24 2010 -0700 @@ -210,7 +210,7 @@ &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);