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

[Xen-devel] [PATCH 2/5] dump-core take 2: libxc: xc_domain memmap functions



# HG changeset patch
# User yamahata@xxxxxxxxxxxxx
# Date 1169100791 -32400
# Node ID c2db94de4afc030170609d7d9de6daf334b17182
# Parent  280d35294b8968b262c37df4d01712e0af288451
libxc:add xc_domain_set_memmap(), xc_domain_get_memmap() which is corresponding
to XENMEM_set_memory_map and XENMEM_get_memory_map.
dump-core needs those functions.
PATCHNAME: libxc_memory_map

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r 280d35294b89 -r c2db94de4afc tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Tue Jan 16 15:40:39 2007 +0900
+++ b/tools/libxc/xc_domain.c   Thu Jan 18 15:13:11 2007 +0900
@@ -351,10 +351,93 @@ int xc_domain_set_memmap_limit(int xc_ha
     unlock_pages(&e820, sizeof(e820));
     return rc;
 }
+
+int xc_domain_set_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int nr_entries)
+{
+    int rc;
+
+    struct xen_foreign_memory_map fmap = {
+        .domid = domid,
+        .map = { .nr_entries = nr_entries }
+    };
+
+    set_xen_guest_handle(fmap.map.buffer, buffer);
+
+    if ( lock_pages(&fmap, sizeof(fmap)) ||
+         lock_pages(buffer, nr_entries * sizeof(struct e820entry)) )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        rc = -1;
+        goto out;
+    }
+
+    rc = xc_memory_op(xc_handle, XENMEM_set_memory_map, &fmap);
+
+ out:
+    unlock_pages(&fmap, sizeof(fmap));
+    unlock_pages(buffer, nr_entries * sizeof(struct e820entry));
+    return rc;
+}
+
+int xc_domain_get_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int *nr_entries)
+{
+    int rc;
+
+    struct xen_foreign_memory_map fmap = {
+        .domid = domid,
+        .map = { .nr_entries = *nr_entries }
+    };
+
+    set_xen_guest_handle(fmap.map.buffer, buffer);
+
+    if ( lock_pages(&fmap, sizeof(fmap)) ||
+         lock_pages(buffer, *nr_entries * sizeof(struct e820entry)) )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        rc = -1;
+        goto out;
+    }
+
+    rc = xc_memory_op(xc_handle, XENMEM_get_memory_map, &fmap);
+
+ out:
+    unlock_pages(&fmap, sizeof(fmap));
+    unlock_pages(buffer, *nr_entries * sizeof(struct e820entry));
+
+    *nr_entries = fmap.map.nr_entries;
+    return rc;
+    
+}
 #else
 int xc_domain_set_memmap_limit(int xc_handle,
                                uint32_t domid,
                                unsigned long map_limitkb)
+{
+    PERROR("Function not implemented");
+    errno = ENOSYS;
+    return -1;
+}
+
+int xc_domain_set_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int nr_entries)
+{
+    PERROR("Function not implemented");
+    errno = ENOSYS;
+    return -1;
+}
+
+int xc_domain_get_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int nr_entries)
 {
     PERROR("Function not implemented");
     errno = ENOSYS;
diff -r 280d35294b89 -r c2db94de4afc tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue Jan 16 15:40:39 2007 +0900
+++ b/tools/libxc/xenctrl.h     Thu Jan 18 15:13:11 2007 +0900
@@ -423,6 +423,16 @@ int xc_domain_set_memmap_limit(int xc_ha
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+int xc_domain_set_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int nr_entries);
+
+int xc_domain_get_memmap(int xc_handle,
+                         uint32_t domid,
+                         void *buffer,
+                         unsigned int *nr_entries);
+
 int xc_domain_set_time_offset(int xc_handle,
                               uint32_t domid,
                               int32_t time_offset_seconds);
--
yamahata

_______________________________________________
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®.