direct-io.hg

changeset 1785:9a1d945b5038

bitkeeper revision 1.1081.1.1 (40f552eaWV4viomXWEuk8dzfLHid7g)

Change to new restart model.
author mjw@wray-m-3.hpl.hp.com
date Wed Jul 14 15:36:10 2004 +0000 (2004-07-14)
parents f48283c49033
children 9c6eeedea833
files .rootkeys tools/examples/xmdefaults tools/examples/xmnetbsd tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xm/create.py tools/python/xen/xm/destroy.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/.rootkeys	Wed Jul 14 11:46:25 2004 +0000
     1.2 +++ b/.rootkeys	Wed Jul 14 15:36:10 2004 +0000
     1.3 @@ -273,6 +273,7 @@ 40c9c469ZqILEQ8x6yWy0_51jopiCg tools/pyt
     1.4  40c9c469LNxLVizOUpOjEaTKKCm8Aw tools/python/xen/xend/sxp.py
     1.5  40d05079aFRp6NQdo5wIh5Ly31c0cg tools/python/xen/xm/__init__.py
     1.6  40cf2937gKQcATgXKGtNeWb1PDH5nA tools/python/xen/xm/create.py
     1.7 +40f552eariuUSB9TWqCPnDLz5zvxMw tools/python/xen/xm/destroy.py
     1.8  40e41cd2w0I4En6qrJn4em8HkK_oxQ tools/python/xen/xm/help.py
     1.9  40cf2937isyS250zyd0Q2GuEDoNXfQ tools/python/xen/xm/main.py
    1.10  40cf2937PSslwBliN1g7ofDy2H_RhA tools/python/xen/xm/opts.py
     2.1 --- a/tools/examples/xmdefaults	Wed Jul 14 11:46:25 2004 +0000
     2.2 +++ b/tools/examples/xmdefaults	Wed Jul 14 15:36:10 2004 +0000
     2.3 @@ -91,8 +91,11 @@ root = "/dev/sda1 ro"
     2.4  extra = "4 VMID=%d usr=/dev/sda6" % vmid
     2.5  
     2.6  #----------------------------------------------------------------------------
     2.7 -# Set according to whether you want the domain  restarted when it exits.
     2.8 -# The default is False.
     2.9 -#autorestart = True
    2.10 +# Set according to whether you want the domain restarted when it exits.
    2.11 +# The default is 'onreboot', which restarts the domain when it shuts down
    2.12 +# with exit code reboot.
    2.13 +# Other values are 'always', and 'never'.
    2.14 +
    2.15 +#restart = 'onreboot'
    2.16  
    2.17  #============================================================================
     3.1 --- a/tools/examples/xmnetbsd	Wed Jul 14 11:46:25 2004 +0000
     3.2 +++ b/tools/examples/xmnetbsd	Wed Jul 14 15:36:10 2004 +0000
     3.3 @@ -94,8 +94,10 @@ extra = "4 VMID=%d bootdev=xennet0" % vm
     3.4  
     3.5  
     3.6  #----------------------------------------------------------------------------
     3.7 -# Set according to whether you want the domain  restarted when it exits.
     3.8 -# The default is False.
     3.9 -#autorestart = True
    3.10 -
    3.11 +# Set according to whether you want the domain restarted when it exits.
    3.12 +# The default is 'onreboot', which restarts the domain when it shuts down
    3.13 +# with exit code reboot.
    3.14 +# Other values are 'always', and 'never'.
    3.15 +#
    3.16 +#restart = 'onreboot'
    3.17  #============================================================================
     4.1 --- a/tools/python/xen/xend/XendClient.py	Wed Jul 14 11:46:25 2004 +0000
     4.2 +++ b/tools/python/xen/xend/XendClient.py	Wed Jul 14 15:36:10 2004 +0000
     4.3 @@ -256,9 +256,10 @@ class Xend:
     4.4                           {'op'      : 'shutdown',
     4.5                            'reason'  : reason })
     4.6  
     4.7 -    def xend_domain_destroy(self, id):
     4.8 +    def xend_domain_destroy(self, id, reason):
     4.9          return xend_call(self.domainurl(id),
    4.10 -                         {'op'      : 'destroy' })
    4.11 +                         {'op'      : 'destroy',
    4.12 +                          'reason'  : reason })
    4.13  
    4.14      def xend_domain_save(self, id, filename):
    4.15          return xend_call(self.domainurl(id),
     5.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Jul 14 11:46:25 2004 +0000
     5.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed Jul 14 15:36:10 2004 +0000
     5.3 @@ -378,9 +378,9 @@ class XendDomain:
     5.4      
     5.5      def domain_shutdown(self, id, reason='poweroff'):
     5.6          """Shutdown domain (nicely).
     5.7 -         - poweroff: domain will restart if has autorestart set.
     5.8 -         - reboot: domain will restart.
     5.9 -         - halt: domain will not restart (even if has autorestart set).
    5.10 +         - poweroff: restart according to exit code and restart mode
    5.11 +         - reboot:   restart on exit
    5.12 +         - halt:     do not restart
    5.13  
    5.14           Returns immediately.
    5.15  
    5.16 @@ -388,12 +388,13 @@ class XendDomain:
    5.17          @param reason: shutdown type: poweroff, reboot, suspend, halt
    5.18          """
    5.19          dom = int(id)
    5.20 +        id = str(id)
    5.21          if dom <= 0:
    5.22              return 0
    5.23          if reason == 'halt':
    5.24              self.domain_restart_cancel(id)
    5.25          else:
    5.26 -            self.domain_restart_schedule(id, reason)
    5.27 +            self.domain_restart_schedule(id, reason, set=1)
    5.28          eserver.inject('xend.domain.shutdown', [id, reason])
    5.29          if reason == 'halt':
    5.30              reason = 'poweroff'
    5.31 @@ -401,21 +402,24 @@ class XendDomain:
    5.32          self.refresh_schedule()
    5.33          return val
    5.34  
    5.35 -    def domain_restart_schedule(self, id, reason):
    5.36 +    def domain_restart_schedule(self, id, reason, set=0):
    5.37          """Schedule a restart for a domain if it needs one.
    5.38  
    5.39          @param id:     domain id
    5.40          @param reason: shutdown reason
    5.41          """
    5.42 +        print 'domain_restart_schedule>', id, reason, set
    5.43          dominfo = self.domain.get(id)
    5.44 -        if not dominfo or id in self.restarts:
    5.45 -            # Don't schedule if unknown or already there.
    5.46 +        if not dominfo:
    5.47 +            return
    5.48 +        if id in self.restarts:
    5.49              return
    5.50 -        restart = ((reason == 'reboot') or
    5.51 -                   (reason == 'poweroff' and dominfo.autorestart))
    5.52 +        if set and reason == 'reboot':
    5.53 +            dominfo.restart_mode = XendDomainInfo.RESTART_ALWAYS
    5.54 +        restart = dominfo.restart_needed(reason)
    5.55          if restart:
    5.56 -            # Clear autorestart flag to avoid multiple restarts.
    5.57 -            dominfo.autorestart = 0
    5.58 +            # Avoid multiple restarts.
    5.59 +            dominfo.restart_mode = XendDomainInfo.RESTART_NEVER
    5.60              self.restarts[id] = dominfo.config
    5.61              print 'Scheduling restart for domain:', id, dominfo.name
    5.62              self.domain_restarts_schedule()
    5.63 @@ -427,7 +431,7 @@ class XendDomain:
    5.64          """
    5.65          dominfo = self.domain.get(id)
    5.66          if dominfo:
    5.67 -            dominfo.autorestart = 0
    5.68 +            dominfo.restart_mode = XendDomainInfo.RESTART_NEVER
    5.69          if id in self.restarts:
    5.70              del self.restarts[id]
    5.71  
    5.72 @@ -474,13 +478,18 @@ class XendDomain:
    5.73              val = xc.domain_destroy(dom=dom)
    5.74          return val       
    5.75  
    5.76 -    def domain_destroy(self, id):
    5.77 +    def domain_destroy(self, id, reason='halt'):
    5.78          """Terminate domain immediately.
    5.79 -        Cancels any restart for the domain.
    5.80 +        - halt:   cancel any restart for the domain
    5.81 +        - reboot  schedule a restart for the domain
    5.82  
    5.83          @param id: domain id
    5.84          """
    5.85 -        self.domain_restart_cancel(id)
    5.86 +        id = str(id)
    5.87 +        if reason == 'halt':
    5.88 +            self.domain_restart_cancel(id)
    5.89 +        elif reason == 'reboot':
    5.90 +            self.domain_restart_schedule(id, reason, set=1)
    5.91          val = self.final_domain_destroy(id)
    5.92          self.refresh_schedule()
    5.93          return val
     6.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Jul 14 11:46:25 2004 +0000
     6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Jul 14 15:36:10 2004 +0000
     6.3 @@ -50,6 +50,16 @@ shutdown_reasons = {
     6.4      DOMAIN_REBOOT  : "reboot",
     6.5      DOMAIN_SUSPEND : "suspend" }
     6.6  
     6.7 +RESTART_ALWAYS   = 'always'
     6.8 +RESTART_ONREBOOT = 'onreboot'
     6.9 +RESTART_NEVER    = 'never'
    6.10 +
    6.11 +restart_modes = [
    6.12 +    RESTART_ALWAYS,
    6.13 +    RESTART_ONREBOOT,
    6.14 +    RESTART_NEVER,
    6.15 +    ]
    6.16 +
    6.17  def shutdown_reason(code):
    6.18      """Get a shutdown reason from a code.
    6.19  
    6.20 @@ -117,7 +127,12 @@ def lookup_disk_uname(uname):
    6.21  def make_disk(dom, uname, dev, mode, recreate=0):
    6.22      """Create a virtual disk device for a domain.
    6.23  
    6.24 -    @returns Deferred
    6.25 +    @param dom:      domain id
    6.26 +    @param uname:    device to export
    6.27 +    @param dev:      device name in domain
    6.28 +    @param mode:     read/write mode
    6.29 +    @param recreate: recreate flag (after xend restart)
    6.30 +    @return: deferred
    6.31      """
    6.32      segments = lookup_disk_uname(uname)
    6.33      if not segments:
    6.34 @@ -234,7 +249,6 @@ def vm_create(config):
    6.35      returns Deferred
    6.36      raises VmError for invalid configuration
    6.37      """
    6.38 -    print 'vm_create>'
    6.39      vm = XendDomainInfo()
    6.40      return vm.construct(config)
    6.41  
    6.42 @@ -289,28 +303,21 @@ def append_deferred(dlist, v):
    6.43  
    6.44  def _vm_configure1(val, vm):
    6.45      d = vm.create_devices()
    6.46 -    #print '_vm_configure1> made devices...'
    6.47      def cbok(x):
    6.48 -        #print '_vm_configure1> cbok', x
    6.49          return x
    6.50      d.addCallback(cbok)
    6.51      d.addCallback(_vm_configure2, vm)
    6.52 -    #print '_vm_configure1<'
    6.53      return d
    6.54  
    6.55  def _vm_configure2(val, vm):
    6.56 -    #print '>callback _vm_configure2...'
    6.57      d = vm.configure_fields()
    6.58      def cbok(results):
    6.59 -        #print '_vm_configure2> cbok', results
    6.60          return vm
    6.61      def cberr(err):
    6.62 -        #print '_vm_configure2> cberr', err
    6.63          vm.destroy()
    6.64          return err
    6.65      d.addCallback(cbok)
    6.66      d.addErrback(cberr)
    6.67 -    #print '<_vm_configure2'
    6.68      return d
    6.69  
    6.70  class XendDomainInfo:
    6.71 @@ -341,7 +348,7 @@ class XendDomainInfo:
    6.72          #todo: set to migrate info if migrating
    6.73          self.migrate = None
    6.74          #Whether to auto-restart
    6.75 -        self.autorestart = 0
    6.76 +        self.restart_mode = RESTART_ONREBOOT
    6.77  
    6.78      def setdom(self, dom):
    6.79          self.dom = int(dom)
    6.80 @@ -381,8 +388,7 @@ class XendDomainInfo:
    6.81              state = run + block + stop + susp + crash
    6.82              sxpr.append(['state', state])
    6.83              if self.info['shutdown']:
    6.84 -                reasons = ["poweroff", "reboot", "suspend"]
    6.85 -                reason = reasons[self.info['shutdown_reason']]
    6.86 +                reason = shutdown_reason(self.info['shutdown_reason'])
    6.87                  sxpr.append(['shutdown_reason', reason])
    6.88              sxpr.append(['cpu', self.info['cpu']])
    6.89              sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
    6.90 @@ -398,8 +404,7 @@ class XendDomainInfo:
    6.91          try:
    6.92              self.name = sxp.child_value(config, 'name')
    6.93              self.memory = int(sxp.child_value(config, 'memory', '128'))
    6.94 -            if sxp.child(config, 'autorestart', None):
    6.95 -                self.autorestart = 1
    6.96 +            self.configure_restart()
    6.97              self.configure_backends()
    6.98              image = sxp.child_value(config, 'image')
    6.99              if image is None:
   6.100 @@ -413,7 +418,6 @@ class XendDomainInfo:
   6.101              image_handler(self, image)
   6.102              deferred = self.configure()
   6.103              def cbok(x):
   6.104 -                print 'vm_create> cbok', x
   6.105                  return x
   6.106              def cberr(err):
   6.107                  self.destroy()
   6.108 @@ -424,7 +428,6 @@ class XendDomainInfo:
   6.109              # Catch errors, cleanup and re-raise.
   6.110              self.destroy()
   6.111              raise
   6.112 -        print 'vm_create<'
   6.113          return deferred
   6.114  
   6.115      def config_devices(self, name):
   6.116 @@ -514,7 +517,6 @@ class XendDomainInfo:
   6.117      def cleanup(self):
   6.118          """Cleanup vm resources: release devices.
   6.119          """
   6.120 -        print 'cleanup>', self.dom
   6.121          self.state = self.STATE_TERMINATED
   6.122          self.release_devices()
   6.123  
   6.124 @@ -526,7 +528,6 @@ class XendDomainInfo:
   6.125      def release_devices(self):
   6.126          """Release all vm devices.
   6.127          """
   6.128 -        print 'release_devices>', self.dom
   6.129          self.release_vifs()
   6.130          self.release_vbds()
   6.131          self.devices = {}
   6.132 @@ -534,7 +535,6 @@ class XendDomainInfo:
   6.133      def release_vifs(self):
   6.134          """Release vm virtual network devices (vifs).
   6.135          """
   6.136 -        print 'release_vifs>', self.dom
   6.137          if self.dom is None: return
   6.138          ctrl = xend.netif_get(self.dom)
   6.139          if ctrl:
   6.140 @@ -543,7 +543,6 @@ class XendDomainInfo:
   6.141      def release_vbds(self):
   6.142          """Release vm virtual block devices (vbds).
   6.143          """
   6.144 -        print 'release_vbds>', self.dom
   6.145          if self.dom is None: return
   6.146          ctrl = xend.blkif_get(self.dom)
   6.147          if ctrl:
   6.148 @@ -574,7 +573,7 @@ class XendDomainInfo:
   6.149          memory = self.memory
   6.150          name = self.name
   6.151          cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
   6.152 -        print 'init_domain>', memory, name, cpu
   6.153 +        #print 'init_domain>', memory, name, cpu
   6.154          dom = xc.domain_create(mem_kb= memory * 1024, name= name, cpu= cpu)
   6.155          if dom <= 0:
   6.156              raise VmError('Creating domain failed: name=%s memory=%d'
   6.157 @@ -589,7 +588,7 @@ class XendDomainInfo:
   6.158              print 'Warning: kernel cmdline too long'
   6.159          dom = self.dom
   6.160          buildfn = getattr(xc, '%s_build' % ostype)
   6.161 -        print 'build_domain>', ostype, dom, kernel, cmdline, ramdisk
   6.162 +        #print 'build_domain>', ostype, dom, kernel, cmdline, ramdisk
   6.163          flags = 0
   6.164          if self.netif_backend: flags |= SIF_NET_BE_DOMAIN
   6.165          if self.blkif_backend: flags |= SIF_BLK_BE_DOMAIN
   6.166 @@ -612,15 +611,12 @@ class XendDomainInfo:
   6.167          cmdline kernel commandline
   6.168          vifs_n  number of network interfaces
   6.169          """
   6.170 -        print 'create_domain>', ostype, kernel
   6.171          if not self.recreate:
   6.172              if not os.path.isfile(kernel):
   6.173                  raise VmError('Kernel image does not exist: %s' % kernel)
   6.174              if ramdisk and not os.path.isfile(ramdisk):
   6.175                  raise VmError('Kernel ramdisk does not exist: %s' % ramdisk)
   6.176 -        print 'create-domain> init_domain...'
   6.177          self.init_domain()
   6.178 -        print 'create_domain>', 'dom=', self.dom
   6.179          self.console = xendConsole.console_create(self.dom)
   6.180          self.build_domain(ostype, kernel, ramdisk, cmdline, vifs_n)
   6.181          self.image = kernel
   6.182 @@ -633,7 +629,6 @@ class XendDomainInfo:
   6.183          returns Deferred
   6.184          raises VmError for invalid devices
   6.185          """
   6.186 -        print '>create_devices'
   6.187          dlist = []
   6.188          devices = sxp.children(self.config, 'device')
   6.189          index = {}
   6.190 @@ -650,7 +645,6 @@ class XendDomainInfo:
   6.191              append_deferred(dlist, v)
   6.192              index[dev_name] = dev_index + 1
   6.193          deferred = defer.DeferredList(dlist, fireOnOneErrback=1)
   6.194 -        print '<create_devices'
   6.195          return deferred
   6.196  
   6.197      def device_create(self, dev_config):
   6.198 @@ -686,6 +680,21 @@ class XendDomainInfo:
   6.199              self.config.remove(['device', dev_config])
   6.200          dev.destroy()
   6.201  
   6.202 +    def configure_restart(self):
   6.203 +        r = sxp.child_value(self.config, 'restart', RESTART_ONREBOOT)
   6.204 +        if r not in restart_modes:
   6.205 +            raise VmError('invalid restart mode: ' + str(r))
   6.206 +        self.restart_mode = r;
   6.207 +
   6.208 +    def restart_needed(self, reason):
   6.209 +        if self.restart_mode == RESTART_NEVER:
   6.210 +            return 0
   6.211 +        if self.restart_mode == RESTART_ALWAYS:
   6.212 +            return 1
   6.213 +        if self.restart_mode == RESTART_ONREBOOT:
   6.214 +            return reason == 'reboot'
   6.215 +        return 0
   6.216 +
   6.217      def configure_backends(self):
   6.218          """Set configuration flags if the vm is a backend for netif of blkif.
   6.219          """
   6.220 @@ -807,7 +816,7 @@ def vm_image_netbsd(vm, image):
   6.221      args = sxp.child_value(image, "args")
   6.222      if args:
   6.223          cmdline += " " + args
   6.224 -    ramdisk = sxp.child_value(image, "ramdisk")
   6.225 +    ramdisk = sxp.child_value(image, "ramdisk", '')
   6.226      vifs = vm.config_devices("vif")
   6.227      vm.create_domain("netbsd", kernel, ramdisk, cmdline, len(vifs))
   6.228      return vm
   6.229 @@ -830,7 +839,6 @@ def vm_dev_vif(vm, val, index):
   6.230          dev = xend.netif_dev(vm.dom, vif)
   6.231          dev.vifctl('up', vmname=vm.name)
   6.232          vm.add_device('vif', dev)
   6.233 -        print 'vm_dev_vif> created', dev
   6.234          return id
   6.235      defer.addCallback(fn)
   6.236      return defer
     7.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Wed Jul 14 11:46:25 2004 +0000
     7.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Wed Jul 14 15:36:10 2004 +0000
     7.3 @@ -50,7 +50,10 @@ class SrvDomain(SrvDir):
     7.4          return val
     7.5  
     7.6      def op_destroy(self, op, req):
     7.7 -        val = self.xd.domain_destroy(self.dom.id)
     7.8 +        fn = FormFn(self.xd.domain_destroy,
     7.9 +                    [['dom', 'int'],
    7.10 +                     ['reason', 'str']])
    7.11 +        val = fn(req.args, {'dom': self.dom.id})
    7.12          req.setHeader("Location", "%s/.." % req.prePathURL())
    7.13          return val
    7.14  
    7.15 @@ -220,7 +223,12 @@ class SrvDomain(SrvDir):
    7.16          req.write('<form method="post" action="%s">' % url)
    7.17          req.write('<input type="submit" name="op" value="unpause">')
    7.18          req.write('<input type="submit" name="op" value="pause">')
    7.19 +        req.write('</form>')
    7.20 +
    7.21 +        req.write('<form method="post" action="%s">' % url)
    7.22          req.write('<input type="submit" name="op" value="destroy">')
    7.23 +        req.write('<input type="radio" name="reason" value="halt" checked>Halt')
    7.24 +        req.write('<input type="radio" name="reason" value="reboot">Reboot')
    7.25          req.write('</form>')
    7.26  
    7.27          req.write('<form method="post" action="%s">' % url)
     8.1 --- a/tools/python/xen/xm/create.py	Wed Jul 14 11:46:25 2004 +0000
     8.2 +++ b/tools/python/xen/xm/create.py	Wed Jul 14 15:36:10 2004 +0000
     8.3 @@ -97,9 +97,13 @@ gopts.var('memory', val='MEMORY',
     8.4           fn=set_value, default=128,
     8.5           use="Domain memory in MB.")
     8.6  
     8.7 -gopts.var('autorestart', val='no|yes',
     8.8 -         fn=set_bool, default=0,
     8.9 -         use="Whether to restart the domain on exit.")
    8.10 +gopts.var('restart', val='onreboot|always|never',
    8.11 +         fn=set_value, default=None,
    8.12 +         use="""Whether the domain should be restarted on exit.
    8.13 +         - onreboot: restart on exit with shutdown code reboot
    8.14 +         - always:   always restart on exit, ignore exit code
    8.15 +         - never:    never restart on exit, ignore exit code
    8.16 +         """)
    8.17  
    8.18  gopts.var('blkif', val='no|yes',
    8.19            fn=set_bool, default=0,
    8.20 @@ -294,8 +298,8 @@ def make_config(vals):
    8.21          config.append(['backend', ['blkif']])
    8.22      if vals.netif:
    8.23          config.append(['backend', ['netif']])
    8.24 -    if vals.autorestart:
    8.25 -        config.append(['autorestart'])
    8.26 +    if vals.restart:
    8.27 +        config.append(['restart', vals.restart])
    8.28      
    8.29      configure_image(config, vals)
    8.30      config_devs = []
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tools/python/xen/xm/destroy.py	Wed Jul 14 15:36:10 2004 +0000
     9.3 @@ -0,0 +1,40 @@
     9.4 +# Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
     9.5 +
     9.6 +"""Destroy a domain.
     9.7 +"""
     9.8 +
     9.9 +from xen.xend.XendClient import server
    9.10 +from xen.xm.opts import *
    9.11 +
    9.12 +gopts = Opts(use="""[options] [DOM]
    9.13 +
    9.14 +Destroy a domain, optionally restarting it.
    9.15 +""")
    9.16 +
    9.17 +gopts.opt('help', short='h',
    9.18 +         fn=set_true, default=0,
    9.19 +         use="Print this help.")
    9.20 +
    9.21 +gopts.opt('reboot', short='R',
    9.22 +          fn=set_true, default=0,
    9.23 +          use='Destroy and restart.')
    9.24 +
    9.25 +def main(argv):
    9.26 +    opts = gopts
    9.27 +    args = opts.parse(argv)
    9.28 +    if opts.vals.help:
    9.29 +        opts.usage()
    9.30 +        return
    9.31 +    if len(args) < 1: opts.err('Missing domain')
    9.32 +    dom = args[0]
    9.33 +    try:
    9.34 +        domid = int(dom)
    9.35 +    except:
    9.36 +        opts.err('Invalid domain: ' + dom)
    9.37 +    if opts.vals.reboot:
    9.38 +        mode = 'reboot'
    9.39 +    else:
    9.40 +        mode = 'halt'
    9.41 +    server.xend_domain_destroy(domid, mode)
    9.42 +    
    9.43 +        
    10.1 --- a/tools/python/xen/xm/main.py	Wed Jul 14 11:46:25 2004 +0000
    10.2 +++ b/tools/python/xen/xm/main.py	Wed Jul 14 15:36:10 2004 +0000
    10.3 @@ -11,7 +11,7 @@ from xen.xend import PrettyPrint
    10.4  from xen.xend import sxp
    10.5  from xen.xend.XendClient import XendError, server
    10.6  from xen.xend.XendClient import main as xend_client_main
    10.7 -from xen.xm import create, shutdown
    10.8 +from xen.xm import create, destroy, shutdown
    10.9  
   10.10  class Prog:
   10.11      """Base class for sub-programs.
   10.12 @@ -268,13 +268,10 @@ class ProgDestroy(Prog):
   10.13      info = """Terminate a domain immediately."""
   10.14  
   10.15      def help(self, args):
   10.16 -        print args[0], 'DOM'
   10.17 -        print '\nTerminate domain DOM immediately.'
   10.18 +        destroy.main([args[0], '-h'])
   10.19  
   10.20      def main(self, args):
   10.21 -        if len(args) < 2: self.err("%s: Missing domain" % args[0])
   10.22 -        dom = args[1]
   10.23 -        server.xend_domain_destroy(dom)
   10.24 +        destroy.main(args)
   10.25  
   10.26  xm.prog(ProgDestroy)
   10.27