[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] export page offline hypercall in libxc


  • To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
  • From: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
  • Date: Sun, 31 May 2009 18:06:12 +0800
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Sun, 31 May 2009 03:06:54 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: Acnh12yOHG0/1NelQqOzYybSmOyE3w==
  • Thread-topic: [PATCH] export page offline hypercall in libxc

Export page offline hypercalls to user space tools.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx>

diff -r 780041c4a96d tools/libxc/Makefile
--- a/tools/libxc/Makefile      Tue May 19 02:23:32 2009 +0100
+++ b/tools/libxc/Makefile      Tue May 19 03:14:30 2009 +0800
@@ -31,6 +31,7 @@ GUEST_SRCS-y :=
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c xc_suspend.c
 GUEST_SRCS-$(CONFIG_MIGRATE) += xc_domain_restore.c xc_domain_save.c
+GUEST_SRCS-y += xc_offline_page.c
 GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
 
 vpath %.c ../../xen/common/libelf
diff -r 780041c4a96d tools/libxc/xc_offline_page.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/xc_offline_page.c     Tue May 19 02:57:37 2009 +0800
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * xc_offline_page.c
+ *
+ * Helper functions to offline/online one page
+ *
+ * Copyright (c) 2003, K A Fraser.
+ * Copyright (c) 2009, Intel Corporation.
+ */
+
+#include <inttypes.h>
+#include <time.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#include "xc_private.h"
+#include "xc_dom.h"
+#include "xg_private.h"
+#include "xg_save_restore.h"
+
+int xc_mark_page_online(int xc, unsigned long start,
+                        unsigned long end, uint32_t *status)
+{
+    DECLARE_SYSCTL;
+    int ret = -1;
+
+    if ( !status || (end < start) )
+        return -EINVAL;
+
+    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
+    {
+        ERROR("Could not lock memory for xc_mark_page_online\n");
+        return -EINVAL;
+    }
+
+    sysctl.cmd = XEN_SYSCTL_page_offline_op;
+    sysctl.u.page_offline.start = start;
+    sysctl.u.page_offline.cmd = sysctl_page_online;
+    sysctl.u.page_offline.end = end;
+    set_xen_guest_handle(sysctl.u.page_offline.status, status);
+    ret = xc_sysctl(xc, &sysctl);
+
+    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
+
+    return ret;
+}
+
+int xc_mark_page_offline(int xc, unsigned long start,
+                          unsigned long end, uint32_t *status)
+{
+    DECLARE_SYSCTL;
+    int ret = -1;
+
+    if ( !status || (end < start) )
+        return -EINVAL;
+
+    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
+    {
+        ERROR("Could not lock memory for xc_mark_page_offline");
+        return -EINVAL;
+    }
+
+    sysctl.cmd = XEN_SYSCTL_page_offline_op;
+    sysctl.u.page_offline.start = start;
+    sysctl.u.page_offline.cmd = sysctl_page_offline;
+    sysctl.u.page_offline.end = end;
+    set_xen_guest_handle(sysctl.u.page_offline.status, status);
+    ret = xc_sysctl(xc, &sysctl);
+
+    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
+
+    return ret;
+}
+
+int xc_query_page_offline_status(int xc, unsigned long start,
+                                 unsigned long end, uint32_t *status)
+{
+    DECLARE_SYSCTL;
+    int ret = -1;
+
+    if ( !status || (end < start) )
+        return -EINVAL;
+
+    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
+    {
+        ERROR("Could not lock memory for xc_query_page_offline_status\n");
+        return -EINVAL;
+    }
+
+    sysctl.cmd = XEN_SYSCTL_page_offline_op;
+    sysctl.u.page_offline.start = start;
+    sysctl.u.page_offline.cmd = sysctl_query_page_offline;
+    sysctl.u.page_offline.end = end;
+    set_xen_guest_handle(sysctl.u.page_offline.status, status);
+    ret = xc_sysctl(xc, &sysctl);
+
+    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
+
+    return ret;
+}
diff -r 780041c4a96d tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Tue May 19 02:23:32 2009 +0100
+++ b/tools/libxc/xenguest.h    Tue May 19 03:13:59 2009 +0800
@@ -148,4 +148,13 @@ int xc_suspend_evtchn_init(int xc, int x
 
 int xc_await_suspend(int xce, int suspend_evtchn);
 
+int xc_mark_page_online(int xc, unsigned long start,
+                        unsigned long end, uint32_t *status);
+
+int xc_mark_page_offline(int xc, unsigned long start,
+                          unsigned long end, uint32_t *status);
+
+int xc_query_page_offline_status(int xc, unsigned long start,
+                                 unsigned long end, uint32_t *status);
+
 #endif /* XENGUEST_H */

Attachment: offline_page_export.patch
Description: offline_page_export.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.