ia64/xen-unstable

changeset 1626:3304775ae8eb

bitkeeper revision 1.1031 (40e1d02b7TWzZP0WaSOhCDygYQPX4w)

Tool cleanups.
author kaf24@scramble.cl.cam.ac.uk
date Tue Jun 29 20:25:15 2004 +0000 (2004-06-29)
parents 489b925b0e22
children 0b23b3e0fc06
files BitKeeper/etc/ignore tools/libxc/Makefile tools/libxutil/Makefile tools/python/setup.py tools/python/xen/ext/xc/xc.c tools/xentrace/Makefile
line diff
     1.1 --- a/BitKeeper/etc/ignore	Tue Jun 29 19:50:04 2004 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Tue Jun 29 20:25:15 2004 +0000
     1.3 @@ -1,4 +1,5 @@
     1.4  *.a
     1.5 +*.d
     1.6  *.o
     1.7  *.pyc
     1.8  *.so
     1.9 @@ -17,29 +18,8 @@ linux-2.4.26-xen/*
    1.10  linux-xen-sparse
    1.11  patches/*
    1.12  tools/*/build/lib*/*.py
    1.13 -tools/balloon/balloon
    1.14  tools/misc/miniterm/miniterm
    1.15  tools/misc/xen_cpuperf
    1.16 -tools/misc/xen_log
    1.17 -tools/misc/xen_read_console
    1.18 -tools/xc/lib/.allocate.o.d
    1.19 -tools/xc/lib/.file_stream.o.d
    1.20 -tools/xc/lib/.gzip_stream.o.d
    1.21 -tools/xc/lib/.iostream.o.d
    1.22 -tools/xc/lib/.sys_net.o.d
    1.23 -tools/xc/lib/.sys_string.o.d
    1.24 -tools/xc/lib/.xc_atropos.o.d
    1.25 -tools/xc/lib/.xc_bvtsched.o.d
    1.26 -tools/xc/lib/.xc_domain.o.d
    1.27 -tools/xc/lib/.xc_evtchn.o.d
    1.28 -tools/xc/lib/.xc_io.o.d
    1.29 -tools/xc/lib/.xc_linux_build.o.d
    1.30 -tools/xc/lib/.xc_linux_restore.o.d
    1.31 -tools/xc/lib/.xc_linux_save.o.d
    1.32 -tools/xc/lib/.xc_misc.o.d
    1.33 -tools/xc/lib/.xc_netbsd_build.o.d
    1.34 -tools/xc/lib/.xc_physdev.o.d
    1.35 -tools/xc/lib/.xc_private.o.d
    1.36  tools/xentrace/xentrace
    1.37  xen/drivers/pci/classlist.h
    1.38  xen/drivers/pci/devlist.h
    1.39 @@ -52,23 +32,3 @@ xen/tools/figlet/figlet
    1.40  xen/xen
    1.41  xen/xen-syms
    1.42  xen/xen.*
    1.43 -tools/xc/lib/.xc_rrobin.o.d
    1.44 -tools/libxc/.xc_atropos.o.d
    1.45 -tools/libxc/.xc_bvtsched.o.d
    1.46 -tools/libxc/.xc_domain.o.d
    1.47 -tools/libxc/.xc_evtchn.o.d
    1.48 -tools/libxc/.xc_io.o.d
    1.49 -tools/libxc/.xc_linux_build.o.d
    1.50 -tools/libxc/.xc_linux_restore.o.d
    1.51 -tools/libxc/.xc_linux_save.o.d
    1.52 -tools/libxc/.xc_misc.o.d
    1.53 -tools/libxc/.xc_netbsd_build.o.d
    1.54 -tools/libxc/.xc_physdev.o.d
    1.55 -tools/libxc/.xc_private.o.d
    1.56 -tools/libxc/.xc_rrobin.o.d
    1.57 -tools/libxutil/.allocate.o.d
    1.58 -tools/libxutil/.file_stream.o.d
    1.59 -tools/libxutil/.gzip_stream.o.d
    1.60 -tools/libxutil/.iostream.o.d
    1.61 -tools/libxutil/.sys_net.o.d
    1.62 -tools/libxutil/.sys_string.o.d
     2.1 --- a/tools/libxc/Makefile	Tue Jun 29 19:50:04 2004 +0000
     2.2 +++ b/tools/libxc/Makefile	Tue Jun 29 20:25:15 2004 +0000
     2.3 @@ -20,26 +20,6 @@ INCLUDES += -I $(XEN_XU)
     2.4  vpath %c       $(XEN_LIBXUTIL)
     2.5  INCLUDES += -I $(XEN_LIBXUTIL)
     2.6  
     2.7 -LIB_SRCS :=
     2.8 -LIB_SRCS += allocate.c
     2.9 -#LIB_SRCS += enum.c
    2.10 -LIB_SRCS += file_stream.c
    2.11 -LIB_SRCS += gzip_stream.c
    2.12 -#LIB_SRCS += hash_table.c
    2.13 -LIB_SRCS += iostream.c
    2.14 -#LIB_SRCS += kernel_stream.c
    2.15 -#LIB_SRCS += lexis.c
    2.16 -#LIB_SRCS += lzi_stream.c
    2.17 -#LIB_SRCS += lzo_stream.c
    2.18 -#LIB_SRCS += marshal.c
    2.19 -#LIB_SRCS += socket_stream.c
    2.20 -#LIB_SRCS += string_stream.c
    2.21 -#LIB_SRCS += sxpr.c
    2.22 -#LIB_SRCS += sxpr_parser.c
    2.23 -LIB_SRCS += sys_net.c
    2.24 -LIB_SRCS += sys_string.c
    2.25 -#LIB_SRCS += xdr.c
    2.26 -
    2.27  SRCS     :=
    2.28  SRCS     += xc_atropos.c
    2.29  SRCS     += xc_bvtsched.c
    2.30 @@ -55,11 +35,8 @@ SRCS     += xc_physdev.c
    2.31  SRCS     += xc_private.c
    2.32  SRCS     += xc_rrobin.c
    2.33  
    2.34 -#SRCS     += $(LIB_SRCS)
    2.35 -
    2.36  CFLAGS   += -Wall
    2.37  CFLAGS   += -Werror
    2.38 -CFLAGS   += -g
    2.39  CFLAGS   += -O3
    2.40  CFLAGS   += -fno-strict-aliasing
    2.41  CFLAGS   += $(INCLUDES)
    2.42 @@ -106,10 +83,6 @@ libxc.so:
    2.43  libxc.so.$(MAJOR):
    2.44  	ln -sf libxc.so.$(MAJOR).$(MINOR) $@
    2.45  libxc.so.$(MAJOR).$(MINOR): $(OBJS)
    2.46 -	$(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ ../libxutil/libxutil.a -lz 
    2.47 -
    2.48 -%.o: %.c Makefile
    2.49 -
    2.50 -#	$(CC) $(CFLAGS) -o $@ $<
    2.51 +	$(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz
    2.52  
    2.53  -include $(DEPS)
     3.1 --- a/tools/libxutil/Makefile	Tue Jun 29 19:50:04 2004 +0000
     3.2 +++ b/tools/libxutil/Makefile	Tue Jun 29 20:25:15 2004 +0000
     3.3 @@ -5,23 +5,11 @@ CC = gcc
     3.4  
     3.5  LIB_SRCS :=
     3.6  LIB_SRCS += allocate.c
     3.7 -#LIB_SRCS += enum.c
     3.8  LIB_SRCS += file_stream.c
     3.9  LIB_SRCS += gzip_stream.c
    3.10 -#LIB_SRCS += hash_table.c
    3.11  LIB_SRCS += iostream.c
    3.12 -#LIB_SRCS += kernel_stream.c
    3.13 -#LIB_SRCS += lexis.c
    3.14 -#LIB_SRCS += lzi_stream.c
    3.15 -#LIB_SRCS += lzo_stream.c
    3.16 -#LIB_SRCS += marshal.c
    3.17 -#LIB_SRCS += socket_stream.c
    3.18 -#LIB_SRCS += string_stream.c
    3.19 -#LIB_SRCS += sxpr.c
    3.20 -#LIB_SRCS += sxpr_parser.c
    3.21  LIB_SRCS += sys_net.c
    3.22  LIB_SRCS += sys_string.c
    3.23 -#LIB_SRCS += xdr.c
    3.24  
    3.25  LIB_OBJS := $(LIB_SRCS:.c=.o)
    3.26  
    3.27 @@ -30,32 +18,28 @@ CFLAGS   += -Werror
    3.28  CFLAGS   += -g
    3.29  CFLAGS   += -O3
    3.30  CFLAGS   += -fno-strict-aliasing
    3.31 -#CFLAGS   += $(INCLUDES)
    3.32 +
    3.33  # Get gcc to generate the dependencies for us.
    3.34  CFLAGS   += -Wp,-MD,.$(@F).d
    3.35  DEPS     = .*.d
    3.36  
    3.37 -MAJOR    = 1.3
    3.38 -MINOR    = 0
    3.39 -LIB_NAME = libxutil
    3.40 -LIB_BASE = $(LIB_NAME).so
    3.41 -LIB_MAJOR= $(LIB_BASE).$(MAJOR)
    3.42 -LIB_MINOR= $(LIB_MAJOR).$(MINOR)
    3.43 -LIB      = $(LIB_BASE) $(LIB_MAJOR) $(LIB_MINOR) $(LIB_NAME).a
    3.44 +MAJOR    := 1.3
    3.45 +MINOR    := 0
    3.46 +LIB_NAME := libxutil
    3.47 +LIB      := $(LIB_NAME).so 
    3.48 +LIB      += $(LIB_NAME).so.$(MAJOR)
    3.49 +LIB      += $(LIB_NAME).so.$(MAJOR).$(MINOR)
    3.50  
    3.51  all: check-for-zlib $(LIB)
    3.52  
    3.53 -$(LIB_BASE):
    3.54 -	ln -sf $(LIB_MAJOR) $@
    3.55 -
    3.56 -$(LIB_MAJOR):
    3.57 -	ln -sf $(LIB_MINOR) $@
    3.58 +$(LIB_NAME).so:
    3.59 +	ln -sf $(LIB_NAME).so.$(MAJOR) $@
    3.60  
    3.61 -$(LIB_MINOR): $(LIB_OBJS)
    3.62 -	$(CC) -Wl,-soname -Wl,$(LIB_MAJOR) -shared -o $@ $^
    3.63 +$(LIB_NAME).so.$(MAJOR):
    3.64 +	ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $@
    3.65  
    3.66 -$(LIB_NAME).a: $(LIB_OBJS)
    3.67 -	$(AR) rc $@ $^
    3.68 +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_OBJS)
    3.69 +	$(CC) -Wl,-soname -Wl,$(LIB_NAME).so.$(MAJOR) -shared -o $@ $^
    3.70  
    3.71  check-for-zlib:
    3.72  	@if [ ! -e /usr/include/zlib.h ]; then \
    3.73 @@ -69,8 +53,7 @@ install: all
    3.74  	mkdir -p $(prefix)/usr/lib
    3.75  	mkdir -p $(prefix)/usr/include
    3.76  	install -m0755 $(LIB) $(prefix)/usr/lib
    3.77 -
    3.78 -#install -m0644 xc.h $(prefix)/usr/include
    3.79 +	install -m0644 xc.h $(prefix)/usr/include
    3.80  
    3.81  clean:
    3.82  	$(RM) *.a *.so *.o *.rpm $(LIB)
     4.1 --- a/tools/python/setup.py	Tue Jun 29 19:50:04 2004 +0000
     4.2 +++ b/tools/python/setup.py	Tue Jun 29 20:25:15 2004 +0000
     4.3 @@ -3,7 +3,7 @@ from distutils.core import setup, Extens
     4.4  
     4.5  XEN_ROOT = "../.."
     4.6  
     4.7 -extra_compile_args  = ["-fno-strict-aliasing"]
     4.8 +extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
     4.9  
    4.10  
    4.11  include_dirs = [ XEN_ROOT + "/xen/include/hypervisor-ifs",
     5.1 --- a/tools/python/xen/ext/xc/xc.c	Tue Jun 29 19:50:04 2004 +0000
     5.2 +++ b/tools/python/xen/ext/xc/xc.c	Tue Jun 29 20:25:15 2004 +0000
     5.3 @@ -191,32 +191,42 @@ static PyObject *pyxc_domain_getinfo(PyO
     5.4      return list;
     5.5  }
     5.6  
     5.7 -static int file_save(XcObject *xc, XcIOContext *ctxt, char *state_file){
     5.8 +static int file_save(XcObject *xc, XcIOContext *ctxt, char *state_file)
     5.9 +{
    5.10      int rc = -1;
    5.11      int fd = -1;
    5.12      int open_flags = (O_CREAT | O_EXCL | O_WRONLY);
    5.13      int open_mode = 0644;
    5.14  
    5.15      printf("%s>\n", __FUNCTION__);
    5.16 -    fd = open(state_file, open_flags, open_mode);
    5.17 -    if(fd < 0){
    5.18 +
    5.19 +    if ( (fd = open(state_file, open_flags, open_mode)) < 0 )
    5.20 +    {
    5.21          xcio_perror(ctxt, "Could not open file for writing");
    5.22          goto exit;
    5.23      }
    5.24 +
    5.25 +    printf("%s>gzip_stream_fdopen... \n", __FUNCTION__);
    5.26 +
    5.27      /* Compression rate 1: we want speed over compression. 
    5.28       * We're mainly going for those zero pages, after all.
    5.29       */
    5.30 -    printf("%s>gzip_stream_fdopen... \n", __FUNCTION__);
    5.31      ctxt->io = gzip_stream_fdopen(fd, "wb1");
    5.32 -    if(!ctxt->io){
    5.33 +    if ( ctxt->io == NULL )
    5.34 +    {
    5.35          xcio_perror(ctxt, "Could not allocate compression state");
    5.36          goto exit;
    5.37      }
    5.38 +
    5.39      printf("%s> xc_linux_save...\n", __FUNCTION__);
    5.40 +
    5.41      rc = xc_linux_save(xc->xc_handle, ctxt);
    5.42 +
    5.43    exit:
    5.44 -    if(ctxt->io) IOStream_close(ctxt->io);
    5.45 -    if(fd >= 0) close(fd);
    5.46 +    if ( ctxt->io != NULL )
    5.47 +        IOStream_close(ctxt->io);
    5.48 +    if ( fd >= 0 )
    5.49 +        close(fd);
    5.50      unlink(state_file);
    5.51      printf("%s> rc=%d\n", __FUNCTION__, rc);
    5.52      return rc;
    5.53 @@ -228,53 +238,62 @@ static PyObject *pyxc_linux_save(PyObjec
    5.54  {
    5.55      XcObject *xc = (XcObject *)self;
    5.56  
    5.57 -    u32 dom;
    5.58      char *state_file;
    5.59      int progress = 1, debug = 0;
    5.60 -    unsigned int flags = 0;
    5.61      PyObject *val = NULL;
    5.62      int rc = -1;
    5.63      XcIOContext ioctxt = { .info = iostdout, .err = iostderr };
    5.64  
    5.65      static char *kwd_list[] = { "dom", "state_file", "vmconfig", "progress", "debug", NULL };
    5.66  
    5.67 -    if (!PyArg_ParseTupleAndKeywords(args, kwds, "is|sii", kwd_list, 
    5.68 -                                     &ioctxt.domain,
    5.69 -                                     &state_file,
    5.70 -                                     &ioctxt.vmconfig,
    5.71 -                                     &progress, 
    5.72 -                                     &debug)){
    5.73 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|sii", kwd_list, 
    5.74 +                                      &ioctxt.domain,
    5.75 +                                      &state_file,
    5.76 +                                      &ioctxt.vmconfig,
    5.77 +                                      &progress, 
    5.78 +                                      &debug) )
    5.79          goto exit;
    5.80 -    }
    5.81 +
    5.82      ioctxt.vmconfig_n = (ioctxt.vmconfig ? strlen(ioctxt.vmconfig) : 0);
    5.83 -    if (progress)  ioctxt.flags |= XCFLAGS_VERBOSE;
    5.84 -    if (debug)     ioctxt.flags |= XCFLAGS_DEBUG;
    5.85 -    if(!state_file || state_file[0] == '\0') goto exit;
    5.86 +
    5.87 +    if ( progress )
    5.88 +        ioctxt.flags |= XCFLAGS_VERBOSE;
    5.89 +    if ( debug )
    5.90 +        ioctxt.flags |= XCFLAGS_DEBUG;
    5.91 +
    5.92 +    if ( (state_file == NULL) || (state_file[0] == '\0') )
    5.93 +        goto exit;
    5.94 +    
    5.95      rc = file_save(xc, &ioctxt, state_file);
    5.96 -    if(rc){
    5.97 +    if ( rc != 0 )
    5.98 +    {
    5.99          PyErr_SetFromErrno(xc_error);
   5.100          goto exit;
   5.101      } 
   5.102 -    //xc_domain_destroy(xc->xc_handle, dom);
   5.103 +
   5.104      Py_INCREF(zero);
   5.105      val = zero;
   5.106 +
   5.107    exit:
   5.108      return val;
   5.109  }
   5.110  
   5.111  
   5.112 -static int file_restore(XcObject *xc, XcIOContext *ioctxt, char *state_file){
   5.113 +static int file_restore(XcObject *xc, XcIOContext *ioctxt, char *state_file)
   5.114 +{
   5.115      int rc = -1;
   5.116  
   5.117      ioctxt->io = gzip_stream_fopen(state_file, "rb");
   5.118 -    if (!ioctxt->io) {
   5.119 +    if ( ioctxt->io == NULL )
   5.120 +    {
   5.121          xcio_perror(ioctxt, "Could not open file for reading");
   5.122 -        goto exit;
   5.123 +        return rc;
   5.124      }
   5.125  
   5.126      rc = xc_linux_restore(xc->xc_handle, ioctxt);
   5.127 -  exit:
   5.128 -    if(ioctxt->io) IOStream_close(ioctxt->io);
   5.129 +
   5.130 +    IOStream_close(ioctxt->io);
   5.131 +    
   5.132      return rc;
   5.133  }
   5.134  
   5.135 @@ -285,33 +304,38 @@ static PyObject *pyxc_linux_restore(PyOb
   5.136      XcObject *xc = (XcObject *)self;
   5.137      char *state_file;
   5.138      int progress = 1, debug = 0;
   5.139 -    u32 dom;
   5.140      PyObject *val = NULL;
   5.141      XcIOContext ioctxt = { .info = iostdout, .err = iostderr };
   5.142      int rc =-1;
   5.143  
   5.144      static char *kwd_list[] = { "state_file", "progress", "debug", NULL };
   5.145  
   5.146 -    if (!PyArg_ParseTupleAndKeywords(args, kwds, "is|ii", kwd_list, 
   5.147 -                                     &ioctxt.domain,
   5.148 -                                     &state_file,
   5.149 -                                     &progress,
   5.150 -                                     &debug)){
   5.151 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|ii", kwd_list,
   5.152 +                                      &ioctxt.domain,
   5.153 +                                      &state_file,
   5.154 +                                      &progress,
   5.155 +                                      &debug) )
   5.156          goto exit;
   5.157 -    }
   5.158 -    if (progress) ioctxt.flags |= XCFLAGS_VERBOSE;
   5.159 -    if (debug)    ioctxt.flags |= XCFLAGS_DEBUG;
   5.160 +
   5.161 +    if ( progress )
   5.162 +        ioctxt.flags |= XCFLAGS_VERBOSE;
   5.163 +    if ( debug )
   5.164 +        ioctxt.flags |= XCFLAGS_DEBUG;
   5.165  
   5.166 -    if(!state_file || state_file[0] == '\0') goto exit;
   5.167 +    if ( (state_file == NULL) || (state_file[0] == '\0') )
   5.168 +        goto exit;
   5.169 +
   5.170      rc = file_restore(xc, &ioctxt, state_file);
   5.171 -    if(rc){
   5.172 +    if ( rc != 0 )
   5.173 +    {
   5.174          PyErr_SetFromErrno(xc_error);
   5.175          goto exit;
   5.176      }
   5.177 +
   5.178      val = Py_BuildValue("{s:i,s:s}",
   5.179                          "dom", ioctxt.domain,
   5.180                          "vmconfig", ioctxt.vmconfig);
   5.181 -    //? free(ioctxt.vmconfig);
   5.182 +
   5.183    exit:
   5.184      return val;
   5.185  }
     6.1 --- a/tools/xentrace/Makefile	Tue Jun 29 19:50:04 2004 +0000
     6.2 +++ b/tools/xentrace/Makefile	Tue Jun 29 20:25:15 2004 +0000
     6.3 @@ -3,7 +3,7 @@ XEN_ROOT=../..
     6.4  include $(XEN_ROOT)/tools/Make.defs
     6.5  
     6.6  CC       = gcc
     6.7 -CFLAGS   = -Wall -O3 -Werror
     6.8 +CFLAGS   = -Wall -Werror -O3
     6.9  
    6.10  CFLAGS  += -I $(XEN_HYPERVISOR_IFS)
    6.11  CFLAGS  += -I $(XEN_LINUX_INCLUDE)
    6.12 @@ -34,4 +34,4 @@ clean:
    6.13  	$(RM) *.a *.so *.o *.rpm $(BIN)
    6.14  
    6.15  %: %.c $(HDRS) Makefile
    6.16 -	$(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -lxc
    6.17 +	$(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) -lxc -lxutil