add architecture-specific parameter to xc_linux_build()
PATCH 1/1 add architecture-specific parameter to xc_linux_build()
(I'm not attached to the name "arch_args" in this patch.)
Keir, this patch applies on top of the xc.c whitespace patch I just sent, and also on top of the contents of xenppc-unstable-merge.hg (because we've moved xc_ppc_linux_build.c into its own directory). We also have a couple important fixes in there anyways, so now would be a good time to pull. :)
.hgignore | 8 a/tools/libxc/xc_ppc_linux_build.c | 408 ------------------------------- b/tools/libxc/powerpc64/Makefile | 1 b/tools/libxc/powerpc64/xc_linux_build.c | 408 +++++++++++++++++++++++++++++++ tools/libxc/xc_ppc_linux_build.c | 40 +-- xen/arch/powerpc/Makefile | 3 xen/arch/powerpc/boot_of.c | 8 xen/arch/powerpc/dom0_ops.c | 43 ++- xen/arch/powerpc/domain.c | 29 +- xen/arch/powerpc/of_handler/devtree.c | 2 xen/arch/powerpc/powerpc64/ppc970.c | 7 xen/arch/powerpc/usercopy.c | 4 xen/include/asm-powerpc/processor.h | 1 13 files changed, 502 insertions(+), 460 deletions(-)
# HG changeset patch
# User Hollis Blanchard <[email protected]>
# Date 1155068244 18000
# Node ID e74340460b8cac614ac71d540ca78eb11a0e917f
# Parent 375fb1f773c5ec053d63315e4d942e7d3aeb0cda
[LIBXC] add architecture-specific parameter to xc_linux_build() On PowerPC, we will pass down the flattened device tree from Python this way. Other architectures currently leave this unused. Should more than one parameter be needed in the future, the address of an architecture-specific structure can be passed instead (i.e. we won't need to add more parameters to the prototype).
tools/libxc/powerpc64/xc_linux_build.c +2 -1
@@ -352,7 +352,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *devtree) { struct domain_setup_info dsi;xen_pfn_t *page_array =NULL ;
tools/libxc/xc_linux_build.c +2 -1
@@ -1337,7 +1337,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *unused) { char *image = NULL;unsigned long image_size;
tools/libxc/xenguest.h +4 -2
@@ -55,7 +55,8 @@ int xc_linux_restore(int xc_handle, int* @parm store_evtchn the store event channel for this domain to use * @parm store_mfn returned with the mfn of the store page * @parm console_evtchn the console event channel for this domain to use -* @parm conole_mfn returned with the mfn of the console page +* @parm console_mfn returned with the mfn of the console page +* @parm arch_args architecture-specific data * @return 0 on success, -1 on failure */ int xc_linux_build(int xc_handle,
@@ -68,7 +69,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn); + unsigned long *console_mfn, + void *arch_args);/** * This function will create a domain for a paravirtualized Linux
tools/python/xen/lowlevel/xc/xc.c +6 -5
@@ -331,25 +331,26 @@ static PyObject *pyxc_linux_build(XcObjeint store_evtchn, console_evtchn;unsigned long store_mfn =0 ;unsigned long console_mfn =0 ; +void *arch_args =NULL ;static char *kwd_list[] = {"dom" ,"store_evtchn" ,"console_evtchn" ,"image" ,/* optional */ "ramdisk" ,"cmdline" ,"flags" , -"features" ,"arch" ,NULL }; - -if ( !PyArg_ParseTupleAndKeywords (args, kwds,"iiis|ssis" , kwd_list, +"features" ,"arch_args" ,NULL }; + +if ( !PyArg_ParseTupleAndKeywords (args, kwds,"iiis|ssiss" , kwd_list, &dom, &store_evtchn, &console_evtchn, &image,/* optional */ &ramdisk, &cmdline, &flags, - &features) ) + &features, &arch_args) )return NULL ;if (xc_linux_build (self->xc_handle, dom, image, ramdisk, cmdline, features, flags, store_evtchn, &store_mfn, - console_evtchn, &console_mfn) !=0 ) { + console_evtchn, &console_mfn, arch_args) !=0 ) {if (!errno) errno =EINVAL ;return PyErr_SetFromErrno (xc_error);
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 9 lines · Hollis Blanchard
diff -r
375fb1f773c5-re74340460b8ctools/python/xen/lowlevel/xc/xc.ctools/python/xen/lowlevel/xc/xc.c +1
-0@@ -331,25 +331,26 @@ static PyObject *pyxc_linux_build(XcObjeint store_evtchn, console_evtchn;unsigned long store_mfn =0 ;unsigned long console_mfn =0 ; +void *arch_args =NULL ;
tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_linux_build(XcObje · line 342
Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +3
-3static char *kwd_list[] = {"dom" ,"store_evtchn" ,"console_evtchn" ,"image" ,/* optional */ "ramdisk" ,"cmdline" ,"flags" , -"features" ,"arch" ,NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list, +"features" ,"arch_args" ,NULL }; + + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssiss", kwd_list,
The one complication is that PPC's data structure has NULL characters in it, which the "s" conversion char doesn't like. Instead you must use "s#" to get the length as well, except I think it's ok to leave it up to the architecture to handle the length itself (after all, even an int that has a NULL byte trips this problem). So here is the updated patch.
# HG changeset patch
# User Hollis Blanchard <[email protected]>
# Date 1155068244 18000
# Node ID e74340460b8cac614ac71d540ca78eb11a0e917f
# Parent 375fb1f773c5ec053d63315e4d942e7d3aeb0cda
[LIBXC] add architecture-specific parameter to xc_linux_build() On PowerPC, we will pass down the flattened device tree from Python this way. Other architectures currently leave this unused. Should more than one parameter be needed in the future, the address of an architecture-specific structure can be passed instead (i.e. we won't need to add more parameters to the prototype).
tools/libxc/powerpc64/xc_linux_build.c +2 -1
@@ -352,7 +352,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *devtree) { struct domain_setup_info dsi;xen_pfn_t *page_array =NULL ;
tools/libxc/xc_linux_build.c +2 -1
@@ -1337,7 +1337,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *unused) { char *image = NULL;unsigned long image_size;
tools/libxc/xenguest.h +4 -2
@@ -55,7 +55,8 @@ int xc_linux_restore(int xc_handle, int* @parm store_evtchn the store event channel for this domain to use * @parm store_mfn returned with the mfn of the store page * @parm console_evtchn the console event channel for this domain to use -* @parm conole_mfn returned with the mfn of the console page +* @parm console_mfn returned with the mfn of the console page +* @parm arch_args architecture-specific data * @return 0 on success, -1 on failure */ int xc_linux_build(int xc_handle,
@@ -68,7 +69,8 @@ int xc_linux_build(int xc_handle,unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn); + unsigned long *console_mfn, + void *arch_args);/** * This function will create a domain for a paravirtualized Linux
python/xen/lowlevel/xc/xc.c renamed from python/xen/lowlevel/xc/xc.c.orig +6 -4
@@ -331,25 +331,27 @@int store_evtchn, console_evtchn;unsigned long store_mfn =0 ;unsigned long console_mfn =0 ; +void *arch_args =NULL ; +int unused;static char *kwd_list[] = {"dom" ,"store_evtchn" ,"console_evtchn" ,"image" ,/* optional */ "ramdisk" ,"cmdline" ,"flags" , -"features" ,NULL }; +"features" ,"arch_args" ,NULL }; -if ( !PyArg_ParseTupleAndKeywords (args, kwds,"iiis|ssis" , kwd_list, +if ( !PyArg_ParseTupleAndKeywords (args, kwds,"iiis|ssiss#" , kwd_list, &dom, &store_evtchn, &console_evtchn, &image,/* optional */ &ramdisk, &cmdline, &flags, - &features) ) + &features, &arch_args, &unused) )return NULL ;if (xc_linux_build (self->xc_handle, dom, image, ramdisk, cmdline, features, flags, store_evtchn, &store_mfn, - console_evtchn, &console_mfn) !=0 ) { + console_evtchn, &console_mfn, arch_args) !=0 ) {if (!errno) errno =EINVAL ;return PyErr_SetFromErrno (xc_error);
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 5 lines · Hollis Blanchard
Keir, this patch applies on top of the
xc.cwhitespace patch I just sent, and also on top of the contents of xenppc-unstable-merge.hg (because we've movedxc_ppc_linux_build.cinto its own directory). We also have a couple important fixes in there anyways, so now would be a good time to pull. :)
The diffstat doesn't correspond to the patch. Can I ignore the diffstat?
-- Keir
Quoted 7 lines · Keir Fraser
Quoted 5 lines
Keir, this patch applies on top of the
xc.cwhitespace patch I just sent, and also on top of the contents of xenppc-unstable-merge.hg (because we've movedxc_ppc_linux_build.cinto its own directory). We also have a couple important fixes in there anyways, so now would be a good time to pull. :)The diffstat doesn't correspond to the patch. Can I ignore the diffstat?
Actually I'm not sure about this approach at all. Couldn't specifying the open firmware tree be done separately from the build (e.g., just after)? Maybe hooked off the new proposed 'platform object' in xend. Xc_linux_build is really ugly enough already: I think in future we would like to split xc_linux_build up into smaller API functions, even for x86, and that the patch you propose goes in the opposite direction to this.
-- Keir
Quoted 11 lines · Keir Fraser
Quoted 5 lines · Hollis Blanchard
Keir, this patch applies on top of the
xc.cwhitespace patch I just sent, and also on top of the contents of xenppc-unstable-merge.hg (because we've movedxc_ppc_linux_build.cinto its own directory). We also have a couple important fixes in there anyways, so now would be a good time to pull. :)The diffstat doesn't correspond to the patch. Can I ignore the diffstat?
Sorry for being unclear. The diffstat corresponds to the contents of the xenppc-unstable-merge.hg tree, which I was asking you to pull.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 7 lines · Keir Fraser
Actually I'm not sure about this approach at all. Couldn't specifying the open firmware tree be done separately from the build (e.g., just after)? Maybe hooked off the new proposed 'platform object' in xend.
Xc_linux_buildis really ugly enough already: I think in future we would like to splitxc_linux_buildup into smaller API functions, even for x86, and that the patch you propose goes in the opposite direction to this.
That direction certainly seems like a good one to me.
In this case, we need to load the device tree into the domain's memory and pass its address in a register (i.e. via xc_vcpu_setcontext). Currently it doesn't look like xc_vcpu_setcontext is exposed to python for us to use. What would you like to see here?
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 4 lines · Hollis Blanchard
Quoted 1 line
The diffstat doesn't correspond to the patch. Can I ignore the diffstat?
Sorry for being unclear. The diffstat corresponds to the contents of the xenppc-unstable-merge.hg tree, which I was asking you to pull.
Ah, I missed that bit.
-- Keir
Quoted 6 lines · Hollis Blanchard
That direction certainly seems like a good one to me.
In this case, we need to load the device tree into the domain's memory and pass its address in a register (i.e. via
xc_vcpu_setcontext). Currently it doesn't look likexc_vcpu_setcontextis exposed to python for us to use. What would you like to see here?
Hmmm... I was expecting you'd want a ppc-specific libxenguest or libxenctrl function, but I guess maybe you could do it by more generic means. That would obviously be much preferable if it's possible.
Could a copy_to/from_guest interface exposed to Python be used? Or does the device tree need some processing in C into an appropriate format for writing into guest memory? As for set/get_vcpu_context, the context could be expressed as a Python dictionary mapping register names to (reasonably constrained) long values.
-- Keir
Quoted 14 lines · Keir Fraser
Quoted 6 lines · Hollis Blanchard
That direction certainly seems like a good one to me.
In this case, we need to load the device tree into the domain's memory and pass its address in a register (i.e. via
xc_vcpu_setcontext). Currently it doesn't look likexc_vcpu_setcontextis exposed to python for us to use. What would you like to see here?Hmmm... I was expecting you'd want a ppc-specific libxenguest or libxenctrl function, but I guess maybe you could do it by more generic means. That would obviously be much preferable if it's possible.
Quoted 5 lines
Could a copy_to/from_guest interface exposed to Python be used? Or does the device tree need some processing in C into an appropriate format for writing into guest memory? As for set/get_vcpu_context, the context could be expressed as a Python dictionary mapping register names to (reasonably constrained) long values.
I spent some time building the proper binary format in Python (through lots of struct.pack and '\0'.join), so the C code doesn't need to reformat it.
However, there are a few values we only determine in C code that need to be inserted into the device tree:
- initrd start/end -- could be done in Python with an xc.copy_to_guest
- console_mfn/store_mfn -- chosen arbitrarily in C, so could just as easily be chosen arbitrarily in Python
Actually, I think that may be it... most of the data we can gather in Python or come directly from the domain config file.
I can implement xc.copy_to_guest() and wc.copy_from_guest() and do the initrd loading in Python (including using the gzip module). However, initrd loading in tools/libxc/xc_linux_build.c looks a little more complicated than I'd feel comfortable modifying without testing, and I'm not really set up to test x86 changes.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center