xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH V2 39/40] HACK: add simple xcbuild
Date: Tue, 26 Jun 2012 10:30:03 +0000	[thread overview]
Message-ID: <1340706604-1313-39-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1340706604-1313-1-git-send-email-ian.campbell@citrix.com>

Based on init-xenstore-domain.c.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 tools/xcutils/Makefile  |    6 ++-
 tools/xcutils/xcbuild.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 1 deletions(-)
 create mode 100644 tools/xcutils/xcbuild.c

diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile
index 6c502f1..dcd2c84 100644
--- a/tools/xcutils/Makefile
+++ b/tools/xcutils/Makefile
@@ -11,7 +11,7 @@
 XEN_ROOT	= $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-PROGRAMS = xc_restore xc_save readnotes lsevtchn
+PROGRAMS = xc_restore xc_save readnotes lsevtchn xcbuild
 
 CFLAGS += -Werror
 
@@ -19,6 +19,7 @@ CFLAGS_xc_restore.o := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_xc_save.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 CFLAGS_readnotes.o  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_lsevtchn.o   := $(CFLAGS_libxenctrl)
+CFLAGS_xcbuild.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 
 .PHONY: all
 all: build
@@ -32,6 +33,9 @@ xc_restore: xc_restore.o
 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)
+
 readnotes: readnotes.o
 	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
 
diff --git a/tools/xcutils/xcbuild.c b/tools/xcutils/xcbuild.c
new file mode 100644
index 0000000..54f5c38
--- /dev/null
+++ b/tools/xcutils/xcbuild.c
@@ -0,0 +1,100 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <errno.h>
+
+#include <xenctrl.h>
+#include <xentoollog.h>
+#include <xc_dom.h>
+
+int main(int argc, char **argv)
+{
+	xentoollog_logger *logger;
+	xc_interface *xch;
+	int rv;
+	const char *image;
+	uint32_t domid;
+	xen_domain_handle_t handle;
+	int maxmem = 128; /* MB */
+	int memory_kb = 2*(maxmem + 1)*1024; /* bit of slack... */
+	struct xc_dom_image *dom;
+
+	image = (argc < 2) ? "guest.img" : argv[1];
+	printf("Image: %s\n", image);
+	printf("Memory: %dKB\n", memory_kb);
+
+	logger = (xentoollog_logger*)
+		xtl_createlogger_stdiostream(stderr, XTL_DEBUG, 0);
+	if ( logger == NULL )
+	{
+		perror("xtl_createlogger_stdiostream");
+		exit(1);
+	}
+
+	xch = xc_interface_open(logger, logger, 0);
+	if ( xch == NULL )
+	{
+		perror("xc_interface_open");
+		exit(1);
+	}
+
+	rv = xc_dom_loginit(xch);
+	if (rv) return rv;
+
+	//rv = xc_flask_context_to_sid(xch, argv[3], strlen(argv[3]), &ssid);
+	//if (rv) return rv;
+
+	rv = xc_domain_create(xch, 0 /* ssid */, handle, 0 /* flags */, &domid);
+	printf("xc_domain_create: %d (%d)\n", rv, errno);
+	if ( rv < 0 )
+	{
+		perror("xc_domain_create");
+		exit(1);
+	}
+
+	printf("building dom%d\n", domid);
+
+	rv = xc_domain_max_vcpus(xch, domid, 1);
+	if ( rv < 0)
+	{
+		perror("xc_domain_max_vcpus");
+		exit(1);
+	}
+
+	rv = xc_domain_setmaxmem(xch, domid, memory_kb);
+	if ( rv < 0)
+	{
+		perror("xc_domain_setmaxmem");
+		exit(1);
+	}
+
+	dom = xc_dom_allocate(xch, "", NULL);
+	rv = xc_dom_kernel_file(dom, image);
+	if (rv) return rv;
+	rv = xc_dom_boot_xen_init(dom, xch, domid);
+	if (rv) return rv;
+	rv = xc_dom_parse_image(dom);
+	if (rv) return rv;
+	rv = xc_dom_mem_init(dom, 2*maxmem);/* XXX */
+	if (rv) return rv;
+	rv = xc_dom_boot_mem_init(dom);
+	if (rv) return rv;
+	rv = xc_dom_build_image(dom);
+	if (rv) return rv;
+	rv = xc_dom_boot_image(dom);
+	if (rv) return rv;
+
+	xc_dom_release(dom);
+
+	rv = xc_domain_unpause(xch, domid);
+	if ( rv )
+	{
+		perror("xc_domain_unpause");
+		exit(1);
+	}
+
+	xc_interface_close(xch);
+
+	return 0;
+}
-- 
1.7.9.1

  parent reply	other threads:[~2012-06-26 10:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 10:29 [PATCH 00/40 V2] arm: boot a dom1 to "Calibrating delay loop" then hang Ian Campbell
2012-06-26 10:29 ` [PATCH V2 01/40] arm: allocate top level p2m page for all non-idle domains Ian Campbell
2012-06-26 10:29   ` [PATCH V2 02/40] arm: handy function to print a walk of a page table Ian Campbell
2012-06-26 10:29   ` [PATCH V2 03/40] arm: correct and expand TLB flush CP15 registers Ian Campbell
2012-06-26 10:29   ` [PATCH V2 04/40] arm: restore stack on return from trap Ian Campbell
2012-06-26 10:29   ` [PATCH V2 05/40] arm: enable interrupts while handling traps Ian Campbell
2012-06-26 10:29   ` [PATCH V2 06/40] arm: hook up domctl and memory_op Ian Campbell
2012-06-26 10:29   ` [PATCH V2 07/40] arm: allocate and setup a guest vcpu Ian Campbell
2012-06-26 10:29   ` [PATCH V2 08/40] arm: print domid as part of debug trap Ian Campbell
2012-06-26 10:29   ` [PATCH V2 09/40] arm: remove unnecessarily verbose print from p2m_load_VTTBR Ian Campbell
2012-06-26 10:29   ` [PATCH V2 10/40] arm: implement p2m lookup Ian Campbell
2012-06-26 10:29   ` [PATCH V2 11/40] arm: remove hard tabs from init_idle_domain Ian Campbell
2012-06-26 10:29   ` [PATCH V2 12/40] arm: stub out sync_vcpu_execstate Ian Campbell
2012-06-26 10:29   ` [PATCH V2 13/40] arm: implement stub version of flush_tlb_mask Ian Campbell
2012-06-26 10:29   ` [PATCH V2 14/40] arm: do not set max_vcpus = 8 in arch_domain_create Ian Campbell
2012-06-26 10:29   ` [PATCH V2 15/40] arm: Add simple cpu_{sibling, core}_mask Ian Campbell
2012-06-26 10:29   ` [PATCH V2 16/40] arm: allow p2m to be created with specific MATTR Ian Campbell
2012-06-28 12:46     ` Ian Campbell
2012-06-28 13:00     ` Stefano Stabellini
2012-06-26 10:29   ` [PATCH V2 17/40] arm: implement vpl011 (UART) emulator Ian Campbell
2012-06-28 11:00     ` Tim Deegan
2012-06-26 10:29   ` [PATCH V2 18/40] arm: context switch a bunch of guest state Ian Campbell
2012-06-26 10:29   ` [PATCH V2 19/40] arm: dump a page table walk when va_to_par fails Ian Campbell
2012-06-26 10:29   ` [PATCH V2 20/40] arm: dump guest s1 walk on data abort which is not a stage 2 issue Ian Campbell
2012-06-26 10:29   ` [PATCH V2 21/40] arm: implement vcpu_show_execution_state Ian Campbell
2012-06-28 13:04     ` Stefano Stabellini
2012-06-26 10:29   ` [PATCH V2 22/40] arm: use correct attributes for mappings in copy_from_paddr() Ian Campbell
2012-06-26 10:29   ` [PATCH V2 23/40] arm: map fixmaps non-executable Ian Campbell
2012-06-26 10:29   ` [PATCH V2 24/40] arm: fix locking in create_p2m_entries Ian Campbell
2012-06-26 10:29   ` [PATCH V2 25/40] arm: split pending SPIs (global) out from pending PPIs and SGIs (per CPU) Ian Campbell
2012-06-28 13:08     ` Stefano Stabellini
2012-06-26 10:29   ` [PATCH V2 26/40] arm: use interrupt safe spin locks in vgic_vcpu_inject_irq Ian Campbell
2012-06-28 13:06     ` Stefano Stabellini
2012-06-26 10:29   ` [PATCH V2 27/40] arm: map GICV in all domains, not just dom0 Ian Campbell
2012-06-26 10:29   ` [PATCH V2 28/40] arm: enable data-cache at the same time as enabling the MMU, not before Ian Campbell
2012-06-28 11:02     ` Tim Deegan
2012-06-26 10:29   ` [PATCH V2 29/40] arm: Upgrade guest barriers to Outer-Shareable. Enable Protected Table Walk Ian Campbell
2012-06-26 10:29   ` [PATCH V2 30/40] arm: gic.lock can be taken in interrupt context, so lock appropriately Ian Campbell
2012-06-26 10:29   ` [PATCH V2 31/40] arm: context switch virtual timer registers Ian Campbell
2012-06-26 10:29   ` [PATCH V2 32/40] arm: the hyp timer seems to work in newer model versions, default to using it Ian Campbell
2012-06-26 10:29   ` [PATCH V2 33/40] arm: unwind allocations etc on arch_domain_create_failure Ian Campbell
2012-06-28 11:05     ` Tim Deegan
2012-06-26 10:29   ` [PATCH V2 34/40] HACK: arm: initial XENMAPSPACE_gmfn_foreign Ian Campbell
2012-06-26 10:29   ` [PATCH V2 35/40] arm: move PSR flag definitions into interface, for tools use Ian Campbell
2012-06-26 10:30   ` [PATCH V2 36/40] libxc: add ARM support to xc_dom (PV domain building) Ian Campbell
2012-06-26 10:30   ` [PATCH V2 37/40] arm: implement VGCF_online Ian Campbell
2012-06-28 11:06     ` Tim Deegan
2012-06-26 10:30   ` [PATCH V2 38/40] arm: fix typo s/approprately/appropriately/g Ian Campbell
2012-06-26 10:30   ` Ian Campbell [this message]
2012-06-26 10:30   ` [PATCH V2 40/40] HACK: arm: disable hypercall continuations Ian Campbell
2012-06-26 15:26 ` [PATCH 00/40 V2] arm: boot a dom1 to "Calibrating delay loop" then hang Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340706604-1313-39-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).