WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] RE: [PATCH] libxc: fix link error of xc_save on ia64

To: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] RE: [PATCH] libxc: fix link error of xc_save on ia64
From: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
Date: Tue, 24 Mar 2009 13:07:50 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc:
Delivery-date: Mon, 23 Mar 2009 22:09:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090324041541.GK21134%yamahata@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090324041541.GK21134%yamahata@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcmsN0FWWmVauhmaRLuw41FilyRSvQABslTw
Thread-topic: [PATCH] libxc: fix link error of xc_save on ia64
Isaku, really sorry to break IA64 again. A bit strange that I tried it in our 
internal test, maybe I missed some step for that tools.

Thanks
Yunhong Jiang

>-----Original Message-----
>From: Isaku Yamahata [mailto:yamahata@xxxxxxxxxxxxx] 
>Sent: 2009年3月24日 12:16
>To: xen-devel@xxxxxxxxxxxxxxxxxxx
>Cc: Jiang, Yunhong
>Subject: [PATCH] libxc: fix link error of xc_save on ia64
>
>note: the copyright clause is copied from
>tools/xcutils/xc_save.c
>
>libxc: fix link error of xc_save on ia64
>
>The suspend event channel functions are arch independent code
>which xc_save uses.
>The changeset of 19382:a5f497f02e34 cause link error on ia64.
>This patch moves the functions into arch common file from
>x86 specific file xc_domain_save.c
>
>Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
>
>diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
>--- a/tools/libxc/Makefile
>+++ b/tools/libxc/Makefile
>@@ -29,7 +29,7 @@ CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.
> CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
> 
> GUEST_SRCS-y :=
>-GUEST_SRCS-y += xg_private.c
>+GUEST_SRCS-y += xg_private.c xc_suspend.c
> GUEST_SRCS-$(CONFIG_MIGRATE) += xc_domain_restore.c xc_domain_save.c
> GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
> 
>diff --git a/tools/libxc/xc_domain_save.c 
>b/tools/libxc/xc_domain_save.c
>--- a/tools/libxc/xc_domain_save.c
>+++ b/tools/libxc/xc_domain_save.c
>@@ -744,115 +744,6 @@ static xen_pfn_t *map_and_save_p2m_table
>     return success ? p2m : NULL;
> }
> 
>-#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);
>-    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 = write_exact(fd, buf, strlen(buf));
>-    close(fd);
>-
>-    return rc;
>-}
>-
>-static int unlock_suspend_event(void)
>-{
>-    int fd, pid, n;
>-    char buf[128];
>-
>-    fd = open(SUSPEND_LOCK_FILE, O_RDWR);
>-
>-    if (fd < 0)
>-        return -EINVAL;
>-
>-    n = read(fd, buf, 127);
>-
>-    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;
>-        }
>-    }
>-
>-    return -EPERM;
>-}
>-
>-int xc_await_suspend(int xce, int suspend_evtchn)
>-{
>-    int rc;
>-
>-    do {
>-        rc = xc_evtchn_pending(xce);
>-        if (rc < 0) {
>-            ERROR("error polling suspend notification 
>channel: %d", rc);
>-            return -1;
>-        }
>-    } while (rc != suspend_evtchn);
>-
>-    /* harmless for one-off suspend */
>-    if (xc_evtchn_unmask(xce, suspend_evtchn) < 0)
>-        ERROR("failed to unmask suspend notification channel: 
>%d", rc);
>-
>-    return 0;
>-}
>-
>-int xc_suspend_evtchn_release(int xce, int suspend_evtchn)
>-{
>-    if (suspend_evtchn >= 0)
>-        xc_evtchn_unbind(xce, suspend_evtchn);
>-
>-    return unlock_suspend_event();
>-}
>-
>-int xc_suspend_evtchn_init(int xc, int xce, int domid, int port)
>-{
>-    int rc, suspend_evtchn = -1;
>-
>-    if (lock_suspend_event())
>-        return -EINVAL;
>-
>-    suspend_evtchn = xc_evtchn_bind_interdomain(xce, domid, port);
>-    if (suspend_evtchn < 0) {
>-        ERROR("failed to bind suspend event channel: %d", 
>suspend_evtchn);
>-        goto cleanup;
>-    }
>-
>-    rc = xc_domain_subscribe_for_suspend(xc, domid, port);
>-    if (rc < 0) {
>-        ERROR("failed to subscribe to domain: %d", rc);
>-        goto cleanup;
>-    }
>-
>-    /* event channel is pending immediately after binding */
>-    xc_await_suspend(xce, suspend_evtchn);
>-
>-    return suspend_evtchn;
>-
>-cleanup:
>-    if (suspend_evtchn > 0)
>-        xc_suspend_evtchn_release(xce, suspend_evtchn);
>-
>-    return -1;
>-}
>-
> int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, 
>uint32_t max_iters,
>                    uint32_t max_factor, uint32_t flags, int 
>(*suspend)(void),
>                    int hvm, void *(*init_qemu_maps)(int, unsigned), 
>diff --git a/tools/libxc/xc_suspend.c b/tools/libxc/xc_suspend.c
>new file mode 100644
>--- /dev/null
>+++ b/tools/libxc/xc_suspend.c
>@@ -0,0 +1,117 @@
>+/*
>+ * This file is subject to the terms and conditions of the GNU General
>+ * Public License.  See the file "COPYING" in the main directory of
>+ * this archive for more details.
>+ */
>+
>+#include "xc_private.h"
>+#include "xenguest.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);
>+    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 = write_exact(fd, buf, strlen(buf));
>+    close(fd);
>+
>+    return rc;
>+}
>+
>+static int unlock_suspend_event(void)
>+{
>+    int fd, pid, n;
>+    char buf[128];
>+
>+    fd = open(SUSPEND_LOCK_FILE, O_RDWR);
>+
>+    if (fd < 0)
>+        return -EINVAL;
>+
>+    n = read(fd, buf, 127);
>+
>+    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;
>+        }
>+    }
>+
>+    return -EPERM;
>+}
>+
>+int xc_await_suspend(int xce, int suspend_evtchn)
>+{
>+    int rc;
>+
>+    do {
>+        rc = xc_evtchn_pending(xce);
>+        if (rc < 0) {
>+            ERROR("error polling suspend notification 
>channel: %d", rc);
>+            return -1;
>+        }
>+    } while (rc != suspend_evtchn);
>+
>+    /* harmless for one-off suspend */
>+    if (xc_evtchn_unmask(xce, suspend_evtchn) < 0)
>+        ERROR("failed to unmask suspend notification channel: 
>%d", rc);
>+
>+    return 0;
>+}
>+
>+int xc_suspend_evtchn_release(int xce, int suspend_evtchn)
>+{
>+    if (suspend_evtchn >= 0)
>+        xc_evtchn_unbind(xce, suspend_evtchn);
>+
>+    return unlock_suspend_event();
>+}
>+
>+int xc_suspend_evtchn_init(int xc, int xce, int domid, int port)
>+{
>+    int rc, suspend_evtchn = -1;
>+
>+    if (lock_suspend_event())
>+        return -EINVAL;
>+
>+    suspend_evtchn = xc_evtchn_bind_interdomain(xce, domid, port);
>+    if (suspend_evtchn < 0) {
>+        ERROR("failed to bind suspend event channel: %d", 
>suspend_evtchn);
>+        goto cleanup;
>+    }
>+
>+    rc = xc_domain_subscribe_for_suspend(xc, domid, port);
>+    if (rc < 0) {
>+        ERROR("failed to subscribe to domain: %d", rc);
>+        goto cleanup;
>+    }
>+
>+    /* event channel is pending immediately after binding */
>+    xc_await_suspend(xce, suspend_evtchn);
>+
>+    return suspend_evtchn;
>+
>+cleanup:
>+    if (suspend_evtchn > 0)
>+        xc_suspend_evtchn_release(xce, suspend_evtchn);
>+
>+    return -1;
>+}
>
>-- 
>yamahata
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>