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

Re: [Xen-devel] [PATCH 5 of 6] xend/xc: Implement a domain_set_e820_hole function to be used by python code



On Sat, 2012-03-24 at 17:41 +0000, Konrad Rzeszutek Wilk wrote:
> # HG changeset patch
> # User Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> # Date 1332610898 14400
> # Node ID 95eda76084314aa8a5cfd4b5e83969823492deda
> # Parent  d42921da3931026ecf5da7c0e5bb86074e77cf71
> xend/xc: Implement a domain_set_e820_hole function to be used by python code
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> 
> diff -r d42921da3931 -r 95eda7608431 tools/python/xen/lowlevel/xc/xc.c
> --- a/tools/python/xen/lowlevel/xc/xc.c       Sat Mar 24 13:41:38 2012 -0400
> +++ b/tools/python/xen/lowlevel/xc/xc.c       Sat Mar 24 13:41:38 2012 -0400
> @@ -16,6 +16,7 @@
>  #include <sys/mman.h>
>  #include <netdb.h>
>  #include <arpa/inet.h>
> +#include <stdio.h>
>  
>  #include "xenctrl.h"
>  #include <xen/elfnote.h>
> @@ -1697,6 +1698,243 @@ static PyObject *pyxc_domain_set_memmap_
>      return zero;
>  }
>  
> +#ifdef PRIu64

This is a really weird condition -- when / where does this end up not
defined?

Perhaps you see this depending on platform? In which case is this just a
case of including the right header (stdint.h?) directly instead of
implicitly via some arch dependent chain of includes?

> +static const char *e820_names(int type)
> +{
> +    switch (type) {
> +        case E820_RAM: return "RAM";
> +        case E820_RESERVED: return "Reserved";
> +        case E820_ACPI: return "ACPI";
> +        case E820_NVS: return "ACPI NVS";
> +        case E820_UNUSABLE: return "Unusable";
> +        default: break;
> +    }
> +    return "Unknown";
> +}
> +#endif
> +static int e820_sanitize(struct e820entry src[],
> +                         uint32_t *nr_entries,
> +                         unsigned long map_limitkb,
> +                         unsigned long balloon_kb)
> +{

Seems odd to do this in the C bindings, can this be done either in the
python layer or in the libxc layer (in which case libxl can use it too?)

[...]
> +}
> +
> +static PyObject *pyxc_domain_set_e820_hole(XcObject *self, PyObject *args)
> +{
> +    uint32_t dom, nr;
> +    unsigned int target_kb;
> +    unsigned int balloon_kb;
> +    int rc;
> +    struct e820entry map[E820MAX];
> +
> +    if ( !PyArg_ParseTuple(args, "iii", &dom, &target_kb, &balloon_kb) )
> +        return NULL;
> +
> +    rc = xc_get_machine_memory_map(self->xc_handle, map, E820MAX);
> +     if (rc < 0)
> +        return pyxc_error_to_exception(self->xc_handle);
> +
> +     nr = rc;
> +     rc = e820_sanitize(map, &nr, target_kb, balloon_kb);
> +     if (rc)
> +        return pyxc_error_to_exception(self->xc_handle);
> +
> +     rc = xc_domain_set_memory_map(self->xc_handle, dom, map, nr);
> +     if (rc < 0)
> +        return pyxc_error_to_exception(self->xc_handle);
> +
> +    Py_INCREF(zero);
> +    return zero;
> +}
> +
>  static PyObject *pyxc_domain_ioport_permission(XcObject *self,
>                                                 PyObject *args,
>                                                 PyObject *kwds)
> @@ -2701,6 +2939,15 @@ static PyMethodDef pyxc_methods[] = {
>        " map_limitkb [int]: .\n"
>        "Returns: [int] 0 on success; -1 on error.\n" },
>  
> +    { "domain_set_e820_hole", 
> +      (PyCFunction)pyxc_domain_set_e820_hole, 
> +      METH_VARARGS, "\n"
> +      "Set a domain's E820 memory map\n"
> +      " dom [int]: Identifier of domain.\n"
> +      " target_memkb [int]: .\n"
> +      " balloon_kb [int]: .\n"
> +      "Returns: [int] 0 on success; -1 on error.\n" },
> +
>  #ifdef __ia64__
>      { "nvram_init",
>        (PyCFunction)pyxc_nvram_init,
> 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.