Skip to contentSkip to conversation

introducing libxenlight

PATCH In review Stefano Stabellini 3 participants 4 messages Nov 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 introducing libxenlight

This patch adds the initial libxenlight implementation under tools/libxl

---

tools/libxl/Makefile new file +81 -0
diff -r 37829fd7c1e3 tools/libxl/Makefile
@@ -0,0 +1,81 @@
+#
+# tools/libxl/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General
+# Public License.  See the file "COPYING" in the main directory of
+# this archive for more details.
+#
+# Copyright (C) 2009 by Stefano Stabellini
+#
+
+XEN_ROOT	= ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+MAJOR = 1.0
+MINOR = 0
+
+#CFLAGS += -Werror
+CFLAGS += -I. -fPIC
+CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
+
+LDFLAGS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) -luuid
+
+LIBCONFIG_URL ?= http://www.hyperrealm.com/libconfig
+LIBCONFIG_SOURCE = libconfig-1.3.2
+LIBCONFIG_OUTPUT = $(LIBCONFIG_SOURCE)/.libs
+WGET=wget -c
+
+LIBXL_OBJS = flexarray.o libxl.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o xenguest.o osdeps.o libxl_utils.o
+
+CLIENTS = xl
+
+.PHONY: all
+all: $(CLIENTS) libxenlight.so libxenlight.a
+
+libxenlight.so: libxenlight.so.$(MAJOR)
+	ln -sf $< $@
+
+libxenlight.so.$(MAJOR): libxenlight.so.$(MAJOR).$(MINOR)
+	ln -sf $< $@
+
+libxenlight.so.$(MAJOR).$(MINOR): $(LIBXL_OBJS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^
+
+libxenlight.a: $(LIBXL_OBJS)
+	$(AR) rcs libxenlight.a $^
+
+$(LIBCONFIG_SOURCE).tar.gz:
+	$(WGET) $(LIBCONFIG_URL)/$@
+
+$(LIBCONFIG_SOURCE): $(LIBCONFIG_SOURCE).tar.gz
+	tar xzf $<
+
+$(LIBCONFIG_OUTPUT)/libconfig.so: $(LIBCONFIG_SOURCE)
+	cd $(LIBCONFIG_SOURCE) && ./configure --prefix=$(DESTDIR)$(PREFIX) && $(MAKE)
+
+xl.o: $(LIBCONFIG_SOURCE)
+	$(CC) $(CFLAGS) -I$(LIBCONFIG_SOURCE) -c xl.c
+
+$(CLIENTS): xl.o libxenlight.so $(LIBCONFIG_OUTPUT)/libconfig.so
+	$(CC) $(LDFLAGS) -o $@ $< -L . -lxenlight -L$(LIBCONFIG_OUTPUT) -lconfig
+
+.PHONY: install
+install: all
+	$(INSTALL_PROG) xl $(DESTDIR)$(SBINDIR)
+	$(INSTALL_PROG) libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+	ln -sf libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenlight.so.$(MAJOR)
+	ln -sf libxenlight.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenlight.so
+	$(INSTALL_DATA) libxenlight.a $(DESTDIR)$(LIBDIR)
+	cd $(LIBCONFIG_SOURCE) && DESTDIR= $(MAKE) install
+
+.PHONY: clean
+clean:
+	$(RM) *.o
+	rm -f *.so*
+	rm -f *.a
+	rm -f $(CLIENTS)
+	rm -rf $(LIBCONFIG_SOURCE)
+
+distclean: clean
+	rm $(LIBCONFIG_SOURCE).tar.gz
+
tools/libxl/flexarray.c new file +78 -0

78 lines not on this page · raw message

tools/libxl/flexarray.h new file +33 -0
diff -r 37829fd7c1e3 tools/libxl/flexarray.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Vincent Hanquez <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef FLEXARRAY_H
+#define FLEXARRAY_H
+
+typedef struct flexarray {
+    int size;
+    int autogrow;
+    void **data; /* array of pointer */
+} flexarray_t;
+
+flexarray_t *flexarray_make(int size, int autogrow);
+void flexarray_free(flexarray_t *array);
+int flexarray_grow(flexarray_t *array, int extents);
+int flexarray_set(flexarray_t *array, unsigned int index, void *ptr);
+int flexarray_get(flexarray_t *array, int index, void **ptr);
+
+void **flexarray_contents(flexarray_t *array);
+
+#endif
tools/libxl/libxl.c new file +742 -0

742 lines not on this page · raw message

tools/libxl/libxl.h new file +200 -0

200 lines not on this page · raw message

tools/libxl/libxl_device.c new file +241 -0

241 lines not on this page · raw message

tools/libxl/libxl_dom.c new file +271 -0

271 lines not on this page · raw message

tools/libxl/libxl_exec.c new file +48 -0

48 lines not on this page · raw message

tools/libxl/libxl_internal.c new file +159 -0

159 lines not on this page · raw message

tools/libxl/libxl_internal.h new file +135 -0

135 lines not on this page · raw message

tools/libxl/libxl_utils.c new file +159 -0

159 lines not on this page · raw message

tools/libxl/libxl_utils.h new file +34 -0
diff -r 37829fd7c1e3 tools/libxl/libxl_utils.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Stefano Stabellini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_UTILS_H
+#define LIBXL_UTILS_H
+
+#include "libxl.h"
+
+#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+
+unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned int smp_cpus);
+int libxl_name_to_domid(struct libxl_ctx *ctx, char *name, uint32_t *domid);
+char *libxl_domid_to_name(struct libxl_ctx *ctx, uint32_t domid);
+int libxl_uuid_to_domid(struct libxl_ctx *ctx, uint8_t *uuid, uint32_t *domid);
+int libxl_domid_to_uuid(struct libxl_ctx *ctx, uint8_t **uuid, uint32_t domid);
+int libxl_is_uuid(char *s);
+uint8_t *string_to_uuid(struct libxl_ctx *ctx, char *s);
+char *uuid_to_string(struct libxl_ctx *ctx, uint8_t *uuid);
+int libxl_param_to_domid(struct libxl_ctx *ctx, char *p, uint32_t *domid);
+
+#endif
+
tools/libxl/libxl_xshelp.c new file +108 -0

108 lines not on this page · raw message

tools/libxl/osdeps.c new file +62 -0

62 lines not on this page · raw message

tools/libxl/osdeps.h new file +24 -0
diff -r 37829fd7c1e3 tools/libxl/osdeps.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Stefano Stabellini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_OSDEP
+#define LIBXL_OSDEP
+
+#include <stdarg.h>
+
+int asprintf(char **buffer, char *fmt, ...);
+int vasprintf(char **buffer, const char *fmt, va_list ap);
+
+#endif
tools/libxl/xenguest.c new file +49 -0

49 lines not on this page · raw message

tools/libxl/xl.c new file +727 -0

576 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw

tools/libxl/Makefile Mon Nov 09 13:44:46 2009 +0000 line 9

Quoted 13 lines · Stefano Stabellini

diff -r 37829fd7c1e3 tools/libxl/Makefile

tools/libxl/Makefile Mon Nov 09 13:44:46 2009 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +9 -0
@@ -0,0 +1,81 @@
+#
+# tools/libxl/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General
+# Public License.  See the file "COPYING" in the main directory of
+# this archive for more details.
+#
+# Copyright (C) 2009 by Stefano Stabellini
+

this might be a little confusing since the libxenlight library is LGPLv2.
not sure we need a copyright notice in a makefile to be honest, and in no case it affect the library anyway.

Signature · 1 line
Vincent
#2 lore raw
Quoted 18 lines · Vincent Hanquez

tools/libxl/Makefile Mon Nov 09 13:44:46 2009 +0000 line 9

Quoted 13 lines · Stefano Stabellini

diff -r 37829fd7c1e3 tools/libxl/Makefile

tools/libxl/Makefile Mon Nov 09 13:44:46 2009 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +9 -0
@@ -0,0 +1,81 @@
+#
+# tools/libxl/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General
+# Public License.  See the file "COPYING" in the main directory of
+# this archive for more details.
+#
+# Copyright (C) 2009 by Stefano Stabellini
+

this might be a little confusing since the libxenlight library is LGPLv2. not sure we need a copyright notice in a makefile to be honest, and in no case it affect the library anyway.

Yeah, my mistake.
Keir, could you please remove the copyright header from the Makefile altogether?

#3 lore raw
Quoted 8 lines · Stefano Stabellini
Quoted 4 lines

this might be a little confusing since the libxenlight library is LGPLv2. not sure we need a copyright notice in a makefile to be honest, and in no case it affect the library anyway.

Yeah, my mistake.
Keir, could you please remove the copyright header from the Makefile altogether?

Yep.

-- Keir