# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1192526875 -3600
# Node ID 1f893d055c6f79d719199d6eac139165295713a0
# Parent 05337cb5206fd3a553d9c3a0c752996bc40e189c
xend: Clean up hvm_build Python wrapper. Python code can get/set hvm
params directly.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
tools/python/xen/lowlevel/xc/xc.c | 61 +++++++++++++++++++++++++-------------
tools/python/xen/xend/image.py | 21 +++++++++----
2 files changed, 57 insertions(+), 25 deletions(-)
diff -r 05337cb5206f -r 1f893d055c6f tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Oct 16 09:40:08 2007 +0100
+++ b/tools/python/xen/lowlevel/xc/xc.c Tue Oct 16 10:27:55 2007 +0100
@@ -498,15 +498,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, ¶m) )
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, ¶m, &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__
@@ -537,15 +557,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 )
@@ -571,14 +590,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,
@@ -1326,7 +1338,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 05337cb5206f -r 1f893d055c6f tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Tue Oct 16 09:40:08 2007 +0100
+++ b/tools/python/xen/xend/image.py Tue Oct 16 10:27:55 2007 +0100
@@ -24,7 +24,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
@@ -274,7 +274,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))
@@ -289,19 +288,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
@@ -517,6 +520,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
|