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

Re: [Xen-devel] [PATCH 11/11] libxl, xl: add event_channels option to xl configuration file



On Wed, 2013-10-02 at 17:36 +0100, David Vrabel wrote:
> From: David Vrabel <david.vrabel@xxxxxxxxxx>
> 
> Add the 'event_channels' option to the xl configuration file to limit
> the number of event channels that domain may use.
> 
> Plumb this option through to libxl via a new libxl_build_info field
> and call xc_domain_set_max_evtchn() in the post build stage of domain
> creation.
> 
> A new LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS #define indicates that this
> new field is available.
> 
> The default value of 1023 limits the domain to using the minimum
> amount of global mapping pages and at most 5 xenheap pages.
> 
> Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>

Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

I'm happy for whoever commits the rest of the series to take this one
too.

> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> ---
>  docs/man/xl.cfg.pod.5       |   11 +++++++++++
>  tools/libxl/libxl.h         |    5 +++++
>  tools/libxl/libxl_create.c  |    3 +++
>  tools/libxl/libxl_dom.c     |    7 +++++++
>  tools/libxl/libxl_types.idl |    1 +
>  tools/libxl/xl_cmdimpl.c    |    3 +++
>  6 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
> index d57cd4d..6312eb0 100644
> --- a/docs/man/xl.cfg.pod.5
> +++ b/docs/man/xl.cfg.pod.5
> @@ -572,6 +572,17 @@ Allow a guest to access specific physical IRQs.
>  It is recommended to use this option only for trusted VMs under
>  administrator control.
>  
> +=item B<max_event_channels=N>
> +
> +Limit the guest to using at most N event channels (PV interrupts).
> +Guests use hypervisor resources for each event channel they use.
> +
> +The default of 1023 should be sufficient for typical guests.  The
> +maximum value depends what the guest supports.  Guests supporting the
> +FIFO-based event channel ABI support up to 131,071 event channels.
> +Other guests are limited to 4095 (64-bit x86 and ARM) or 1023 (32-bit
> +x86).
> +
>  =back
>  
>  =head2 Paravirtualised (PV) Guest Specific Options
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 4cab294..30712c2 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -90,6 +90,11 @@
>  #define LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE 1
>  
>  /*
> + * The libxl_domain_build_info has the event_channels field.
> + */
> +#define LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS 1
> +
> +/*
>   * libxl ABI compatibility
>   *
>   * The only guarantee which libxl makes regarding ABI compatibility
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index 7567238..790eb32 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -208,6 +208,9 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
>  
>      libxl_defbool_setdefault(&b_info->disable_migrate, false);
>  
> +    if (!b_info->event_channels)
> +        b_info->event_channels = 1023;
> +
>      switch (b_info->type) {
>      case LIBXL_DOMAIN_TYPE_HVM:
>          if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index 6e2252a..356f920 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -268,6 +268,13 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
>      if (rc)
>          return rc;
>  
> +    rc = xc_domain_set_max_evtchn(ctx->xch, domid, info->event_channels);
> +    if (rc) {
> +        LOG(ERROR, "Failed to set event channel limit to %d (%d)",
> +            info->event_channels, rc);
> +        return ERROR_FAIL;
> +    }
> +
>      libxl_cpuid_apply_policy(ctx, domid);
>      if (info->cpuid != NULL)
>          libxl_cpuid_set(ctx, domid, info->cpuid);
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index 049dbb5..7bf517d 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -308,6 +308,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>      ("irqs",             Array(uint32, "num_irqs")),
>      ("iomem",            Array(libxl_iomem_range, "num_iomem")),
>      ("claim_mode",        libxl_defbool),
> +    ("event_channels",   uint32),
>      ("u", KeyedUnion(None, libxl_domain_type, "type",
>                  [("hvm", Struct(None, [("firmware",         string),
>                                         ("bios",             libxl_bios_type),
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 642b130..c54b44e 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -813,6 +813,9 @@ static void parse_config_data(const char *config_source,
>      if (!xlu_cfg_get_long (config, "videoram", &l, 0))
>          b_info->video_memkb = l * 1024;
>  
> +    if (!xlu_cfg_get_long(config, "max_event_channels", &l, 0))
> +        b_info->event_channels = l;
> +
>      switch(b_info->type) {
>      case LIBXL_DOMAIN_TYPE_HVM:
>          if (!xlu_cfg_get_string (config, "kernel", &buf, 0))



_______________________________________________
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®.