ia64/xen-unstable

changeset 1063:2dcb5a482b05

bitkeeper revision 1.702 (401ff4c1wsnjlon2jUHePX5hLh-cGA)

Delete junk tools.
author iap10@striker.cl.cam.ac.uk
date Tue Feb 03 19:21:37 2004 +0000 (2004-02-03)
parents ff3df62df71e
children cdc8a05cc2af
files .rootkeys tools/examples/add_vbd_to_dom.py tools/examples/createlinuxdom.py tools/examples/destroydom.py tools/examples/list_vbds.py tools/examples/listdoms.py tools/examples/pincpu.py tools/examples/readxenconsolering.py tools/examples/remove_vbd_from_dom.py tools/examples/startdom.py tools/examples/stopdom.py tools/examples/vd_create.py tools/examples/vd_delete.py tools/examples/vd_format.py tools/examples/vd_freespace.py tools/examples/vd_list.py tools/examples/vd_read_from_file.py tools/examples/vd_refresh.py tools/examples/vd_to_file.py tools/examples/vd_undelete.py tools/misc/xen_refresh_dev.c
line diff
     1.1 --- a/.rootkeys	Sun Feb 01 23:33:55 2004 +0000
     1.2 +++ b/.rootkeys	Tue Feb 03 19:21:37 2004 +0000
     1.3 @@ -42,27 +42,8 @@ 3e6377d6eiFjF1hHIS6JEIOFk62xSA tools/bal
     1.4  3e6377dbGcgnisKw16DPCaND7oGO3Q tools/balloon/balloon.c
     1.5  401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile
     1.6  401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
     1.7 -40083bb4_j61quzxosgZ19LUgLlgYw tools/examples/add_vbd_to_dom.py
     1.8 -3fbe2f12OPAkzIUtumU3wRAihnhocQ tools/examples/createlinuxdom.py
     1.9  401d7e16GS8YesM1zateRbaOoI6YLQ tools/examples/defaults
    1.10  401d7e16NoWaBGC1RXbBcqAOr5Uaag tools/examples/democd
    1.11 -3fbe2f12dZbmXLlgQdMgkmnSUj23AQ tools/examples/destroydom.py
    1.12 -40083bb4lxCIf5HRu6fwWUyHCYOHKA tools/examples/list_vbds.py
    1.13 -3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py
    1.14 -3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py
    1.15 -3fd8bc48ww3aOqPhYjCr8KGulG0NQQ tools/examples/readxenconsolering.py
    1.16 -40083bb4zWkCUTHJKd1ApEOoPAuihg tools/examples/remove_vbd_from_dom.py
    1.17 -3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py
    1.18 -3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py
    1.19 -40083bb4LeyQyL-0riaV3UYDfHkl5g tools/examples/vd_create.py
    1.20 -40083bb4TmKs8pcFkOcJj1bKn3zcmg tools/examples/vd_delete.py
    1.21 -40083bb4u9Od6ujgect6mrxWfkk1pQ tools/examples/vd_format.py
    1.22 -400c33000SvWkdG92u4Bvdu6BPjGPw tools/examples/vd_freespace.py
    1.23 -400c3300jb_Ufz2kWsovGKNoDPEf-A tools/examples/vd_list.py
    1.24 -400c774eVfeVCkLn34s-Lh4-6jBXWw tools/examples/vd_read_from_file.py
    1.25 -40083bb4NhDpKiYTrebI3ZjX__oI_w tools/examples/vd_refresh.py
    1.26 -400c774eXs8hWKK70ZYzi1ScKiSjPQ tools/examples/vd_to_file.py
    1.27 -400c33001-uDKTfHBchTKUwuMFcqTA tools/examples/vd_undelete.py
    1.28  401d7e16NpnVrFSsR7lKKKfTwCYvWA tools/examples/xc_dom_control.py
    1.29  401d7e16RJj-lbtsVEjua6HYAIiKiA tools/examples/xc_dom_create.py
    1.30  401d7e16X4iojyKopo_j63AyzYZd2A tools/examples/xc_vd_tool.py
    1.31 @@ -80,7 +61,6 @@ 3f8bcf29ulZIC9rC4wM70H_q4s6VPg tools/mis
    1.32  3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/xen_nat_enable
    1.33  3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README
    1.34  3f1668d4F29Jsw0aC0bJEIkOBiagiQ tools/misc/xen_read_console.c
    1.35 -3f87ba90EUVPQLVOlFG0sW89BCwouQ tools/misc/xen_refresh_dev.c
    1.36  3fbca441SjQr8vJwTQIgH1laysaWog tools/xc/Makefile
    1.37  3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/xc/lib/Makefile
    1.38  3fbba6dc1uU7U3IFeF6A-XEOYF2MkQ tools/xc/lib/rpm.spec
     2.1 --- a/tools/examples/add_vbd_to_dom.py	Sun Feb 01 23:33:55 2004 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,51 +0,0 @@
     2.4 -#!/usr/bin/env python
     2.5 -
     2.6 -# Used to map a VBD into a domain's device space.  Useful for populating a new
     2.7 -# VBD with data from DOM0 before starting a new domain using it, for instance.
     2.8 -
     2.9 -import Xc, XenoUtil, sys
    2.10 -
    2.11 -XenoUtil.VBD_EXPERT_LEVEL = 0 # sets the allowed level of potentially unsafe mappings
    2.12 -
    2.13 -def usage():
    2.14 -    print >>sys.stderr,"""Usage: add_vdisk_to_dom.py uname target-dev target-dom [perms]
    2.15 -        uname        - the uname of the source device, e.g. vd:2341 or phy:hda3
    2.16 -        target-dev   - the device node to map the VBD to
    2.17 -        target-dom   - domain to add the new VBD to
    2.18 -        perms        - optionally specify 'r', or 'rw' (default is 'r')
    2.19 -        """
    2.20 -    sys.exit(1)    
    2.21 -
    2.22 -xc = Xc.new()
    2.23 -
    2.24 -if not 4 <= len(sys.argv) <= 5:
    2.25 -    print len(sys.argv)
    2.26 -    usage()
    2.27 -    
    2.28 -writeable = 0
    2.29 -
    2.30 -if len(sys.argv) == 5:
    2.31 -    if sys.argv[4] == 'rw':
    2.32 -        writeable = 1;
    2.33 -    else:
    2.34 -        if sys.argv[4] != 'r':
    2.35 -            usage()
    2.36 -
    2.37 -segments = XenoUtil.lookup_disk_uname(sys.argv[1])
    2.38 -
    2.39 -if XenoUtil.vd_extents_validate(segments,writeable) < 0:
    2.40 -    print "That mapping is too unsafe for the current VBD expertise level"
    2.41 -    sys.exit(1)
    2.42 -
    2.43 -virt_dev = XenoUtil.blkdev_name_to_number(sys.argv[2])
    2.44 -
    2.45 -target_dom = int(sys.argv[3])
    2.46 -
    2.47 -xc.vbd_create(target_dom,virt_dev,writeable)
    2.48 -
    2.49 -if xc.vbd_setextents( target_dom, virt_dev, segments ):
    2.50 -    print "Error populating VBD vbd=%d\n" % virt_dev
    2.51 -    sys.exit(1)
    2.52 -
    2.53 -
    2.54 -print "Added " + sys.argv[1] + " to domain " + sys.argv[3] + " as device " + sys.argv[2]
     3.1 --- a/tools/examples/createlinuxdom.py	Sun Feb 01 23:33:55 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,183 +0,0 @@
     3.4 -#!/usr/bin/env python
     3.5 -
     3.6 -#
     3.7 -# Example script for creating and building a new Linux guest OS for Xen.
     3.8 -# It takes an optional parameter that specifies offsets to be added to the
     3.9 -# ip address and root partition numbers, enabling multiple domains to be
    3.10 -# started from the one script.
    3.11 -#
    3.12 -# Edit as required...
    3.13 -#
    3.14 -
    3.15 -import Xc, XenoUtil, string, sys, os, time, socket
    3.16 -
    3.17 -# initialize a few variables that might come in handy
    3.18 -thishostname = socket.gethostname()
    3.19 -guestid = 0
    3.20 -if len(sys.argv) >= 2:
    3.21 -    guestid = string.atoi(sys.argv[1])
    3.22 -    print "Offset to add to guest's IP etc : %d\n" % guestid
    3.23 - 
    3.24 -##### This section of the code establishes various settings to be used 
    3.25 -##### for this guest virtual machine
    3.26 -
    3.27 -# STEP 1. Specify kernel image file. Can be gzip'ed.
    3.28 -image = "../../../install/boot/xenolinux.gz"
    3.29 -
    3.30 -# STEP 2. How many megabytes of memory for the new domain?
    3.31 -memory_megabytes = 64
    3.32 -
    3.33 -# STEP 3. A handy name for your new domain.
    3.34 -domain_name = "This is VM %d" % guestid
    3.35 -
    3.36 -# STEP 4. Specify IP address(es), netmask and gateway for the new
    3.37 -# domain.  You need to configure IP addrs within the domain just as
    3.38 -# you do normally.  This is just to let Xen know about them so it can
    3.39 -# route packets appropriately. 
    3.40 -
    3.41 -#ipaddr = ["111.222.333.444","222.333.444.555"]
    3.42 -ipaddr  = [XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),guestid)]
    3.43 -netmask = XenoUtil.get_current_ipmask()
    3.44 -gateway = XenoUtil.get_current_ipgw()
    3.45 -nfsserv = '169.254.1.0'  # You need to set this if you're using NFS root
    3.46 -
    3.47 -# STEP 5. Identify any physcial partitions or virtual disks you want the
    3.48 -# domain to have access to, and what you want them accessible as
    3.49 -# e.g. vbds = [ ('phy:sda1','sda1', 'w'),
    3.50 -#	 ('phy:sda4','sda%d' % (3+guestid), 'r'), 
    3.51 -#	 ('vd:as73gd784dh','hda1','w') ]
    3.52 -
    3.53 -vbds = [ ('phy:sda%d'%(7+guestid),'sda1','w' ), 
    3.54 -	 ('phy:sda6','sda6','r'),
    3.55 -	 ('phy:cdrom','hdd','r') ]
    3.56 -
    3.57 -# STEP 5b. Set the VBD expertise level.  Most people should leave this
    3.58 -# on 0, at least to begin with - this script can detect most dangerous
    3.59 -# disk sharing between domains and with this set to zero it will only
    3.60 -# allow read only sharing.
    3.61 -vbd_expert = 0
    3.62 -
    3.63 -# STEP 6. Build the command line for the new domain. Edit as req'd.
    3.64 -# You only need the ip= line if you're NFS booting or the root file system
    3.65 -# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
    3.66 -# You can use 'extrabit' to set the runlevel and custom environment
    3.67 -# variables used by custom rc scripts (e.g. DOMID=, usr= )
    3.68 -
    3.69 -ipbit = "ip="+ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
    3.70 -rootbit = "root=/dev/sda1 ro"
    3.71 -#rootbit = "root=/dev/nfs nfsroot=/full/path/to/root/directory"
    3.72 -extrabit = "4 DOMID=%d usr=/dev/sda6" % guestid 
    3.73 -cmdline = ipbit +" "+ rootbit +" "+ extrabit
    3.74 -
    3.75 -# STEP 7. Set according to whether you want the script to watch the domain 
    3.76 -# and auto-restart it should it die or exit.
    3.77 -
    3.78 -auto_restart = False
    3.79 -#auto_restart = True
    3.80 -
    3.81 -
    3.82 -##### Print some debug info just incase things don't work out...
    3.83 -##### 
    3.84 -
    3.85 -print "Domain image          : ", image
    3.86 -print "Domain memory         : ", memory_megabytes
    3.87 -print "Domain IP address(es) : ", ipaddr 
    3.88 -print "Domain block devices  : ", vbds
    3.89 -print 'Domain cmdline        : "%s"' % cmdline
    3.90 -
    3.91 -
    3.92 -##### Code beyond this point is actually used to manage the mechanics of
    3.93 -##### starting (and watching if necessary) guest virtual machines.
    3.94 -
    3.95 -# Obtain an instance of the Xen control interface
    3.96 -xc = Xc.new()
    3.97 -
    3.98 -# This function creates, builds and starts a domain, using the values
    3.99 -# in the global variables, set above.  It is used in the subsequent
   3.100 -# code for starting the new domain and rebooting it if appropriate.
   3.101 -def make_domain():
   3.102 -    """Create, build and start a domain.
   3.103 -    Returns: [int] the ID of the new domain.
   3.104 -    """
   3.105 -
   3.106 -    # set up access to the global variables declared above
   3.107 -    global image, memory_megabytes, domain_name, ipaddr, netmask
   3.108 -    global vbds, cmdline, xc, vbd_expert
   3.109 -    	
   3.110 -    if not os.path.isfile( image ):
   3.111 -        print "Image file '" + image + "' does not exist"
   3.112 -        sys.exit()
   3.113 -
   3.114 -    id = xc.domain_create( mem_kb=memory_megabytes*1024, name=domain_name )
   3.115 -    print "Created new domain with id = " + str(id)
   3.116 -    if id <= 0:
   3.117 -        print "Error creating domain"
   3.118 -        sys.exit()
   3.119 -
   3.120 -    ret = xc.linux_build( dom=id, image=image, cmdline=cmdline )
   3.121 -    if ret < 0:
   3.122 -        print "Error building Linux guest OS: "
   3.123 -        print "Return code from linux_build = " + str(ret)
   3.124 -        xc.domain_destroy ( dom=id )
   3.125 -        sys.exit()
   3.126 -
   3.127 -    # setup the virtual block devices
   3.128 -
   3.129 -    # set the expertise level appropriately
   3.130 -    XenoUtil.VBD_EXPERT_MODE = vbd_expert
   3.131 -    
   3.132 -    for ( uname, virt_name, rw ) in vbds:
   3.133 -	virt_dev = XenoUtil.blkdev_name_to_number( virt_name )
   3.134 -
   3.135 -	segments = XenoUtil.lookup_disk_uname( uname )
   3.136 -	if not segments:
   3.137 -	    print "Error looking up %s\n" % uname
   3.138 -	    xc.domain_destroy ( dom=id )
   3.139 -	    sys.exit()
   3.140 -
   3.141 -        # check that setting up this VBD won't violate the sharing
   3.142 -        # allowed by the current VBD expertise level
   3.143 -        if XenoUtil.vd_extents_validate(segments, rw=='w') < 0:
   3.144 -            xc.domain_destroy( dom = id )
   3.145 -            sys.exit()
   3.146 -            
   3.147 -	if xc.vbd_create( dom=id, vbd=virt_dev, writeable= rw=='w' ):
   3.148 -	    print "Error creating VBD vbd=%d writeable=%d\n" % (virt_dev,rw)
   3.149 -	    xc.domain_destroy ( dom=id )
   3.150 -	    sys.exit()
   3.151 -
   3.152 -        if xc.vbd_setextents( dom=id,
   3.153 -                              vbd=virt_dev,
   3.154 -                              extents=segments):
   3.155 -            print "Error populating VBD vbd=%d\n" % virt_dev
   3.156 -            xc.domain_destroy ( dom=id )
   3.157 -            sys.exit()
   3.158 -
   3.159 -    # setup virtual firewall rules for all aliases
   3.160 -    for ip in ipaddr:
   3.161 -	XenoUtil.setup_vfr_rules_for_vif( id, 0, ip )
   3.162 -
   3.163 -    if xc.domain_start( dom=id ) < 0:
   3.164 -        print "Error starting domain"
   3.165 -        xc.domain_destroy ( dom=id )
   3.166 -        sys.exit()
   3.167 -
   3.168 -    return id
   3.169 -# end of make_domain()
   3.170 -
   3.171 -
   3.172 -
   3.173 -# The starting / monitoring of the domain actually happens here...
   3.174 -
   3.175 -# start the domain and record its ID number
   3.176 -current_id = make_domain()
   3.177 -
   3.178 -# if the auto_restart flag is set then keep polling to see if the domain is
   3.179 -# alive - restart if it is not by calling make_domain() again (it's necessary
   3.180 -# to update the id variable, since the new domain may have a new ID)
   3.181 -
   3.182 -while auto_restart:
   3.183 -    time.sleep(1)
   3.184 -    if not xc.domain_getinfo(current_id):
   3.185 -        print "The virtual machine has terminated, restarting in a new domain"
   3.186 -        current_id = make_domain()
     4.1 --- a/tools/examples/destroydom.py	Sun Feb 01 23:33:55 2004 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,18 +0,0 @@
     4.4 -#!/usr/bin/env python
     4.5 -
     4.6 -#
     4.7 -# Destroy specified domain.
     4.8 -#
     4.9 -
    4.10 -import Xc, sys, re
    4.11 -
    4.12 -xc = Xc.new()
    4.13 -
    4.14 -if len(sys.argv) < 2:
    4.15 -    print "Specify a domain identifier"
    4.16 -    sys.exit()
    4.17 -
    4.18 -if (len(sys.argv) > 2) and re.match( 'force', sys.argv[2] ):
    4.19 -    xc.domain_destroy( dom=int(sys.argv[1]), force=1 )
    4.20 -else:
    4.21 -    xc.domain_destroy( dom=int(sys.argv[1]), force=0 )
     5.1 --- a/tools/examples/list_vbds.py	Sun Feb 01 23:33:55 2004 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,8 +0,0 @@
     5.4 -#!/usr/bin/env python
     5.5 -
     5.6 -
     5.7 -import Xc, sys
     5.8 -
     5.9 -xc = Xc.new()
    5.10 -
    5.11 -print xc.vbd_probe()
     6.1 --- a/tools/examples/listdoms.py	Sun Feb 01 23:33:55 2004 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,10 +0,0 @@
     6.4 -#!/usr/bin/env python
     6.5 -
     6.6 -#
     6.7 -# List info on all domains.
     6.8 -#
     6.9 -
    6.10 -import Xc, sys
    6.11 -xc = Xc.new()
    6.12 -print xc.domain_getinfo()
    6.13 -
     7.1 --- a/tools/examples/pincpu.py	Sun Feb 01 23:33:55 2004 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,31 +0,0 @@
     7.4 -#!/usr/bin/env python
     7.5 -
     7.6 -#
     7.7 -# Destroy specified domain.
     7.8 -#
     7.9 -
    7.10 -import Xc, sys, re, time
    7.11 -
    7.12 -xc = Xc.new()
    7.13 -
    7.14 -if len(sys.argv) < 3:
    7.15 -    print "Specify a domain identifier and CPU"
    7.16 -    sys.exit()
    7.17 -
    7.18 -dom = int(sys.argv[1])
    7.19 -cpu = int(sys.argv[2])
    7.20 -
    7.21 -orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped']
    7.22 -
    7.23 -while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1:
    7.24 -    xc.domain_stop( dom=dom )
    7.25 -    time.sleep(0.1)
    7.26 -
    7.27 -xc.domain_pincpu( dom, cpu )
    7.28 -
    7.29 -if orig_state == 0:
    7.30 -    xc.domain_start( dom=dom )
    7.31 -
    7.32 -
    7.33 -
    7.34 -
     8.1 --- a/tools/examples/readxenconsolering.py	Sun Feb 01 23:33:55 2004 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,48 +0,0 @@
     8.4 -#!/usr/bin/env python
     8.5 -
     8.6 -# Copyright (C) 2003 by Intel Research Cambridge
     8.7 -
     8.8 -# File:   tools/examples/readconsolering.py
     8.9 -# Author: Mark A Williamson (mark.a.williamson@intel.com)
    8.10 -# Date:   2003-12-02
    8.11 -
    8.12 -# This program is free software; you can redistribute it and/or
    8.13 -# modify it under the terms of the GNU General Public License
    8.14 -# as published by the Free Software Foundation; either version 2
    8.15 -# of the License, or (at your option) any later version.
    8.16 -#
    8.17 -# This program is distributed in the hope that it will be useful,
    8.18 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.19 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.20 -# GNU General Public License for more details.
    8.21 -#
    8.22 -# You should have received a copy of the GNU General Public License
    8.23 -# along with this program; if not, write to the Free Software
    8.24 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    8.25 -
    8.26 - 
    8.27 -
    8.28 -"""Reads out the contents of the console ring
    8.29 -
    8.30 -Usage: readconsolering.py [-c]
    8.31 -The -c option causes the contents to be cleared.
    8.32 -"""
    8.33 -
    8.34 -import sys, Xc # import the Xc Xen Control module
    8.35 -
    8.36 -xc = Xc.new() # get a new instance of the control interface
    8.37 -
    8.38 -clear_buffer = False
    8.39 -
    8.40 -if sys.argv[1:] != []:
    8.41 -    if sys.argv[1] == "-c":
    8.42 -        clear_buffer = True
    8.43 -    else:
    8.44 -        print >> sys.stderr, "Usage: " + sys.argv[0] + """ [-c]
    8.45 -       Reads the contents of the console buffer.
    8.46 -       (specifying -c will also clear current contents)"""
    8.47 -
    8.48 -# Get the console ring's contents as a string and print it out.
    8.49 -# If argument to readconsolering is true then the buffer is cleared as well as
    8.50 -# fetching the (pre-clearing) contents.
    8.51 -print xc.readconsolering(clear_buffer)
     9.1 --- a/tools/examples/remove_vbd_from_dom.py	Sun Feb 01 23:33:55 2004 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,29 +0,0 @@
     9.4 -#!/usr/bin/env python
     9.5 -
     9.6 -# Used to map a VBD into a domain's device space.  Useful for populating a new
     9.7 -# VBD with data from DOM0 before starting a new domain using it, for instance.
     9.8 -
     9.9 -# Usage: add_vdisk_to_dom.py uname target-dev-name target-dom-number
    9.10 -#        uname             - the uname of the device, e.g. vd:2341 or phy:hda3
    9.11 -#        target-dev-name   - the device node to map the VBD to
    9.12 -#        target-dom-number - domain to add the new VBD to
    9.13 -
    9.14 -import Xc, XenoUtil, sys
    9.15 -
    9.16 -xc = Xc.new()
    9.17 -
    9.18 -if len(sys.argv) != 3:
    9.19 -    print >>sys.stderr,"""Usage: add_vdisk_to_dom.py target-dev target-dom
    9.20 -        target-dev   - the device node the VBD is mapped to
    9.21 -        target-dom   - domain to remove the VBD from"""
    9.22 -    sys.exit(1)
    9.23 -
    9.24 -virt_dev = XenoUtil.blkdev_name_to_number(sys.argv[1])
    9.25 -
    9.26 -target_dom = int(sys.argv[2])
    9.27 -
    9.28 -if not xc.vbd_destroy(target_dom,virt_dev):
    9.29 -    print "Removed " + sys.argv[1] + " from domain " + sys.argv[2]
    9.30 -else:
    9.31 -    print "Failed"
    9.32 -    sys.exit(1)
    10.1 --- a/tools/examples/startdom.py	Sun Feb 01 23:33:55 2004 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,15 +0,0 @@
    10.4 -#!/usr/bin/env python
    10.5 -
    10.6 -#
    10.7 -# Start execution of specified domain.
    10.8 -#
    10.9 -
   10.10 -import Xc, sys, re
   10.11 -
   10.12 -xc = Xc.new()
   10.13 -
   10.14 -if len(sys.argv) != 2:
   10.15 -    print "Specify a domain identifier"
   10.16 -    sys.exit()
   10.17 -
   10.18 -xc.domain_start( dom=int(sys.argv[1]) )
    11.1 --- a/tools/examples/stopdom.py	Sun Feb 01 23:33:55 2004 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,15 +0,0 @@
    11.4 -#!/usr/bin/env python
    11.5 -
    11.6 -#
    11.7 -# Stop execution of specified domain.
    11.8 -#
    11.9 -
   11.10 -import Xc, sys, re
   11.11 -
   11.12 -xc = Xc.new()
   11.13 -
   11.14 -if len(sys.argv) != 2:
   11.15 -    print "Specify a domain identifier"
   11.16 -    sys.exit()
   11.17 -
   11.18 -xc.domain_stop( dom=int(sys.argv[1]) )
    12.1 --- a/tools/examples/vd_create.py	Sun Feb 01 23:33:55 2004 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,36 +0,0 @@
    12.4 -#!/usr/bin/env python
    12.5 -
    12.6 -#
    12.7 -# Wrapper script for creating a virtual disk.
    12.8 -#
    12.9 -# Usage: vd_create.py size [expiry]
   12.10 -#
   12.11 -
   12.12 -import XenoUtil, sys
   12.13 -
   12.14 -if len(sys.argv) > 1:
   12.15 -    size = int(sys.argv[1])
   12.16 -else:
   12.17 -    print "Usage: " + sys.argv[0] + """ size [expiry]
   12.18 -    Allocates a Virtual Disk out of the free space pool.  An expiry time
   12.19 -    can be specified in seconds from now (0 means never expire) - the default
   12.20 -    is for disks to never expire."""
   12.21 -    sys.exit(1)
   12.22 -
   12.23 -if len(sys.argv) > 2:
   12.24 -    expiry_time = int(sys.argv[2])
   12.25 -else:
   12.26 -    print "No expiry time specified - using default\n"
   12.27 -    expiry_time = 0
   12.28 -
   12.29 -print "Creating a virtual disk"
   12.30 -print "Size: %d" % size
   12.31 -print "Expiry time (seconds from now): %d" % expiry_time
   12.32 -
   12.33 -ret = XenoUtil.vd_create(size, expiry_time)
   12.34 -
   12.35 -if ret < 0:
   12.36 -    print >> sys.stderr, "An error occurred creating the the disk"
   12.37 -    sys.exit(ret)
   12.38 -else:
   12.39 -    print "Virtual disk allocated, with ID: " + ret
    13.1 --- a/tools/examples/vd_delete.py	Sun Feb 01 23:33:55 2004 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,23 +0,0 @@
    13.4 -#!/usr/bin/env python
    13.5 -
    13.6 -#
    13.7 -# Wrapper script for deleting a virtual disk.
    13.8 -#
    13.9 -# Usage: vd_create.py id
   13.10 -#
   13.11 -
   13.12 -import sys, XenoUtil
   13.13 -
   13.14 -if len(sys.argv) > 1:
   13.15 -        id = sys.argv[1]
   13.16 -else:
   13.17 -    print "Usage: " + sys.argv[0] + """ id
   13.18 -    Deletes a virtual disk."""
   13.19 -    sys.exit(1)
   13.20 -
   13.21 -print "Deleting a virtual disk with ID: " + id
   13.22 -
   13.23 -ret = XenoUtil.vd_delete(id)
   13.24 -
   13.25 -if ret:
   13.26 -    print "Deletion failed: invalid ID, or disk already expired / deleted"
    14.1 --- a/tools/examples/vd_format.py	Sun Feb 01 23:33:55 2004 +0000
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,34 +0,0 @@
    14.4 -#!/usr/bin/env python
    14.5 -
    14.6 -#
    14.7 -# Wrapper script for formatting a device to host Xen virtual disk extents
    14.8 -#
    14.9 -# Usage: vd_format.py device [extent_size]
   14.10 -#
   14.11 -
   14.12 -import sys, XenoUtil
   14.13 -
   14.14 -if len(sys.argv) > 1:
   14.15 -    device = sys.argv[1]
   14.16 -else:
   14.17 -    print "Usage: " + sys.argv[0] + """ device [extent_size]
   14.18 -     Formats a device to host Xen virtual disk extents.  The extent size can
   14.19 -     optionally be specified in megabytes (default 64MB)."""
   14.20 -    sys.exit(1)
   14.21 -
   14.22 -if len(sys.argv) > 2:
   14.23 -    extent_size = int(sys.argv[2])
   14.24 -else:
   14.25 -    print """No extent size specified - using default size
   14.26 -    (for really small devices, the default size of 64MB might not work)"""
   14.27 -    extent_size = 64
   14.28 -
   14.29 -print "Formatting for virtual disks"
   14.30 -print "Device: " + sys.argv[1]
   14.31 -print "Extent size: " + str(extent_size) + "MB"
   14.32 -
   14.33 -ret = XenoUtil.vd_format(device, extent_size)
   14.34 -
   14.35 -if ret:
   14.36 -    print >> sys.stderr, "An error occurred formatting the device"
   14.37 -    sys.exit(ret)
    15.1 --- a/tools/examples/vd_freespace.py	Sun Feb 01 23:33:55 2004 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,11 +0,0 @@
    15.4 -#!/usr/bin/env python
    15.5 -
    15.6 -#
    15.7 -# vd_freespace.py
    15.8 -#
    15.9 -# Prints out the amount of free space (in megabytes) for creating virtual disks.
   15.10 -#
   15.11 -
   15.12 -import XenoUtil
   15.13 -
   15.14 -print XenoUtil.vd_freespace()
    16.1 --- a/tools/examples/vd_list.py	Sun Feb 01 23:33:55 2004 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,10 +0,0 @@
    16.4 -#!/usr/bin/env python
    16.5 -
    16.6 -#
    16.7 -# vd_list.py - use this to list all the unexpired virtual disks in the
    16.8 -# virtual disk database
    16.9 -#
   16.10 -
   16.11 -import XenoUtil
   16.12 -
   16.13 -print XenoUtil.vd_list()
    17.1 --- a/tools/examples/vd_read_from_file.py	Sun Feb 01 23:33:55 2004 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,29 +0,0 @@
    17.4 -#!/usr/bin/env python
    17.5 -
    17.6 -#
    17.7 -# vd_read_from_file.py filename
    17.8 -#
    17.9 -# Reads a virtual disk in from a file and allocates a VD (prints out its ID)
   17.10 -#
   17.11 -
   17.12 -import XenoUtil, sys
   17.13 -
   17.14 -if len(sys.argv) < 2:
   17.15 -    print "Usage: " + sys.argv[0] + """ filename [expiry]
   17.16 -    Reads in a virtual disk form a file and allocates a VD.
   17.17 -    Can optionally set the expiry time in seconds from now
   17.18 -    (default - don't expire)
   17.19 -    """
   17.20 -    sys.exit()
   17.21 -
   17.22 -if len(sys.argv) > 2:
   17.23 -    expiry = int(sys.argv[2])
   17.24 -else:
   17.25 -    expiry = 0
   17.26 -
   17.27 -ret = XenoUtil.vd_read_from_file(sys.argv[1], expiry)
   17.28 -
   17.29 -if ret < 0:
   17.30 -    print "Operation failed"
   17.31 -else:
   17.32 -    print "File " + sys.argv[1] + " read into virtual disk ID " + ret
    18.1 --- a/tools/examples/vd_refresh.py	Sun Feb 01 23:33:55 2004 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,33 +0,0 @@
    18.4 -#!/usr/bin/env python
    18.5 -
    18.6 -#
    18.7 -# Wrapper script for creating a virtual disk.
    18.8 -#
    18.9 -# Usage: vd_refresh.py id [new-expiry]
   18.10 -#
   18.11 -
   18.12 -import sys, XenoUtil
   18.13 -
   18.14 -if len(sys.argv) > 1:
   18.15 -        id = sys.argv[1]
   18.16 -else:
   18.17 -    print "Usage: " + sys.argv[0] + """ ID [expiry-new]
   18.18 -    Refreshes a Virtual Disk expiry time.  An expiry time
   18.19 -    can be specified in seconds from now (0 means never expire) - the default
   18.20 -    is for disks to never expire."""
   18.21 -    sys.exit(1)
   18.22 -
   18.23 -if len(sys.argv) > 2:
   18.24 -    expiry_time = int(sys.argv[2])
   18.25 -else:
   18.26 -    print "No expiry time specified - using default\n"
   18.27 -    expiry_time = 0
   18.28 -
   18.29 -print "Refreshing a virtual disk"
   18.30 -print "Id: " + sys.argv[1]
   18.31 -print "Expiry time (seconds from now): " + sys.argv[2]
   18.32 -
   18.33 -ret = XenoUtil.vd_refresh(id, expiry_time)
   18.34 -
   18.35 -if ret:
   18.36 -    print "Refresh failed, non-existent virtual disk or disk is expired / deleted"
    19.1 --- a/tools/examples/vd_to_file.py	Sun Feb 01 23:33:55 2004 +0000
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,34 +0,0 @@
    19.4 -#!/usr/bin/env python
    19.5 -
    19.6 -#
    19.7 -# vd_to_file.py filename [-m]
    19.8 -#
    19.9 -# Writes a virtual disk out to a file.  Optionally, the "-m" (move)
   19.10 -# flag causes the virtual disk to be deallocated once its data is
   19.11 -# read out.
   19.12 -
   19.13 -import XenoUtil, sys
   19.14 -
   19.15 -def usage():
   19.16 -    print "Usage: " + sys.argv[0] + """ vdisk_id filename [-m]
   19.17 -    Writes a virtual disk out to a file.  Optionally, the "-m" (move)
   19.18 -    flag causes the virtual disk to be deallocated once its data is
   19.19 -    read out.
   19.20 -    """
   19.21 -    sys.exit()
   19.22 -
   19.23 -if not 3 <= len(sys.argv) <= 4:
   19.24 -    usage()
   19.25 -
   19.26 -if len(sys.argv) == 4:
   19.27 -    if sys.argv[3] != "-m":
   19.28 -        usage()
   19.29 -    else:
   19.30 -        print "Doing move to file..."
   19.31 -        if XenoUtil.vd_mv_to_file(sys.argv[1],sys.argv[2]):
   19.32 -            print "Failed"    
   19.33 -else:
   19.34 -    print "Doing copy to file..."
   19.35 -    if XenoUtil.vd_cp_to_file(sys.argv[1], sys.argv[2]):
   19.36 -        print "Failed"
   19.37 -    
    20.1 --- a/tools/examples/vd_undelete.py	Sun Feb 01 23:33:55 2004 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,32 +0,0 @@
    20.4 -#!/usr/bin/env python
    20.5 -
    20.6 -#
    20.7 -# vd_undelete.py vdisk_id [ new_expiry ]
    20.8 -#
    20.9 -# Undeletes a VD and, optionally, sets a new expiry time or disables
   20.10 -# expiry if the time value is zero (default)
   20.11 -#
   20.12 -
   20.13 -import XenoUtil, sys
   20.14 -
   20.15 -if len(sys.argv) < 2:
   20.16 -    print >>sys.stderr, "Usage: " + sys.argv[0] + """ vdisk_id [ new_expiry ]
   20.17 -    vdisk_id   - the identifier of the deleted VD
   20.18 -    new_expiry - optionally the new expiry time in seconds from now (0
   20.19 -                 for never expire - which is the default)
   20.20 -
   20.21 -    VDs can currently only be undeleted if it is safe to do so,
   20.22 -    i.e. if none of their space has been reallocated.
   20.23 - """
   20.24 -
   20.25 -vdisk_id = sys.argv[1]
   20.26 -
   20.27 -if len(sys.argv) == 3:
   20.28 -    expiry = int(sys.argv[2])
   20.29 -else:
   20.30 -    expiry = 0
   20.31 -
   20.32 -if XenoUtil.vd_undelete(vdisk_id, expiry):
   20.33 -    print "Undelete operation failed for virtual disk: " + vdisk_id
   20.34 -else:
   20.35 -    print "Undelete operation succeeded for virtual disk: " + vdisk_id
    21.1 --- a/tools/misc/xen_refresh_dev.c	Sun Feb 01 23:33:55 2004 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,49 +0,0 @@
    21.4 -/******************************************************************************
    21.5 - * xen_refresh_dev.c
    21.6 - * 
    21.7 - * Refresh our view of a block device by rereading its partition table. This 
    21.8 - * is necessary to synchronise with VBD attaches and unattaches in Xen. 
    21.9 - * Currently there's no automatic plumbing of attach/unattach requests.
   21.10 - * 
   21.11 - * Copyright (c) 2003, K A Fraser
   21.12 - */
   21.13 -
   21.14 -#include <stdio.h>
   21.15 -#include <stdlib.h>
   21.16 -#include <sys/ioctl.h>
   21.17 -#include <sys/stat.h>
   21.18 -#include <sys/types.h>
   21.19 -#include <fcntl.h>
   21.20 -#include <string.h>
   21.21 -#include <errno.h>
   21.22 -#include <unistd.h>
   21.23 -#include <sys/mount.h> /* BLKRRPART */
   21.24 -
   21.25 -int main(int argc, char **argv)
   21.26 -{
   21.27 -    int fd;
   21.28 -
   21.29 -    if ( argc != 2 )
   21.30 -    {
   21.31 -        fprintf(stderr, "xen_refresh_dev <blkdev>\ne.g., /dev/xvda\n");
   21.32 -        return 1;
   21.33 -    }
   21.34 -
   21.35 -    if ( (fd = open(argv[1], O_RDWR)) == -1 )
   21.36 -    {
   21.37 -        fprintf(stderr, "Error opening %s: %s (%d)\n",
   21.38 -                argv[1], strerror(errno), errno);
   21.39 -        return 1;
   21.40 -    }
   21.41 -
   21.42 -    if ( ioctl(fd, BLKRRPART) == -1 )
   21.43 -    {
   21.44 -        fprintf(stderr, "Error executing BLKRRPART on %s: %s (%d)\n",
   21.45 -                argv[1], strerror(errno), errno);
   21.46 -        return 1;
   21.47 -    }
   21.48 -
   21.49 -    close(fd);
   21.50 -
   21.51 -    return 0;
   21.52 -}