9a05aa7fc4
22707-x2apic-preenabled-check.patch - bnc#641419 - L3: Xen: qemu-dm reports "xc_map_foreign_batch: mmap failed: Cannot allocate memory" 7434-qemu-rlimit-as.patch - Additional or upstream patches from Jan 22693-fam10-mmio-conf-base-protect.patch 22694-x86_64-no-weak.patch 22708-xenctx-misc.patch 21432-4.0-cpu-boot-failure.patch 22645-amd-flush-filter.patch qemu-fix-7433.patch - Maintain compatibility with the extid flag even though it is deprecated for both legacy and sxp config files. hv_extid_compatibility.patch - bnc#649209-improve suspend eventchn lock suspend_evtchn_lock.patch - Removed the hyper-v shim patches in favor of using the upstream version. - bnc#641419 - L3: Xen: qemu-dm reports "xc_map_foreign_batch: mmap failed: Cannot allocate memory" qemu-rlimit-as.patch - Upstream c/s 7433 to replace qemu_altgr_more.patch 7433-qemu-altgr.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=90
88 lines
2.2 KiB
Diff
88 lines
2.2 KiB
Diff
Improve suspend eventchn lock, use flock instead of exclusive lock
|
|
file to avoid that sometimes the lock file is not removed cleanly
|
|
and affacts later getting lock.
|
|
http://lists.xensource.com/archives/html/xen-devel/2010-11/msg01559.html
|
|
|
|
Signed-off-by cyliu@novell.com
|
|
|
|
Index: xen-4.0.1-testing/tools/libxc/xc_suspend.c
|
|
===================================================================
|
|
--- xen-4.0.1-testing.orig/tools/libxc/xc_suspend.c
|
|
+++ xen-4.0.1-testing/tools/libxc/xc_suspend.c
|
|
@@ -6,25 +6,25 @@
|
|
|
|
#include "xc_private.h"
|
|
#include "xenguest.h"
|
|
+#include <sys/file.h>
|
|
+#include <sys/fcntl.h>
|
|
|
|
#define SUSPEND_LOCK_FILE "/var/lib/xen/suspend_evtchn_lock.d"
|
|
static int lock_suspend_event(void)
|
|
{
|
|
int fd, rc;
|
|
mode_t mask;
|
|
- char buf[128];
|
|
|
|
mask = umask(022);
|
|
- fd = open(SUSPEND_LOCK_FILE, O_CREAT | O_EXCL | O_RDWR, 0666);
|
|
+ fd = open(SUSPEND_LOCK_FILE, O_CREAT | O_RDWR, 0666);
|
|
if (fd < 0)
|
|
{
|
|
ERROR("Can't create lock file for suspend event channel\n");
|
|
return -EINVAL;
|
|
}
|
|
umask(mask);
|
|
- snprintf(buf, sizeof(buf), "%10ld", (long)getpid());
|
|
+ rc = flock(fd, LOCK_EX | LOCK_NB);
|
|
|
|
- rc = write_exact(fd, buf, strlen(buf));
|
|
close(fd);
|
|
|
|
return rc;
|
|
@@ -32,30 +32,21 @@ static int lock_suspend_event(void)
|
|
|
|
static int unlock_suspend_event(void)
|
|
{
|
|
- int fd, pid, n;
|
|
- char buf[128];
|
|
+ int fd, rc;
|
|
|
|
fd = open(SUSPEND_LOCK_FILE, O_RDWR);
|
|
|
|
if (fd < 0)
|
|
return -EINVAL;
|
|
|
|
- n = read(fd, buf, 127);
|
|
+ rc = flock(fd, LOCK_UN | LOCK_NB);
|
|
|
|
close(fd);
|
|
|
|
- if (n > 0)
|
|
- {
|
|
- sscanf(buf, "%d", &pid);
|
|
- /* We are the owner, so we can simply delete the file */
|
|
- if (pid == getpid())
|
|
- {
|
|
- unlink(SUSPEND_LOCK_FILE);
|
|
- return 0;
|
|
- }
|
|
- }
|
|
+ if(!rc)
|
|
+ unlink(SUSPEND_LOCK_FILE);
|
|
|
|
- return -EPERM;
|
|
+ return rc;
|
|
}
|
|
|
|
int xc_await_suspend(int xce, int suspend_evtchn)
|
|
@@ -110,8 +101,7 @@ int xc_suspend_evtchn_init(int xc, int x
|
|
return suspend_evtchn;
|
|
|
|
cleanup:
|
|
- if (suspend_evtchn != -1)
|
|
- xc_suspend_evtchn_release(xce, suspend_evtchn);
|
|
+ xc_suspend_evtchn_release(xce, suspend_evtchn);
|
|
|
|
return -1;
|
|
}
|