This patch moves the building, save, and restore code to a seperate
library (libxenbuild). This hasn't been done in a very clean way (since
the header dependencies are pretty nightmarish in libxc right now) but
this is something we can start from.
I haven't tested with IA64, hopefully that build doesn't break. This
patch depends on the previous patch submitted.
Regards,
Anthony Liguori
# HG changeset patch
# User Anthony Liguori <aliguori@xxxxxxxxxx>
# Node ID e6db3830c47d620bac83feb9755eb14f5f57068c
# Parent 54370eeeb3311db2bcacfc797766a5993a079b4c
This patch breaks the building/save/restore code out into a separate library
libxenbuild. It also updates the tools accordingly.
The build process isn't all that pretty right.
Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/Makefile
--- a/tools/libxc/Makefile Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/Makefile Wed Aug 24 20:39:38 2005
@@ -19,22 +19,24 @@
SRCS += xc_domain.c
SRCS += xc_evtchn.c
SRCS += xc_gnttab.c
-SRCS += xc_load_bin.c
-SRCS += xc_load_elf.c
-SRCS += xc_linux_build.c
SRCS += xc_misc.c
SRCS += xc_physdev.c
SRCS += xc_private.c
+SRCS += xc_ptrace.c
+SRCS += xc_ptrace_core.c
+
ifeq ($(XEN_TARGET_ARCH),ia64)
SRCS += xc_ia64_stubs.c
-else
-SRCS += xc_load_aout9.c
-SRCS += xc_linux_restore.c
-SRCS += xc_linux_save.c
-SRCS += xc_vmx_build.c
-SRCS += xc_ptrace.c
-SRCS += xc_ptrace_core.c
endif
+
+BUILD_SRCS := xc_load_aout9.c
+BUILD_SRCS += xc_load_bin.c
+BUILD_SRCS += xc_load_elf.c
+BUILD_SRCS += xc_linux_build.c
+BUILD_SRCS += xc_linux_restore.c
+BUILD_SRCS += xc_linux_save.c
+BUILD_SRCS += xc_vmx_build.c
+BUILD_SRCS += xc_build_private.c
CFLAGS += -Wall
CFLAGS += -Werror
@@ -48,8 +50,14 @@
LIB_OBJS := $(patsubst %.c,%.o,$(SRCS))
PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
-LIB := libxenctrl.a libxenctrl-pic.a
+LIB_BUILD_OBJS := $(patsubst %.c,%.o,$(BUILD_SRCS))
+PIC_BUILD_OBJS := $(patsubst %.c,%.opic,$(BUILD_SRCS))
+
+LIB := libxenctrl.a
LIB += libxenctrl.so libxenctrl.so.$(MAJOR)
libxenctrl.so.$(MAJOR).$(MINOR)
+
+LIB += libxenbuild.a
+LIB += libxenbuild.so libxenbuild.so.$(MAJOR)
libxenbuild.so.$(MAJOR).$(MINOR)
all: build
build: check-for-zlib mk-symlinks
@@ -83,6 +91,11 @@
ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenctrl.so
$(INSTALL_DATA) xenctrl.h $(DESTDIR)/usr/include/xen
+ $(INSTALL_PROG) libxenbuild.so.$(MAJOR).$(MINOR)
$(DESTDIR)/usr/$(LIBDIR)
+ $(INSTALL_DATA) libxenbuild.a $(DESTDIR)/usr/$(LIBDIR)
+ ln -sf libxenbuild.so.$(MAJOR).$(MINOR)
$(DESTDIR)/usr/$(LIBDIR)/libxenbuild.so.$(MAJOR)
+ ln -sf libxenbuild.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenbuild.so
+
.PHONY: TAGS clean rpm install all
TAGS:
@@ -100,10 +113,9 @@
mv staging/i386/*.rpm .
rm -rf staging
+# libxenctrl
+
libxenctrl.a: $(LIB_OBJS)
- $(AR) rc $@ $^
-
-libxenctrl-pic.a: $(PIC_OBJS)
$(AR) rc $@ $^
libxenctrl.so: libxenctrl.so.$(MAJOR)
@@ -112,6 +124,19 @@
ln -sf $< $@
libxenctrl.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenctrl.so.$(MAJOR)
-shared -o $@ $^ -lz
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenctrl.so.$(MAJOR)
-shared -o $@ $^
+
+# libxenbuild
+
+libxenbuild.a: $(LIB_BUILD_OBJS)
+ $(AR) rc $@ $^
+
+libxenbuild.so: libxenbuild.so.$(MAJOR)
+ ln -sf $< $@
+libxenbuild.so.$(MAJOR): libxenbuild.so.$(MAJOR).$(MINOR)
+ ln -sf $< $@
+
+libxenbuild.so.$(MAJOR).$(MINOR): $(PIC_BUILD_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenbuild.so.$(MAJOR)
-shared -o $@ $^ -lz -lxenctrl
-include $(DEPS)
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_linux_build.c Wed Aug 24 20:39:38 2005
@@ -2,7 +2,7 @@
* xc_linux_build.c
*/
-#include "xc_private.h"
+#include "xc_build_private.h"
#if defined(__i386__)
#define ELFSIZE 32
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_linux_restore.c Wed Aug 24 20:39:38 2005
@@ -6,7 +6,7 @@
* Copyright (c) 2003, K A Fraser.
*/
-#include "xc_private.h"
+#include "xc_build_private.h"
#include <xen/linux/suspend.h>
#define MAX_BATCH_SIZE 1024
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_linux_save.c Wed Aug 24 20:39:38 2005
@@ -8,7 +8,7 @@
#include <inttypes.h>
#include <sys/time.h>
-#include "xc_private.h"
+#include "xc_build_private.h"
#include <xen/linux/suspend.h>
#include <xen/io/domain_controller.h>
#include <time.h>
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_private.c Wed Aug 24 20:39:38 2005
@@ -332,53 +332,6 @@
return sz;
}
-char *xc_read_kernel_image(const char *filename, unsigned long *size)
-{
- int kernel_fd = -1;
- gzFile kernel_gfd = NULL;
- char *image = NULL;
- unsigned int bytes;
-
- if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
- {
- PERROR("Could not open kernel image");
- goto out;
- }
-
- if ( (*size = xc_get_filesz(kernel_fd)) == 0 )
- {
- PERROR("Could not read kernel image");
- goto out;
- }
-
- if ( (kernel_gfd = gzdopen(kernel_fd, "rb")) == NULL )
- {
- PERROR("Could not allocate decompression state for state file");
- goto out;
- }
-
- if ( (image = malloc(*size)) == NULL )
- {
- PERROR("Could not allocate memory for kernel image");
- goto out;
- }
-
- if ( (bytes = gzread(kernel_gfd, image, *size)) != *size )
- {
- PERROR("Error reading kernel image, could not"
- " read the whole image (%d != %ld).", bytes, *size);
- free(image);
- image = NULL;
- }
-
- out:
- if ( kernel_gfd != NULL )
- gzclose(kernel_gfd);
- else if ( kernel_fd >= 0 )
- close(kernel_fd);
- return image;
-}
-
void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
int xch, u32 dom, unsigned long *parray,
unsigned long vstart)
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_private.h Wed Aug 24 20:39:38 2005
@@ -1,6 +1,6 @@
-#ifndef __XC_PRIVATE_H__
-#define __XC_PRIVATE_H__
+#ifndef XC_PRIVATE_H
+#define XC_PRIVATE_H
#include <unistd.h>
#include <stdio.h>
@@ -15,6 +15,7 @@
#include <string.h>
#include "xenctrl.h"
+#include "xenbuild.h"
#include <xen/linux/privcmd.h>
@@ -316,8 +317,6 @@
unsigned long xc_get_filesz(int fd);
-char *xc_read_kernel_image(const char *filename, unsigned long *size);
-
void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
int xch, u32 dom, unsigned long *parray,
unsigned long vstart);
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_vmx_build.c Wed Aug 24 20:39:38 2005
@@ -3,7 +3,7 @@
*/
#include <stddef.h>
-#include "xc_private.h"
+#include "xc_build_private.h"
#define ELFSIZE 32
#include "xc_elf.h"
#include <stdlib.h>
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xenctrl.h Wed Aug 24 20:39:38 2005
@@ -6,8 +6,8 @@
* Copyright (c) 2003-2004, K A Fraser.
*/
-#ifndef __XC_H__
-#define __XC_H__
+#ifndef XENCTRL_H
+#define XENCTRL_H
#include <stdint.h>
@@ -254,63 +254,6 @@
unsigned long pages,
xc_shadow_control_stats_t *stats);
-
-#define XCFLAGS_VERBOSE 1
-#define XCFLAGS_LIVE 2
-#define XCFLAGS_DEBUG 4
-#define XCFLAGS_CONFIGURE 8
-
-struct XcIOContext;
-
-/**
- * This function will save a domain running Linux.
- *
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm fd the file descriptor to save a domain to
- * @parm dom the id of the domain
- * @return 0 on success, -1 on failure
- */
-int xc_linux_save(int xc_handle, int fd, u32 dom);
-
-/**
- * This function will restore a saved domain running Linux.
- *
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm fd the file descriptor to restore a domain from
- * @parm dom the id of the domain
- * @parm nr_pfns the number of pages
- * @parm store_evtchn the store event channel for this domain to use
- * @parm store_mfn returned with the mfn of the store page
- * @return 0 on success, -1 on failure
- */
-int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
- unsigned int store_evtchn, unsigned long *store_mfn);
-
-int xc_linux_build(int xc_handle,
- u32 domid,
- const char *image_name,
- const char *ramdisk_name,
- const char *cmdline,
- unsigned int control_evtchn,
- unsigned long flags,
- unsigned int vcpus,
- unsigned int store_evtchn,
- unsigned long *store_mfn);
-
-struct mem_map;
-int xc_vmx_build(int xc_handle,
- u32 domid,
- int memsize,
- const char *image_name,
- struct mem_map *memmap,
- const char *ramdisk_name,
- const char *cmdline,
- unsigned int control_evtchn,
- unsigned long flags,
- unsigned int vcpus,
- unsigned int store_evtchn,
- unsigned long *store_mfn);
-
int xc_bvtsched_global_set(int xc_handle,
unsigned long ctx_allow);
@@ -555,4 +498,4 @@
*/
long xc_init_store(int xc_handle, int remote_port);
-#endif /* __XC_H__ */
+#endif
diff -r 54370eeeb331 -r e6db3830c47d tools/python/setup.py
--- a/tools/python/setup.py Wed Aug 24 20:38:03 2005
+++ b/tools/python/setup.py Wed Aug 24 20:39:38 2005
@@ -17,7 +17,7 @@
XEN_ROOT + "/tools/xenstore",
]
-libraries = [ "xenctrl", "xenstore" ]
+libraries = [ "xenctrl", "xenbuild", "xenstore" ]
xc = Extension("xc",
extra_compile_args = extra_compile_args,
diff -r 54370eeeb331 -r e6db3830c47d tools/xcutils/Makefile
--- a/tools/xcutils/Makefile Wed Aug 24 20:38:03 2005
+++ b/tools/xcutils/Makefile Wed Aug 24 20:39:38 2005
@@ -30,7 +30,7 @@
PROGRAMS = xc_restore xc_save
-LDLIBS = -L$(XEN_LIBXC) -lxenctrl
+LDLIBS = -L$(XEN_LIBXC) -lxenbuild
.PHONY: all
all: build
diff -r 54370eeeb331 -r e6db3830c47d tools/xcutils/xc_restore.c
--- a/tools/xcutils/xc_restore.c Wed Aug 24 20:38:03 2005
+++ b/tools/xcutils/xc_restore.c Wed Aug 24 20:39:38 2005
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <err.h>
-#include <xenctrl.h>
+#include <xenbuild.h>
int
main(int argc, char **argv)
diff -r 54370eeeb331 -r e6db3830c47d tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c Wed Aug 24 20:38:03 2005
+++ b/tools/xcutils/xc_save.c Wed Aug 24 20:39:38 2005
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <err.h>
-#include <xenctrl.h>
+#include <xenbuild.h>
int
main(int argc, char **argv)
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_build_private.c
--- /dev/null Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_build_private.c Wed Aug 24 20:39:38 2005
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * xc_build_private.c
+ *
+ * Helper functions for the rest of the library.
+ */
+
+#include <zlib.h>
+#include "xc_build_private.h"
+
+char *xc_read_kernel_image(const char *filename, unsigned long *size)
+{
+ int kernel_fd = -1;
+ gzFile kernel_gfd = NULL;
+ char *image = NULL;
+ unsigned int bytes;
+
+ if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
+ {
+ PERROR("Could not open kernel image");
+ goto out;
+ }
+
+ if ( (*size = xc_get_filesz(kernel_fd)) == 0 )
+ {
+ PERROR("Could not read kernel image");
+ goto out;
+ }
+
+ if ( (kernel_gfd = gzdopen(kernel_fd, "rb")) == NULL )
+ {
+ PERROR("Could not allocate decompression state for state file");
+ goto out;
+ }
+
+ if ( (image = malloc(*size)) == NULL )
+ {
+ PERROR("Could not allocate memory for kernel image");
+ goto out;
+ }
+
+ if ( (bytes = gzread(kernel_gfd, image, *size)) != *size )
+ {
+ PERROR("Error reading kernel image, could not"
+ " read the whole image (%d != %ld).", bytes, *size);
+ free(image);
+ image = NULL;
+ }
+
+ out:
+ if ( kernel_gfd != NULL )
+ gzclose(kernel_gfd);
+ else if ( kernel_fd >= 0 )
+ close(kernel_fd);
+ return image;
+}
+
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xc_build_private.h
--- /dev/null Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xc_build_private.h Wed Aug 24 20:39:38 2005
@@ -0,0 +1,9 @@
+#ifndef XC_BUILD_PRIVATE_H
+#define XC_BUILD_PRIVATE_H
+
+#include "xc_private.h"
+
+char *xc_read_kernel_image(const char *filename, unsigned long *size);
+
+#endif
+
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xenbuild.c
--- /dev/null Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xenbuild.c Wed Aug 24 20:39:38 2005
@@ -0,0 +1,11 @@
+/******************************************************************************
+ * xenctrl.h
+ *
+ * A library for low-level access to the Xen control interfaces.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ */
+
+#ifndef __XC_H__
+#define __XC_H__
+
diff -r 54370eeeb331 -r e6db3830c47d tools/libxc/xenbuild.h
--- /dev/null Wed Aug 24 20:38:03 2005
+++ b/tools/libxc/xenbuild.h Wed Aug 24 20:39:38 2005
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * xenctrl.h
+ *
+ * A library for low-level access to the Xen control interfaces.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ */
+
+#ifndef XENBUILD_H
+#define XENBUILD_H
+
+#include "xenctrl.h"
+
+
+#define XCFLAGS_VERBOSE 1
+#define XCFLAGS_LIVE 2
+#define XCFLAGS_DEBUG 4
+#define XCFLAGS_CONFIGURE 8
+
+/**
+ * This function will save a domain running Linux.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm fd the file descriptor to save a domain to
+ * @parm dom the id of the domain
+ * @return 0 on success, -1 on failure
+ */
+int xc_linux_save(int xc_handle, int fd, u32 dom);
+
+/**
+ * This function will restore a saved domain running Linux.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm fd the file descriptor to restore a domain from
+ * @parm dom the id of the domain
+ * @parm nr_pfns the number of pages
+ * @parm store_evtchn the store event channel for this domain to use
+ * @parm store_mfn returned with the mfn of the store page
+ * @return 0 on success, -1 on failure
+ */
+int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
+ unsigned int store_evtchn, unsigned long *store_mfn);
+
+int xc_linux_build(int xc_handle,
+ u32 domid,
+ const char *image_name,
+ const char *ramdisk_name,
+ const char *cmdline,
+ unsigned int control_evtchn,
+ unsigned long flags,
+ unsigned int vcpus,
+ unsigned int store_evtchn,
+ unsigned long *store_mfn);
+
+struct mem_map;
+int xc_vmx_build(int xc_handle,
+ u32 domid,
+ int memsize,
+ const char *image_name,
+ struct mem_map *memmap,
+ const char *ramdisk_name,
+ const char *cmdline,
+ unsigned int control_evtchn,
+ unsigned long flags,
+ unsigned int vcpus,
+ unsigned int store_evtchn,
+ unsigned long *store_mfn);
+
+#endif
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|