ia64/xen-unstable

changeset 520:f15a7e78b8cb

bitkeeper revision 1.287 (3f09868dbEGgx_VclUxqKkhY0if9xA)

Delete vdmanager as any useful code it contained has been moved into the old xenctl web src
author rac61@labyrinth.cl.cam.ac.uk
date Mon Jul 07 14:41:17 2003 +0000 (2003-07-07)
parents 8f3e358c9972
children 209c95700af8
files .rootkeys tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDiskManager.java tools/vdmanager/Makefile tools/vdmanager/build.xml tools/vdmanager/notes.xml tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Extent.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Library.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Main.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Mode.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Parser.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Partition.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/PartitionManager.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualBlockDevice.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualDisk.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XML.java tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XMLHelper.java tools/vdmanager/vdmanager
line diff
     1.1 --- a/.rootkeys	Mon Jul 07 14:24:01 2003 +0000
     1.2 +++ b/.rootkeys	Mon Jul 07 14:41:17 2003 +0000
     1.3 @@ -57,7 +57,6 @@ 3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/con
     1.4  3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/uk/ac/cam/cl/xeno/xenctl/SystemConfigurationBean.java
     1.5  3ec41f7dlW5Buk3MO18HHtBax1Jz9g tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualBlockDevice.java
     1.6  3ec41f7dP3VglJUTuP45rwvSAoW_pg tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDisk.java
     1.7 -3ec41f7d8_ZsS9JjYQq861OFAZS9GA tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDiskManager.java
     1.8  3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml
     1.9  3ec41f7dRAPXBA0jQUd1k6MB3xVidg tools/control/web/img/cambridge.gif
    1.10  3ec41f7dvxVe1Vb3kVOLZcN5Jra2tQ tools/control/web/img/help.gif
    1.11 @@ -123,22 +122,7 @@ 3f0458aaVAbFSwptQbQAnDOiZlwQ3w tools/int
    1.12  3eb781fd8oRfPgH7qTh7xvgmwD6NgA tools/internal/xi_start.c
    1.13  3eb781fd0Eo9K1jEFCSAVzO51i_ngg tools/internal/xi_stop.c
    1.14  3eb781fd7211MZsLxJSiuy7W4KnJXg tools/internal/xi_vifinit
    1.15 -3eb788dbUz7cB-Gj-Y2mcQUzxWN3NQ tools/vdmanager/Makefile
    1.16 -3ea53c6dz47kAOwpk54f8_zOAQ5ngw tools/vdmanager/build.xml
    1.17 -3eaff785PwN0C3-xhCf_zMCL27JIgQ tools/vdmanager/notes.xml
    1.18 -3ea53c6dE-azH1i1VJmJMp9SHnETkQ tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Extent.java
    1.19 -3ea53c6dtqvqC3gxeAjzmSwkYsowIw tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Library.java
    1.20 -3ea53c6dVva2nmEP3TNM37RmshYJ1g tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Main.java
    1.21 -3ea53c6dF_CltZw3zVG3-R76tMlhMA tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Mode.java
    1.22 -3ea53c6dpDHzX93WBQXulAmm85Njzw tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Parser.java
    1.23 -3ea53c6d5Rgb_r3sSpgpgP-LEn423Q tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Partition.java
    1.24 -3ea53c6d2dbw9PQT8bGwFUIFIeVhGA tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/PartitionManager.java
    1.25 -3ea53c6dSKVeFlBS7VwTO38BCueHBQ tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualBlockDevice.java
    1.26 -3ea53c6dCSPB23LMsHvf44Pp6WL2Pg tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualDisk.java
    1.27  3ea53c6d48QGVkviHh0jBB_h_ZqZDw tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualDiskManager.java
    1.28 -3ea53c6efdL6CPTu_z5b_MxlxTdX_Q tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XML.java
    1.29 -3ea53c6ek5CbDZbBF3513sZKa5W3cQ tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XMLHelper.java
    1.30 -3ea53c6eKECrbeZtdlbaR1zcBwn94A tools/vdmanager/vdmanager
    1.31  3ddb79bcbOVHh38VJzc97-JEGD4dJQ xen/Makefile
    1.32  3ddb79bcCa2VbsMp7mWKlhgwLQUQGA xen/README
    1.33  3ddb79bcWnTwYsQRWl_PaneJfa6p0w xen/Rules.mk
     2.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDiskManager.java	Mon Jul 07 14:24:01 2003 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,315 +0,0 @@
     2.4 -/*
     2.5 - * VirtualDiskManager.java
     2.6 - * 03.03.26 aho creation
     2.7 - */
     2.8 -
     2.9 -package uk.ac.cam.cl.xeno.xenctl;
    2.10 -
    2.11 -import java.util.Enumeration;
    2.12 -import java.util.Vector;
    2.13 -import java.util.Hashtable;
    2.14 -import java.util.Date;
    2.15 -import java.io.PrintWriter;
    2.16 -
    2.17 -public class
    2.18 -VirtualDiskManager
    2.19 -{
    2.20 -  VirtualDisk free_disk;
    2.21 -  Vector virtual_disks;
    2.22 -  Hashtable virtual_block_devices;
    2.23 -  Hashtable key_hash;
    2.24 -
    2.25 -  VirtualDiskManager ()
    2.26 -  {
    2.27 -    free_disk = new VirtualDisk("free");
    2.28 -
    2.29 -    virtual_disks = new Vector(10,5);
    2.30 -    flush_virtual_block_devices();
    2.31 -    key_hash = new Hashtable(100);
    2.32 -  }
    2.33 -
    2.34 -  public VirtualDisk
    2.35 -  get_virtual_disk_key (String key)
    2.36 -  {
    2.37 -    return ((VirtualDisk) key_hash.get(key));
    2.38 -  }
    2.39 -
    2.40 -  public void
    2.41 -  add_xeno_partition (Partition partition, long size)
    2.42 -  {
    2.43 -    free_disk.add_new_partition (partition, size);
    2.44 -    return;
    2.45 -  }
    2.46 -
    2.47 -  /*
    2.48 -   * create a new virtual disk
    2.49 -   */
    2.50 -
    2.51 -  public VirtualDisk
    2.52 -  create_virtual_disk(String name, long size, Date expiry)
    2.53 -  {
    2.54 -    VirtualDisk vd = new VirtualDisk (name, expiry);
    2.55 -
    2.56 -    while (size > 0)
    2.57 -    {
    2.58 -      Extent e;
    2.59 -
    2.60 -      e = free_disk.remove_extent();
    2.61 -      if (e == null)
    2.62 -      {
    2.63 -	return null;
    2.64 -      }
    2.65 -      size -= e.size;
    2.66 -      vd.add_extent(e);
    2.67 -    }
    2.68 -
    2.69 -    add_virtual_disk(vd);
    2.70 -
    2.71 -    return vd;
    2.72 -  }
    2.73 -
    2.74 -  /*
    2.75 -   * delete a new virtual disk.  extents go back into the free pool
    2.76 -   */
    2.77 -
    2.78 -  public void
    2.79 -  delete_virtual_disk (String key)
    2.80 -  {
    2.81 -    VirtualDisk vd;
    2.82 -
    2.83 -    vd = (VirtualDisk) key_hash.get(key);
    2.84 -    if (vd != null)
    2.85 -    {
    2.86 -      Extent e;
    2.87 -
    2.88 -      key_hash.remove(key);
    2.89 -      virtual_disks.remove(vd);
    2.90 -
    2.91 -      e = vd.remove_extent();
    2.92 -      while (e != null)
    2.93 -      {
    2.94 -	free_disk.add_extent(e);
    2.95 -	e = vd.remove_extent();
    2.96 -      }
    2.97 -    }
    2.98 -    return;
    2.99 -  }
   2.100 -
   2.101 -  /*
   2.102 -   * reset the expiry time for a virtual disk
   2.103 -   */
   2.104 -
   2.105 -  public void
   2.106 -  refresh_virtual_disk (String key, Date expiry)
   2.107 -  {
   2.108 -    VirtualDisk vd = (VirtualDisk) key_hash.get(key);
   2.109 -    if (vd != null)
   2.110 -    {
   2.111 -      vd.set_expiry(expiry);
   2.112 -    }
   2.113 -  }
   2.114 -
   2.115 -  /*
   2.116 -   * create a new virtual block device
   2.117 -   */
   2.118 -  public VirtualBlockDevice
   2.119 -  create_virtual_block_device (String key, int domain, int vbd_num, 
   2.120 -			       String mode)
   2.121 -  {
   2.122 -    VirtualBlockDevice vbd = new VirtualBlockDevice();
   2.123 -    VirtualDisk vd = get_virtual_disk_key(key);
   2.124 -
   2.125 -    if (vd == null)
   2.126 -    {
   2.127 -      System.err.println("create virtual block device error: unknown key " +
   2.128 -			 "[" + key + "]");
   2.129 -      return null;
   2.130 -    }
   2.131 -
   2.132 -    vbd.key = key;
   2.133 -    vbd.domain = domain;
   2.134 -    vbd.vbdnum = vbd_num;
   2.135 -
   2.136 -    if (mode.equals(Mode.READ_ONLY.toString()) ||
   2.137 -	mode.equals("RO") ||
   2.138 -	mode.equals("ro"))
   2.139 -    {
   2.140 -      vbd.mode = Mode.READ_ONLY;
   2.141 -    }
   2.142 -    else if (mode.equals(Mode.READ_WRITE.toString()) ||
   2.143 -	     mode.equals("RW") ||
   2.144 -	     mode.equals("rw"))
   2.145 -    {
   2.146 -      vbd.mode = Mode.READ_WRITE;
   2.147 -    }
   2.148 -    else
   2.149 -    {
   2.150 -      System.err.println("create virtual block device error: unknown mode " +
   2.151 -			 "[" + mode + "]");
   2.152 -      return null;
   2.153 -    }
   2.154 -
   2.155 -    add_virtual_block_device(vbd);
   2.156 -
   2.157 -    return vbd;
   2.158 -  }
   2.159 -
   2.160 -  /*
   2.161 -   * delete a virtual block device 
   2.162 -   */
   2.163 -  public void
   2.164 -  delete_virtual_block_device (int domain, int vbd_num)
   2.165 -  {
   2.166 -    Object hash = get_vbd_hash(domain, vbd_num);
   2.167 -    VirtualBlockDevice vbd = (VirtualBlockDevice)virtual_block_devices.remove(hash);
   2.168 -    return;
   2.169 -  }
   2.170 -
   2.171 -  /*
   2.172 -   * flush all virtual block devices
   2.173 -   */
   2.174 -  public void
   2.175 -  flush_virtual_block_devices ()
   2.176 -  {
   2.177 -                            /* isn't automatic garbage collection wonderful? */
   2.178 -    virtual_block_devices = new Hashtable(100);
   2.179 -  }
   2.180 -
   2.181 -  public void
   2.182 -  add_virtual_disk (VirtualDisk vd)
   2.183 -  {
   2.184 -    virtual_disks.add(vd);
   2.185 -    key_hash.put(vd.get_key(), vd);
   2.186 -  }
   2.187 -
   2.188 -  public void
   2.189 -  add_virtual_block_device (VirtualBlockDevice vbd)
   2.190 -  {
   2.191 -    Object hash = get_vbd_hash(vbd.domain, vbd.vbdnum);
   2.192 -    virtual_block_devices.put(hash, vbd);
   2.193 -  }
   2.194 -
   2.195 -  Object
   2.196 -  get_vbd_hash (int domain, int vbd_num)
   2.197 -  {
   2.198 -    return new Integer(domain * 16 + vbd_num);
   2.199 -  }
   2.200 -
   2.201 -  public void
   2.202 -  add_free (VirtualDisk vd)
   2.203 -  {
   2.204 -    free_disk = vd;
   2.205 -  }
   2.206 -
   2.207 -  public String
   2.208 -  dump_virtualdisk (int segment)
   2.209 -  {
   2.210 -    if (segment < 0 || segment >= virtual_disks.size())
   2.211 -    {
   2.212 -      return null;
   2.213 -    }
   2.214 -    else
   2.215 -    {
   2.216 -      VirtualDisk vd = (VirtualDisk) virtual_disks.get(segment);
   2.217 -      return (vd.dump(true, true));
   2.218 -    }
   2.219 -  }
   2.220 -
   2.221 -  public String
   2.222 -  dump_free()
   2.223 -  {
   2.224 -    return(free_disk.dump(true, false));
   2.225 -  }
   2.226 -
   2.227 -  public String
   2.228 -  dump_virtualdisks()
   2.229 -  {
   2.230 -    StringBuffer sb = new StringBuffer();
   2.231 -
   2.232 -    for (int i = 0; i < virtual_disks.size(); i++)
   2.233 -    {
   2.234 -      VirtualDisk vd = (VirtualDisk) virtual_disks.get(i);
   2.235 -      if (i == 0)
   2.236 -      {
   2.237 -	sb.append(vd.dump(false, true));
   2.238 -      }
   2.239 -      sb.append(vd.dump(false, false));
   2.240 -    }
   2.241 -
   2.242 -    return sb.toString();
   2.243 -  }
   2.244 -
   2.245 -  public String
   2.246 -  dump_virtualblockdevices()
   2.247 -  {
   2.248 -    StringBuffer sb = new StringBuffer();
   2.249 -    boolean first = true;
   2.250 -
   2.251 -    for (Enumeration enumeration = virtual_block_devices.elements() ; 
   2.252 -	 enumeration.hasMoreElements() ;) 
   2.253 -    {
   2.254 -      VirtualBlockDevice vbd = (VirtualBlockDevice) enumeration.nextElement();
   2.255 -      if (first)
   2.256 -      {
   2.257 -	sb.append(vbd.dump(true));
   2.258 -	first = false;
   2.259 -      }
   2.260 -
   2.261 -      sb.append(vbd.dump(false));
   2.262 -    }
   2.263 -
   2.264 -    return sb.toString();
   2.265 -  }
   2.266 -
   2.267 -  public void
   2.268 -  dump_xml(PrintWriter out)
   2.269 -  {
   2.270 -    out.println("<free>");
   2.271 -    free_disk.dump_xml(out);
   2.272 -    out.println("</free>");
   2.273 -    out.println("<virtual_disks>");
   2.274 -    for (int i = 0; i < virtual_disks.size(); i++)
   2.275 -    {
   2.276 -      VirtualDisk vd = (VirtualDisk) virtual_disks.get(i);
   2.277 -      vd.dump_xml(out);
   2.278 -    }
   2.279 -    out.println("</virtual_disks>");
   2.280 -    out.println("<virtual_block_devices>");
   2.281 -    for (Enumeration enumeration = virtual_block_devices.elements() ; 
   2.282 -	 enumeration.hasMoreElements() ;) 
   2.283 -    {
   2.284 -      VirtualBlockDevice vbd = (VirtualBlockDevice) enumeration.nextElement();
   2.285 -      vbd.dump_xml(out);
   2.286 -    }
   2.287 - 
   2.288 -    out.println("</virtual_block_devices>");
   2.289 -
   2.290 -    return;
   2.291 -  }
   2.292 -
   2.293 -  /*************************************************************************/
   2.294 -
   2.295 -  public int
   2.296 -  getVirtualDiskCount ()
   2.297 -  {
   2.298 -    return virtual_disks.size();
   2.299 -  }
   2.300 -
   2.301 -  public VirtualDisk
   2.302 -  getVirtualDisk (int index)
   2.303 -  {
   2.304 -    return (VirtualDisk) virtual_disks.get(index);
   2.305 -  }
   2.306 -
   2.307 -  public VirtualDisk
   2.308 -  getFreeVirtualDisk ()
   2.309 -  {
   2.310 -    return free_disk;
   2.311 -  }
   2.312 -
   2.313 -  public Enumeration
   2.314 -  getVirtualBlockDevices ()
   2.315 -  {
   2.316 -    return virtual_block_devices.elements();
   2.317 -  }
   2.318 -}
     3.1 --- a/tools/vdmanager/Makefile	Mon Jul 07 14:24:01 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,9 +0,0 @@
     3.4 -default:
     3.5 -	ant dist
     3.6 -
     3.7 -install: default
     3.8 -	cp -a vdmanager vdmanager.jar ../../../install/bin
     3.9 -	chmod 755 ../../../install/bin/vdmanager
    3.10 -clean:
    3.11 -	ant clean
    3.12 -	rm -f vdmanager.jar
     4.1 --- a/tools/vdmanager/build.xml	Mon Jul 07 14:24:01 2003 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,45 +0,0 @@
     4.4 -<project name="vdmanager project" default="compile">
     4.5 -  <property name="src" location="src"/>
     4.6 -  <property name="build" location="build"/>
     4.7 -  <property name="dist" location="dist"/>
     4.8 -  <property name="lib" location="lib"/>
     4.9 -
    4.10 -  <target name="init">
    4.11 -    <tstamp/>
    4.12 -    <mkdir dir="${build}"/>     
    4.13 -  </target>
    4.14 -
    4.15 -  <target name="compile" depends="init">
    4.16 -    <javac srcdir="${src}" destdir="${build}" debug="on"/>
    4.17 -  </target>
    4.18 -
    4.19 -  <target name="dist" depends="compile">
    4.20 -    <jar jarfile="vdmanager.jar"
    4.21 -         excludes="*~"
    4.22 -	 basedir="${build}">
    4.23 -      <fileset dir="${src}" />
    4.24 -      <fileset dir=".">
    4.25 -        <include name="build.xml"/>
    4.26 -        <include name="vdmanager"/>
    4.27 -      </fileset>
    4.28 -      <manifest>
    4.29 -        <attribute name="Built-By" value="${user.name}"/>
    4.30 -	<attribute name="Main-Class" value="uk.ac.cam.cl.xeno.vdmanager.Main"/>
    4.31 -	<attribute name="Sealed" value="true"/>
    4.32 -      </manifest>
    4.33 -    </jar>
    4.34 -  </target>
    4.35 -
    4.36 -  <target name="test" depends="compile">
    4.37 -    <java fork="true" classname="uk.ac.cam.cl.xeno.vdmanager.Main">
    4.38 -      <classpath>
    4.39 -        <pathelement path="${build}"/>
    4.40 -      </classpath>
    4.41 -    </java>
    4.42 -  </target>
    4.43 -
    4.44 -  <target name="clean">
    4.45 -    <delete dir="${build}"/>
    4.46 -    <delete dir="${lib}"/>
    4.47 -  </target>
    4.48 -</project>
    4.49 \ No newline at end of file
     5.1 --- a/tools/vdmanager/notes.xml	Mon Jul 07 14:24:01 2003 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,35 +0,0 @@
     5.4 -<?xml version="1.0"?>
     5.5 -<!DOCTYPE vdmanager.dtd [
     5.6 -<!ELEMENT vdmanager (partitions|free|virtual_disks|virtual_block_devices)*>
     5.7 -
     5.8 -<!ELEMENT partitions (partition)*>
     5.9 -<!ELEMENT partition (major, minor, blocks, star_sect, nr_sects, name)>
    5.10 -<!ELEMENT major (#PCDATA)>
    5.11 -<!ELEMENT minor (#PCDATA)>
    5.12 -<!ELEMENT blocks (#PCDATA)>
    5.13 -<!ELEMENT start_sect (#PCDATA)>
    5.14 -<!ELEMENT nr_sects (#PCDATA)>
    5.15 -<!ELEMENT name (#PCDATA)>
    5.16 -
    5.17 -<!ELEMENT free (virtual_disk)?>
    5.18 -<!ELEMENT virtual_disks (virtual_disk)*>
    5.19 -<!ELEMENT virtual_disk (name, key, expiry, extents)>
    5.20 -<!ELEMENT name (#PCDATA)>
    5.21 -<!ELEMENT key (#PCDATA)>
    5.22 -<!ELEMENT expiry (#PCDATA)>
    5.23 -<!ELEMENT extents (extent)*>
    5.24 -<!ELEMENT extent (disk, size, offset)>
    5.25 -<!ELEMENT disk (#PCDATA)>
    5.26 -<!ELEMENT size (#PCDATA)>
    5.27 -<!ELEMENT offset (#PCDATA)>
    5.28 -
    5.29 -<!ELEMENT virtual_block_devices (virtual_block_device)*>
    5.30 -<!ELEMENT virtual_block_device (key, domain, vbdnum, mode)>
    5.31 -<!ELEMENT key (#PCDATA)>
    5.32 -<!ELEMENT domain (#PCDATA)>
    5.33 -<!ELEMENT vbdnum (#PCDATA)>
    5.34 -<!ELEMENT mode (#PCDATA)>
    5.35 -]>
    5.36 -
    5.37 -<vdmanager>
    5.38 -</vdmanager>
     6.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Extent.java	Mon Jul 07 14:24:01 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,14 +0,0 @@
     6.4 -/*
     6.5 - * Extent.java
     6.6 - * 03.03.26 aho creation
     6.7 - */
     6.8 -
     6.9 -package uk.ac.cam.cl.xeno.vdmanager;
    6.10 -
    6.11 -public class
    6.12 -Extent
    6.13 -{
    6.14 -  int disk;
    6.15 -  long offset;                                           /* offset into disk */
    6.16 -  long size;                      /* size of this extent in 512 byte sectors */
    6.17 -}
     7.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Library.java	Mon Jul 07 14:24:01 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,114 +0,0 @@
     7.4 -/*
     7.5 - * Library.java
     7.6 - * 03.03.28 aho creation
     7.7 - */
     7.8 -
     7.9 -package uk.ac.cam.cl.xeno.vdmanager;
    7.10 -
    7.11 -public class
    7.12 -Library
    7.13 -{
    7.14 -  /*
    7.15 -   * convert a number to a fixed width string
    7.16 -   */
    7.17 -  static String
    7.18 -  format (long input, int width, int prefix)
    7.19 -  {
    7.20 -    String sss = Long.toString(input);
    7.21 -    String space = "                                ";
    7.22 -
    7.23 -    if (width < sss.length())
    7.24 -    {
    7.25 -      width = sss.length();
    7.26 -    }
    7.27 -
    7.28 -    if (prefix == 0)
    7.29 -    {
    7.30 -      return space.substring(0, width - sss.length()) + sss;
    7.31 -    }
    7.32 -    else
    7.33 -    {
    7.34 -      return sss + space.substring(0, width - sss.length());
    7.35 -    }
    7.36 -  }
    7.37 -
    7.38 -  /*
    7.39 -   * convert a string to a fixed width string
    7.40 -   */
    7.41 -  static String
    7.42 -  format (String input, int width, int prefix)
    7.43 -  {
    7.44 -    String space = "                                ";
    7.45 -
    7.46 -    if (width < input.length())
    7.47 -    {
    7.48 -      width = input.length();
    7.49 -    }
    7.50 -
    7.51 -    if (prefix == 0)
    7.52 -    {
    7.53 -      return space.substring(0, width - input.length()) + input;
    7.54 -    }
    7.55 -    else
    7.56 -    {
    7.57 -      return input + space.substring(0, width - input.length());
    7.58 -    }
    7.59 -  }
    7.60 -
    7.61 -  /*
    7.62 -   * convert a number (string format) into 
    7.63 -   * the corresponding integer value.
    7.64 -   */
    7.65 -  static long
    7.66 -  parse_size(String size)
    7.67 -  {
    7.68 -    String substring = size;
    7.69 -    int    suffix = 1;
    7.70 -
    7.71 -    if ((substring = check(size, 'm')) != null)
    7.72 -    {
    7.73 -      suffix = 1024 * 1024;
    7.74 -    }
    7.75 -    else if ((substring = check(size, 'M')) != null)
    7.76 -    {
    7.77 -      suffix = 1024 * 1024;
    7.78 -    }
    7.79 -    else if ((substring = check(size, 'k')) != null)
    7.80 -    {
    7.81 -      suffix = 1024;
    7.82 -    }
    7.83 -    else if ((substring = check(size, 'K')) != null)
    7.84 -    {
    7.85 -      suffix = 1024;
    7.86 -    }
    7.87 -    else if ((substring = check(size, 'g')) != null)
    7.88 -    {
    7.89 -      suffix = 1024 * 1024 * 1024;
    7.90 -    }
    7.91 -    else if ((substring = check(size, 'G')) != null)
    7.92 -    {
    7.93 -      suffix = 1024 * 1024 * 1024;
    7.94 -    }
    7.95 -    else
    7.96 -    {
    7.97 -      substring = size;
    7.98 -    }
    7.99 -
   7.100 -    return Long.decode(substring).longValue() * suffix;
   7.101 -  }
   7.102 -
   7.103 -  static String
   7.104 -  check(String size, char suffix)
   7.105 -  {
   7.106 -    int index = size.indexOf(suffix);
   7.107 -
   7.108 -    if (index != -1)
   7.109 -    {
   7.110 -      return size.substring(0, index);
   7.111 -    }
   7.112 -    else
   7.113 -    {
   7.114 -      return null;
   7.115 -    }
   7.116 -  }
   7.117 -}
     8.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Main.java	Mon Jul 07 14:24:01 2003 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,35 +0,0 @@
     8.4 -/*
     8.5 - * Main.java
     8.6 - * 03.03.26 aho creation
     8.7 - */
     8.8 -
     8.9 -package uk.ac.cam.cl.xeno.vdmanager;
    8.10 -
    8.11 -import java.util.Date;
    8.12 -
    8.13 -public class
    8.14 -Main
    8.15 -{
    8.16 -  static String state_filename_in  = "/var/lib/xen/vdstate.xml";
    8.17 -  static String state_filename_out = "/var/lib/xen/vdstate.xml";
    8.18 -  static String partition_filename = "/proc/partitions";
    8.19 -
    8.20 -  void
    8.21 -  go (String[] argv)
    8.22 -  {
    8.23 -    PartitionManager pm = new PartitionManager(partition_filename);
    8.24 -    VirtualDiskManager vdm = new VirtualDiskManager();;
    8.25 -    Parser parser = new Parser(pm, vdm);
    8.26 -
    8.27 -    XML.load_state(pm, vdm, state_filename_in);
    8.28 -    parser.parse_main(argv);
    8.29 -    XML.dump_state(pm, vdm, state_filename_out);
    8.30 -  }
    8.31 -
    8.32 -  public static void
    8.33 -  main (String[] argv)
    8.34 -  {
    8.35 -    Main foo = new Main();
    8.36 -    foo.go(argv);
    8.37 -  }
    8.38 -}
     9.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Mode.java	Mon Jul 07 14:24:01 2003 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,20 +0,0 @@
     9.4 -/*
     9.5 - * Mode.java
     9.6 - * 03.03.27 aho creation
     9.7 - */
     9.8 -
     9.9 -package uk.ac.cam.cl.xeno.vdmanager;
    9.10 -
    9.11 -public class 
    9.12 -Mode 
    9.13 -{
    9.14 -  private final String name;
    9.15 -
    9.16 -  private Mode(String name) { this.name = name; }
    9.17 -
    9.18 -  public String toString()  { return name; }
    9.19 -
    9.20 -  public static final Mode READ_ONLY  = new Mode("ro");
    9.21 -  public static final Mode READ_WRITE = new Mode("rw");
    9.22 -}
    9.23 -
    10.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Parser.java	Mon Jul 07 14:24:01 2003 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,446 +0,0 @@
    10.4 -/*
    10.5 - * Parser.java
    10.6 - * 03.03.27 aho creation
    10.7 - */
    10.8 -
    10.9 -package uk.ac.cam.cl.xeno.vdmanager;
   10.10 -
   10.11 -import java.io.BufferedReader;
   10.12 -import java.io.FileReader;
   10.13 -import java.io.InputStreamReader;
   10.14 -import java.io.FileNotFoundException;
   10.15 -import java.io.IOException;
   10.16 -import java.util.StringTokenizer;
   10.17 -import java.util.Vector;
   10.18 -import java.util.Date;
   10.19 -
   10.20 -public class
   10.21 -Parser
   10.22 -{
   10.23 -  static String prompt = "vdmanager> ";
   10.24 -  static String default_addpartition_chunksize = "104857600";        /* 100M */
   10.25 -  static int    default_sector_size = 512;
   10.26 -
   10.27 -  PartitionManager pm;
   10.28 -  VirtualDiskManager vdm;
   10.29 -
   10.30 -  Parser (PartitionManager pm, VirtualDiskManager vdm)
   10.31 -  {
   10.32 -    this.pm = pm;
   10.33 -    this.vdm = vdm;
   10.34 -  }
   10.35 -
   10.36 -  void
   10.37 -  parse_main (String[] argv)
   10.38 -  {
   10.39 -    if (argv.length == 0)
   10.40 -    {
   10.41 -      parse_input(null);
   10.42 -    }
   10.43 -    else
   10.44 -    {
   10.45 -      parse_commandline(argv);
   10.46 -    }
   10.47 -  }
   10.48 -
   10.49 -  void
   10.50 -  parse_input (String filename)
   10.51 -  {
   10.52 -    String line;
   10.53 -    BufferedReader in;
   10.54 -
   10.55 -    if (filename != null)
   10.56 -    {
   10.57 -      try
   10.58 -      {
   10.59 -	in = new BufferedReader(new FileReader(filename));
   10.60 -      }
   10.61 -      catch (FileNotFoundException fnfe)
   10.62 -      {
   10.63 -	System.err.println (fnfe);
   10.64 -	return;
   10.65 -      }
   10.66 -    }
   10.67 -    else
   10.68 -    {
   10.69 -      in = new BufferedReader(new InputStreamReader(System.in));
   10.70 -    }
   10.71 -
   10.72 -    try
   10.73 -    {
   10.74 -      if (filename == null)
   10.75 -      {
   10.76 -	System.out.print (prompt);
   10.77 -      }
   10.78 -      line = in.readLine();
   10.79 -      while (line != null)
   10.80 -      {
   10.81 -	StringTokenizer st = new StringTokenizer(line);
   10.82 -	Vector v = new Vector();
   10.83 -
   10.84 -	while (st.hasMoreTokens()) 
   10.85 -	{
   10.86 -	  v.add(st.nextToken());
   10.87 -	}
   10.88 -
   10.89 -	if (parse_commandline((String[]) v.toArray(new String[v.size()])))
   10.90 -	{
   10.91 -	  return;
   10.92 -	}
   10.93 -	
   10.94 -	if (filename == null)
   10.95 -	{
   10.96 -	  System.out.print (prompt);
   10.97 -	}
   10.98 -	line = in.readLine();
   10.99 -      }
  10.100 -    }
  10.101 -    catch (IOException ioe)
  10.102 -    {
  10.103 -      System.err.println(ioe);
  10.104 -    }
  10.105 -
  10.106 -    if (filename == null)
  10.107 -    {
  10.108 -      System.out.println ("");
  10.109 -    }
  10.110 -    return;
  10.111 -  }
  10.112 -
  10.113 -  boolean
  10.114 -  parse_commandline (String[] commands)
  10.115 -  {
  10.116 -    if (commands.length == 0)
  10.117 -    {
  10.118 -      return false;
  10.119 -    }
  10.120 -
  10.121 -    String keyword = commands[0].toLowerCase();
  10.122 -    if (keyword.equals("file"))
  10.123 -    {
  10.124 -      if (commands.length < 2)
  10.125 -      {
  10.126 -	System.out.println ("file [filename]");
  10.127 -	return false;
  10.128 -      }
  10.129 -      for (int i = 1; i < commands.length; i++)
  10.130 -      {
  10.131 -	System.out.println ("file " + commands[i]);
  10.132 -	parse_input(commands[i]);
  10.133 -      }
  10.134 -    }
  10.135 -    else if (keyword.equals("show"))
  10.136 -    {
  10.137 -      parse_show(commands);
  10.138 -    }
  10.139 -    else if (keyword.equals("addpartition"))
  10.140 -    {
  10.141 -      parse_addpartition(commands);
  10.142 -    }
  10.143 -    else if (keyword.equals("vdcreate"))
  10.144 -    {
  10.145 -      parse_vdcreate(commands);
  10.146 -    }
  10.147 -    else if (keyword.equals("vddelete"))
  10.148 -    {
  10.149 -      parse_vddelete(commands);
  10.150 -    }
  10.151 -    else if (keyword.equals("vdrefresh"))
  10.152 -    {
  10.153 -      parse_vdrefresh(commands);
  10.154 -    }
  10.155 -    else if (keyword.equals("vbdcreate"))
  10.156 -    {
  10.157 -      parse_vbdcreate(commands);
  10.158 -    }
  10.159 -    else if (keyword.equals("vbddelete"))
  10.160 -    {
  10.161 -      parse_vbddelete(commands);
  10.162 -    }
  10.163 -    else if (keyword.equals("vbdflush"))
  10.164 -    {
  10.165 -      vdm.flush_virtual_block_devices();
  10.166 -    }
  10.167 -    else if (keyword.equals("load"))
  10.168 -    {
  10.169 -      if (commands.length < 2)
  10.170 -      {
  10.171 -	System.out.println ("load <filename>");
  10.172 -	return false;
  10.173 -      }
  10.174 -      XML.load_state (pm, vdm, commands[1]);
  10.175 -    }
  10.176 -    else if (keyword.equals("save"))
  10.177 -    {
  10.178 -      if (commands.length < 2)
  10.179 -      {
  10.180 -	System.out.println ("save <filename>");
  10.181 -	return false;
  10.182 -      }
  10.183 -      XML.dump_state (pm, vdm, commands[1]);
  10.184 -    }
  10.185 -    else if (keyword.equals("help") ||
  10.186 -	     keyword.equals("?"))
  10.187 -    {
  10.188 -      parse_help();
  10.189 -    }
  10.190 -    else if (keyword.equals("exit") ||
  10.191 -	     keyword.equals("quit"))
  10.192 -    {
  10.193 -      return true;
  10.194 -    }
  10.195 -    else
  10.196 -    {
  10.197 -      System.out.println ("unknown command [" + commands[0] + "]. " +
  10.198 -			  "try \"help\"");
  10.199 -    }
  10.200 -    return false;
  10.201 -  }
  10.202 -
  10.203 -  void
  10.204 -  parse_vdcreate (String[] commands)
  10.205 -  {
  10.206 -    VirtualDisk vd;
  10.207 -
  10.208 -    if (commands.length < 4)
  10.209 -    {
  10.210 -      System.out.println ("vdcreate name size expiry");
  10.211 -      return;
  10.212 -    }
  10.213 -
  10.214 -    vd = vdm.create_virtual_disk(commands[1],
  10.215 -		     Library.parse_size(commands[2]) / default_sector_size,
  10.216 -				 new Date());
  10.217 -
  10.218 -    System.out.println ("Virtual Disk created with key: " + vd.get_key());
  10.219 -  }
  10.220 -
  10.221 -  void
  10.222 -  parse_vddelete (String[] commands)
  10.223 -  {
  10.224 -    if (commands.length < 2)
  10.225 -    {
  10.226 -      System.out.println ("vddelete key");
  10.227 -      return;
  10.228 -    }
  10.229 -
  10.230 -    vdm.delete_virtual_disk(commands[1]);
  10.231 -  }
  10.232 -
  10.233 -  void
  10.234 -  parse_vdrefresh (String[] commands)
  10.235 -  {
  10.236 -    if (commands.length < 3)
  10.237 -    {
  10.238 -      System.out.println ("vdrefresh key expiry");
  10.239 -      return;
  10.240 -    }
  10.241 -
  10.242 -    vdm.refresh_virtual_disk(commands[1],
  10.243 -			     new Date());
  10.244 -  }
  10.245 -
  10.246 -  void
  10.247 -  parse_vbdcreate (String[] commands)
  10.248 -  {
  10.249 -    VirtualDisk vd;
  10.250 -    VirtualBlockDevice vbd;
  10.251 -
  10.252 -    if (commands.length < 4)
  10.253 -    {
  10.254 -      System.out.println ("vbdcreate <key> <domain number> <vbd number>");
  10.255 -      return;
  10.256 -    }
  10.257 -
  10.258 -    if (commands[1].startsWith("sd") ||
  10.259 -	commands[1].startsWith("hd"))
  10.260 -    {
  10.261 -      /*
  10.262 -       * this is a gross hack to allow you to create a virtual block
  10.263 -       * device that maps directly to a physical partition
  10.264 -       */
  10.265 -
  10.266 -      /* find the appropriate partition */
  10.267 -      Partition partition = pm.get_partition(commands[1]);
  10.268 -      if (partition == null)
  10.269 -      {
  10.270 -	System.out.println ("vbdcreate error: couldn't find partition \"" +
  10.271 -			    commands[1] + "\"");
  10.272 -	return;
  10.273 -      }
  10.274 -
  10.275 -      /* create a virtual disk */
  10.276 -      vd = new VirtualDisk("vbd:" + commands[1]);
  10.277 -      vd.add_new_partition(partition, partition.nr_sects);
  10.278 -
  10.279 -
  10.280 -      /* display result */
  10.281 -      System.out.print("domain:" + commands[2] + " ");
  10.282 -      if (commands.length == 4)
  10.283 -      {
  10.284 -	System.out.print ("rw ");
  10.285 -      }
  10.286 -      else
  10.287 -      {
  10.288 -	System.out.print(commands[4] + " ");
  10.289 -      }
  10.290 -      System.out.print("segment:" + commands[3] + " ");
  10.291 -      System.out.print(vd.dump_xen());
  10.292 -      System.out.println("");
  10.293 -
  10.294 -      return;
  10.295 -    } 
  10.296 -
  10.297 -    if (commands.length == 4)
  10.298 -    {
  10.299 -      vbd =
  10.300 -      vdm.create_virtual_block_device(commands[1],
  10.301 -				      Integer.decode(commands[2]).intValue(),
  10.302 -				      Integer.decode(commands[3]).intValue(),
  10.303 -				      "rw");
  10.304 -    }
  10.305 -    else
  10.306 -    {
  10.307 -      vbd =
  10.308 -      vdm.create_virtual_block_device(commands[1],
  10.309 -				      Integer.decode(commands[2]).intValue(),
  10.310 -				      Integer.decode(commands[3]).intValue(),
  10.311 -				      commands[4]);
  10.312 -    }
  10.313 -
  10.314 -    /* display commandline to user */
  10.315 -    {
  10.316 -      vd = vdm.get_virtual_disk_key(commands[1]);
  10.317 -      System.out.println ("\n" + vd.dump_xen(vbd) + "\n");
  10.318 -    }
  10.319 -  }
  10.320 -
  10.321 -  void
  10.322 -  parse_vbddelete (String[] commands)
  10.323 -  {
  10.324 -    if (commands.length < 3)
  10.325 -    {
  10.326 -      System.out.println ("vbddelete <domain number> <vbd number>");
  10.327 -      return;
  10.328 -    }
  10.329 -
  10.330 -    vdm.delete_virtual_block_device(Integer.decode(commands[1]).intValue(),
  10.331 -				    Integer.decode(commands[2]).intValue());
  10.332 -  }
  10.333 -
  10.334 -  static String show_helptxt = "show <partitions | free | vd [vd number] | vbd>";
  10.335 -  void
  10.336 -  parse_show (String[] commands)
  10.337 -  {
  10.338 -    String subword;
  10.339 -      
  10.340 -    if (commands.length < 2)
  10.341 -    {
  10.342 -      System.out.println (show_helptxt);
  10.343 -      return;
  10.344 -    }
  10.345 -
  10.346 -    subword = commands[1].toLowerCase();
  10.347 -    if (subword.equals("partition") ||
  10.348 -	subword.equals("partitions"))
  10.349 -    {
  10.350 -      System.out.println(pm.dump(true));
  10.351 -    }
  10.352 -    else if (subword.equals("vd"))
  10.353 -    {
  10.354 -      String text;
  10.355 -
  10.356 -      if (commands.length < 3)
  10.357 -      {
  10.358 -	System.out.println(vdm.dump_virtualdisks());
  10.359 -	return;
  10.360 -      }
  10.361 -      text = vdm.dump_virtualdisk(Integer.decode(commands[2]).intValue());
  10.362 -      if (text == null)
  10.363 -      {
  10.364 -	System.out.println("show vd error: invalid virtual disk number");
  10.365 -      }
  10.366 -      else
  10.367 -      {
  10.368 -	System.out.println(text);
  10.369 -      }
  10.370 -    }
  10.371 -    else if (subword.equals("vbd"))
  10.372 -    {
  10.373 -      System.out.println(vdm.dump_virtualblockdevices());
  10.374 -    }
  10.375 -    else if (subword.equals("free"))
  10.376 -    {
  10.377 -      System.out.println(vdm.dump_free());
  10.378 -    }
  10.379 -    else
  10.380 -    {
  10.381 -      System.out.println (show_helptxt);
  10.382 -      return;
  10.383 -    }
  10.384 -  }
  10.385 -
  10.386 -  void
  10.387 -  parse_addpartition(String[] commands)
  10.388 -  {
  10.389 -    String chunksize = default_addpartition_chunksize;
  10.390 -
  10.391 -    if (commands.length > 3 || commands.length < 2)
  10.392 -    {
  10.393 -      System.out.println ("addpartition <partition number> [chunksize]");
  10.394 -      return;
  10.395 -    }
  10.396 -    if (commands.length == 3)
  10.397 -    {
  10.398 -      chunksize = commands[2];
  10.399 -    }
  10.400 -
  10.401 -    System.out.println ("add partition " + commands[1] + " " + chunksize);
  10.402 -
  10.403 -    vdm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1])), 
  10.404 -			   Library.parse_size(chunksize)/default_sector_size);
  10.405 -    pm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1])));
  10.406 -  }
  10.407 -
  10.408 -  void
  10.409 -  parse_help()
  10.410 -  {
  10.411 -    System.out.println ("file <filename>     " +
  10.412 -			"read the contents of a file as input to vdmanager");
  10.413 -    System.out.println ("addpartition <partition number> [chunksize]");
  10.414 -    System.out.println ("                    " +
  10.415 -			"add a partition as a xeno partition");
  10.416 -    System.out.println ("vdcreate <name> <size> <expiry>");
  10.417 -    System.out.println ("                    " +
  10.418 -			"create a new virtual disk");
  10.419 -    System.out.println ("vddelete <key>      " +
  10.420 -			"delete a virtual disk");
  10.421 -    System.out.println ("vdrefresh <key> <expiry>");
  10.422 -    System.out.println ("                    " +
  10.423 -			"reset virtual disk expiry");
  10.424 -    System.out.println ("vbdcreate <key> <domain number> <vbd number> [rw|ro]");
  10.425 -    System.out.println ("                    " +
  10.426 -			"create a new virtual block device");
  10.427 -    System.out.println ("vbddelete <domain number> <vbd number>");
  10.428 -    System.out.println ("                    " +
  10.429 -			"delete a new virtual block device");
  10.430 -    System.out.println ("vbdflush            " +
  10.431 -			"remove all virtual block devices");
  10.432 -    System.out.println ("show partitions     " +
  10.433 -			"display a complete list of disk partitions");
  10.434 -    System.out.println ("show vd <vd number> " +
  10.435 -			"display virtual disk information");
  10.436 -    System.out.println ("show vbd            " +
  10.437 -			"display virtual virtual block device list");
  10.438 -    System.out.println ("show free           " +
  10.439 -			"display details about unallocated space");
  10.440 -    System.out.println ("load <filename>     " +
  10.441 -			"load new state from file");
  10.442 -    System.out.println ("save <filename>     " +
  10.443 -			"save state to file");
  10.444 -    System.out.println ("help                " +
  10.445 -			"display this help message");
  10.446 -    System.out.println ("quit                " +
  10.447 -			"exit");
  10.448 -  }
  10.449 -}
    11.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/Partition.java	Mon Jul 07 14:24:01 2003 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,80 +0,0 @@
    11.4 -/*
    11.5 - * PartitionManager.java
    11.6 - * 03.03.26 aho creation
    11.7 - */
    11.8 -
    11.9 -package uk.ac.cam.cl.xeno.vdmanager;
   11.10 -
   11.11 -import java.io.*;
   11.12 -
   11.13 -public class
   11.14 -Partition
   11.15 -{
   11.16 -  int major;
   11.17 -  int minor;
   11.18 -  long blocks;
   11.19 -  long start_sect;
   11.20 -  long nr_sects;
   11.21 -  String name;
   11.22 -
   11.23 -  boolean 
   11.24 -  identical (Partition p)
   11.25 -  {
   11.26 -    return (major == p.major &&
   11.27 -	    minor == p.minor &&
   11.28 -	    blocks == p.blocks &&
   11.29 -	    start_sect == p.start_sect &&
   11.30 -	    nr_sects == p.nr_sects &&
   11.31 -	    name.equals(p.name));
   11.32 -  }
   11.33 -
   11.34 -  Partition
   11.35 -  duplicate ()
   11.36 -  {
   11.37 -    Partition p = new Partition();
   11.38 -
   11.39 -    p.major = major;
   11.40 -    p.minor = minor;
   11.41 -    p.blocks = blocks;
   11.42 -    p.start_sect = start_sect;
   11.43 -    p.nr_sects = nr_sects;
   11.44 -    p.name = name;
   11.45 -
   11.46 -    return p;
   11.47 -  }
   11.48 -
   11.49 -  String 
   11.50 -  dump (boolean title)
   11.51 -  {
   11.52 -    if (title)
   11.53 -    {
   11.54 -      return ("maj:min " + 
   11.55 -	      "    blocks " +
   11.56 -	      "start sect " +
   11.57 -	      " num sects " +
   11.58 -	      "name");
   11.59 -    }
   11.60 -    else
   11.61 -    {
   11.62 -      return (Library.format(major,3,0) + ":" + 
   11.63 -	      Library.format(minor,3,1) + " " +
   11.64 -	      Library.format(blocks,10,0) + " " +
   11.65 -	      Library.format(start_sect,10,0) + " " +
   11.66 -	      Library.format(nr_sects,10,0) + " " +
   11.67 -	      Library.format(name,7,1));
   11.68 -    }
   11.69 -  }
   11.70 -
   11.71 -  void
   11.72 -  dump_xml(PrintWriter out)
   11.73 -  {
   11.74 -    out.println ("  <partition>\n" +
   11.75 -		 "    <major>" + major + "</major>\n" +
   11.76 -		 "    <minor>" + minor + "</minor>\n" +
   11.77 -		 "    <blocks>" + blocks + "</blocks>\n" +
   11.78 -		 "    <start_sect>" + start_sect + "</start_sect>\n" +
   11.79 -		 "    <nr_sects>" + nr_sects + "</nr_sects>\n" +
   11.80 -		 "    <name>" + name + "</name>\n" +
   11.81 -		 "  </partition>");
   11.82 -  }
   11.83 -}
    12.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/PartitionManager.java	Mon Jul 07 14:24:01 2003 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,176 +0,0 @@
    12.4 -/*
    12.5 - * PartitionManager.java
    12.6 - * 03.03.26 aho creation
    12.7 - */
    12.8 -
    12.9 -package uk.ac.cam.cl.xeno.vdmanager;
   12.10 -
   12.11 -import java.io.*;
   12.12 -import java.util.Vector;
   12.13 -import java.util.Enumeration;
   12.14 -
   12.15 -public class
   12.16 -PartitionManager
   12.17 -{
   12.18 -  Vector partition_map;
   12.19 -  Vector xeno_partition_list;
   12.20 -
   12.21 -  static String proc_template =
   12.22 -    "major minor  #blocks  start_sect   nr_sects name";
   12.23 -
   12.24 -  /*
   12.25 -   * Initialize partition manager with source file.
   12.26 -   * Normally we read from /proc/partitions, but we can
   12.27 -   * specify an alternative file for debugging
   12.28 -   */
   12.29 -  PartitionManager (String filename)
   12.30 -  {
   12.31 -    String str;
   12.32 -    BufferedReader in;
   12.33 -
   12.34 -    partition_map = new Vector(100,10);
   12.35 -    xeno_partition_list = new Vector(10,5);
   12.36 -
   12.37 -    try
   12.38 -    {
   12.39 -      in = new BufferedReader(new FileReader(filename));
   12.40 -
   12.41 -      str = in.readLine();                                  /* skip headings */
   12.42 -      if (str.length() < proc_template.length() ||
   12.43 -	  !str.substring(0, proc_template.length()).equals(proc_template))
   12.44 -      {
   12.45 -	System.err.println ("Error: Incorrect /proc/partitions.");
   12.46 -	System.err.println ("       Is this Xeno?");
   12.47 -	System.exit (1);
   12.48 -      }
   12.49 -
   12.50 -      str = in.readLine();                                /* skip blank line */
   12.51 -
   12.52 -      str = in.readLine();
   12.53 -      while (str != null)
   12.54 -      {
   12.55 -	Partition partition = new Partition();
   12.56 -
   12.57 -	partition.major = Integer.parseInt(str.substring(0,5).trim());
   12.58 -	partition.minor = Integer.parseInt(str.substring(5,10).trim());
   12.59 -	partition.blocks = Integer.parseInt(str.substring(10,21).trim());
   12.60 -	partition.start_sect = Integer.parseInt(str.substring(21,32).trim());
   12.61 -	partition.nr_sects = Integer.parseInt(str.substring(32,43).trim());
   12.62 -	partition.name = str.substring(43).trim();
   12.63 -
   12.64 -	partition_map.add(partition);
   12.65 -	str = in.readLine();
   12.66 -      }
   12.67 -    }
   12.68 -    catch (IOException io)
   12.69 -    {
   12.70 -      System.err.println ("PartitionManager: error reading partition file [" 
   12.71 -			  + filename + "]");
   12.72 -      System.err.println (io);
   12.73 -    }
   12.74 -  }
   12.75 -
   12.76 -  Partition
   12.77 -  get_partition (String name)
   12.78 -  {
   12.79 -    Partition partition = null;
   12.80 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
   12.81 -    {
   12.82 -      partition = (Partition) e.nextElement();
   12.83 -      if (partition.name.equals(name))
   12.84 -      {
   12.85 -	return partition;
   12.86 -      }
   12.87 -    }
   12.88 -    return null;
   12.89 -  }
   12.90 -
   12.91 -  Partition
   12.92 -  get_partition (int index)
   12.93 -  {
   12.94 -    return (Partition) partition_map.get(index);
   12.95 -  }
   12.96 -
   12.97 -  void
   12.98 -  add_xeno_partition (Partition partition)
   12.99 -  {
  12.100 -    Partition xeno_partition = (Partition) partition.duplicate();
  12.101 -
  12.102 -    xeno_partition_list.add(xeno_partition);
  12.103 -  }
  12.104 -
  12.105 -  /*
  12.106 -   * dump the xeno partition list as xml
  12.107 -   */
  12.108 -  void
  12.109 -  dump_xml (PrintWriter out)
  12.110 -  {
  12.111 -    int loop;
  12.112 -
  12.113 -    out.println("<partitions>");
  12.114 -    for (loop = 0; loop < xeno_partition_list.size(); loop++)
  12.115 -    {
  12.116 -      Partition partition = (Partition) xeno_partition_list.get(loop);
  12.117 -      partition.dump_xml(out);
  12.118 -    }
  12.119 -    out.println("</partitions>");
  12.120 -
  12.121 -    return;
  12.122 -  }
  12.123 -
  12.124 -  /*
  12.125 -   * dump the partition map as a string
  12.126 -   * mark: mark the current xeno partitions in the partition map
  12.127 -   */
  12.128 -  String
  12.129 -  dump (boolean mark)
  12.130 -  {
  12.131 -    int loop, idx;
  12.132 -    StringBuffer sb = new StringBuffer();
  12.133 -    Partition partition;
  12.134 -
  12.135 -    for (idx = 0; idx < partition_map.size(); idx++)
  12.136 -    {
  12.137 -      boolean xeno_partition = false;
  12.138 -
  12.139 -      partition = (Partition) partition_map.get(idx);
  12.140 -
  12.141 -      /* is this a xeno partition */
  12.142 -      if (mark)
  12.143 -      {
  12.144 -	for (loop = 0; loop < xeno_partition_list.size(); loop++)
  12.145 -	{
  12.146 -	  if (partition.identical((Partition)xeno_partition_list.get(loop)))
  12.147 -	  {
  12.148 -	    xeno_partition = true;
  12.149 -	    break;
  12.150 -	  }
  12.151 -	}
  12.152 -      }
  12.153 -
  12.154 -      if (idx == 0)
  12.155 -      {
  12.156 -	sb.append(" idx " + partition.dump(true) + "\n");
  12.157 -      }
  12.158 -      if (xeno_partition)
  12.159 -      {
  12.160 -	sb.append("[ ");
  12.161 -      }
  12.162 -      else
  12.163 -      {
  12.164 -	sb.append("  ");
  12.165 -      }
  12.166 -      sb.append(Library.format(idx,2,0) + " " + partition.dump(false));
  12.167 -      if (xeno_partition)
  12.168 -      {
  12.169 -	sb.append("]\n");
  12.170 -      }
  12.171 -      else
  12.172 -      {
  12.173 -	sb.append("\n");
  12.174 -      }
  12.175 -    }
  12.176 -
  12.177 -    return sb.toString();
  12.178 -  }
  12.179 -}
    13.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualBlockDevice.java	Mon Jul 07 14:24:01 2003 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,51 +0,0 @@
    13.4 -/*
    13.5 - * VirtualBlockDevice.java
    13.6 - * 03.03.27 aho creation
    13.7 - */
    13.8 -
    13.9 -package uk.ac.cam.cl.xeno.vdmanager;
   13.10 -
   13.11 -import java.io.PrintWriter;
   13.12 -
   13.13 -public class
   13.14 -VirtualBlockDevice
   13.15 -{
   13.16 -  String key;
   13.17 -  int domain;
   13.18 -  int vbdnum;
   13.19 -  Mode mode;                                                     /* rw or ro */
   13.20 -
   13.21 -  String
   13.22 -  dump (boolean title)
   13.23 -  {
   13.24 -    StringBuffer sb = new StringBuffer();
   13.25 -    int loop;
   13.26 -
   13.27 -    if (title)
   13.28 -    {
   13.29 -      sb.append("  key         dom vbd mode\n");
   13.30 -    }
   13.31 -    else
   13.32 -    {
   13.33 -      sb.append("  " + key + "  " +
   13.34 -		Library.format(domain,3,0) + " " + 
   13.35 -		Library.format(vbdnum,3,0) + " " + 
   13.36 -		mode.toString() + "\n");
   13.37 -    }
   13.38 -
   13.39 -    return sb.toString();
   13.40 -  }
   13.41 -
   13.42 -  void
   13.43 -  dump_xml (PrintWriter out)
   13.44 -  {
   13.45 -    out.println("  <virtual_block_device>");
   13.46 -    out.println("    <key>" + key + "</key>");
   13.47 -    out.println("    <domain>" + domain + "</domain>");
   13.48 -    out.println("    <vbdnum>" + vbdnum + "</vbdnum>");
   13.49 -    out.println("    <mode>" + mode + "</mode>");
   13.50 -    out.println("  </virtual_block_device>");
   13.51 -
   13.52 -    return;
   13.53 -  }
   13.54 -}
    14.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/VirtualDisk.java	Mon Jul 07 14:24:01 2003 +0000
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,227 +0,0 @@
    14.4 -/*
    14.5 - * VirtualDisk.java
    14.6 - * 03.03.26 aho creation
    14.7 - */
    14.8 -
    14.9 -package uk.ac.cam.cl.xeno.vdmanager;
   14.10 -
   14.11 -import java.util.Date;
   14.12 -import java.util.Vector;
   14.13 -import java.lang.Math;
   14.14 -import java.io.PrintWriter;
   14.15 -
   14.16 -public class
   14.17 -VirtualDisk
   14.18 -{
   14.19 -  String name;
   14.20 -  String key;
   14.21 -  Date   expiry;
   14.22 -  Vector extents;
   14.23 -
   14.24 -  VirtualDisk (String name, Date expiry, String key)
   14.25 -  {
   14.26 -    this.name = name;
   14.27 -    this.key = key;
   14.28 -    this.expiry = expiry;
   14.29 -    extents = new Vector();
   14.30 -  }
   14.31 -
   14.32 -  VirtualDisk (String name)
   14.33 -  {
   14.34 -    this (name, null, null);
   14.35 -    this.key = generate_key();
   14.36 -    extents = new Vector();
   14.37 -
   14.38 -    return;
   14.39 -  }
   14.40 -
   14.41 -  VirtualDisk (String name, Date expiry)
   14.42 -  {
   14.43 -    this(name, expiry, null);
   14.44 -    this.key = generate_key();
   14.45 -  }
   14.46 -
   14.47 -  /*
   14.48 -   * generate a unique key for this virtual disk.
   14.49 -   * for now, just generate a 10 digit number
   14.50 -   */
   14.51 -  String
   14.52 -  generate_key ()
   14.53 -  {
   14.54 -    return Long.toString(1000000000l + (long)(Math.random() * 8999999999l));
   14.55 -  }
   14.56 -
   14.57 -  String
   14.58 -  get_key ()
   14.59 -  {
   14.60 -    return key;
   14.61 -  }
   14.62 -
   14.63 -  Date
   14.64 -  get_expiry ()
   14.65 -  {
   14.66 -    return expiry;
   14.67 -  }
   14.68 -  
   14.69 -  void
   14.70 -  set_expiry (Date expiry)
   14.71 -  {
   14.72 -    this.expiry = expiry;
   14.73 -  }
   14.74 -
   14.75 -  public void
   14.76 -  add_extent (Extent extent)
   14.77 -  {
   14.78 -    extents.add(extent);
   14.79 -  }
   14.80 -
   14.81 -  public Extent
   14.82 -  remove_extent ()
   14.83 -  {
   14.84 -    Extent e;
   14.85 -
   14.86 -    if (extents.size() > 0)
   14.87 -    {
   14.88 -      e = (Extent) extents.remove(0);
   14.89 -    }
   14.90 -    else
   14.91 -    {
   14.92 -      e = null;
   14.93 -    }
   14.94 -
   14.95 -    return e;
   14.96 -  }
   14.97 -
   14.98 -  String
   14.99 -  dump (boolean details, boolean title)
  14.100 -  {
  14.101 -    StringBuffer sb = new StringBuffer();
  14.102 -    int loop;
  14.103 -
  14.104 -    if (details)
  14.105 -    {
  14.106 -      if (title)
  14.107 -      {
  14.108 -	sb.append("  name: " + name   + "\n");
  14.109 -	sb.append("   key: " + key    + "\n");
  14.110 -	sb.append("expiry: " + expiry + "\n");
  14.111 -	sb.append("\n");
  14.112 -      }
  14.113 -      sb.append("   idx  disk    offset      size \n");
  14.114 -      for (loop = 0; loop < extents.size(); loop++)
  14.115 -      {
  14.116 -	Extent e = (Extent) extents.get(loop);
  14.117 -	sb.append("  " + 
  14.118 -		  Library.format(loop,3,0) + " " +
  14.119 -		  Library.format(e.disk,6,0) +
  14.120 -		  Library.format(e.offset,10,0) +
  14.121 -		  Library.format(e.size,10,0) + "\n");
  14.122 -      }
  14.123 -    }
  14.124 -    else
  14.125 -    {
  14.126 -      if (title)
  14.127 -      {
  14.128 -	sb.append("  key         expiry                        name\n");
  14.129 -      }
  14.130 -      else
  14.131 -      {
  14.132 -	sb.append("  " + key + "  " + expiry.toString() + "  " + name + "\n");
  14.133 -      }
  14.134 -    }
  14.135 -
  14.136 -    return sb.toString();
  14.137 -  }
  14.138 -
  14.139 -  String
  14.140 -  dump_xen ()
  14.141 -  {
  14.142 -    StringBuffer sb = new StringBuffer();
  14.143 -
  14.144 -    sb.append("extents:" + extents.size() + " ");
  14.145 -    for (int loop = 0; loop < extents.size(); loop++)
  14.146 -    {
  14.147 -      Extent e = (Extent) extents.get(loop);
  14.148 -      sb.append("(disk:" + e.disk + " " +
  14.149 -		"offset:" + e.offset + " " +
  14.150 -		"size:" + e.size + ")");
  14.151 -    }
  14.152 -    return sb.toString();
  14.153 -  }
  14.154 -
  14.155 -  String
  14.156 -  dump_xen (VirtualBlockDevice vbd)
  14.157 -  {
  14.158 -    StringBuffer sb = new StringBuffer();
  14.159 -
  14.160 -    sb.append("domain:" + vbd.domain + " " +
  14.161 -	      vbd.mode.toString() + " " +
  14.162 -	      "segment:" + vbd.vbdnum + " " +
  14.163 -	      "extents:" + extents.size() + " ");
  14.164 -    for (int loop = 0; loop < extents.size(); loop++)
  14.165 -    {
  14.166 -      Extent e = (Extent) extents.get(loop);
  14.167 -      sb.append("(disk:" + e.disk + " " +
  14.168 -		"offset:" + e.offset + " " +
  14.169 -		"size:" + e.size + ")");
  14.170 -    }
  14.171 -    return sb.toString();
  14.172 -  }
  14.173 -
  14.174 -  void
  14.175 -  dump_xml (PrintWriter out)
  14.176 -  {
  14.177 -    out.println("  <virtual_disk>");
  14.178 -    out.println("    <name>" + name + "</name>");
  14.179 -    out.println("    <key>" + key + "</key>");
  14.180 -    if (expiry == null)
  14.181 -    {
  14.182 -      out.println("    <expiry>0</expiry>");
  14.183 -    }
  14.184 -    else
  14.185 -    {
  14.186 -      out.println("    <expiry>" + expiry.getTime() + "</expiry>");
  14.187 -    }
  14.188 -    out.println("    <extents>");
  14.189 -    for (int loop = 0; loop < extents.size(); loop++)
  14.190 -    {
  14.191 -      Extent e = (Extent) extents.get(loop);
  14.192 -      out.println("      <extent>");
  14.193 -      out.println("        <disk>" + e.disk + "</disk>");
  14.194 -      out.println("        <size>" + e.size + "</size>");
  14.195 -      out.println("        <offset>" + e.offset + "</offset>");
  14.196 -      out.println("      </extent>");
  14.197 -    }
  14.198 -    out.println("    </extents>");
  14.199 -    out.println("  </virtual_disk>");
  14.200 -
  14.201 -    return;
  14.202 -  }
  14.203 -
  14.204 -  /*
  14.205 -   * Add a partition as a XenoPartition.
  14.206 -   * Chop the partition in to extents and of size "size" sectors
  14.207 -   * and add them to the virtual disk.
  14.208 -   */
  14.209 -
  14.210 -  void
  14.211 -  add_new_partition (Partition partition, long size)
  14.212 -  {
  14.213 -    int loop;
  14.214 -
  14.215 -    for (loop = 0; loop < partition.nr_sects / size; loop++)
  14.216 -    {
  14.217 -      Extent extent = new Extent();
  14.218 -
  14.219 -      extent.disk = partition.major << 8;
  14.220 -      extent.disk = extent.disk | (partition.minor >> 5) << 5;
  14.221 -      extent.size = size;
  14.222 -      extent.offset = partition.start_sect + (size * loop);
  14.223 -
  14.224 -      add_extent(extent);
  14.225 -    }
  14.226 -    
  14.227 -    return;
  14.228 -  }
  14.229 -  
  14.230 -}
    15.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XML.java	Mon Jul 07 14:24:01 2003 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,126 +0,0 @@
    15.4 -/*
    15.5 - * XML.java
    15.6 - * 03.03.26 aho creation
    15.7 - */
    15.8 -
    15.9 -package uk.ac.cam.cl.xeno.vdmanager;
   15.10 -
   15.11 -import java.io.File;
   15.12 -import java.io.IOException;
   15.13 -import java.io.PrintWriter;
   15.14 -import java.io.FileWriter;
   15.15 -import java.io.BufferedWriter;
   15.16 -import java.io.FileNotFoundException;
   15.17 -import javax.xml.parsers.DocumentBuilder; 
   15.18 -import javax.xml.parsers.DocumentBuilderFactory; 
   15.19 -import javax.xml.parsers.FactoryConfigurationError; 
   15.20 -import javax.xml.parsers.ParserConfigurationException;
   15.21 -import org.w3c.dom.Document;
   15.22 -import org.w3c.dom.DOMException;
   15.23 -import org.w3c.dom.NodeList;
   15.24 -import org.xml.sax.SAXException; 
   15.25 -import org.xml.sax.SAXParseException;
   15.26 - 
   15.27 -public class
   15.28 -XML
   15.29 -{
   15.30 -  static Document document = null;
   15.31 -
   15.32 -  /*
   15.33 -   * dump partition manager and virtual disk manager state to filename
   15.34 -   */
   15.35 -
   15.36 -  static void
   15.37 -  dump_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
   15.38 -  {
   15.39 -    PrintWriter out;
   15.40 -
   15.41 -    try
   15.42 -    {
   15.43 -      out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
   15.44 -    }
   15.45 -    catch (IOException e)
   15.46 -    {
   15.47 -      System.err.println ("XML.dump_state error [" + filename + "]");
   15.48 -      System.err.println (e);
   15.49 -      return;
   15.50 -    }
   15.51 -
   15.52 -    out.println("<?xml version=\"1.0\"?>");
   15.53 -    out.println("<vdmanager>");
   15.54 -    pm.dump_xml(out);
   15.55 -    vdm.dump_xml(out);
   15.56 -    out.println("</vdmanager>");
   15.57 -
   15.58 -    out.close();
   15.59 -    return;
   15.60 -  }
   15.61 -
   15.62 -  /*
   15.63 -   * load partition manager and virtual disk manager state from filename
   15.64 -   */
   15.65 -  static void
   15.66 -  load_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
   15.67 -  {
   15.68 -    if (document == null)
   15.69 -    {
   15.70 -      load_file (filename);
   15.71 -    }
   15.72 -
   15.73 -    XMLHelper.parse(pm, vdm, document);
   15.74 -  }
   15.75 -
   15.76 -  /*
   15.77 -   * load XML from disk
   15.78 -   */
   15.79 -  static void
   15.80 -  load_file (String filename)
   15.81 -  {
   15.82 -    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   15.83 -    // factory.setNamespaceAware(true);
   15.84 -    // factory.setValidating(true);
   15.85 -
   15.86 -    try
   15.87 -    {
   15.88 -      File file = new File(filename);
   15.89 -
   15.90 -      DocumentBuilder builder = factory.newDocumentBuilder();
   15.91 -      document = builder.parse(file);
   15.92 -    }
   15.93 -    catch (SAXParseException spe)               /* error generated by parser */
   15.94 -    {
   15.95 -      System.err.println ("xml parser exception on line " + 
   15.96 -			  spe.getLineNumber() + 
   15.97 -			  " for uri " + spe.getSystemId());
   15.98 -      System.err.println (spe.getMessage());
   15.99 -
  15.100 -      Exception x = spe;
  15.101 -      if (spe.getException() != null)
  15.102 -	x = spe.getException();
  15.103 -      x.printStackTrace();
  15.104 -      System.exit(1);
  15.105 -    }
  15.106 -    catch (SAXException sxe)
  15.107 -    {
  15.108 -      Exception e = sxe;
  15.109 -      if (sxe.getException() != null)
  15.110 -	e = sxe.getException();
  15.111 -      e.printStackTrace();
  15.112 -      System.exit(1);
  15.113 -    }
  15.114 -    catch (ParserConfigurationException pce)
  15.115 -    {
  15.116 -      pce.printStackTrace();
  15.117 -    }
  15.118 -    catch (FileNotFoundException fnfe)
  15.119 -    {
  15.120 -      System.err.println ("warning: state file not found [" +
  15.121 -			  filename + "]");
  15.122 -    }
  15.123 -    catch (IOException ioe)
  15.124 -    {
  15.125 -      ioe.printStackTrace();
  15.126 -    }
  15.127 -    return;
  15.128 -  }
  15.129 -}
    16.1 --- a/tools/vdmanager/src/uk/ac/cam/cl/xeno/vdmanager/XMLHelper.java	Mon Jul 07 14:24:01 2003 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,205 +0,0 @@
    16.4 -/*
    16.5 - * XMLHelper.java
    16.6 - * 03.03.27 aho creation
    16.7 - */
    16.8 -
    16.9 -package uk.ac.cam.cl.xeno.vdmanager;
   16.10 -
   16.11 -import java.util.Date;
   16.12 -import org.w3c.dom.Document;
   16.13 -import org.w3c.dom.Element;
   16.14 -import org.w3c.dom.Node;
   16.15 -import org.w3c.dom.NodeList;
   16.16 -
   16.17 -public class
   16.18 -XMLHelper
   16.19 -{
   16.20 -  static void
   16.21 -  dump_document (Document document)
   16.22 -  {
   16.23 -    dump_element(document.getDocumentElement(), 0);
   16.24 -  }
   16.25 -
   16.26 -  static void
   16.27 -  dump_element (Element element, int indent)
   16.28 -  {
   16.29 -    NodeList nl = element.getChildNodes();
   16.30 -
   16.31 -    System.out.println ("<" + element.getTagName() + ">");
   16.32 -    dump_nodelist(nl, indent + 1);
   16.33 -    System.out.println("</" + element.getTagName() + ">");
   16.34 -  }
   16.35 -
   16.36 -  static void
   16.37 -  dump_nodelist (NodeList nl, int indent)
   16.38 -  {
   16.39 -    for (int loop = 0; loop < nl.getLength(); loop++)
   16.40 -    {
   16.41 -      Node node = nl.item(loop);
   16.42 -      switch (node.getNodeType())
   16.43 -      {
   16.44 -	case Node.ELEMENT_NODE : 
   16.45 -	{
   16.46 -	  dump_element((Element)node, indent);
   16.47 -	  break;
   16.48 -	}
   16.49 -	case Node.TEXT_NODE :
   16.50 -	{
   16.51 -	  System.out.println("TEXT: " + node.getNodeValue());
   16.52 -	  break;
   16.53 -	}
   16.54 -	default :
   16.55 -	{
   16.56 -	  System.out.println("NODE: " + node.getNodeType());
   16.57 -	}
   16.58 -      }
   16.59 -    }
   16.60 -  }
   16.61 -
   16.62 -  static Node 
   16.63 -  get_subnode (String name, Node node) 
   16.64 -  {
   16.65 -    if (node.getNodeType() != Node.ELEMENT_NODE) 
   16.66 -    {
   16.67 -      System.err.println("Error: Search node not of element type");
   16.68 -      return null;
   16.69 -    }
   16.70 -
   16.71 -    if (!node.hasChildNodes()) return null;
   16.72 -
   16.73 -    NodeList list = node.getChildNodes();
   16.74 -    for (int i=0; i < list.getLength(); i++) 
   16.75 -    {
   16.76 -      Node subnode = list.item(i);
   16.77 -      if (subnode.getNodeType() == Node.ELEMENT_NODE) 
   16.78 -      {
   16.79 -	if (subnode.getNodeName() == name) return subnode;
   16.80 -      }
   16.81 -    }
   16.82 -    return null;
   16.83 -  }
   16.84 -
   16.85 -  static String 
   16.86 -  get_text (Node node) 
   16.87 -  {
   16.88 -    StringBuffer result = new StringBuffer();
   16.89 -    if (node==null || !node.hasChildNodes()) return "";
   16.90 -
   16.91 -    NodeList list = node.getChildNodes();
   16.92 -    for (int i=0; i < list.getLength(); i++) 
   16.93 -    {
   16.94 -      Node subnode = list.item(i);
   16.95 -      if (subnode.getNodeType() == Node.TEXT_NODE) 
   16.96 -      {
   16.97 -	result.append(subnode.getNodeValue());
   16.98 -      }
   16.99 -    }
  16.100 -    return result.toString();
  16.101 -  }
  16.102 -
  16.103 -  static void
  16.104 -  parse (PartitionManager pm, VirtualDiskManager vdm, Document document)
  16.105 -  {
  16.106 -    if (document == null) return;
  16.107 -
  16.108 -    /* parse partitions */
  16.109 -    parse_partitions(pm, document.getElementsByTagName("partition"));
  16.110 -
  16.111 -    /* parse virtual disks */
  16.112 -    NodeList list = document.getElementsByTagName("virtual_disk");
  16.113 -    for (int i = 0; i < list.getLength(); i++)
  16.114 -    {
  16.115 -      Node subnode = list.item(i);
  16.116 -      String parent = subnode.getParentNode().getNodeName();
  16.117 -      VirtualDisk vd =  parse_virtual_disk(subnode);
  16.118 -
  16.119 -      if (parent.equals("free"))
  16.120 -      {
  16.121 -	vdm.add_free(vd);
  16.122 -      }
  16.123 -      else if (parent.equals("virtual_disks"))
  16.124 -      {
  16.125 -	vdm.add_virtual_disk(vd);
  16.126 -      }
  16.127 -      else
  16.128 -      {
  16.129 -	System.out.println ("XML parse error: unknown parent for virtual_disk "
  16.130 -			    + "[" + parent + "]");
  16.131 -      }
  16.132 -    }
  16.133 -
  16.134 -    /* parse virtual block devices */
  16.135 -    parse_virtual_block_devices(vdm, document.getElementsByTagName("virtual_block_device"));
  16.136 -
  16.137 -    return;
  16.138 -  }
  16.139 -
  16.140 -  static VirtualDisk
  16.141 -  parse_virtual_disk(Node node)
  16.142 -  {
  16.143 -    VirtualDisk vd;
  16.144 -    Date date = new Date();
  16.145 -    NodeList list;
  16.146 -
  16.147 -    date.setTime(Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("expiry", node))));
  16.148 -    vd = new VirtualDisk(XMLHelper.get_text(XMLHelper.get_subnode("name", node)),
  16.149 -			 date,
  16.150 -			 XMLHelper.get_text(XMLHelper.get_subnode("key", node)));
  16.151 -
  16.152 -    list = XMLHelper.get_subnode("extents", node).getChildNodes();
  16.153 -    for (int i = 0; i < list.getLength(); i++)
  16.154 -    {
  16.155 -      Node enode = list.item(i);
  16.156 -
  16.157 -      if (enode.getNodeType() == Node.ELEMENT_NODE &&
  16.158 -	  enode.getNodeName().equals("extent"))
  16.159 -      {
  16.160 -	Extent extent = new Extent();
  16.161 -
  16.162 -	extent.disk = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("disk", enode)));
  16.163 -	extent.size = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("size", enode)));
  16.164 -	extent.offset = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("offset", enode)));
  16.165 -	vd.add_extent(extent);
  16.166 -      }
  16.167 -    }
  16.168 -
  16.169 -    return vd;
  16.170 -  }
  16.171 -
  16.172 -  static void
  16.173 -  parse_partitions (PartitionManager pm, NodeList nl)
  16.174 -  {
  16.175 -    Partition partition;
  16.176 -
  16.177 -    for (int loop = 0; loop < nl.getLength(); loop++)
  16.178 -    {
  16.179 -      Node node = nl.item(loop);
  16.180 -
  16.181 -      partition = new Partition();
  16.182 -      partition.major = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("major", node)));
  16.183 -      partition.minor = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("minor", node)));
  16.184 -      partition.blocks = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("blocks", node)));
  16.185 -      partition.start_sect = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("start_sect", node)));
  16.186 -      partition.nr_sects = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("nr_sects", node)));
  16.187 -      partition.name = XMLHelper.get_text(XMLHelper.get_subnode("name", node));
  16.188 -
  16.189 -      pm.add_xeno_partition(partition);
  16.190 -    }
  16.191 -  }
  16.192 -
  16.193 -  static void
  16.194 -  parse_virtual_block_devices (VirtualDiskManager vdm, NodeList nl)
  16.195 -  {
  16.196 -    VirtualBlockDevice vbd;
  16.197 -
  16.198 -    for (int loop = 0; loop < nl.getLength(); loop++)
  16.199 -    {
  16.200 -      Node node = nl.item(loop);
  16.201 -
  16.202 -      vdm.create_virtual_block_device(XMLHelper.get_text(XMLHelper.get_subnode("key", node)),
  16.203 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("domain", node))),
  16.204 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("vbdnum", node))),
  16.205 -				      XMLHelper.get_text(XMLHelper.get_subnode("mode", node)));
  16.206 -    }
  16.207 -  }
  16.208 -}
    17.1 --- a/tools/vdmanager/vdmanager	Mon Jul 07 14:24:01 2003 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,16 +0,0 @@
    17.4 -#!/bin/sh
    17.5 -
    17.6 -# development only
    17.7 -export ANT_HOME=/anfs/scratch/boulderdash/ach61/jakarta-ant-1.5.1
    17.8 -export JAVA_HOME=/anfs/scratch/labyrinth/ach61/java-1.4.1
    17.9 -export PATH=${ANT_HOME}/bin:${JAVA_HOME}/bin:${PATH}
   17.10 -
   17.11 -# runtime
   17.12 -export JAVA_HOME=../jre-1.4.1
   17.13 -export PATH=${JAVA_HOME}/bin:${PATH}
   17.14 -if [ -f /var/lib/xen/vdstate.xml ]
   17.15 -then
   17.16 -  cp /var/lib/xen/vdstate.xml /var/lib/xen/vdstate.old.xml
   17.17 -fi
   17.18 -
   17.19 -java -jar vdmanager.jar $*