Skip to contentSkip to conversation

compile xenstored for mini-OS

PATCH In review Alex Zeffertt 1 participant 2 messages Mar 23, 2009 – Mar 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 13/24 compile xenstored for mini-OS

Changes to xenstored to run in minios stubdom.

TODO: probably want a separate in-memory db flag, at least.

---

extras/mini-os/include/list.h +3 -3
diff -r 571b1a125fef extras/mini-os/include/list.h
@@ -1,5 +1,5 @@
-#ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
+#ifndef _MINIOS_LIST_H
+#define _MINIOS_LIST_H
 
 /*
  * Simple doubly linked list implementation.
@@ -186,5 +186,5 @@
 		n = minios_list_entry(pos->member.next, typeof(*pos), member);	\
 	     &pos->member != (head); 					\
 	     pos = n, n = minios_list_entry(n->member.next, typeof(*n), member))
-#endif /* _LINUX_LIST_H */
+#endif /* _MINIOS_LIST_H */
 
stubdom/Makefile +26 -3
diff -r 571b1a125fef stubdom/Makefile
@@ -73,12 +73,12 @@
 
 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
 
-TARGETS=ioemu c caml grub
+TARGETS=ioemu c caml grub xenstore
 
 .PHONY: all
 all: build
 ifeq ($(STUBDOM_SUPPORTED),1)
-build: ioemu-stubdom c-stubdom pv-grub
+build: ioemu-stubdom c-stubdom pv-grub xenstore-stubdom
 else
 build:
 endif
@@ -209,6 +209,11 @@
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
+	mkdir -p xenstore
+	[ -h xenstore/Makefile ] || ( cd xenstore && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/*.c . && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/*.h . && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/Makefile . )
 	$(MAKE) -C $(MINI_OS) links
 	touch mk-headers-$(XEN_TARGET_ARCH)
 
@@ -275,6 +280,14 @@
 	mkdir -p grub-$(XEN_TARGET_ARCH)
 	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
 
+##########
+# xenstore
+##########
+
+.PHONY: xenstore
+xenstore: $(CROSS_ROOT)
+	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip xenstored.a CONFIG_STUBDOM=y
+
 ########
 # minios
 ########
@@ -297,12 +310,16 @@
 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
+.PHONY: xenstore-stubdom
+xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc xenstore
+	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_XENSTORE $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/xenstore/xenstored.a
+
 #########
 # install
 #########
 
 ifeq ($(STUBDOM_SUPPORTED),1)
-install: install-readme install-ioemu install-grub
+install: install-readme install-ioemu install-grub install-xenstore
 else
 install:
 endif
@@ -321,6 +338,10 @@
 	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
 	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
 
+install-xenstore: xenstore-stubdom
+	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
+	$(INSTALL_PROG) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/xenstore-stubdom.gz"
+
 #######
 # clean
 #######
@@ -332,11 +353,13 @@
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-c
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
+	rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstore
 	$(MAKE) -C caml clean
 	$(MAKE) -C c clean
 	rm -fr grub-$(XEN_TARGET_ARCH)
 	[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
 	-[ ! -d ioemu ] || $(MAKE) -C ioemu clean
+	-[ ! -d xenstore ] || $(MAKE) -C xenstore clean
 
 # clean the cross-compilation result
 .PHONY: crossclean
tools/xenstore/Makefile +8 -1
diff -r 571b1a125fef tools/xenstore/Makefile
@@ -26,6 +26,10 @@
 xenstore xenstore-control: CFLAGS += -static
 endif
 
+ifdef CONFIG_STUBDOM
+CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_SYSLOG=1 -DNO_REOPEN_LOG=1
+endif
+
 .PHONY: all
 all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump 
 
@@ -43,9 +47,12 @@
 
 CFLAGS += -DHAVE_DTRACE=1
 endif
- 
+
 xenstored: $(XENSTORED_OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDFLAGS_libxenctrl) $(SOCKET_LIBS) -o $@
+
+xenstored.a: $(XENSTORED_OBJS)
+	$(AR) cr $@ $^
 
 $(CLIENTS): xenstore
 	ln -f xenstore $@
tools/xenstore/tdb.c +3 -3
diff -r 571b1a125fef tools/xenstore/tdb.c
@@ -1334,7 +1334,7 @@
 
 		/* Iterate through chain */
 		while( tlock->off) {
-			tdb_off current;
+			tdb_off mycurrent;
 			if (rec_read(tdb, tlock->off, rec) == -1)
 				goto fail;
 
@@ -1352,10 +1352,10 @@
 			}
 
 			/* Try to clean dead ones from old traverses */
-			current = tlock->off;
+			mycurrent = tlock->off;
 			tlock->off = rec->next;
 			if (!tdb->read_only && 
-			    do_delete(tdb, current, rec) != 0)
+			    do_delete(tdb, mycurrent, rec) != 0)
 				goto fail;
 		}
 		tdb_unlock(tdb, tlock->hash, F_WRLCK);
tools/xenstore/utils.h +2 -0
diff -r 571b1a125fef tools/xenstore/utils.h
@@ -19,7 +19,9 @@
 	return streq(a + strlen(a) - strlen(b), b);
 }
 
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
 
 void barf(const char *fmt, ...) __attribute__((noreturn));
 void barf_perror(const char *fmt, ...) __attribute__((noreturn));
tools/xenstore/xenstored_core.c +42 -1

159 lines not on this page · raw message

tools/xenstore/xenstored_domain.c +8 -1
diff -r 571b1a125fef tools/xenstore/xenstored_domain.c
@@ -555,6 +555,12 @@
 {
 }
 
+#ifdef __MINIOS__
+static inline int local_dom_init(void)
+{
+	return 0;
+}
+#else
 static int local_dom_init(void)
 {
 	extern unsigned int local_domid;
@@ -588,6 +594,7 @@
 
 	return 0; 
 }
+#endif
 
 static int dom0_init(void) 
 { 
@@ -609,7 +616,7 @@
 		return -1;
 	}
 
-	dom0->interface = xc_gnttab_map_grant_ref(*xcg_handle,
+	dom0->interface = xc_gnttab_map_grant_ref(xce_handle,
 	                                          0,
 	                                          dom0_grant_ref,
 	                                          PROT_READ|PROT_WRITE);
tools/xenstore/xenstored_transaction.c +2 -0
diff -r 571b1a125fef tools/xenstore/xenstored_transaction.c
@@ -120,7 +120,9 @@
 	trace_destroy(trans, "transaction");
 	if (trans->tdb)
 		tdb_close(trans->tdb);
+#ifndef __MINIOS__
 	unlink(trans->tdb_name);
+#endif
 	return 0;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 1 line · Alex Zeffertt

I've spotted a mistake in the stubdom_xenstored patch I previously posted. For some reason I made xenstored use an evtchn handle to map dom0's xenbus page, where previously it was (correctly) using a grant table handle. I'm not sure why this didn't break it....

Anyway, please find attached a corrected version of the patch.

Regards,

Alex

Changes to xenstored to run in minios stubdom.

TODO: probably want a separate in-memory db flag, at least.

---

extras/mini-os/include/list.h +3 -3
diff -r 571b1a125fef extras/mini-os/include/list.h
@@ -1,5 +1,5 @@
-#ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
+#ifndef _MINIOS_LIST_H
+#define _MINIOS_LIST_H
 
 /*
  * Simple doubly linked list implementation.
@@ -186,5 +186,5 @@
 		n = minios_list_entry(pos->member.next, typeof(*pos), member);	\
 	     &pos->member != (head); 					\
 	     pos = n, n = minios_list_entry(n->member.next, typeof(*n), member))
-#endif /* _LINUX_LIST_H */
+#endif /* _MINIOS_LIST_H */
 
stubdom/Makefile +26 -3
diff -r 571b1a125fef stubdom/Makefile
@@ -73,12 +73,12 @@
 
 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
 
-TARGETS=ioemu c caml grub
+TARGETS=ioemu c caml grub xenstore
 
 .PHONY: all
 all: build
 ifeq ($(STUBDOM_SUPPORTED),1)
-build: ioemu-stubdom c-stubdom pv-grub
+build: ioemu-stubdom c-stubdom pv-grub xenstore-stubdom
 else
 build:
 endif
@@ -209,6 +209,11 @@
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
 	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
+	mkdir -p xenstore
+	[ -h xenstore/Makefile ] || ( cd xenstore && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/*.c . && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/*.h . && \
+	  ln -sf ../$(XEN_ROOT)/tools/xenstore/Makefile . )
 	$(MAKE) -C $(MINI_OS) links
 	touch mk-headers-$(XEN_TARGET_ARCH)
 
@@ -275,6 +280,14 @@
 	mkdir -p grub-$(XEN_TARGET_ARCH)
 	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
 
+##########
+# xenstore
+##########
+
+.PHONY: xenstore
+xenstore: $(CROSS_ROOT)
+	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip xenstored.a CONFIG_STUBDOM=y
+
 ########
 # minios
 ########
@@ -297,12 +310,16 @@
 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
+.PHONY: xenstore-stubdom
+xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc xenstore
+	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_XENSTORE $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/xenstore/xenstored.a
+
 #########
 # install
 #########
 
 ifeq ($(STUBDOM_SUPPORTED),1)
-install: install-readme install-ioemu install-grub
+install: install-readme install-ioemu install-grub install-xenstore
 else
 install:
 endif
@@ -321,6 +338,10 @@
 	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
 	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
 
+install-xenstore: xenstore-stubdom
+	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
+	$(INSTALL_PROG) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/xenstore-stubdom.gz"
+
 #######
 # clean
 #######
@@ -332,11 +353,13 @@
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-c
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
+	rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstore
 	$(MAKE) -C caml clean
 	$(MAKE) -C c clean
 	rm -fr grub-$(XEN_TARGET_ARCH)
 	[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
 	-[ ! -d ioemu ] || $(MAKE) -C ioemu clean
+	-[ ! -d xenstore ] || $(MAKE) -C xenstore clean
 
 # clean the cross-compilation result
 .PHONY: crossclean
tools/xenstore/Makefile +8 -1
diff -r 571b1a125fef tools/xenstore/Makefile
@@ -26,6 +26,10 @@
 xenstore xenstore-control: CFLAGS += -static
 endif
 
+ifdef CONFIG_STUBDOM
+CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_SYSLOG=1 -DNO_REOPEN_LOG=1
+endif
+
 .PHONY: all
 all: libxenstore.so libxenstore.a xenstored clients xs_tdb_dump 
 
@@ -43,9 +47,12 @@
 
 CFLAGS += -DHAVE_DTRACE=1
 endif
- 
+
 xenstored: $(XENSTORED_OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDFLAGS_libxenctrl) $(SOCKET_LIBS) -o $@
+
+xenstored.a: $(XENSTORED_OBJS)
+	$(AR) cr $@ $^
 
 $(CLIENTS): xenstore
 	ln -f xenstore $@
tools/xenstore/tdb.c +3 -3
diff -r 571b1a125fef tools/xenstore/tdb.c
@@ -1334,7 +1334,7 @@
 
 		/* Iterate through chain */
 		while( tlock->off) {
-			tdb_off current;
+			tdb_off mycurrent;
 			if (rec_read(tdb, tlock->off, rec) == -1)
 				goto fail;
 
@@ -1352,10 +1352,10 @@
 			}
 
 			/* Try to clean dead ones from old traverses */
-			current = tlock->off;
+			mycurrent = tlock->off;
 			tlock->off = rec->next;
 			if (!tdb->read_only && 
-			    do_delete(tdb, current, rec) != 0)
+			    do_delete(tdb, mycurrent, rec) != 0)
 				goto fail;
 		}
 		tdb_unlock(tdb, tlock->hash, F_WRLCK);
tools/xenstore/utils.h +2 -0
diff -r 571b1a125fef tools/xenstore/utils.h
@@ -19,7 +19,9 @@
 	return streq(a + strlen(a) - strlen(b), b);
 }
 
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
 
 void barf(const char *fmt, ...) __attribute__((noreturn));
 void barf_perror(const char *fmt, ...) __attribute__((noreturn));
tools/xenstore/xenstored_core.c +42 -1

159 lines not on this page · raw message

tools/xenstore/xenstored_domain.c +7 -0
diff -r 571b1a125fef tools/xenstore/xenstored_domain.c
@@ -555,6 +555,12 @@
 {
 }
 
+#ifdef __MINIOS__
+static inline int local_dom_init(void)
+{
+	return 0;
+}
+#else
 static int local_dom_init(void)
 {
 	extern unsigned int local_domid;
@@ -588,6 +594,7 @@
 
 	return 0; 
 }
+#endif
 
 static int dom0_init(void) 
 { 
tools/xenstore/xenstored_transaction.c +2 -0
diff -r 571b1a125fef tools/xenstore/xenstored_transaction.c
@@ -120,7 +120,9 @@
 	trace_destroy(trans, "transaction");
 	if (trans->tdb)
 		tdb_close(trans->tdb);
+#ifndef __MINIOS__
 	unlink(trans->tdb_name);
+#endif
 	return 0;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel