direct-io.hg

changeset 12782:e843c1fde3c2

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Dec 07 13:18:08 2006 +0000 (2006-12-07)
parents a89599a12d4b a330509abb20
children 27294bab3d62
files
line diff
     1.1 --- a/tools/examples/init.d/xendomains	Thu Dec 07 13:14:44 2006 +0000
     1.2 +++ b/tools/examples/init.d/xendomains	Thu Dec 07 13:18:08 2006 +0000
     1.3 @@ -204,12 +204,14 @@ start()
     1.4  	return; 
     1.5      fi
     1.6  
     1.7 +    saved_domains=" "
     1.8      if [ "$XENDOMAINS_RESTORE" = "true" ] &&
     1.9         contains_something "$XENDOMAINS_SAVE"
    1.10      then
    1.11          mkdir -p $(dirname "$LOCKFILE")
    1.12  	touch $LOCKFILE
    1.13  	echo -n "Restoring Xen domains:"
    1.14 +	saved_domains=`ls $XENDOMAINS_SAVE`
    1.15  	for dom in $XENDOMAINS_SAVE/*; do
    1.16  	    echo -n " ${dom##*/}"
    1.17  	    xm restore $dom
    1.18 @@ -234,9 +236,14 @@ start()
    1.19  	# Create all domains with config files in XENDOMAINS_AUTO.
    1.20  	# TODO: We should record which domain name belongs 
    1.21  	# so we have the option to selectively shut down / migrate later
    1.22 +	# If a domain statefile from $XENDOMAINS_SAVE matches a domain name
    1.23 +	# in $XENDOMAINS_AUTO, do not try to start that domain; if it didn't 
    1.24 +	# restore correctly it requires administrative attention.
    1.25  	for dom in $XENDOMAINS_AUTO/*; do
    1.26  	    echo -n " ${dom##*/}"
    1.27 -	    if is_running $dom; then
    1.28 +	    shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p')
    1.29 +	    echo $saved_domains | grep -w $shortdom > /dev/null
    1.30 +	    if [ $? -eq 0 ] || is_running $dom; then
    1.31  		echo -n "(skip)"
    1.32  	    else
    1.33  		xm create --quiet --defconfig $dom
     2.1 --- a/tools/ioemu/hw/usb-hid.c	Thu Dec 07 13:14:44 2006 +0000
     2.2 +++ b/tools/ioemu/hw/usb-hid.c	Thu Dec 07 13:18:08 2006 +0000
     2.3 @@ -39,6 +39,7 @@ typedef struct USBMouseState {
     2.4      int x, y;
     2.5      int kind;
     2.6      int mouse_grabbed;
     2.7 +    int status_changed;
     2.8  } USBMouseState;
     2.9  
    2.10  /* mostly the same values as the Bochs USB Mouse device */
    2.11 @@ -231,6 +232,7 @@ static void usb_mouse_event(void *opaque
    2.12      s->dy += dy1;
    2.13      s->dz += dz1;
    2.14      s->buttons_state = buttons_state;
    2.15 +    s->status_changed = 1;
    2.16  }
    2.17  
    2.18  static void usb_tablet_event(void *opaque,
    2.19 @@ -242,6 +244,7 @@ static void usb_tablet_event(void *opaqu
    2.20      s->y = y;
    2.21      s->dz += dz;
    2.22      s->buttons_state = buttons_state;
    2.23 +    s->status_changed = 1;
    2.24  }
    2.25  
    2.26  static inline int int_clamp(int val, int vmin, int vmax)
    2.27 @@ -483,10 +486,16 @@ static int usb_mouse_handle_data(USBDevi
    2.28      switch(pid) {
    2.29      case USB_TOKEN_IN:
    2.30          if (devep == 1) {
    2.31 -	    if (s->kind == USB_MOUSE)
    2.32 -		ret = usb_mouse_poll(s, data, len);
    2.33 -	    else if (s->kind == USB_TABLET)
    2.34 -		ret = usb_tablet_poll(s, data, len);
    2.35 +            if (s->kind == USB_MOUSE)
    2.36 +                ret = usb_mouse_poll(s, data, len);
    2.37 +            else if (s->kind == USB_TABLET)
    2.38 +                ret = usb_tablet_poll(s, data, len);
    2.39 +
    2.40 +            if (!s->status_changed)
    2.41 +                ret = USB_RET_NAK;
    2.42 +            else
    2.43 +                s->status_changed = 0;
    2.44 +
    2.45          } else {
    2.46              goto fail;
    2.47          }
    2.48 @@ -523,6 +532,7 @@ USBDevice *usb_tablet_init(void)
    2.49      s->dev.handle_data = usb_mouse_handle_data;
    2.50      s->dev.handle_destroy = usb_mouse_handle_destroy;
    2.51      s->kind = USB_TABLET;
    2.52 +    s->status_changed = 0;
    2.53  
    2.54      pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet");
    2.55  
    2.56 @@ -544,6 +554,7 @@ USBDevice *usb_mouse_init(void)
    2.57      s->dev.handle_data = usb_mouse_handle_data;
    2.58      s->dev.handle_destroy = usb_mouse_handle_destroy;
    2.59      s->kind = USB_MOUSE;
    2.60 +    s->status_changed = 0;
    2.61  
    2.62      pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse");
    2.63  
     3.1 --- a/tools/ioemu/hw/usb-uhci.c	Thu Dec 07 13:14:44 2006 +0000
     3.2 +++ b/tools/ioemu/hw/usb-uhci.c	Thu Dec 07 13:18:08 2006 +0000
     3.3 @@ -424,12 +424,10 @@ static int uhci_handle_td(UHCIState *s, 
     3.4      uint8_t buf[2048];
     3.5      int len, max_len, err, ret;
     3.6  
     3.7 -    if (td->ctrl & TD_CTRL_IOC) {
     3.8 -        *int_mask |= 0x01;
     3.9 +    if (!(td->ctrl & TD_CTRL_ACTIVE)){
    3.10 +        ret = 1;
    3.11 +        goto out;
    3.12      }
    3.13 -    
    3.14 -    if (!(td->ctrl & TD_CTRL_ACTIVE))
    3.15 -        return 1;
    3.16  
    3.17      /* TD is active */
    3.18      max_len = ((td->token >> 21) + 1) & 0x7ff;
    3.19 @@ -467,7 +465,8 @@ static int uhci_handle_td(UHCIState *s, 
    3.20          /* invalid pid : frame interrupted */
    3.21          s->status |= UHCI_STS_HCPERR;
    3.22          uhci_update_irq(s);
    3.23 -        return -1;
    3.24 +        ret = -1;
    3.25 +        goto out;
    3.26      }
    3.27      if (td->ctrl & TD_CTRL_IOS)
    3.28          td->ctrl &= ~TD_CTRL_ACTIVE;
    3.29 @@ -479,10 +478,12 @@ static int uhci_handle_td(UHCIState *s, 
    3.30              len < max_len) {
    3.31              *int_mask |= 0x02;
    3.32              /* short packet: do not update QH */
    3.33 -            return 1;
    3.34 +            ret = 1;
    3.35 +            goto out;
    3.36          } else {
    3.37              /* success */
    3.38 -            return 0;
    3.39 +            ret = 0;
    3.40 +            goto out;
    3.41          }
    3.42      } else {
    3.43          switch(ret) {
    3.44 @@ -501,23 +502,34 @@ static int uhci_handle_td(UHCIState *s, 
    3.45              }
    3.46              td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) | 
    3.47                  (err << TD_CTRL_ERROR_SHIFT);
    3.48 -            return 1;
    3.49 +            ret = 1;
    3.50 +            goto out;
    3.51          case USB_RET_NAK:
    3.52              td->ctrl |= TD_CTRL_NAK;
    3.53              if (pid == USB_TOKEN_SETUP)
    3.54                  goto do_timeout;
    3.55 -            return 1;
    3.56 +            ret = 1;
    3.57 +            goto out;
    3.58          case USB_RET_STALL:
    3.59              td->ctrl |= TD_CTRL_STALL;
    3.60              td->ctrl &= ~TD_CTRL_ACTIVE;
    3.61 -            return 1;
    3.62 +            ret = 1;
    3.63 +            goto out;
    3.64          case USB_RET_BABBLE:
    3.65              td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
    3.66              td->ctrl &= ~TD_CTRL_ACTIVE;
    3.67              /* frame interrupted */
    3.68 -            return -1;
    3.69 +            ret = -1;
    3.70 +            goto out;
    3.71          }
    3.72      }
    3.73 +   
    3.74 +out:
    3.75 +    /* If TD is inactive and IOC bit set to 1 then update int_mask */ 
    3.76 +    if ((td->ctrl & TD_CTRL_IOC) && (!(td->ctrl & TD_CTRL_ACTIVE))) {
    3.77 +        *int_mask |= 0x01;
    3.78 +    }
    3.79 +    return ret;
    3.80  }
    3.81  
    3.82  static void uhci_frame_timer(void *opaque)
     4.1 --- a/tools/python/xen/web/httpserver.py	Thu Dec 07 13:14:44 2006 +0000
     4.2 +++ b/tools/python/xen/web/httpserver.py	Thu Dec 07 13:18:08 2006 +0000
     4.3 @@ -264,7 +264,32 @@ class HttpServerRequest(http.HttpRequest
     4.4              s += x + "/"
     4.5              self.write(' <a href="%s">%s</a>/' % (s, x))
     4.6          self.write("</h1>")
     4.7 -        
     4.8 +
     4.9 +class HttpServerClient:
    4.10 +
    4.11 +    def __init__(self, server, sock, addr):
    4.12 +        self.server = server
    4.13 +        self.sock = sock
    4.14 +        self.addr = addr
    4.15 +
    4.16 +    def process(self):
    4.17 +        thread = threading.Thread(target=self.doProcess)
    4.18 +        thread.setDaemon(True)
    4.19 +        thread.start()
    4.20 +
    4.21 +    def doProcess(self):
    4.22 +        try:
    4.23 +            rp = RequestProcessor(self.server, self.sock, self.addr)
    4.24 +            rp.process()
    4.25 +        except SystemExit:
    4.26 +            raise
    4.27 +        except Exception, ex:
    4.28 +            print 'HttpServer>processRequest> exception: ', ex
    4.29 +            try:
    4.30 +                self.sock.close()
    4.31 +            except:
    4.32 +                pass
    4.33 +
    4.34  class HttpServer:
    4.35  
    4.36      backlog = 5
    4.37 @@ -286,8 +311,8 @@ class HttpServer:
    4.38  
    4.39          while not self.closed:
    4.40              (sock, addr) = self.accept()
    4.41 -            self.processRequest(sock, addr)
    4.42 -
    4.43 +            cl = HttpServerClient(self, sock, addr)
    4.44 +            cl.process()
    4.45  
    4.46      def stop(self):
    4.47          self.close()
    4.48 @@ -314,19 +339,6 @@ class HttpServer:
    4.49          except:
    4.50              pass
    4.51  
    4.52 -    def processRequest(self, sock, addr):
    4.53 -        try:
    4.54 -            rp = RequestProcessor(self, sock, addr)
    4.55 -            rp.process()
    4.56 -        except SystemExit:
    4.57 -            raise
    4.58 -        except Exception, ex:
    4.59 -            print 'HttpServer>processRequest> exception: ', ex
    4.60 -            try:
    4.61 -                sock.close()
    4.62 -            except:
    4.63 -                pass
    4.64 -
    4.65      def getServerAddr(self):
    4.66          return (socket.gethostname(), self.port)
    4.67  
     5.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Dec 07 13:14:44 2006 +0000
     5.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Dec 07 13:18:08 2006 +0000
     5.3 @@ -42,6 +42,39 @@ def reverse_dict(adict):
     5.4  def bool0(v):
     5.5      return v != '0' and bool(v)
     5.6  
     5.7 +# Recursively copy a data struct, scrubbing out VNC passwords.
     5.8 +# Will scrub any dict entry with a key of 'vncpasswd' or any
     5.9 +# 2-element list whose first member is 'vncpasswd'. It will
    5.10 +# also scrub a string matching '(vncpasswd XYZ)'. Everything
    5.11 +# else is no-op passthrough
    5.12 +def scrub_password(data):
    5.13 +    if type(data) == dict or type(data) == XendConfig:
    5.14 +        scrubbed = {}
    5.15 +        for key in data.keys():
    5.16 +            if key == "vncpasswd":
    5.17 +                scrubbed[key] = "XXXXXXXX"
    5.18 +            else:
    5.19 +                scrubbed[key] = scrub_password(data[key])
    5.20 +        return scrubbed
    5.21 +    elif type(data) == list:
    5.22 +        if len(data) == 2 and type(data[0]) == str and data[0] == 'vncpasswd':
    5.23 +            return ['vncpasswd', 'XXXXXXXX']
    5.24 +        else:
    5.25 +            scrubbed = []
    5.26 +            for entry in data:
    5.27 +                scrubbed.append(scrub_password(entry))
    5.28 +            return scrubbed
    5.29 +    elif type(data) == tuple:
    5.30 +        scrubbed = []
    5.31 +        for entry in data:
    5.32 +            scrubbed.append(scrub_password(entry))
    5.33 +        return tuple(scrubbed)
    5.34 +    elif type(data) == str:
    5.35 +        return re.sub(r'\(vncpasswd\s+[^\)]+\)','(vncpasswd XXXXXX)', data)
    5.36 +    else:
    5.37 +        return data
    5.38 +
    5.39 +
    5.40  # Mapping from XendConfig configuration keys to the old
    5.41  # legacy configuration keys that map directly.
    5.42  
    5.43 @@ -269,7 +302,7 @@ class XendConfig(dict):
    5.44              # output from xc.domain_getinfo
    5.45              self._dominfo_to_xapi(dominfo)
    5.46  
    5.47 -        log.debug('XendConfig.init: %s' % self)
    5.48 +        log.debug('XendConfig.init: %s' % scrub_password(self))
    5.49  
    5.50          # validators go here
    5.51          self.validate()
    5.52 @@ -478,7 +511,7 @@ class XendConfig(dict):
    5.53              else:
    5.54                  for opt, val in config[1:]:
    5.55                      dev_info[opt] = val
    5.56 -                log.debug("XendConfig: reading device: %s" % dev_info)
    5.57 +                log.debug("XendConfig: reading device: %s" % scrub_password(dev_info))
    5.58                  # create uuid if it doesn't
    5.59                  dev_uuid = dev_info.get('uuid', uuid.createString())
    5.60                  dev_info['uuid'] = dev_uuid
     6.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 13:14:44 2006 +0000
     6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 13:18:08 2006 +0000
     6.3 @@ -40,6 +40,7 @@ from xen.util import security
     6.4  from xen.xend import balloon, sxp, uuid, image, arch
     6.5  from xen.xend import XendRoot, XendNode, XendConfig
     6.6  
     6.7 +from xen.xend.XendConfig import scrub_password
     6.8  from xen.xend.XendBootloader import bootloader
     6.9  from xen.xend.XendError import XendError, VmError
    6.10  from xen.xend.XendDevices import XendDevices
    6.11 @@ -148,7 +149,7 @@ def create(config):
    6.12      @raise VmError: Invalid configuration or failure to start.
    6.13      """
    6.14  
    6.15 -    log.debug("XendDomainInfo.create(%s)", config)
    6.16 +    log.debug("XendDomainInfo.create(%s)", scrub_password(config))
    6.17      vm = XendDomainInfo(XendConfig.XendConfig(sxp_obj = config))
    6.18      try:
    6.19          vm.start()
    6.20 @@ -175,7 +176,7 @@ def recreate(info, priv):
    6.21      @raise XendError: Errors with configuration.
    6.22      """
    6.23  
    6.24 -    log.debug("XendDomainInfo.recreate(%s)", info)
    6.25 +    log.debug("XendDomainInfo.recreate(%s)", scrub_password(info))
    6.26  
    6.27      assert not info['dying']
    6.28  
    6.29 @@ -257,7 +258,7 @@ def restore(config):
    6.30      @raise XendError: Errors with configuration.
    6.31      """
    6.32  
    6.33 -    log.debug("XendDomainInfo.restore(%s)", config)
    6.34 +    log.debug("XendDomainInfo.restore(%s)", scrub_password(config))
    6.35      vm = XendDomainInfo(XendConfig.XendConfig(sxp_obj = config),
    6.36                          resume = True)
    6.37      try:
    6.38 @@ -280,7 +281,7 @@ def createDormant(domconfig):
    6.39      @raise XendError: Errors with configuration.    
    6.40      """
    6.41      
    6.42 -    log.debug("XendDomainInfo.createDormant(%s)", domconfig)
    6.43 +    log.debug("XendDomainInfo.createDormant(%s)", scrub_password(domconfig))
    6.44      
    6.45      # domid does not make sense for non-running domains.
    6.46      domconfig.pop('domid', None)
    6.47 @@ -520,11 +521,11 @@ class XendDomainInfo:
    6.48          @param dev_config: device configuration
    6.49          @type  dev_config: SXP object (parsed config)
    6.50          """
    6.51 -        log.debug("XendDomainInfo.device_create: %s" % dev_config)
    6.52 +        log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config))
    6.53          dev_type = sxp.name(dev_config)
    6.54          dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config)
    6.55          dev_config_dict = self.info['devices'][dev_uuid][1]
    6.56 -        log.debug("XendDomainInfo.device_create: %s" % dev_config_dict)
    6.57 +        log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict))
    6.58          devid = self._createDevice(dev_type, dev_config_dict)
    6.59          self._waitForDevice(dev_type, devid)
    6.60          return self.getDeviceController(dev_type).sxpr(devid)
    6.61 @@ -746,7 +747,7 @@ class XendDomainInfo:
    6.62  
    6.63          to_store.update(self._vcpuDomDetails())
    6.64  
    6.65 -        log.debug("Storing domain details: %s", to_store)
    6.66 +        log.debug("Storing domain details: %s", scrub_password(to_store))
    6.67  
    6.68          self._writeDom(to_store)
    6.69  
    6.70 @@ -1188,7 +1189,7 @@ class XendDomainInfo:
    6.71          """
    6.72          for (devclass, config) in self.info.get('devices', {}).values():
    6.73              if devclass in XendDevices.valid_devices():            
    6.74 -                log.info("createDevice: %s : %s" % (devclass, config))
    6.75 +                log.info("createDevice: %s : %s" % (devclass, scrub_password(config)))
    6.76                  self._createDevice(devclass, config)
    6.77  
    6.78          if self.image:
    6.79 @@ -1667,7 +1668,7 @@ class XendDomainInfo:
    6.80          if not self._readVm('xend/restart_count'):
    6.81              to_store['xend/restart_count'] = str(0)
    6.82  
    6.83 -        log.debug("Storing VM details: %s", to_store)
    6.84 +        log.debug("Storing VM details: %s", scrub_password(to_store))
    6.85  
    6.86          self._writeVm(to_store)
    6.87          self._setVmPermissions()
     7.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Thu Dec 07 13:14:44 2006 +0000
     7.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Thu Dec 07 13:18:08 2006 +0000
     7.3 @@ -21,6 +21,7 @@ from xen.web import http
     7.4  from xen.xend import sxp
     7.5  from xen.xend import XendDomain
     7.6  from xen.xend.Args import FormFn
     7.7 +from xen.xend.XendLogging import log
     7.8  
     7.9  from xen.web.SrvDir import SrvDir
    7.10  
    7.11 @@ -63,6 +64,18 @@ class SrvDomain(SrvDir):
    7.12          self.acceptCommand(req)
    7.13          return self.dom.shutdown(req.args['reason'][0])
    7.14  
    7.15 +    def op_delete(self, _, req):
    7.16 +        self.acceptCommand(req)
    7.17 +        return self.xd.domain_delete(self.dom.getName())
    7.18 +
    7.19 +    def op_start(self, _, req):
    7.20 +        self.acceptCommand(req)
    7.21 +        paused = False
    7.22 +        if 'paused' in req.args and req.args['paused'] == [1]:
    7.23 +            paused = True
    7.24 +        log.debug("Starting domain " + self.dom.getName() + " " + str(paused))
    7.25 +        return self.xd.domain_start(self.dom.getName(), paused)
    7.26 +
    7.27      def op_sysrq(self, _, req):
    7.28          self.acceptCommand(req)
    7.29          return self.dom.send_sysrq(int(req.args['key'][0]))
     8.1 --- a/tools/python/xen/xend/server/SrvDomainDir.py	Thu Dec 07 13:14:44 2006 +0000
     8.2 +++ b/tools/python/xen/xend/server/SrvDomainDir.py	Thu Dec 07 13:18:08 2006 +0000
     8.3 @@ -25,6 +25,8 @@ from xen.xend import XendDomain
     8.4  from xen.xend.XendDomainInfo import XendDomainInfo
     8.5  from xen.xend.Args import FormFn
     8.6  from xen.xend.XendError import XendError
     8.7 +from xen.xend.XendLogging import log
     8.8 +from xen.xend.XendConstants import DOM_STATE_RUNNING
     8.9  
    8.10  from xen.web.SrvDir import SrvDir
    8.11  from SrvDomain import SrvDomain
    8.12 @@ -101,6 +103,35 @@ class SrvDomainDir(SrvDir):
    8.13              out.close()
    8.14              return val
    8.15  
    8.16 +    def op_new(self, _, req):
    8.17 +        """Define a new domain.
    8.18 +        Expects the domain config in request parameter 'config' in SXP format.
    8.19 +        """
    8.20 +        ok = 0
    8.21 +        errmsg = ''
    8.22 +        try:
    8.23 +            configstring = req.args.get('config')[0]
    8.24 +            #print 'op_create>', 'config:', configstring
    8.25 +            pin = sxp.Parser()
    8.26 +            pin.input(configstring)
    8.27 +            pin.input_eof()
    8.28 +            config = pin.get_val()
    8.29 +            ok = 1
    8.30 +        except sxp.ParseError, ex:
    8.31 +            errmsg = 'Invalid configuration ' + str(ex)
    8.32 +        except Exception, ex:
    8.33 +            print 'op_create> Exception in config', ex
    8.34 +            traceback.print_exc()
    8.35 +            errmsg = 'Configuration error ' + str(ex)
    8.36 +        if not ok:
    8.37 +            raise XendError(errmsg)
    8.38 +        try:
    8.39 +            self.xd.domain_new(config)
    8.40 +        except Exception, ex:
    8.41 +            print 'op_create> Exception creating domain:'
    8.42 +            traceback.print_exc()
    8.43 +            raise XendError("Error creating domain: " + str(ex))
    8.44 +
    8.45      def op_restore(self, op, req):
    8.46          """Restore a domain from file.
    8.47  
    8.48 @@ -159,7 +190,11 @@ class SrvDomainDir(SrvDir):
    8.49              if detail:
    8.50                  sxp.show(map(XendDomainInfo.sxpr, self.xd.list()), out=req)
    8.51              else:
    8.52 -                sxp.show(self.xd.list_names(), out=req)
    8.53 +                state = DOM_STATE_RUNNING
    8.54 +                if 'state' in req.args and len(req.args['state']) > 0:
    8.55 +                    state = req.args['state'][0]
    8.56 +                log.debug("Listing domains in state " + str(state))
    8.57 +                sxp.show(self.xd.list_names(state), out=req)
    8.58          else:
    8.59              domains = self.xd.list_sorted()
    8.60              req.write('<ul>')
     9.1 --- a/tools/python/xen/xm/create.py	Thu Dec 07 13:14:44 2006 +0000
     9.2 +++ b/tools/python/xen/xm/create.py	Thu Dec 07 13:18:08 2006 +0000
     9.3 @@ -704,8 +704,10 @@ def configure_hvm(config_image, vals):
     9.4      config_image.append(['vncpasswd', vals.vncpasswd])
     9.5  
     9.6  def run_bootloader(vals, config_image):
     9.7 +    if not os.access(vals.bootloader, os.F_OK):
     9.8 +        err("Bootloader '%s' does not exist" % vals.bootloader)
     9.9      if not os.access(vals.bootloader, os.X_OK):
    9.10 -        err("Bootloader isn't executable")
    9.11 +        err("Bootloader '%s' isn't executable" % vals.bootloader)
    9.12      if len(vals.disk) < 1:
    9.13          err("No disks configured and boot loader requested")
    9.14      (uname, dev, mode, backend) = vals.disk[0]
    10.1 --- a/tools/python/xen/xm/main.py	Thu Dec 07 13:14:44 2006 +0000
    10.2 +++ b/tools/python/xen/xm/main.py	Thu Dec 07 13:18:08 2006 +0000
    10.3 @@ -30,6 +30,7 @@ import socket
    10.4  import traceback
    10.5  import xmlrpclib
    10.6  import traceback
    10.7 +import time
    10.8  import datetime
    10.9  from select import select
   10.10  import xml.dom.minidom
   10.11 @@ -626,7 +627,13 @@ def parse_doms_info(info):
   10.12  
   10.13      def get_status(n, t, d):
   10.14          return DOM_STATES[t(sxp.child_value(info, n, d))]
   10.15 -    
   10.16 +
   10.17 +    start_time = get_info('start_time', float, -1)
   10.18 +    if start_time == -1:
   10.19 +        up_time = float(-1)
   10.20 +    else:
   10.21 +        up_time = time.time() - start_time
   10.22 +
   10.23      return {
   10.24          'domid'    : get_info('domid',        str,   ''),
   10.25          'name'     : get_info('name',         str,   '??'),
   10.26 @@ -634,7 +641,7 @@ def parse_doms_info(info):
   10.27          'vcpus'    : get_info('vcpus',        int,   0),
   10.28          'state'    : get_info('state',        str,    ''),
   10.29          'cpu_time' : get_info('cpu_time',     float, 0),
   10.30 -        'up_time'  : get_info('up_time',      float, -1),
   10.31 +        'up_time'  : up_time,
   10.32          'seclabel' : security.get_security_printlabel(info),
   10.33          }
   10.34  
   10.35 @@ -1209,7 +1216,7 @@ def xm_uptime(args):
   10.36  
   10.37      for dom in doms:
   10.38          d = parse_doms_info(dom)
   10.39 -        if d['domid'] > 0:
   10.40 +        if int(d['domid']) > 0:
   10.41              uptime = int(round(d['up_time']))
   10.42          else:
   10.43              f=open('/proc/uptime', 'r')
   10.44 @@ -1236,10 +1243,10 @@ def xm_uptime(args):
   10.45          if short_mode:
   10.46              now = datetime.datetime.now()
   10.47              upstring = now.strftime(" %H:%M:%S") + " up " + upstring
   10.48 -            upstring += ", " + d['name'] + " (" + str(d['domid']) + ")"
   10.49 +            upstring += ", " + d['name'] + " (" + d['domid'] + ")"
   10.50          else:
   10.51              upstring += ':%(seconds)02d' % vars()
   10.52 -            upstring = ("%(name)-32s %(domid)3d " % d) + upstring
   10.53 +            upstring = ("%(name)-32s %(domid)3s " % d) + upstring
   10.54  
   10.55          print upstring
   10.56