Mailing List Archive

[PATCH 05/18] tools/libxl: pull xenstore/console domids from xenstore
Instead of assuming that xenstored and xenconsoled are running in dom0,
pull the domain IDs from xenstore.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---
tools/libxl/libxl_dom.c | 14 ++++++++++++--
tools/libxl/libxl_internal.h | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index a4725fe..5e39595 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -73,6 +73,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
{
libxl_ctx *ctx = libxl__gc_owner(gc);
int tsc_mode;
+ char *xs_domid, *con_domid;
xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
if (info->type == LIBXL_DOMAIN_TYPE_PV)
@@ -104,9 +105,18 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
}

- state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0);
- state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0);
+ xs_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenstored/domid", NULL);
+ state->store_domid = xs_domid ? atoi(xs_domid) : 0;
+ free(xs_domid);
+
+ con_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenconsoled/domid", NULL);
+ state->console_domid = con_domid ? atoi(con_domid) : 0;
+ free(con_domid);
+
+ state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->store_domid);
+ state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid);
state->vm_generationid_addr = 0;
+
return 0;
}

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 288c03c..97ead08 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -219,9 +219,11 @@ _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
libxl__domain_type((gc), (domid)) == LIBXL_DOMAIN_TYPE_##type
typedef struct {
uint32_t store_port;
+ uint32_t store_domid;
unsigned long store_mfn;

uint32_t console_port;
+ uint32_t console_domid;
unsigned long console_mfn;
unsigned long vm_generationid_addr;
} libxl__domain_build_state;
--
1.7.7.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH 05/18] tools/libxl: pull xenstore/console domids from xenstore [ In reply to ]
On Thu, 2012-01-12 at 23:35 +0000, Daniel De Graaf wrote:
> Instead of assuming that xenstored and xenconsoled are running in dom0,
> pull the domain IDs from xenstore.
>
> Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

I'm not sure we need to carry these around in the build state, since
they can just be looked up (perhaps by helper functions) but
nevertheless:

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

> ---
> tools/libxl/libxl_dom.c | 14 ++++++++++++--
> tools/libxl/libxl_internal.h | 2 ++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index a4725fe..5e39595 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -73,6 +73,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> {
> libxl_ctx *ctx = libxl__gc_owner(gc);
> int tsc_mode;
> + char *xs_domid, *con_domid;
> xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
> xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
> if (info->type == LIBXL_DOMAIN_TYPE_PV)
> @@ -104,9 +105,18 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
> }
>
> - state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0);
> - state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0);
> + xs_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenstored/domid", NULL);
> + state->store_domid = xs_domid ? atoi(xs_domid) : 0;
> + free(xs_domid);
> +
> + con_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenconsoled/domid", NULL);
> + state->console_domid = con_domid ? atoi(con_domid) : 0;
> + free(con_domid);
> +
> + state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->store_domid);
> + state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid);
> state->vm_generationid_addr = 0;
> +
> return 0;
> }
>
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 288c03c..97ead08 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -219,9 +219,11 @@ _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
> libxl__domain_type((gc), (domid)) == LIBXL_DOMAIN_TYPE_##type
> typedef struct {
> uint32_t store_port;
> + uint32_t store_domid;
> unsigned long store_mfn;
>
> uint32_t console_port;
> + uint32_t console_domid;
> unsigned long console_mfn;
> unsigned long vm_generationid_addr;
> } libxl__domain_build_state;



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