ia64/xen-unstable

changeset 500:dc332ee77380

bitkeeper revision 1.269.1.1 (3f056369hGuaG-n9I5TVNc_VCjsyXw)

Prune old VD stuff which has been ported
author rac61@labyrinth.cl.cam.ac.uk
date Fri Jul 04 11:22:17 2003 +0000 (2003-07-04)
parents 4b8ce663794b
children 9741cc1fa3e3
files .rootkeys tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/Mode.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/Partition.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/PartitionManager.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/XML.java tools/control/src/uk/ac/cam/cl/xeno/xenctl/XMLHelper.java
line diff
     1.1 --- a/.rootkeys	Fri Jul 04 11:21:03 2003 +0000
     1.2 +++ b/.rootkeys	Fri Jul 04 11:22:17 2003 +0000
     1.3 @@ -51,20 +51,13 @@ 3eb781fdmMkFbyb2SAGR0vsuFtl9Lw tools/con
     1.4  3eb781fdpgi83RpUvQWVccWjsDJK7w tools/control/src/org/xenoserver/control/StringPattern.java
     1.5  3ec41f7dUPpYTwYL5QVpRBv6PLKPrg tools/control/src/org/xenoserver/control/XML.java
     1.6  3ec41f7d7Try-2zmfnpaALwJjY0GCA tools/control/src/org/xenoserver/control/XMLHelper.java
     1.7 -3ec41f7csVaMDEEUMZBotpSftCy0rg tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java
     1.8 -3ec41f7cO5uUI4qZmJ29jsammoZP4Q tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java
     1.9  3ec41f7civcv4mQiYK0DeX9Zvsxhrw tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig
    1.10 -3ec41f7dOVcHj4xU3BFut_einNzj6A tools/control/src/uk/ac/cam/cl/xeno/xenctl/Mode.java
    1.11  3ec41f7d3-xTeoVJBJqWqxVfU-ANoQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java
    1.12 -3ec41f7dnnLe-6h-XWIvQVoP9oZu_A tools/control/src/uk/ac/cam/cl/xeno/xenctl/Partition.java
    1.13 -3ec41f7dD8h6MGxKTPtKzXPdGJS7bw tools/control/src/uk/ac/cam/cl/xeno/xenctl/PartitionManager.java
    1.14  3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/RootBean.java
    1.15  3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/uk/ac/cam/cl/xeno/xenctl/SystemConfigurationBean.java
    1.16  3ec41f7dlW5Buk3MO18HHtBax1Jz9g tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualBlockDevice.java
    1.17  3ec41f7dP3VglJUTuP45rwvSAoW_pg tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDisk.java
    1.18  3ec41f7d8_ZsS9JjYQq861OFAZS9GA tools/control/src/uk/ac/cam/cl/xeno/xenctl/VirtualDiskManager.java
    1.19 -3ec41f7dSJieScU3uvPMGXk-8NgHvA tools/control/src/uk/ac/cam/cl/xeno/xenctl/XML.java
    1.20 -3ec41f7dGO96BS8-6FWGDjCxjncOGg tools/control/src/uk/ac/cam/cl/xeno/xenctl/XMLHelper.java
    1.21  3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml
    1.22  3ec41f7dRAPXBA0jQUd1k6MB3xVidg tools/control/web/img/cambridge.gif
    1.23  3ec41f7dvxVe1Vb3kVOLZcN5Jra2tQ tools/control/web/img/help.gif
     2.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java	Fri Jul 04 11:21:03 2003 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,32 +0,0 @@
     2.4 -/*
     2.5 - * Extent.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 -public class
    2.12 -Extent
    2.13 -{
    2.14 -  int disk;
    2.15 -  long offset;                                           /* offset into disk */
    2.16 -  long size;                      /* size of this extent in 512 byte sectors */
    2.17 -
    2.18 -  public int
    2.19 -  getDisk()
    2.20 -  {
    2.21 -    return disk;
    2.22 -  }
    2.23 -
    2.24 -  public long
    2.25 -  getOffset()
    2.26 -  {
    2.27 -    return offset;
    2.28 -  }
    2.29 -
    2.30 -  public long
    2.31 -  getSize()
    2.32 -  {
    2.33 -    return size;
    2.34 -  }
    2.35 -}
     3.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java	Fri Jul 04 11:21:03 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,129 +0,0 @@
     3.4 -/*
     3.5 - * Library.java
     3.6 - * 03.03.28 aho creation
     3.7 - */
     3.8 -
     3.9 -package uk.ac.cam.cl.xeno.xenctl;
    3.10 -
    3.11 -public class
    3.12 -Library
    3.13 -{
    3.14 -  /*
    3.15 -   * convert a number to a fixed width string
    3.16 -   */
    3.17 -  static String
    3.18 -  format (long input, int width, int prefix)
    3.19 -  {
    3.20 -    String sss = Long.toString(input);
    3.21 -    String space = "                                ";
    3.22 -
    3.23 -    if (width < sss.length())
    3.24 -    {
    3.25 -      width = sss.length();
    3.26 -    }
    3.27 -
    3.28 -    if (prefix == 0)
    3.29 -    {
    3.30 -      return space.substring(0, width - sss.length()) + sss;
    3.31 -    }
    3.32 -    else
    3.33 -    {
    3.34 -      return sss + space.substring(0, width - sss.length());
    3.35 -    }
    3.36 -  }
    3.37 -
    3.38 -  /*
    3.39 -   * convert a string to a fixed width string
    3.40 -   */
    3.41 -  static String
    3.42 -  format (String input, int width, int prefix)
    3.43 -  {
    3.44 -    String space = "                                ";
    3.45 -
    3.46 -    if (width < input.length())
    3.47 -    {
    3.48 -      width = input.length();
    3.49 -    }
    3.50 -
    3.51 -    if (prefix == 0)
    3.52 -    {
    3.53 -      return space.substring(0, width - input.length()) + input;
    3.54 -    }
    3.55 -    else
    3.56 -    {
    3.57 -      return input + space.substring(0, width - input.length());
    3.58 -    }
    3.59 -  }
    3.60 -
    3.61 -  /*
    3.62 -   * convert a number (string format) into 
    3.63 -   * the corresponding integer value.
    3.64 -   */
    3.65 -  static long
    3.66 -  parse_size(String size)
    3.67 -  {
    3.68 -    String substring = size;
    3.69 -    int    suffix = 1;
    3.70 -    long   value = 0;
    3.71 -
    3.72 -    if (size == null)
    3.73 -    {
    3.74 -      return 0;
    3.75 -    }
    3.76 -
    3.77 -    if ((substring = check(size, 'm')) != null)
    3.78 -    {
    3.79 -      suffix = 1024 * 1024;
    3.80 -    }
    3.81 -    else if ((substring = check(size, 'M')) != null)
    3.82 -    {
    3.83 -      suffix = 1024 * 1024;
    3.84 -    }
    3.85 -    else if ((substring = check(size, 'k')) != null)
    3.86 -    {
    3.87 -      suffix = 1024;
    3.88 -    }
    3.89 -    else if ((substring = check(size, 'K')) != null)
    3.90 -    {
    3.91 -      suffix = 1024;
    3.92 -    }
    3.93 -    else if ((substring = check(size, 'g')) != null)
    3.94 -    {
    3.95 -      suffix = 1024 * 1024 * 1024;
    3.96 -    }
    3.97 -    else if ((substring = check(size, 'G')) != null)
    3.98 -    {
    3.99 -      suffix = 1024 * 1024 * 1024;
   3.100 -    }
   3.101 -    else
   3.102 -    {
   3.103 -      substring = size;
   3.104 -    }
   3.105 -
   3.106 -    try
   3.107 -    {
   3.108 -      value = Long.decode(substring).longValue() * suffix;
   3.109 -    }
   3.110 -    catch (NumberFormatException e)
   3.111 -    {
   3.112 -      value = 0;
   3.113 -    }
   3.114 -
   3.115 -    return value;
   3.116 -  }
   3.117 -
   3.118 -  static String
   3.119 -  check(String size, char suffix)
   3.120 -  {
   3.121 -    int index = size.indexOf(suffix);
   3.122 -
   3.123 -    if (index != -1)
   3.124 -    {
   3.125 -      return size.substring(0, index);
   3.126 -    }
   3.127 -    else
   3.128 -    {
   3.129 -      return null;
   3.130 -    }
   3.131 -  }
   3.132 -}
     4.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Mode.java	Fri Jul 04 11:21:03 2003 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,22 +0,0 @@
     4.4 -/*
     4.5 - * Mode.java
     4.6 - * 03.03.27 aho creation
     4.7 - *
     4.8 - * until we have jdk1.5, we're left with this mess...
     4.9 - */
    4.10 -
    4.11 -package uk.ac.cam.cl.xeno.xenctl;
    4.12 -
    4.13 -public class 
    4.14 -Mode 
    4.15 -{
    4.16 -  private final String name;
    4.17 -
    4.18 -  private Mode(String name) { this.name = name; }
    4.19 -
    4.20 -  public String toString()  { return name; }
    4.21 -
    4.22 -  public static final Mode READ_ONLY  = new Mode("ro");
    4.23 -  public static final Mode READ_WRITE = new Mode("rw");
    4.24 -}
    4.25 -
     5.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Partition.java	Fri Jul 04 11:21:03 2003 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,125 +0,0 @@
     5.4 -/*
     5.5 - * Partition.java
     5.6 - * 03.03.26 aho creation
     5.7 - */
     5.8 -
     5.9 -package uk.ac.cam.cl.xeno.xenctl;
    5.10 -
    5.11 -import java.io.*;
    5.12 -
    5.13 -public class
    5.14 -Partition
    5.15 -{
    5.16 -  int major;
    5.17 -  int minor;
    5.18 -  long blocks;
    5.19 -  long start_sect;
    5.20 -  long nr_sects;
    5.21 -  String name;
    5.22 -  boolean xeno;
    5.23 -
    5.24 -  boolean 
    5.25 -  identical (Partition p)
    5.26 -  {
    5.27 -    return (major == p.major &&
    5.28 -	    minor == p.minor &&
    5.29 -	    blocks == p.blocks &&
    5.30 -	    start_sect == p.start_sect &&
    5.31 -	    nr_sects == p.nr_sects &&
    5.32 -	    name.equals(p.name));
    5.33 -  }
    5.34 -
    5.35 -  Partition
    5.36 -  duplicate ()
    5.37 -  {
    5.38 -    Partition p = new Partition();
    5.39 -
    5.40 -    p.major = major;
    5.41 -    p.minor = minor;
    5.42 -    p.blocks = blocks;
    5.43 -    p.start_sect = start_sect;
    5.44 -    p.nr_sects = nr_sects;
    5.45 -    p.name = name;
    5.46 -    p.xeno = xeno;
    5.47 -
    5.48 -    return p;
    5.49 -  }
    5.50 -
    5.51 -  String 
    5.52 -  dump (boolean title)
    5.53 -  {
    5.54 -    if (title)
    5.55 -    {
    5.56 -      return ("maj:min " + 
    5.57 -	      "    blocks " +
    5.58 -	      "start sect " +
    5.59 -	      " num sects " +
    5.60 -	      "name");
    5.61 -    }
    5.62 -    else
    5.63 -    {
    5.64 -      return (Library.format(major,3,0) + ":" + 
    5.65 -	      Library.format(minor,3,1) + " " +
    5.66 -	      Library.format(blocks,10,0) + " " +
    5.67 -	      Library.format(start_sect,10,0) + " " +
    5.68 -	      Library.format(nr_sects,10,0) + " " +
    5.69 -	      Library.format(name,7,1));
    5.70 -    }
    5.71 -  }
    5.72 -
    5.73 -  void
    5.74 -  dump_xml(PrintWriter out)
    5.75 -  {
    5.76 -    out.println ("  <partition>\n" +
    5.77 -		 "    <major>" + major + "</major>\n" +
    5.78 -		 "    <minor>" + minor + "</minor>\n" +
    5.79 -		 "    <blocks>" + blocks + "</blocks>\n" +
    5.80 -		 "    <start_sect>" + start_sect + "</start_sect>\n" +
    5.81 -		 "    <nr_sects>" + nr_sects + "</nr_sects>\n" +
    5.82 -		 "    <name>" + name + "</name>\n" +
    5.83 -		 "  </partition>");
    5.84 -  }
    5.85 -
    5.86 -  public int
    5.87 -  getMajor()
    5.88 -  {
    5.89 -    return major;
    5.90 -  }
    5.91 -
    5.92 -  public int
    5.93 -  getMinor()
    5.94 -  {
    5.95 -    return minor;
    5.96 -  }
    5.97 -
    5.98 -  public long
    5.99 -  getBlocks()
   5.100 -  {
   5.101 -    return blocks;
   5.102 -  }
   5.103 -  
   5.104 -  public long
   5.105 -  getStartSect()
   5.106 -  {
   5.107 -    return start_sect;
   5.108 -  }
   5.109 -
   5.110 -  public long
   5.111 -  getNumSects()
   5.112 -  {
   5.113 -    return nr_sects;
   5.114 -  }
   5.115 -  
   5.116 -  public String
   5.117 -  getName()
   5.118 -  {
   5.119 -    return name;
   5.120 -  }
   5.121 -
   5.122 -  public boolean
   5.123 -  getIsXeno()
   5.124 -  {
   5.125 -    return xeno;
   5.126 -  }
   5.127 -
   5.128 -}
     6.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/PartitionManager.java	Fri Jul 04 11:21:03 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,191 +0,0 @@
     6.4 -/*
     6.5 - * PartitionManager.java
     6.6 - * 03.03.26 aho creation
     6.7 - */
     6.8 -
     6.9 -package uk.ac.cam.cl.xeno.xenctl;
    6.10 -
    6.11 -import java.io.*;
    6.12 -import java.util.Vector;
    6.13 -import java.util.Enumeration;
    6.14 -
    6.15 -public class
    6.16 -PartitionManager
    6.17 -{
    6.18 -  Vector partition_map;
    6.19 -
    6.20 -  static String proc_template =
    6.21 -    "major minor  #blocks  start_sect   nr_sects name";
    6.22 -
    6.23 -  /*
    6.24 -   * Initialize partition manager with source file.
    6.25 -   * Normally we read from /proc/partitions, but we can
    6.26 -   * specify an alternative file for debugging
    6.27 -   */
    6.28 -  PartitionManager (String filename)
    6.29 -  {
    6.30 -    String str;
    6.31 -    BufferedReader in;
    6.32 -
    6.33 -    partition_map = new Vector(100,10);
    6.34 -
    6.35 -    try
    6.36 -    {
    6.37 -      in = new BufferedReader(new FileReader(filename));
    6.38 -
    6.39 -      str = in.readLine();                                  /* skip headings */
    6.40 -      if (str.length() < proc_template.length() ||
    6.41 -	  !str.substring(0, proc_template.length()).equals(proc_template))
    6.42 -      {
    6.43 -	System.err.println ("Error: Incorrect /proc/partitions.");
    6.44 -	System.err.println ("       Is this Xeno?");
    6.45 -	System.exit (1);
    6.46 -      }
    6.47 -
    6.48 -      str = in.readLine();                                /* skip blank line */
    6.49 -
    6.50 -      str = in.readLine();
    6.51 -      while (str != null)
    6.52 -      {
    6.53 -	Partition partition = new Partition();
    6.54 -
    6.55 -	partition.major = Integer.parseInt(str.substring(0,5).trim());
    6.56 -	partition.minor = Integer.parseInt(str.substring(5,10).trim());
    6.57 -	partition.blocks = Integer.parseInt(str.substring(10,21).trim());
    6.58 -	partition.start_sect = Integer.parseInt(str.substring(21,32).trim());
    6.59 -	partition.nr_sects = Integer.parseInt(str.substring(32,43).trim());
    6.60 -	partition.name = str.substring(43).trim();
    6.61 -	partition.xeno = false;
    6.62 -
    6.63 -	partition_map.add(partition);
    6.64 -	str = in.readLine();
    6.65 -      }
    6.66 -    }
    6.67 -    catch (IOException io)
    6.68 -    {
    6.69 -      System.err.println ("PartitionManager: error reading partition file [" 
    6.70 -			  + filename + "]");
    6.71 -      System.err.println (io);
    6.72 -    }
    6.73 -  }
    6.74 -
    6.75 -  Partition
    6.76 -  get_partition (String name)
    6.77 -  {
    6.78 -    Partition partition = null;
    6.79 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
    6.80 -    {
    6.81 -      partition = (Partition) e.nextElement();
    6.82 -      if (partition.name.equals(name))
    6.83 -      {
    6.84 -	return partition;
    6.85 -      }
    6.86 -    }
    6.87 -    return null;
    6.88 -  }
    6.89 -
    6.90 -  Partition
    6.91 -  get_partition (int index)
    6.92 -  {
    6.93 -    return (Partition) partition_map.get(index);
    6.94 -  }
    6.95 -
    6.96 -  void
    6.97 -  add_xeno_partition (Partition p)
    6.98 -  {
    6.99 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
   6.100 -    {
   6.101 -      Partition partition = (Partition) e.nextElement();
   6.102 -      if (partition.identical(p))
   6.103 -      {
   6.104 -	partition.xeno = true;
   6.105 -      }
   6.106 -    }
   6.107 -  }
   6.108 -
   6.109 -  /*
   6.110 -   * dump the xeno partition list as xml
   6.111 -   */
   6.112 -  void
   6.113 -  dump_xml (PrintWriter out)
   6.114 -  {
   6.115 -    int loop;
   6.116 -
   6.117 -    out.println("<partitions>");
   6.118 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
   6.119 -    {
   6.120 -      Partition partition = (Partition) e.nextElement();
   6.121 -      if (partition.xeno == true)
   6.122 -      {
   6.123 -	partition.dump_xml(out);
   6.124 -      }
   6.125 -    }
   6.126 -
   6.127 -    out.println("</partitions>");
   6.128 -
   6.129 -    return;
   6.130 -  }
   6.131 -
   6.132 -  /*
   6.133 -   * dump the partition map as a string
   6.134 -   * mark: mark the current xeno partitions in the partition map
   6.135 -   */
   6.136 -  String
   6.137 -  dump (boolean mark)
   6.138 -  {
   6.139 -    int loop, idx;
   6.140 -    StringBuffer sb = new StringBuffer();
   6.141 -    Partition partition;
   6.142 -
   6.143 -    for (idx = 0; idx < partition_map.size(); idx++)
   6.144 -    {
   6.145 -      partition = (Partition) partition_map.get(idx);
   6.146 -
   6.147 -      if (idx == 0)
   6.148 -      {
   6.149 -	sb.append(" idx " + partition.dump(true) + "\n");
   6.150 -      }
   6.151 -      if (partition.xeno)
   6.152 -      {
   6.153 -	sb.append("[ ");
   6.154 -      }
   6.155 -      else
   6.156 -      {
   6.157 -	sb.append("  ");
   6.158 -      }
   6.159 -      sb.append(Library.format(idx,2,0) + " " + partition.dump(false));
   6.160 -      if (partition.xeno)
   6.161 -      {
   6.162 -	sb.append("]\n");
   6.163 -      }
   6.164 -      else
   6.165 -      {
   6.166 -	sb.append("\n");
   6.167 -      }
   6.168 -    }
   6.169 -
   6.170 -    return sb.toString();
   6.171 -  }
   6.172 -
   6.173 -  /**
   6.174 -   * get the number of partitions 
   6.175 -   */
   6.176 -
   6.177 -  int
   6.178 -  getPartitionCount ()
   6.179 -  {
   6.180 -    return partition_map.size();
   6.181 -  }
   6.182 -
   6.183 -  /**
   6.184 -   * get the details about a particular partition
   6.185 -   *
   6.186 -   */
   6.187 -  Partition
   6.188 -  getPartition (int index)
   6.189 -  {
   6.190 -    Partition partition = (Partition) partition_map.get(index);
   6.191 -    return partition;
   6.192 -  }
   6.193 -
   6.194 -}
     7.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/XML.java	Fri Jul 04 11:21:03 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,126 +0,0 @@
     7.4 -/*
     7.5 - * XML.java
     7.6 - * 03.03.26 aho creation
     7.7 - */
     7.8 -
     7.9 -package uk.ac.cam.cl.xeno.xenctl;
    7.10 -
    7.11 -import java.io.File;
    7.12 -import java.io.IOException;
    7.13 -import java.io.PrintWriter;
    7.14 -import java.io.FileWriter;
    7.15 -import java.io.BufferedWriter;
    7.16 -import java.io.FileNotFoundException;
    7.17 -import javax.xml.parsers.DocumentBuilder; 
    7.18 -import javax.xml.parsers.DocumentBuilderFactory; 
    7.19 -import javax.xml.parsers.FactoryConfigurationError; 
    7.20 -import javax.xml.parsers.ParserConfigurationException;
    7.21 -import org.w3c.dom.Document;
    7.22 -import org.w3c.dom.DOMException;
    7.23 -import org.w3c.dom.NodeList;
    7.24 -import org.xml.sax.SAXException; 
    7.25 -import org.xml.sax.SAXParseException;
    7.26 - 
    7.27 -public class
    7.28 -XML
    7.29 -{
    7.30 -  static Document document = null;
    7.31 -
    7.32 -  /*
    7.33 -   * dump partition manager and virtual disk manager state to filename
    7.34 -   */
    7.35 -
    7.36 -  static void
    7.37 -  dump_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
    7.38 -  {
    7.39 -    PrintWriter out;
    7.40 -
    7.41 -    try
    7.42 -    {
    7.43 -      out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
    7.44 -    }
    7.45 -    catch (IOException e)
    7.46 -    {
    7.47 -      System.err.println ("XML.dump_state error [" + filename + "]");
    7.48 -      System.err.println (e);
    7.49 -      return;
    7.50 -    }
    7.51 -
    7.52 -    out.println("<?xml version=\"1.0\"?>");
    7.53 -    out.println("<vdmanager>");
    7.54 -    pm.dump_xml(out);
    7.55 -    vdm.dump_xml(out);
    7.56 -    out.println("</vdmanager>");
    7.57 -
    7.58 -    out.close();
    7.59 -    return;
    7.60 -  }
    7.61 -
    7.62 -  /*
    7.63 -   * load partition manager and virtual disk manager state from filename
    7.64 -   */
    7.65 -  static void
    7.66 -  load_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
    7.67 -  {
    7.68 -    if (document == null)
    7.69 -    {
    7.70 -      load_file (filename);
    7.71 -    }
    7.72 -
    7.73 -    XMLHelper.parse(pm, vdm, document);
    7.74 -  }
    7.75 -
    7.76 -  /*
    7.77 -   * load XML from disk
    7.78 -   */
    7.79 -  static void
    7.80 -  load_file (String filename)
    7.81 -  {
    7.82 -    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    7.83 -    // factory.setNamespaceAware(true);
    7.84 -    // factory.setValidating(true);
    7.85 -
    7.86 -    try
    7.87 -    {
    7.88 -      File file = new File(filename);
    7.89 -
    7.90 -      DocumentBuilder builder = factory.newDocumentBuilder();
    7.91 -      document = builder.parse(file);
    7.92 -    }
    7.93 -    catch (SAXParseException spe)               /* error generated by parser */
    7.94 -    {
    7.95 -      System.err.println ("xml parser exception on line " + 
    7.96 -			  spe.getLineNumber() + 
    7.97 -			  " for uri " + spe.getSystemId());
    7.98 -      System.err.println (spe.getMessage());
    7.99 -
   7.100 -      Exception x = spe;
   7.101 -      if (spe.getException() != null)
   7.102 -	x = spe.getException();
   7.103 -      x.printStackTrace();
   7.104 -      System.exit(1);
   7.105 -    }
   7.106 -    catch (SAXException sxe)
   7.107 -    {
   7.108 -      Exception e = sxe;
   7.109 -      if (sxe.getException() != null)
   7.110 -	e = sxe.getException();
   7.111 -      e.printStackTrace();
   7.112 -      System.exit(1);
   7.113 -    }
   7.114 -    catch (ParserConfigurationException pce)
   7.115 -    {
   7.116 -      pce.printStackTrace();
   7.117 -    }
   7.118 -    catch (FileNotFoundException fnfe)
   7.119 -    {
   7.120 -      System.err.println ("warning: state file not found [" +
   7.121 -			  filename + "]");
   7.122 -    }
   7.123 -    catch (IOException ioe)
   7.124 -    {
   7.125 -      ioe.printStackTrace();
   7.126 -    }
   7.127 -    return;
   7.128 -  }
   7.129 -}
     8.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/XMLHelper.java	Fri Jul 04 11:21:03 2003 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,205 +0,0 @@
     8.4 -/*
     8.5 - * XMLHelper.java
     8.6 - * 03.03.27 aho creation
     8.7 - */
     8.8 -
     8.9 -package uk.ac.cam.cl.xeno.xenctl;
    8.10 -
    8.11 -import java.util.Date;
    8.12 -import org.w3c.dom.Document;
    8.13 -import org.w3c.dom.Element;
    8.14 -import org.w3c.dom.Node;
    8.15 -import org.w3c.dom.NodeList;
    8.16 -
    8.17 -public class
    8.18 -XMLHelper
    8.19 -{
    8.20 -  static void
    8.21 -  dump_document (Document document)
    8.22 -  {
    8.23 -    dump_element(document.getDocumentElement(), 0);
    8.24 -  }
    8.25 -
    8.26 -  static void
    8.27 -  dump_element (Element element, int indent)
    8.28 -  {
    8.29 -    NodeList nl = element.getChildNodes();
    8.30 -
    8.31 -    System.out.println ("<" + element.getTagName() + ">");
    8.32 -    dump_nodelist(nl, indent + 1);
    8.33 -    System.out.println("</" + element.getTagName() + ">");
    8.34 -  }
    8.35 -
    8.36 -  static void
    8.37 -  dump_nodelist (NodeList nl, int indent)
    8.38 -  {
    8.39 -    for (int loop = 0; loop < nl.getLength(); loop++)
    8.40 -    {
    8.41 -      Node node = nl.item(loop);
    8.42 -      switch (node.getNodeType())
    8.43 -      {
    8.44 -	case Node.ELEMENT_NODE : 
    8.45 -	{
    8.46 -	  dump_element((Element)node, indent);
    8.47 -	  break;
    8.48 -	}
    8.49 -	case Node.TEXT_NODE :
    8.50 -	{
    8.51 -	  System.out.println("TEXT: " + node.getNodeValue());
    8.52 -	  break;
    8.53 -	}
    8.54 -	default :
    8.55 -	{
    8.56 -	  System.out.println("NODE: " + node.getNodeType());
    8.57 -	}
    8.58 -      }
    8.59 -    }
    8.60 -  }
    8.61 -
    8.62 -  static Node 
    8.63 -  get_subnode (String name, Node node) 
    8.64 -  {
    8.65 -    if (node.getNodeType() != Node.ELEMENT_NODE) 
    8.66 -    {
    8.67 -      System.err.println("Error: Search node not of element type");
    8.68 -      return null;
    8.69 -    }
    8.70 -
    8.71 -    if (!node.hasChildNodes()) return null;
    8.72 -
    8.73 -    NodeList list = node.getChildNodes();
    8.74 -    for (int i=0; i < list.getLength(); i++) 
    8.75 -    {
    8.76 -      Node subnode = list.item(i);
    8.77 -      if (subnode.getNodeType() == Node.ELEMENT_NODE) 
    8.78 -      {
    8.79 -	if (subnode.getNodeName() == name) return subnode;
    8.80 -      }
    8.81 -    }
    8.82 -    return null;
    8.83 -  }
    8.84 -
    8.85 -  static String 
    8.86 -  get_text (Node node) 
    8.87 -  {
    8.88 -    StringBuffer result = new StringBuffer();
    8.89 -    if (node==null || !node.hasChildNodes()) return "";
    8.90 -
    8.91 -    NodeList list = node.getChildNodes();
    8.92 -    for (int i=0; i < list.getLength(); i++) 
    8.93 -    {
    8.94 -      Node subnode = list.item(i);
    8.95 -      if (subnode.getNodeType() == Node.TEXT_NODE) 
    8.96 -      {
    8.97 -	result.append(subnode.getNodeValue());
    8.98 -      }
    8.99 -    }
   8.100 -    return result.toString();
   8.101 -  }
   8.102 -
   8.103 -  static void
   8.104 -  parse (PartitionManager pm, VirtualDiskManager vdm, Document document)
   8.105 -  {
   8.106 -    if (document == null) return;
   8.107 -
   8.108 -    /* parse partitions */
   8.109 -    parse_partitions(pm, document.getElementsByTagName("partition"));
   8.110 -
   8.111 -    /* parse virtual disks */
   8.112 -    NodeList list = document.getElementsByTagName("virtual_disk");
   8.113 -    for (int i = 0; i < list.getLength(); i++)
   8.114 -    {
   8.115 -      Node subnode = list.item(i);
   8.116 -      String parent = subnode.getParentNode().getNodeName();
   8.117 -      VirtualDisk vd =  parse_virtual_disk(subnode);
   8.118 -
   8.119 -      if (parent.equals("free"))
   8.120 -      {
   8.121 -	vdm.add_free(vd);
   8.122 -      }
   8.123 -      else if (parent.equals("virtual_disks"))
   8.124 -      {
   8.125 -	vdm.add_virtual_disk(vd);
   8.126 -      }
   8.127 -      else
   8.128 -      {
   8.129 -	System.out.println ("XML parse error: unknown parent for virtual_disk "
   8.130 -			    + "[" + parent + "]");
   8.131 -      }
   8.132 -    }
   8.133 -
   8.134 -    /* parse virtual block devices */
   8.135 -    parse_virtual_block_devices(vdm, document.getElementsByTagName("virtual_block_device"));
   8.136 -
   8.137 -    return;
   8.138 -  }
   8.139 -
   8.140 -  static VirtualDisk
   8.141 -  parse_virtual_disk(Node node)
   8.142 -  {
   8.143 -    VirtualDisk vd;
   8.144 -    Date date = new Date();
   8.145 -    NodeList list;
   8.146 -
   8.147 -    date.setTime(Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("expiry", node))));
   8.148 -    vd = new VirtualDisk(XMLHelper.get_text(XMLHelper.get_subnode("name", node)),
   8.149 -			 date,
   8.150 -			 XMLHelper.get_text(XMLHelper.get_subnode("key", node)));
   8.151 -
   8.152 -    list = XMLHelper.get_subnode("extents", node).getChildNodes();
   8.153 -    for (int i = 0; i < list.getLength(); i++)
   8.154 -    {
   8.155 -      Node enode = list.item(i);
   8.156 -
   8.157 -      if (enode.getNodeType() == Node.ELEMENT_NODE &&
   8.158 -	  enode.getNodeName().equals("extent"))
   8.159 -      {
   8.160 -	Extent extent = new Extent();
   8.161 -
   8.162 -	extent.disk = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("disk", enode)));
   8.163 -	extent.size = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("size", enode)));
   8.164 -	extent.offset = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("offset", enode)));
   8.165 -	vd.add_extent(extent);
   8.166 -      }
   8.167 -    }
   8.168 -
   8.169 -    return vd;
   8.170 -  }
   8.171 -
   8.172 -  static void
   8.173 -  parse_partitions (PartitionManager pm, NodeList nl)
   8.174 -  {
   8.175 -    Partition partition;
   8.176 -
   8.177 -    for (int loop = 0; loop < nl.getLength(); loop++)
   8.178 -    {
   8.179 -      Node node = nl.item(loop);
   8.180 -
   8.181 -      partition = new Partition();
   8.182 -      partition.major = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("major", node)));
   8.183 -      partition.minor = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("minor", node)));
   8.184 -      partition.blocks = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("blocks", node)));
   8.185 -      partition.start_sect = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("start_sect", node)));
   8.186 -      partition.nr_sects = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("nr_sects", node)));
   8.187 -      partition.name = XMLHelper.get_text(XMLHelper.get_subnode("name", node));
   8.188 -
   8.189 -      pm.add_xeno_partition(partition);
   8.190 -    }
   8.191 -  }
   8.192 -
   8.193 -  static void
   8.194 -  parse_virtual_block_devices (VirtualDiskManager vdm, NodeList nl)
   8.195 -  {
   8.196 -    VirtualBlockDevice vbd;
   8.197 -
   8.198 -    for (int loop = 0; loop < nl.getLength(); loop++)
   8.199 -    {
   8.200 -      Node node = nl.item(loop);
   8.201 -
   8.202 -      vdm.create_virtual_block_device(XMLHelper.get_text(XMLHelper.get_subnode("key", node)),
   8.203 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("domain", node))),
   8.204 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("vbdnum", node))),
   8.205 -				      XMLHelper.get_text(XMLHelper.get_subnode("mode", node)));
   8.206 -    }
   8.207 -  }
   8.208 -}