xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xensource.com, keir.fraser@eu.citrix.com
Cc: konrad.wilk@oracle.com
Subject: [PATCH 1 of 5] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls
Date: Thu, 07 Apr 2011 16:25:22 -0400	[thread overview]
Message-ID: <decab6c21cc3d7ce4d4d.1302207922@localhost6.localdomain6> (raw)
In-Reply-To: <patchbomb.1302207921@localhost6.localdomain6>

# HG changeset patch
# User Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
# Date 1302194186 14400
# Node ID decab6c21cc3d7ce4d4dad949d34ba35d4600490
# Parent  97763efc41f9b664cf6f7db653c9c3f51e50b358
tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls.

The later retrieves the E820 as seen by the hypervisor (completly
unchanged) and the second call sets the E820 for a specific guest.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

diff -r 97763efc41f9 -r decab6c21cc3 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c	Tue Apr 05 18:23:54 2011 +0100
+++ b/tools/libxc/xc_domain.c	Thu Apr 07 12:36:26 2011 -0400
@@ -510,6 +510,55 @@
 
     return rc;
 }
+
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries)
+{
+    int rc;
+    struct xen_foreign_memory_map fmap = {
+        .domid = domid,
+        .map = { .nr_entries = nr_entries }
+    };
+    DECLARE_HYPERCALL_BOUNCE(entries, nr_entries * sizeof(struct e820entry),
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( !entries || xc_hypercall_bounce_pre(xch, entries) )
+        return -1;
+
+    set_xen_guest_handle(fmap.map.buffer, entries);
+
+    rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap));
+
+    xc_hypercall_bounce_post(xch, entries);
+
+    return rc;
+}
+
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries)
+{
+    int rc;
+    struct xen_memory_map memmap = {
+        .nr_entries = max_entries
+    };
+    DECLARE_HYPERCALL_BOUNCE(entries, sizeof(struct e820entry) * max_entries,
+                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( !entries || xc_hypercall_bounce_pre(xch, entries) || max_entries <= 1)
+        return -1;
+
+
+    set_xen_guest_handle(memmap.buffer, entries);
+
+    rc = do_memory_op(xch, XENMEM_machine_memory_map, &memmap, sizeof(memmap));
+
+    xc_hypercall_bounce_post(xch, entries);
+
+    return rc ? rc : memmap.nr_entries;
+}
 #else
 int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
@@ -519,6 +568,23 @@
     errno = ENOSYS;
     return -1;
 }
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries)
+{
+    PERROR("Function not implemented");
+    errno = ENOSYS;
+    return -1;
+}
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries)
+{
+    PERROR("Function not implemented");
+    errno = ENOSYS;
+    return -1;
+}
 #endif
 
 int xc_domain_set_time_offset(xc_interface *xch,
diff -r 97763efc41f9 -r decab6c21cc3 tools/libxc/xc_e820.h
--- a/tools/libxc/xc_e820.h	Tue Apr 05 18:23:54 2011 +0100
+++ b/tools/libxc/xc_e820.h	Thu Apr 07 12:36:26 2011 -0400
@@ -26,6 +26,7 @@
 #define E820_RESERVED     2
 #define E820_ACPI         3
 #define E820_NVS          4
+#define E820_UNUSABLE     5
 
 struct e820entry {
     uint64_t addr;
diff -r 97763efc41f9 -r decab6c21cc3 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h	Tue Apr 05 18:23:54 2011 +0100
+++ b/tools/libxc/xenctrl.h	Thu Apr 07 12:36:26 2011 -0400
@@ -53,6 +53,7 @@
 #include <xen/foreign/x86_32.h>
 #include <xen/foreign/x86_64.h>
 #include <xen/arch-x86/xen-mca.h>
+#include "xc_e820.h"
 #endif
 
 #ifdef __ia64__
@@ -966,6 +967,15 @@
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries);
+
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries);
+
 int xc_domain_set_time_offset(xc_interface *xch,
                               uint32_t domid,
                               int32_t time_offset_seconds);

  reply	other threads:[~2011-04-07 20:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07 20:25 [PATCH 0 of 5] Patches for PCI passthrough with modified E820 Konrad Rzeszutek Wilk
2011-04-07 20:25 ` Konrad Rzeszutek Wilk [this message]
2011-04-08  8:18   ` [PATCH 1 of 5] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls Ian Campbell
2011-04-08 13:19     ` Konrad Rzeszutek Wilk
2011-04-07 20:25 ` [PATCH 2 of 5] x86: make the pv-only e820 array be dynamic Konrad Rzeszutek Wilk
2011-04-08  8:22   ` Ian Campbell
2011-04-08 13:21     ` Konrad Rzeszutek Wilk
2011-04-07 20:25 ` [PATCH 3 of 5] x86: adjust the size of the e820 for pv guest to " Konrad Rzeszutek Wilk
2011-04-07 20:25 ` [PATCH 4 of 5] libxl: Add support for passing in the machine's E820 for PCI passthrough Konrad Rzeszutek Wilk
2011-04-08  8:36   ` Ian Campbell
2011-04-08 10:56     ` Ian Jackson
2011-04-08 13:35       ` Konrad Rzeszutek Wilk
2011-04-08 13:55         ` Ian Campbell
2011-04-08 14:09           ` Tim Deegan
2011-04-08 14:17             ` Ian Campbell
2011-04-08 14:25               ` Tim Deegan
2011-04-08 14:33                 ` Ian Campbell
2011-04-08 15:00                   ` Konrad Rzeszutek Wilk
2011-04-08 14:34                 ` Konrad Rzeszutek Wilk
2011-04-08 14:42                   ` Ian Campbell
2011-04-08 14:54                     ` Konrad Rzeszutek Wilk
2011-04-08 16:01                 ` Ian Jackson
2011-04-08 13:33     ` Konrad Rzeszutek Wilk
2011-04-08 14:00       ` Ian Campbell
2011-04-07 20:25 ` [PATCH 5 of 5] libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate Konrad Rzeszutek Wilk
2011-04-08  8:42 ` [PATCH 0 of 5] Patches for PCI passthrough with modified E820 Ian Campbell
2011-04-08 13:24   ` Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=decab6c21cc3d7ce4d4d.1302207922@localhost6.localdomain6 \
    --to=konrad.wilk@oracle.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).