ia64/xen-unstable

changeset 2544:0f827b0e0801

bitkeeper revision 1.1159.1.174 (41544174lO23TSzrMCtW6FnECUFlnQ)

Revert to constructing image first when creating a domain - doing
it later breaks restore.
author mjw@wray-m-3.hpl.hp.com
date Fri Sep 24 15:47:00 2004 +0000 (2004-09-24)
parents 79efeae6d510
children de88814afd44
files tools/libxc/xc_io.h tools/python/xen/xend/XendDomainInfo.py tools/xfrd/xen_domain.c tools/xfrd/xfrd.c
line diff
     1.1 --- a/tools/libxc/xc_io.h	Fri Sep 24 14:19:26 2004 +0000
     1.2 +++ b/tools/libxc/xc_io.h	Fri Sep 24 15:47:00 2004 +0000
     1.3 @@ -13,7 +13,8 @@ typedef struct XcIOContext {
     1.4      IOStream *err;
     1.5      char *vmconfig;
     1.6      int vmconfig_n;
     1.7 -    int (*suspend)(u32 domain, void *data);
     1.8 +    int (*suspend)(void *data, u32 domain);
     1.9 +    int (*configure)(void *data, u32 domain, char *vmconfig, int vmconfig_n);
    1.10      void *data;
    1.11  } XcIOContext;
    1.12  
    1.13 @@ -21,7 +22,18 @@ static inline int xcio_suspend_domain(Xc
    1.14      int err = 0;
    1.15  
    1.16      if(ctxt->suspend){
    1.17 -        err = ctxt->suspend(ctxt->domain, ctxt->data);
    1.18 +        err = ctxt->suspend(ctxt->data, ctxt->domain);
    1.19 +    } else {
    1.20 +        err = -EINVAL;
    1.21 +    }
    1.22 +    return err;
    1.23 +}
    1.24 +
    1.25 +static inline int xcio_configure_domain(XcIOContext *ctxt){
    1.26 +    int err = 0;
    1.27 +
    1.28 +    if(ctxt->configure){
    1.29 +        err = ctxt->configure(ctxt->data, ctxt->domain, ctxt->vmconfig, ctxt->vmconfig_n);
    1.30      } else {
    1.31          err = -EINVAL;
    1.32      }
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 24 14:19:26 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 24 15:47:00 2004 +0000
     2.3 @@ -500,16 +500,14 @@ class XendDomainInfo:
     2.4                  raise VmError('missing memory size')
     2.5  
     2.6              self.init_domain()
     2.7 +            self.construct_image()
     2.8              self.configure_console()
     2.9              self.configure_restart()
    2.10              self.configure_backends()
    2.11              deferred = self.configure()
    2.12 -            def cbok(val):
    2.13 -                return self.construct_image()
    2.14              def cberr(err):
    2.15                  self.destroy()
    2.16                  return err
    2.17 -            deferred.addCallback(cbok)
    2.18              deferred.addErrback(cberr)
    2.19          except StandardError, ex:
    2.20              # Catch errors, cleanup and re-raise.
    2.21 @@ -651,12 +649,7 @@ class XendDomainInfo:
    2.22          devices have been released.
    2.23          """
    2.24          if self.dom is None: return 0
    2.25 -        if self.console:
    2.26 -            if self.restart_pending():
    2.27 -                self.console.deregisterChannel()
    2.28 -            else:
    2.29 -                log.debug('Closing console, domain %s', self.id)
    2.30 -                self.console.close()
    2.31 +        self.destroy_console()
    2.32          chan = xend.getDomChannel(self.dom)
    2.33          if chan:
    2.34              log.debug("Closing channel to domain %d", self.dom)
    2.35 @@ -666,6 +659,14 @@ class XendDomainInfo:
    2.36          except Exception, err:
    2.37              log.exception("Domain destroy failed: %s", self.name)
    2.38  
    2.39 +    def destroy_console(self):
    2.40 +        if self.console:
    2.41 +            if self.restart_pending():
    2.42 +                self.console.deregisterChannel()
    2.43 +            else:
    2.44 +                log.debug('Closing console, domain %s', self.id)
    2.45 +                self.console.close()
    2.46 +
    2.47      def cleanup(self):
    2.48          """Cleanup vm resources: release devices.
    2.49          """
     3.1 --- a/tools/xfrd/xen_domain.c	Fri Sep 24 14:19:26 2004 +0000
     3.2 +++ b/tools/xfrd/xen_domain.c	Fri Sep 24 15:47:00 2004 +0000
     3.3 @@ -16,11 +16,10 @@ typedef unsigned long u32;
     3.4  
     3.5  #define MODULE_NAME "XFRD"
     3.6  #define DEBUG 1
     3.7 -#undef DEBUG
     3.8 +//#undef DEBUG
     3.9  #include "debug.h"
    3.10  
    3.11 -
    3.12 -int domain_suspend(u32 dom, void *data){
    3.13 +int domain_suspend(void *data, u32 dom){
    3.14      int err = 0;
    3.15      Conn *xend = data;
    3.16  
    3.17 @@ -30,6 +29,10 @@ int domain_suspend(u32 dom, void *data){
    3.18      return err;
    3.19  }
    3.20  
    3.21 +int domain_configure(void *data, u32 dom, char *vmconfig, int vmconfig_n){
    3.22 +    return xen_domain_configure(dom, vmconfig, vmconfig_n);
    3.23 +}
    3.24 +
    3.25  #ifndef _XEN_XFR_STUB_
    3.26  static int xc_handle = 0;
    3.27  
    3.28 @@ -131,6 +134,7 @@ int xen_domain_rcv(IOStream *io, uint32_
    3.29      ioctxt->io = io;
    3.30      ioctxt->info = iostdout;
    3.31      ioctxt->err = iostderr;
    3.32 +    ioctxt->configure = domain_configure;
    3.33  
    3.34      err = xc_linux_restore(xcinit(), ioctxt);
    3.35      *dom = ioctxt->domain;
     4.1 --- a/tools/xfrd/xfrd.c	Fri Sep 24 14:19:26 2004 +0000
     4.2 +++ b/tools/xfrd/xfrd.c	Fri Sep 24 15:47:00 2004 +0000
     4.3 @@ -49,8 +49,8 @@
     4.4  #include "select.h"
     4.5  
     4.6  #define MODULE_NAME "XFRD"
     4.7 -#define DEBUG 0
     4.8 -#undef DEBUG
     4.9 +#define DEBUG 1
    4.10 +//#undef DEBUG
    4.11  #include "debug.h"
    4.12  
    4.13  /*
    4.14 @@ -796,7 +796,6 @@ int xfr_recv(Args *args, XfrState *state
    4.15      // before we configure the new one.
    4.16      err = Conn_sxpr(peer, &sxpr);
    4.17      if(err) goto exit;
    4.18 -    //sleep(2);
    4.19      err = xen_domain_configure(state->vmid_new, state->vmconfig, state->vmconfig_n);
    4.20      if(err) goto exit;
    4.21      err = xen_domain_unpause(state->vmid_new);
    4.22 @@ -916,7 +915,7 @@ int xfrd_accept(Args *args, int sock){
    4.23      pid_t pid;
    4.24      int err = 0;
    4.25      
    4.26 -    dprintf(">\n");
    4.27 +    dprintf("> sock=%d\n", sock);
    4.28      dprintf("> accept...\n");
    4.29      peersock = accept(sock, peer, &peer_n);
    4.30      dprintf("> accept=%d\n", peersock);
    4.31 @@ -925,8 +924,8 @@ int xfrd_accept(Args *args, int sock){
    4.32          err = -errno;
    4.33          goto exit;
    4.34      }
    4.35 -    iprintf("> Accepted connection from %s:%d\n",
    4.36 -            inet_ntoa(peer_in.sin_addr), htons(peer_in.sin_port));
    4.37 +    iprintf("> Accepted connection from %s:%d on %d\n",
    4.38 +            inet_ntoa(peer_in.sin_addr), htons(peer_in.sin_port), sock);
    4.39      pid = fork();
    4.40      if(pid > 0){
    4.41          // Parent, fork succeeded.