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

Re: [Xen-devel] [PATCH 5/5] xcbuild: add console and xenstore support



Do you not have libxl and friends up and running sufficiently to use?
This xcbuild was really just intended to tide us over until that stuff
worked, not to be an actual thing...

On Fri, 2012-06-22 at 17:09 +0100, Stefano Stabellini wrote:
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> ---
>  tools/xcutils/Makefile  |    4 +-
>  tools/xcutils/xcbuild.c |   58 
> ++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 59 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile
> index 92c5a68..c88f286 100644
> --- a/tools/xcutils/Makefile
> +++ b/tools/xcutils/Makefile
> @@ -20,7 +20,7 @@ CFLAGS_xc_save.o    := $(CFLAGS_libxenctrl) 
> $(CFLAGS_libxenguest) $(CFLAGS_libxe
>  CFLAGS_readnotes.o  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
>  CFLAGS_lsevtchn.o   := $(CFLAGS_libxenctrl)
>  CFLAGS_xcversion.o  := $(CFLAGS_libxenctrl)
> -CFLAGS_xcbuild.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
> +CFLAGS_xcbuild.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) 
> $(CFLAGS_libxenstore)
>  
>  .PHONY: all
>  all: build
> @@ -35,7 +35,7 @@ xc_save: xc_save.o
>       $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
>  
>  xcbuild: xcbuild.o
> -     $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(APPEND_LDFLAGS)
> +     $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
>  
>  readnotes: readnotes.o
>       $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(APPEND_LDFLAGS)
> diff --git a/tools/xcutils/xcbuild.c b/tools/xcutils/xcbuild.c
> index a70c3ca..7b5c0f8 100644
> --- a/tools/xcutils/xcbuild.c
> +++ b/tools/xcutils/xcbuild.c
> @@ -1,6 +1,7 @@
>  #include <unistd.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> +#include <string.h>
>  
>  #include <errno.h>
>  
> @@ -8,6 +9,7 @@
>  //#include <xenguest.h>
>  #include <xentoollog.h>
>  #include <xc_dom.h>
> +#include <xenstore.h>
>  
>  int main(int argc, char **argv)
>  {
> @@ -15,11 +17,19 @@ int main(int argc, char **argv)
>       xc_interface *xch;
>       int rv;
>       const char *image;
> -     uint32_t domid;
> +     uint32_t domid = 1;
>       xen_domain_handle_t handle;
>       int maxmem = 128; /* MB */ //atoi(argv[2]);
>       int memory_kb = 2*(maxmem + 1)*1024; /* bit of slack... */
>       struct xc_dom_image *dom;
> +     unsigned long console_mfn;
> +     unsigned long console_port;
> +     unsigned long store_mfn;
> +     unsigned long store_port;
> +     struct xs_handle *xs;
> +     char *dom_path;
> +     char path[256];
> +     char val[256];
>  
>       image = (argc < 2) ? "guest.img" : argv[1];
>       printf("Image: %s\n", image);
> @@ -103,6 +113,52 @@ int main(int argc, char **argv)
>       if (rv) return rv;
>       rv = xc_dom_build_image(dom);
>       if (rv) return rv;
> +
> +     xc_get_hvm_param(xch, domid, HVM_PARAM_CONSOLE_PFN, &console_mfn);
> +     console_port = xc_evtchn_alloc_unbound(xch, domid, 0);
> +     xc_set_hvm_param(xch, domid, HVM_PARAM_CONSOLE_EVTCHN, console_port);
> +
> +     xc_get_hvm_param(xch, domid, HVM_PARAM_STORE_PFN, &store_mfn);
> +     store_port = xc_evtchn_alloc_unbound(xch, domid, 0);
> +     xc_set_hvm_param(xch, domid, HVM_PARAM_STORE_EVTCHN, store_port);
> +     xs = xs_daemon_open();
> +     if (xs == NULL) {
> +             printf("Could not contact XenStore");
> +             return errno;
> +     }
> +     dom_path = xs_get_domain_path(xs, domid);
> +
> +     snprintf(path, sizeof(path), "%s/console/port", dom_path);
> +     snprintf(val, sizeof(val), "%lu", console_port);
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/console/ring-ref", dom_path);
> +     snprintf(val, sizeof(val), "%lu", console_mfn);
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/console/type", dom_path);
> +     snprintf(val, sizeof(val), "xenconsoled");
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/console/output", dom_path);
> +     snprintf(val, sizeof(val), "pty");
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/console/limit", dom_path);
> +     snprintf(val, sizeof(val), "%d", 1048576);
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/store/port", dom_path);
> +     snprintf(val, sizeof(val), "%lu", store_port);
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +
> +     snprintf(path, sizeof(path), "%s/store/ring-ref", dom_path);
> +     snprintf(val, sizeof(val), "%lu", store_mfn);
> +     xs_write(xs, XBT_NULL, path, val, strlen(val));
> +     xs_introduce_domain(xs, domid, store_mfn, store_port);
> +
> +     xs_daemon_close(xs);
> +
>       rv = xc_dom_boot_image(dom);
>       if (rv) return rv;
>  



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