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-changelog

[Xen-changelog] [xen-3.1-testing] xend: Clean up hvm_build Python wrappe

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.1-testing] xend: Clean up hvm_build Python wrapper. Python code can get/set hvm
From: "Xen patchbot-3.1-testing" <patchbot-3.1-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Dec 2007 12:00:28 -0800
Delivery-date: Thu, 20 Dec 2007 12:01:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1198162623 0
# Node ID 9093b433fa5c1f2058dfc3228ddbb5d8ef182093
# Parent  d9333dfae0203d02459811fb0235b50255655bad
xend: Clean up hvm_build Python wrapper. Python code can get/set hvm
params directly.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
xen-unstable changeset:   16116:1f893d055c6f79d719199d6eac139165295713a0
xen-unstable date:        Tue Oct 16 10:27:55 2007 +0100
---
 tools/python/xen/lowlevel/xc/xc.c |   61 +++++++++++++++++++++++++-------------
 tools/python/xen/xend/image.py    |   21 +++++++++----
 2 files changed, 57 insertions(+), 25 deletions(-)

diff -r d9333dfae020 -r 9093b433fa5c tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Thu Dec 20 11:07:03 2007 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Dec 20 14:57:03 2007 +0000
@@ -497,15 +497,35 @@ static PyObject *pyxc_get_hvm_param(XcOb
     unsigned long value;
 
     static char *kwd_list[] = { "domid", "param", NULL }; 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
                                       &dom, &param) )
         return NULL;
 
     if ( xc_get_hvm_param(self->xc_handle, dom, param, &value) != 0 )
         return pyxc_error_to_exception();
 
-    return Py_BuildValue("i", value);
-
+    return PyLong_FromUnsignedLong(value);
+
+}
+
+static PyObject *pyxc_set_hvm_param(XcObject *self,
+                                    PyObject *args,
+                                    PyObject *kwds)
+{
+    uint32_t dom;
+    int param;
+    uint64_t value;
+
+    static char *kwd_list[] = { "domid", "param", "value", NULL }; 
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiL", kwd_list,
+                                      &dom, &param, &value) )
+        return NULL;
+
+    if ( xc_set_hvm_param(self->xc_handle, dom, param, value) != 0 )
+        return pyxc_error_to_exception();
+
+    Py_INCREF(zero);
+    return zero;
 }
 
 #ifdef __ia64__
@@ -536,15 +556,14 @@ static PyObject *pyxc_hvm_build(XcObject
     int i;
 #endif
     char *image;
-    int store_evtchn, memsize, vcpus = 1, pae = 0, acpi = 0, apic = 1;
-    unsigned long store_mfn;
-
-    static char *kwd_list[] = { "domid", "store_evtchn",
-                               "memsize", "image", "vcpus", "pae", "acpi",
+    int memsize, vcpus = 1, acpi = 0, apic = 1;
+
+    static char *kwd_list[] = { "domid",
+                               "memsize", "image", "vcpus", "acpi",
                                "apic", NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|iiii", kwd_list,
-                                      &dom, &store_evtchn, &memsize,
-                                      &image, &vcpus, &pae, &acpi, &apic) )
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iii", kwd_list,
+                                      &dom, &memsize,
+                                      &image, &vcpus, &acpi, &apic) )
         return NULL;
 
     if ( xc_hvm_build(self->xc_handle, dom, memsize, image) != 0 )
@@ -570,14 +589,7 @@ static PyObject *pyxc_hvm_build(XcObject
     munmap(va_map, XC_PAGE_SIZE);
 #endif
 
-    xc_get_hvm_param(self->xc_handle, dom, HVM_PARAM_STORE_PFN, &store_mfn);
-#if !defined(__ia64__)
-    xc_set_hvm_param(self->xc_handle, dom, HVM_PARAM_PAE_ENABLED, pae);
-#endif
-    xc_set_hvm_param(self->xc_handle, dom, HVM_PARAM_STORE_EVTCHN,
-                     store_evtchn);
-
-    return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
+    return Py_BuildValue("{}");
 }
 
 static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
@@ -1296,7 +1308,16 @@ static PyMethodDef pyxc_methods[] = {
       "get a parameter of HVM guest OS.\n"
       " dom     [int]:      Identifier of domain to build into.\n"
       " param   [int]:      No. of HVM param.\n"
-      "Returns: [int] value of the param.\n" },
+      "Returns: [long] value of the param.\n" },
+
+    { "hvm_set_param", 
+      (PyCFunction)pyxc_set_hvm_param, 
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "set a parameter of HVM guest OS.\n"
+      " dom     [int]:      Identifier of domain to build into.\n"
+      " param   [int]:      No. of HVM param.\n"
+      " value   [long]:     Value of param.\n"
+      "Returns: [int] 0 on success.\n" },
 
     { "sched_id_get",
       (PyCFunction)pyxc_sched_id_get,
diff -r d9333dfae020 -r 9093b433fa5c tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Dec 20 11:07:03 2007 +0000
+++ b/tools/python/xen/xend/image.py    Thu Dec 20 14:57:03 2007 +0000
@@ -23,7 +23,7 @@ import signal
 import signal
 
 import xen.lowlevel.xc
-from xen.xend.XendConstants import REVERSE_DOMAIN_SHUTDOWN_REASONS
+from xen.xend.XendConstants import *
 from xen.xend.XendError import VmError, XendError, HVMRequired
 from xen.xend.XendLogging import log
 from xen.xend.XendOptions import instance as xenopts
@@ -264,7 +264,6 @@ class HVMImageHandler(ImageHandler):
 
         self.pid = None
 
-        self.pae  = int(vmConfig['platform'].get('pae',  0))
         self.apic = int(vmConfig['platform'].get('apic', 0))
         self.acpi = int(vmConfig['platform'].get('acpi', 0))
         
@@ -279,19 +278,23 @@ class HVMImageHandler(ImageHandler):
         log.debug("store_evtchn   = %d", store_evtchn)
         log.debug("memsize        = %d", mem_mb)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
-        log.debug("pae            = %d", self.pae)
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
 
         rc = xc.hvm_build(domid          = self.vm.getDomid(),
                           image          = self.kernel,
-                          store_evtchn   = store_evtchn,
                           memsize        = mem_mb,
                           vcpus          = self.vm.getVCpuCount(),
-                          pae            = self.pae,
                           acpi           = self.acpi,
                           apic           = self.apic)
+
         rc['notes'] = { 'SUSPEND_CANCEL': 1 }
+
+        rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(),
+                                           HVM_PARAM_STORE_PFN)
+        xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_STORE_EVTCHN,
+                         store_evtchn)
+
         return rc
 
     # Return a list of cmd line args to the device models based on the
@@ -491,6 +494,14 @@ class IA64_HVM_ImageHandler(HVMImageHand
 
 class X86_HVM_ImageHandler(HVMImageHandler):
 
+    def configure(self, vmConfig):
+        HVMImageHandler.configure(self, vmConfig)
+        self.pae = int(vmConfig['platform'].get('pae',  0))
+
+    def buildDomain(self):
+        xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_PAE_ENABLED, self.pae)
+        return HVMImageHandler.buildDomain(self)
+
     def getRequiredAvailableMemory(self, mem_kb):
         # Add 8 MiB overhead for QEMU's video RAM.
         return mem_kb + 8192

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.1-testing] xend: Clean up hvm_build Python wrapper. Python code can get/set hvm, Xen patchbot-3.1-testing <=