All of lore.kernel.org
 help / color / mirror / Atom feed
* Unable to bring up Mini-OS on x86_64
@ 2006-05-16 19:57 Puthiyaparambil, Aravindh
  2006-05-16 20:43 ` Keir Fraser
  2006-05-16 21:05 ` Chris Wright
  0 siblings, 2 replies; 8+ messages in thread
From: Puthiyaparambil, Aravindh @ 2006-05-16 19:57 UTC (permalink / raw)
  To: xen-devel

I am getting the following error when I try to bring up Mini-OS on x86_64 Xen (unstable: 9994). It is dying in xc_linux_build() causing xend to fault and restart. Any clue why this happening? Has something changed in the builder that Mini-OS needs to be aware of?

PS: I tried reverting changeset 9993 (Allow linking of mini-os with application-specific object code), but still got the same error

Thanks,

Aravindh Puthiyaparambil
Xen Development Team
Unisys, Tredyffrin, PA
E-Mail:  aravindh.puthiyaparambil@unisys.com 

xenbox:~/xen/xen-unstable/extras/mini-os # xm create domain_config Using config file "domain_config".
Error: <ProtocolError for /RPC2: -1 >

Dmesg
-----
xenbox kernel: python[12171] general protection rip:2b14fba3776e rsp:427ff7d0 error:0

Xend.log
--------
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:186) XendDomainInfo.create(['vm', ['name', 'Mini-OS'], ['memory', 32], ['on_crash', 'destroy'], ['vcpus', 1], ['image', ['linux', ['kernel', '/root/xen/xen-unstable.hg/extras/mini-os/mini-os.elf']]]])
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:292) parseConfig: config is ['vm', ['name', 'Mini-OS'], ['memory', 32], ['on_crash', 'destroy'], ['vcpus', 1], ['image', ['linux', ['kernel', '/root/xen/xen-unstable.hg/extras/mini-os/mini-os.elf']]]]
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:391) parseConfig: result is {'uuid': None, 'on_crash': 'destroy', 'on_reboot': None, 'image': ['linux', ['kernel', '/root/xen/xen-unstable.hg/extras/mini-os/mini-os.elf']], 'on_poweroff': None, 'bootloader_args': None, 'cpus': None, 'name': 'Mini-OS', 'backend': [], 'vcpus': 1, 'cpu_weight': None, 'features': None, 'vcpu_avail': None, 'memory': 32, 'device': [], 'bootloader': None, 'cpu': None, 'maxmem': None}
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:1229) XendDomainInfo.construct: None
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:1261) XendDomainInfo.initDomain: 1 1.0
[2006-05-16 13:30:55 xend] DEBUG (balloon:126) Balloon: free 3705; need 33; done.
[2006-05-16 13:30:55 xend] INFO (image:133) buildDomain os=linux dom=1 vcpus=1
[2006-05-16 13:30:55 xend] DEBUG (image:171) dom            = 1
[2006-05-16 13:30:55 xend] DEBUG (image:172) image          = /root/xen/xen-unstable.hg/extras/mini-os/mini-os.elf
[2006-05-16 13:30:55 xend] DEBUG (image:173) store_evtchn   = 1
[2006-05-16 13:30:55 xend] DEBUG (image:174) console_evtchn = 2
[2006-05-16 13:30:55 xend] DEBUG (image:175) cmdline        =
[2006-05-16 13:30:55 xend] DEBUG (image:176) ramdisk        =
[2006-05-16 13:30:55 xend] DEBUG (image:177) vcpus          = 1
[2006-05-16 13:30:55 xend] DEBUG (image:178) features       =
[2006-05-16 13:30:55 xend] CRITICAL (SrvDaemon:195) Xend died due to signal 11!  Restarting it.
[2006-05-16 13:30:55 xend] INFO (SrvDaemon:283) Xend Daemon started
[2006-05-16 13:30:55 xend] INFO (SrvDaemon:287) Xend changeset: Tue May 16 09:08:06 2006 +0100 9994:4fd6ba0e3336.
[2006-05-16 13:30:55 xend.XendDomainInfo] DEBUG (XendDomainInfo:208) XendDomainInfo.recreate({'paused': 0, 'cpu_time': 128897604096L, 'ssidref': 0, 'handle': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'shutdown_reason': 0, 'dying': 0, 'dom': 0, 'mem_kb': 257024, 'maxmem_kb': 17179869180, 'max_vcpu_id': 3, 'crashed': 0, 'running': 1, 'shutdown': 0, 'online_vcpus': 1, 'blocked': 0})
[2006-05-16 13:30:55 xend.XendDomainInfo] INFO (XendDomainInfo:220) Recreating domain 0, UUID 00000000-0000-0000-0000-000000000000.
[2006-05-16 13:30:56 xend] DEBUG (XendDomain:153) number of vcpus to use is 0
[2006-05-16 13:30:56 xend.XendDomainInfo] DEBUG (XendDomainInfo:208) XendDomainInfo.recreate({'paused': 1, 'cpu_time': 0L, 'ssidref': 0, 'handle': [41, 26, 222, 114, 44, 108, 25, 70, 96, 32, 205, 220, 180, 114, 246, 3], 'shutdown_reason': 0, 'dying': 0, 'dom': 1, 'mem_kb': 32768, 'maxmem_kb': 32768, 'max_vcpu_id': 0, 'crashed': 0, 'running': 0, 'shutdown': 0, 'online_vcpus': 1, 'blocked': 0})
[2006-05-16 13:30:56 xend.XendDomainInfo] INFO (XendDomainInfo:220) Recreating domain 1, UUID 291ade72-2c6c-1946-6020-cddcb472f603.
[2006-05-16 13:30:56 xend.XendDomainInfo] DEBUG (XendDomainInfo:702) Storing VM details: {'name': 'Domain-1', 'on_reboot': 'restart', 'image': '()', 'on_poweroff': 'destroy', 'uuid': '291ade72-2c6c-1946-6020-cddcb472f603', 'on_crash': 'restart', 'vcpus': '1', 'vcpu_avail': '1', 'memory': '32', 'maxmem': '32'}
[2006-05-16 13:30:56 xend.XendDomainInfo] DEBUG (XendDomainInfo:727) Storing domain details: {'cpu/0/availability': 'online', 'memory/target': '32768', 'name': 'Domain-1', 'console/limit': '1048576', 'vm': '/vm/291ade72-2c6c-1946-6020-cddcb472f603', 'domid': '1'}
[2006-05-16 13:30:56 xend.XendDomainInfo] DEBUG (XendDomainInfo:910) XendDomainInfo.handleShutdownWatch
[2006-05-16 13:30:56 xend.XendDomainInfo] DEBUG (XendDomainInfo:910) XendDomainInfo.handleShutdownWatch
[2006-05-16 13:31:04 xend.XendDomainInfo] DEBUG (XendDomainInfo:1397) XendDomainInfo.destroy: domid=1
[2006-05-16 13:31:04 xend.XendDomainInfo] DEBUG (XendDomainInfo:1405) XendDomainInfo.destroyDomain(1)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Unable to bring up Mini-OS on x86_64
  2006-05-16 19:57 Unable to bring up Mini-OS on x86_64 Puthiyaparambil, Aravindh
@ 2006-05-16 20:43 ` Keir Fraser
  2006-05-16 21:05 ` Chris Wright
  1 sibling, 0 replies; 8+ messages in thread
From: Keir Fraser @ 2006-05-16 20:43 UTC (permalink / raw)
  To: Puthiyaparambil, Aravindh; +Cc: xen-devel


On 16 May 2006, at 20:57, Puthiyaparambil, Aravindh wrote:

> I am getting the following error when I try to bring up Mini-OS on 
> x86_64 Xen (unstable: 9994). It is dying in xc_linux_build() causing 
> xend to fault and restart. Any clue why this happening? Has something 
> changed in the builder that Mini-OS needs to be aware of?
>
> PS: I tried reverting changeset 9993 (Allow linking of mini-os with 
> application-specific object code), but still got the same error

Whatever the problem is, it'd be good to fix whatever bug this is 
triggering in the builder as well as fixing mini-os (although maybe the 
bug is solely in the builder). It shouldn't be possible for bogus 
kernel images to kill xend, although I'm sure xc_linux_build() has 
various holes in this respect. It'd be nice to fix them as we find them 
though.

  -- Keir

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Unable to bring up Mini-OS on x86_64
  2006-05-16 19:57 Unable to bring up Mini-OS on x86_64 Puthiyaparambil, Aravindh
  2006-05-16 20:43 ` Keir Fraser
@ 2006-05-16 21:05 ` Chris Wright
  1 sibling, 0 replies; 8+ messages in thread
From: Chris Wright @ 2006-05-16 21:05 UTC (permalink / raw)
  To: Puthiyaparambil, Aravindh; +Cc: xen-devel

> xenbox:~/xen/xen-unstable/extras/mini-os # xm create domain_config Using config file "domain_config".
> Error: <ProtocolError for /RPC2: -1 >

I got this as well with Linux a few days ago after a pull and rebuild.
Fix for me was a clean slate, rebuild must've had a bad dependency
somehwere.  So a simple:
   make -C tools clean && make -C tools && sudo make -C tools install
fixed it.  I didn't actually have the time to track the dependency
breakage in tools/

thanks,
-chris

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Unable to bring up Mini-OS on x86_64
@ 2006-05-17  0:46 Puthiyaparambil, Aravindh
  2006-05-17 11:48 ` Jacob Gorm Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: Puthiyaparambil, Aravindh @ 2006-05-17  0:46 UTC (permalink / raw)
  To: Chris Wright, Keir Fraser; +Cc: xen-devel

> > xenbox:~/xen/xen-unstable/extras/mini-os # xm create domain_config
Using
> config file "domain_config".
> > Error: <ProtocolError for /RPC2: -1 >
> 
> I got this as well with Linux a few days ago after a pull and rebuild.
> Fix for me was a clean slate, rebuild must've had a bad dependency
> somehwere.  So a simple:
>    make -C tools clean && make -C tools && sudo make -C tools install
> fixed it.

I did a fresh clone and a build and I am still running into the same
issue. So it looks like there is a bug in xc_linux_build() and/or
Mini-OS.

What is the best way to debug libxc? I usually do fprintf(stderr,...)
and the output shows up in xend-debug.log. But it is very flaky as
sometimes messages are overwritten. Is there a better way to do prints?

Thanks,
Aravindh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Unable to bring up Mini-OS on x86_64
  2006-05-17  0:46 Puthiyaparambil, Aravindh
@ 2006-05-17 11:48 ` Jacob Gorm Hansen
  0 siblings, 0 replies; 8+ messages in thread
From: Jacob Gorm Hansen @ 2006-05-17 11:48 UTC (permalink / raw)
  To: Puthiyaparambil, Aravindh; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

On 5/17/06, Puthiyaparambil, Aravindh <aravindh.puthiyaparambil@unisys.com>

> I did a fresh clone and a build and I am still running into the same
> issue. So it looks like there is a bug in xc_linux_build() and/or
> Mini-OS.
>
> What is the best way to debug libxc? I usually do fprintf(stderr,...)
> and the output shows up in xend-debug.log. But it is very flaky as
> sometimes messages are overwritten. Is there a better way to do prints?

I would recommend writing a small c program that calls libxc directly,
that will save you a bunch of time fighting the python/xend logging.

I have attached a patch with my own hand-rolled tools as an example.
The most interesting one is buscreate, which reads a config-file like:

kernel=/home/jacobg/xen-3.0-testing2.hg/linux-2.6.16-xen/vmlinux
mem=16
maxmem=16
console=1
initrd=/home/jacobg/domUinitrd
cmdline=mem=16M init=/linuxrc root=/dev/ram xencons=ttyS0
vbd=706,301,w

- and creates a domain without needing xend at all. xenstored and
xenconsoled need to be running though.

Jacob

[-- Attachment #2: migrationtools --]
[-- Type: application/octet-stream, Size: 21115 bytes --]

diff -r 0bfe5613711a tools/Makefile
--- a/tools/Makefile	Thu May 11 10:43:24 2006 +0200
+++ b/tools/Makefile	Tue May 16 10:35:46 2006 +0200
@@ -13,6 +13,7 @@ SUBDIRS += console
 SUBDIRS += console
 SUBDIRS += xenmon
 SUBDIRS += guest-headers
+SUBDIRS += migrate
 ifeq ($(VTPM_TOOLS),y)
 SUBDIRS += vtpm_manager
 SUBDIRS += vtpm
diff -r 0bfe5613711a tools/migrate/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/Makefile	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,73 @@
+XEN_ROOT=../..
+include $(XEN_ROOT)/tools/Rules.mk
+XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
+
+INSTALL		= install
+INSTALL_PROG	= $(INSTALL) -m0755
+INSTALL_DATA	= $(INSTALL) -m0644
+INSTALL_DIR	= $(INSTALL) -d -m0755
+
+MAJOR    = 3.0
+MINOR    = 0
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BASECFLAGS=-Wall -g -Werror
+# Make gcc generate dependencies.
+BASECFLAGS += -Wp,-MD,.$(@F).d
+PROG_DEP = .*.d
+BASECFLAGS+= $(PROFILE)
+BASECFLAGS+= -I$(XEN_ROOT)/tools/libxc -I$(XEN_ROOT)/tools/xenstore
+BASECFLAGS+= -I.
+CFLAGS  += $(BASECFLAGS)
+
+LDFLAGS += $(PROFILE) -L$(XEN_LIBXC)
+
+# Get gcc to generate the dependencies for us.
+CFLAGS   += -Wp,-MD,.$(@F).d
+LDFLAGS  += -L. -L$(XEN_XC) -L$(XEN_ROOT)/tools/xenstore
+DEPS     = .*.d
+
+LDLIBS := -lxenctrl -lxenguest -lxenstore
+
+EXES := pack repair minimig buscreate purgedoms listdoms xdmesg
+
+all: $(EXES)
+
+pack: pack.o
+	$(LINK.o) $^ -o $@
+
+repair: repair.o
+	$(LINK.o) $^ -o $@
+
+buscreate: buscreate.o configfile.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -o $@
+
+listdoms: listdoms.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -o $@
+
+purgedoms: purgedoms.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -o $@
+
+xdmesg: xdmesg.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -o $@
+
+minimig: minimig.o
+	$(LINK.o) $^ -static -o $@
+
+install:
+	$(INSTALL_PROG) buscreate $(DESTDIR)/usr/sbin
+	$(INSTALL_PROG) listdoms $(DESTDIR)/usr/sbin
+	$(INSTALL_PROG) purgedoms $(DESTDIR)/usr/sbin
+	$(INSTALL_PROG) repair $(DESTDIR)/usr/sbin
+
+.PHONY: TAGS clean rpm install all
+
+TAGS:
+	etags -t *.c *.h
+
+clean:
+	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS)
+	rm $(EXES)
+
diff -r 0bfe5613711a tools/migrate/buscreate.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/buscreate.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,337 @@
+#include <xenctrl.h>
+#include <xenguest.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <xs.h>
+#include <fcntl.h>
+
+#include "configfile.h"
+#include "xenutil.h"
+#include "evtchn.h"
+
+
+int xc;
+struct xs_handle *xs;
+xs_transaction_t t;
+int evtchn_fd;
+
+#define xs_w(a,b) xs_write(xs,t,a,b,strlen(b))
+//#define xs_w(a,b) printf("%s <- %s\n",a,b); xs_write(xs,t,a,b,strlen(b))
+#define xs_begin() t = xs_transaction_start(xs)
+#define xs_end() xs_transaction_end(xs,t,0)
+
+void setup_console(int domid, int rconsole, unsigned long mfn_console)
+{
+	char s[256];
+	char s2[256];
+	char* home = xs_get_domain_path(xs,domid);
+
+	printf("dom %d home %s\n",domid,home);
+
+	xs_begin();
+	sprintf(s,"%s/domid",home);
+	sprintf(s2,"%d",domid);
+	xs_w(s,s2);
+
+	sprintf(s,"%s/console/ring-ref",home);
+	sprintf(s2,"%lu",mfn_console);
+	xs_w(s, s2 );
+
+	sprintf(s,"%s/console/port",home);
+	sprintf(s2,"%d",rconsole);
+	xs_w(s, s2 );
+
+	xs_end();
+
+}
+void setup_vif(int domid, int uuid)
+{
+	char s[256];
+	char s2[256];
+
+	char* home = xs_get_domain_path(xs,domid);
+	char* dom0_home = xs_get_domain_path(xs,0);
+
+	char backend[256];
+	char frontend[256];
+
+	printf("dom0_home is %s\n",dom0_home);
+	sprintf(backend,"%s/backend/vif/%d/%d",dom0_home,uuid,domid);
+	sprintf(frontend, "%s/device/vif/%d",home,uuid);
+
+
+
+	xs_begin();
+
+	sprintf(s,"%s/handle",frontend);
+	sprintf(s2,"%d",uuid);
+	xs_w(s, s2);
+
+	sprintf(s,"%s/mac",frontend);
+	xs_w(s, "aa:00:00:11:a6:02");
+
+	sprintf(s, "%s/backend-id", frontend);
+	xs_w(s, "0");
+	
+	sprintf(s,"%s/backend",frontend);
+	xs_w(s, backend );
+
+	xs_end();
+
+	xs_begin();
+
+	sprintf(s,"%s/handle",backend);
+	sprintf(s2,"%d",uuid);
+	xs_w(s, s2);
+	
+	sprintf(s,"%s/mac",backend);
+	xs_w(s, "aa:00:00:11:a6:02");
+
+	sprintf(s,"%s/frontend",backend);
+	xs_w(s, frontend );
+
+	sprintf(s,"%s/frontend-id",backend);
+	sprintf(s2,"%d",domid);
+	xs_w(s, s2 );
+
+
+	xs_end();
+
+
+
+}
+
+void setup_vbd(int domid, struct vbd* vbd)
+{
+
+	char s[256];
+	char s2[256];
+	char pdev[8];
+	char vdev[8];
+	char backend[256];
+	char frontend[256];
+	char node[16];
+
+	struct xs_permissions xsperms[2];
+	char* home = xs_get_domain_path(xs,domid);
+	char* dom0_home = xs_get_domain_path(xs,0);
+
+	xsperms[0].id = domid;
+	xsperms[0].perms = XS_PERM_READ | XS_PERM_WRITE;
+
+	printf("dom0_home is %s\n",dom0_home);
+	sprintf(pdev,"%u:%u",vbd->pdev>>8, vbd->pdev & 0xff);
+
+	sprintf(backend,"%s/backend/vbd/%d/%d",dom0_home,domid,vbd->vdev);
+	sprintf(frontend, "%s/device/vbd/%d",home,vbd->vdev);
+
+	xs_begin();
+	xs_mkdir(xs,t,backend);
+	xs_set_permissions(xs, t, backend, xsperms, 1);
+
+	sprintf(s,"%s/backend",frontend);
+	xs_w(s, backend );
+
+	sprintf(s, "%s/backend-id", frontend);
+	xs_w(s, "0");
+
+	sprintf(s, "%s/state", frontend);
+	xs_w(s, "1");
+
+	
+	sprintf(s, "%s/virtual-device", frontend);
+	sprintf(vdev,"%u",vbd->vdev);
+	xs_w(s, vdev );
+
+
+	sprintf(s,"%s/domain",backend);
+	sprintf(s2,"%d",domid);
+	xs_w(s, s2);
+
+	sprintf(s,"%s/frontend",backend);
+	xs_w(s, frontend );
+
+	sprintf(s,"%s/frontend-id",backend);
+	sprintf(s2,"%d",domid);
+	xs_w(s, s2 );
+
+	sprintf(s, "%s/state", backend);
+	xs_w(s, "1");
+
+
+
+	sprintf(s, "%s/physical-device",backend);
+	xs_w(s, pdev );
+
+	sprintf(s, "%s/mode",backend);
+	xs_w(s, vbd->mode);
+
+	sprintf(node,"/dev/hda%d",vbd->vdev-0x300);
+
+#if 0
+	sprintf(s, "%s/dev",backend);
+	xs_w(s, node);
+
+	sprintf(s, "%s/node",backend);
+	xs_w(s, node);
+#endif
+
+	xs_end();
+
+}
+
+void usage(void)
+{
+	puts("\ncreate: create a new Xen domain, with settings read from file\n");
+	puts("usage: create [-p] configfile\n");
+	puts("flags:");
+	puts("      -p : purge all unpriv domains first\n");
+	exit(-1);
+}
+
+int main(int argc,char** argv)
+{
+	char kernel[256] = "";
+	char ramdisk[256] = "";
+	char cmdline[256] = "";
+	char cmdline2[256] = "";
+	char ip[16], ip2[16];
+	int console = 0;
+	int vif = 0;
+	int num_vbds;
+	struct vbd vbds[16];
+	int mem_mb = 16;
+	int maxmem_mb = 16;
+	int flag_purge=0;
+	int uuid;
+	int arg_pos=1;
+	int i;
+	char* cfgfile;
+	unsigned int domid = 0;
+	int rconsole = 0;
+	int rstore = 0;
+	unsigned long mfn_store, mfn_console;
+	struct xs_permissions xsperms[2];
+	char* home; 
+
+
+	xen_domain_handle_t xen_handle = {0,};
+
+	if(argc<2) usage();
+
+	xc = xc_interface_open();
+	if(xc<0) goto xc_failed;
+
+	xs = xs_daemon_open();
+	if(xs<0) goto xs_failed;
+
+	evtchn_fd = open("/dev/xen/evtchn", O_RDWR);
+	
+	//char pdev[] = "3:2";
+	//char pdev[16] = "";
+	//char vdev[] = "769";
+
+	for(i=1; i<argc-1; i++)
+	{
+		if(argv[i][0]=='-') 
+		{
+			switch(argv[i][1])
+			{
+				case 'p':
+					flag_purge=1;
+					arg_pos++;
+					break;
+
+				default:
+					usage();
+			}
+		}
+		
+	}
+	cfgfile = argv[arg_pos++];
+	read_config(cfgfile, ip, ip2, ramdisk, kernel, cmdline, &mem_mb, &maxmem_mb,
+			&console,&vif,&num_vbds,vbds);
+
+	printf("got %d\n",num_vbds);
+
+	if(flag_purge) purge_all_unpriv_domains(xc);
+
+
+
+	xc_domain_create(xc, ACM_DEFAULT_SSID, xen_handle, &domid);
+
+	if(arg_pos<argc) 
+	{
+		sprintf(cmdline2,cmdline,atoi(argv[arg_pos]));
+		uuid = atoi(argv[arg_pos]);
+	}
+	else 
+	{
+		strcpy(cmdline2,cmdline);
+		uuid = 10000+domid*100;
+	}
+
+	xc_domain_setmaxmem(xc,domid, maxmem_mb << 10);
+	xc_domain_memory_increase_reservation(xc,domid, mem_mb << 8, 0,0,0);
+	printf("%d\n",domid);
+
+	// 2) Build domain
+
+	rconsole = xc_evtchn_alloc_unbound(xc,domid,DOMID_SELF);
+	rstore = xc_evtchn_alloc_unbound(xc,domid,DOMID_SELF);
+	if(rstore<0 || rconsole<0) goto out;
+
+#if 0
+int xc_linux_build(int xc_handle,
+                   uint32_t domid,
+                   const char *image_name,
+                   const char *initrd_name,
+                   const char *cmdline,
+                   const char *features,
+                   unsigned long flags,
+                   unsigned int store_evtchn,
+                   unsigned long *store_mfn,
+                   unsigned int console_evtchn,
+                   unsigned long *console_mfn)
+#endif
+
+	if( xc_linux_build(xc, domid, kernel, ramdisk, cmdline2,NULL, 0, 
+			rstore, &mfn_store, rconsole, &mfn_console))
+		goto out;
+
+	printf("intro %d, %08lx, %d\n",domid,mfn_store,rstore);
+
+	if(!xs_introduce_domain(xs, domid, mfn_store, rstore))
+		goto out;
+
+	xsperms[0].id = domid;
+	xsperms[0].perms = XS_PERM_READ | XS_PERM_WRITE;
+
+
+
+	if(console) setup_console(domid, rconsole, mfn_console);
+	home = xs_get_domain_path(xs,domid);
+	xs_begin();
+	xs_set_permissions(xs, t, home, xsperms, 1);
+	xs_end();
+
+	for(i=0; i<num_vbds; i++)
+	{
+		setup_vbd(domid,&vbds[i]);
+	}
+
+	if(vif) setup_vif(domid,0);
+
+
+	xc_domain_unpause(xc,domid);
+out:
+
+	xs_daemon_close(xs);
+xs_failed:
+	xc_interface_close(xc);
+xc_failed:
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/configfile.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/configfile.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "configfile.h"
+
+void read_config(char* cfgfile, char* ip, char* ip2, char* initrd,
+		char* kernel, char* cmdline, int* mem_mb, int* maxmem_mb,
+		int* console, int* vif, int* num_vbds,struct vbd* vbds)
+
+{
+	char key[256];
+	char value[256];
+	struct vbd* vbd = vbds;
+	FILE* f = fopen(cfgfile,"r");
+
+	*num_vbds=0;
+
+	if(!f)
+	{
+		printf("error opening cfg file %s\n", cfgfile);
+		exit(-1);
+	}
+
+	while( fscanf(f, "%[^=] = %[^\n]\n", key, value)!= EOF)
+	{
+		if(!strcmp(key, "kernel"))
+		{
+			strcpy(kernel,value);
+		}
+		else if(!strcmp(key, "initrd"))
+		{
+			strcpy(initrd,value);
+		}
+		else if(!strcmp(key, "ip"))
+		{
+			strcpy(ip,value);
+		}
+		else if(!strcmp(key, "ip2"))
+		{
+			strcpy(ip2,value);
+		}
+		else if(!strcmp(key, "cmdline"))
+		{
+			strcpy(cmdline,value);
+		}
+		else if(vbd && !strcmp(key, "vbd"))
+		{
+			strcpy(vbd->mode,"r");
+			sscanf(value, "%x,%x,%s\n", &vbd->pdev,&vbd->vdev,vbd->mode);
+			vbd++;
+			++(*num_vbds);
+		}
+		else if(!strcmp(key, "mem"))
+		{
+			sscanf(value, "%dM", mem_mb);
+		}
+		else if(!strcmp(key, "maxmem"))
+		{
+			sscanf(value, "%dM", maxmem_mb);
+		}
+
+		else if(!strcmp(key, "console"))
+		{
+			sscanf(value, "%d", console);
+		}
+		else if(!strcmp(key, "vif"))
+		{
+			sscanf(value, "%d", vif);
+		}
+	}
+
+	fclose(f);
+}
diff -r 0bfe5613711a tools/migrate/configfile.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/configfile.h	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,10 @@
+struct vbd {
+	unsigned int pdev;
+	unsigned int vdev;
+	char mode[4];
+};
+
+extern void read_config(char* cfgfile, char* ip, char* ip2, char* initrd,
+		char* kernel, char* cmdline, int* mem_mb, int* maxmem_mb,
+		int* console, int* vif, int* num_vbds,struct vbd* vbd);
+
diff -r 0bfe5613711a tools/migrate/evtchn.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/evtchn.h	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,1 @@
+int evtchn_bind_interdomain(int xc, int evtchn_fd, int domid, int remote_port);
diff -r 0bfe5613711a tools/migrate/listdoms.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/listdoms.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <xenctrl.h>
+
+int main(int argc, char** argv)
+{
+	int xc_handle = xc_interface_open();
+	xc_dominfo_t infos[100];
+
+	int n = xc_domain_getinfo(xc_handle, 1, 100, infos);
+
+	int i;
+	for(i=0; i<n; i++)
+	{
+		printf("Domain %d, mem %lu kB\n",
+				(int)infos[i].domid,infos[i].nr_pages*4);
+
+	}
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/minimig.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/minimig.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,149 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#define PAGE_SIZE 4096
+#define O_DIRECT      040000
+
+int main(int argc,char** argv)
+{
+	size_t loader_size;
+	unsigned long loader_pages;
+	unsigned long offset = 0;
+	char* page;
+	char* loader = mmap(0, 8*PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0,0);
+	int f;
+	int i;
+	int o;
+	unsigned long num_mfns;
+	struct {
+		unsigned long pfn;
+		char page[PAGE_SIZE];
+	} data;
+
+
+	memset(loader,0,8*PAGE_SIZE);
+
+	if(argc>1) offset = atoi(argv[1]) * 4200 * PAGE_SIZE;
+
+	/* to work with O_DIRECT, we need to correctly align the loader. 512 bytes should be
+	 * enough, but let's do PAGE_SIZE for now
+	 */
+
+	f = open("loader", O_RDONLY);
+	if(f>=0)
+	{
+		size_t* a;
+
+		loader_size = read(f,loader+4, 8*PAGE_SIZE);
+		close(f);
+		loader_pages = (loader_size + 3*sizeof(size_t) + (PAGE_SIZE-1)) / PAGE_SIZE;
+		printf("loader pages %d\n", (int)loader_pages);
+		a = (size_t*) loader;
+
+		/* first long has length of loader minus arguments */
+		*a = loader_pages*PAGE_SIZE - 12;
+
+		a = (size_t*) ( loader+loader_pages * PAGE_SIZE - 8);
+		*a++ = sizeof(size_t);  /* four bytes of args */
+		*a++ = 0x1000;          /* argument: number of pages in checkpoint */
+
+		/* so loader and arguments ended up page-aligned after all */
+
+	}
+	else
+	{
+		puts("no file: 'loader'");
+		exit(-1);
+	}
+
+	page = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0,0);
+	o = open("/dev/hda1",O_WRONLY|O_TRUNC|O_DIRECT);
+
+	if(o<0)
+	{
+		printf("could not open output fd for write %d\n",o);
+		exit(-1);
+	}
+
+	printf("wiping /dev/hda1, fd %d\n",o);
+	memset(page,0,PAGE_SIZE);
+	for(i=0; i<0x1003; i++)
+	{
+		int r;
+
+		lseek(o, offset + i * PAGE_SIZE, SEEK_SET);
+		r = write(o, page, PAGE_SIZE);
+		if(r<0)
+		{
+			printf("r %d\n",r);
+			exit(-1);
+		}
+	}
+
+	/* write the loader and its args */
+	lseek(o, offset + 0, SEEK_SET);
+	write(o, loader, loader_pages * PAGE_SIZE);
+
+
+	f = open("/dev/checkpoint",O_RDONLY);
+	printf("writing checkpoint to fd %d\n",o);
+
+	if(f<0) switch(errno)
+	{
+		case ENOENT:
+			puts("no /dev/checkpoint!");
+			puts("please create with:\n\tmknod /dev/checkpoint c 1 12\n\tchmod 400 /dev/checkpoint");
+			exit(-1);
+		default:
+			puts("unable to open /dev/checkpoint");
+			exit(-1);
+	}
+
+	read(f, &num_mfns, sizeof(num_mfns));
+	printf("%08lx page frames\n", num_mfns);
+	if(num_mfns<=0) exit(-1);
+
+	for(;;)
+	{
+		int len = read(f, &data,sizeof(data));
+		int r;
+
+		if(len<0) 
+		{ 
+			printf("we have arrived.\n");
+			close(o);
+			close(f);
+			
+			/* if run as init we cannot exit */
+			//if(getpid()==1) while(1) sleep(100); else 
+			exit(0);
+		}
+		lseek(o, offset + (loader_pages + data.pfn) * PAGE_SIZE, SEEK_SET);
+		memcpy(page,data.page,PAGE_SIZE);
+		r = write(o, page, PAGE_SIZE);
+
+		if(r<0)
+		{
+			printf("r %d\n",r);
+			exit(-1);
+		}
+
+		fsync(o);
+
+		if(len!=sizeof(data)) 
+		{
+			printf("last one , pfn %lu\n",data.pfn);
+			break;
+		}
+	}
+	close(o);
+	puts("done");
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/pack.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/pack.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/sendfile.h>
+
+#include <string.h>
+
+
+
+struct file {
+	char* name;
+	size_t size;
+	int fd;
+	int optional;
+};
+
+
+void stat_files(struct file* files,int num_files)
+{
+	int i;
+	for(i=0; i<num_files;i++)
+	{
+		struct file* f = &files[i];
+		f->fd = open(f->name, O_RDONLY);
+
+		if(f->name && *(f->name) && f->fd>=0)
+		{
+			struct stat stat;
+			fstat(f->fd, &stat);
+			f->size = stat.st_size;
+			printf("%s size %d\n", f->name, f->size);
+		}
+		else if(!f->optional)
+		{
+			printf("no file: '%s'\n",f->name);
+			exit(-1);
+		}
+	}
+}
+
+void write_file(FILE* out, struct file* f)
+{
+	char* d= malloc(f->size);
+	if(f->fd>=0)
+	{
+		printf("sending file %s\n", f->name);
+		if(read(f->fd,d,f->size)!=f->size)
+		{
+			printf("read err\n");
+			exit(-1);
+
+		}
+
+		fwrite(d, f->size,1,out);
+		free(d);
+		close(f->fd);
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int args_size;
+	int i;
+	char cmdline[256];
+	int num_pfns = 0x1000;
+	struct file files[] = {
+		{ "/root/bin/linux_loader", 0,0,0},
+		{ "/root/vmlinux", 0,0,0},
+		{ "/root/domUinitrd", 0,0,1}
+	};
+
+	const int num_files = sizeof(files)/sizeof(struct file);
+
+	FILE* out = fopen("/tmp/out.img","w");
+
+	memset(cmdline,0,sizeof(cmdline));
+	strcpy(cmdline,"mem=16M init=/linuxrc root=/dev/ram xencons=ttyS0");
+
+	printf("%d files\n", num_files);
+	stat_files(files,num_files);
+
+	fwrite(&files[0].size, sizeof(size_t),1,out);
+	write_file( out, &files[0] );
+
+	args_size = sizeof(cmdline) + 3*sizeof(size_t);
+	fwrite(&args_size, sizeof(args_size),1,out);
+
+	fwrite(&num_pfns, sizeof(num_pfns),1,out);
+	fwrite(cmdline, sizeof(cmdline),1,out);
+	fwrite(&files[1].size, sizeof(size_t),1,out);
+	fwrite(&files[2].size, sizeof(size_t),1,out);
+
+	for(i=1; i<num_files; i++) write_file( out, &files[i] );
+
+	fclose(out);
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/purgedoms.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/purgedoms.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,18 @@
+#include <xenctrl.h>
+#include <xenguest.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <xs.h>
+#include <fcntl.h>
+
+#include "xenutil.h"
+
+int main(int argc, char** argv)
+{
+	purge_all_unpriv_domains( xc_interface_open() );
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/repair.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/repair.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,83 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+
+#define PAGE_SIZE 4096
+#define O_DIRECT      040000
+
+int main(int argc, char** argv)
+{
+	int i;
+	int o,f;
+	size_t loader_size;
+	char* loader = mmap(0, 8*PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0,0);
+	unsigned long offset = 0;
+	unsigned long loader_pages;
+
+	if(argc>1) offset = atoi(argv[1]) * 4200 * PAGE_SIZE;
+
+	o = open("/tmp/chk.img",O_WRONLY|O_CREAT);
+	f = open("/dev/loop/6", O_RDONLY|O_DIRECT);
+	for(i=0; i<4100; i++)
+	{
+		lseek(f, offset + i*PAGE_SIZE, SEEK_SET);
+		read(f,loader,PAGE_SIZE);
+		lseek(o, i*PAGE_SIZE, SEEK_SET);
+		write(o,loader,PAGE_SIZE);
+	}
+	close(f);
+
+
+
+
+	f = open("/bin/loader", O_RDONLY);
+	if(f<0) f = open("loader", O_RDONLY);
+
+	memset(loader,0,8*PAGE_SIZE);
+
+	/* to work with O_DIRECT, we need to correctly align the loader. 512 bytes should be
+	 * enough, but let's do PAGE_SIZE for now
+	 */
+
+	if(f>=0)
+	{
+		size_t* a;
+		loader_size = read(f,loader+4, 8*PAGE_SIZE);
+		close(f);
+		loader_pages = (loader_size + 3*sizeof(size_t) + (PAGE_SIZE-1)) / PAGE_SIZE;
+		printf("loader pages %d\n", (int)loader_pages);
+		a = (size_t*) loader;
+
+		/* first long has length of loader minus arguments */
+		*a = loader_pages*PAGE_SIZE - 12;
+
+		a = (size_t*) ( loader+loader_pages * PAGE_SIZE - 8);
+		*a++ = sizeof(size_t);  /* four bytes of args */
+		*a++ = 0x1000;          /* argument: number of pages in checkpoint */
+
+		/* so loader and arguments ended up page-aligned after all */
+
+	}
+	else
+	{
+		puts("no file: 'loader'");
+		exit(-1);
+	}
+	/* write the loader and its args */
+	lseek(o, 0, SEEK_SET);
+	write(o, loader, loader_pages * PAGE_SIZE);
+
+
+
+
+	close(f);
+	close(o);
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/xdmesg.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/xdmesg.c	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,39 @@
+#include <xenctrl.h>
+#include <xenguest.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <xs.h>
+#include <fcntl.h>
+
+#include <sys/mman.h>
+
+#define PAGE_SIZE 4096
+
+int xc;
+
+int main(int argc, char** argv)
+{
+	char* b= (char*) mmap(0,PAGE_SIZE, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0,0);
+	char* a = b;
+	unsigned int n=PAGE_SIZE;
+	int i;
+
+	xc = xc_interface_open();
+
+	xc_readconsolering(xc,&b,&n,0);
+
+	for(i=0; i<n; i++) if(!isascii(a[i])) a[i]=' ';
+
+	a[n]='\0';
+
+	xc_interface_close(xc);
+
+	puts(a);
+
+	return 0;
+}
diff -r 0bfe5613711a tools/migrate/xenutil.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/migrate/xenutil.h	Tue May 16 10:35:46 2006 +0200
@@ -0,0 +1,11 @@
+static inline void purge_all_unpriv_domains(int xc)
+{
+	xc_dominfo_t infos[128];
+	int n = xc_domain_getinfo(xc, 1,128, infos);
+
+	int i;
+	for(i=0; i<n; i++)
+		xc_domain_destroy(xc, infos[i].domid );
+
+}
+

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Unable to bring up Mini-OS on x86_64
@ 2006-05-17 18:49 Puthiyaparambil, Aravindh
  0 siblings, 0 replies; 8+ messages in thread
From: Puthiyaparambil, Aravindh @ 2006-05-17 18:49 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

> Whatever the problem is, it'd be good to fix whatever bug this is
> triggering in the builder as well as fixing mini-os (although maybe
the
> bug is solely in the builder). It shouldn't be possible for bogus
> kernel images to kill xend, although I'm sure xc_linux_build() has
> various holes in this respect. It'd be nice to fix them as we find
them
> though.

Ok, I have found the bug. Mini-OS does not define VIRT_BASE in its
__xen_guest section. This causes dsi->elf_paddr_offset in
parseelfimage() [xc_load_elf.c] to be set to 0. This in turn causes
parray[pa>>PAGE_SHIFT] in loadelfimage[xc_load_elf.c] to go out of
bounds causing a segmentation fault.

This can also happen when an OS elfimage has VIRT_BASE or
ELF_PADDR_OFFSET set to 0. 

The case where VIRT_BASE is set correctly and ELF_PADDR_OFFSET is 0 has
been taken care of.

The fix here is to always ensure that VIRT_BASE is always defined and
when defined it is not set to 0 i.e. always ensure that virt_base
variable in parseelfimage() [xc_load_elf.c] is not 0. 

I will send in a patch for this.

Thanks,
Aravindh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Unable to bring up Mini-OS on x86_64
@ 2006-05-17 22:16 ` Puthiyaparambil, Aravindh
  2006-10-09 14:22   ` Jacob Gorm Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: Puthiyaparambil, Aravindh @ 2006-05-17 22:16 UTC (permalink / raw)
  To: Jacob Gorm Hansen; +Cc: xen-devel


> I would recommend writing a small c program that calls libxc directly,
> that will save you a bunch of time fighting the python/xend logging.
> 
> I have attached a patch with my own hand-rolled tools as an example.
> The most interesting one is buscreate, which reads a config-file like:

Jacob,

Your tools were very helpful. I am interested in receiving updates :-) 

One thing I was never able to get "listdoms" to work. I think
do_dom0_op(xc_handle, &op) in xc_domain_getinfo()is failing.

Thanks,
Aravindh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Unable to bring up Mini-OS on x86_64
  2006-05-17 22:16 ` Puthiyaparambil, Aravindh
@ 2006-10-09 14:22   ` Jacob Gorm Hansen
  0 siblings, 0 replies; 8+ messages in thread
From: Jacob Gorm Hansen @ 2006-10-09 14:22 UTC (permalink / raw)
  To: Puthiyaparambil, Aravindh; +Cc: xen-devel

On 5/17/06, Puthiyaparambil, Aravindh
<aravindh.puthiyaparambil@unisys.com> wrote:
>
> > I would recommend writing a small c program that calls libxc directly,
> > that will save you a bunch of time fighting the python/xend logging.
> >
> > I have attached a patch with my own hand-rolled tools as an example.
> > The most interesting one is buscreate, which reads a config-file like:
>
> Jacob,
>
> Your tools were very helpful. I am interested in receiving updates :-)

hi,

my minimal domain management tools (for various reasons known as
'migrationtools') are now available standalone from
http://www.diku.dk/~jacobg .

Jacob

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-10-09 14:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-16 19:57 Unable to bring up Mini-OS on x86_64 Puthiyaparambil, Aravindh
2006-05-16 20:43 ` Keir Fraser
2006-05-16 21:05 ` Chris Wright
  -- strict thread matches above, loose matches on Subject: below --
2006-05-17  0:46 Puthiyaparambil, Aravindh
2006-05-17 11:48 ` Jacob Gorm Hansen
2006-05-17 18:49 Puthiyaparambil, Aravindh
     [not found] <AcZ5p+KpFIIaM+iCRoSrbklVgbsVZAAVoOJg>
2006-05-17 22:16 ` Puthiyaparambil, Aravindh
2006-10-09 14:22   ` Jacob Gorm Hansen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.