ia64/xen-unstable

changeset 502:bb7333faba06

bitkeeper revision 1.271 (3f056397PcaG7S5EhqWlJo04hQMtfA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/rac61/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/sos22/xeno.bk
author sos22@labyrinth.cl.cam.ac.uk
date Fri Jul 04 11:23:03 2003 +0000 (2003-07-04)
parents f18ad5c14d58 9741cc1fa3e3
children 6be2874c3f07
files .rootkeys BitKeeper/etc/ignore 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:22:06 2003 +0000
     1.2 +++ b/.rootkeys	Fri Jul 04 11:23:03 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/BitKeeper/etc/ignore	Fri Jul 04 11:22:06 2003 +0000
     2.2 +++ b/BitKeeper/etc/ignore	Fri Jul 04 11:23:03 2003 +0000
     2.3 @@ -232,6 +232,12 @@ tools/internal/xi_create
     2.4  tools/internal/xi_create.o
     2.5  tools/internal/xi_destroy
     2.6  tools/internal/xi_destroy.o
     2.7 +tools/internal/xi_phys_grant
     2.8 +tools/internal/xi_phys_grant.o
     2.9 +tools/internal/xi_phys_probe
    2.10 +tools/internal/xi_phys_probe.o
    2.11 +tools/internal/xi_phys_revoke
    2.12 +tools/internal/xi_phys_revoke.o
    2.13  tools/internal/xi_start
    2.14  tools/internal/xi_start.o
    2.15  tools/internal/xi_stop
    2.16 @@ -408,6 +414,7 @@ xen/include/asm
    2.17  xen/include/hypervisor-ifs/hypervisor-ifs
    2.18  xen/include/linux
    2.19  xen/include/xeno/compile.h
    2.20 +xen/include/xeno/physdisk.h~
    2.21  xen/net/dev.o
    2.22  xen/net/dev_mcast.o
    2.23  xen/net/devinit.o
    2.24 @@ -419,4 +426,3 @@ xen/tools/figlet/figlet
    2.25  xenolinux-2.4.16-sparse/arch/xeno/drivers/block/Makefile.orig
    2.26  xenolinux-2.4.16-sparse/arch/xeno/drivers/block/block.c.orig
    2.27  xenolinux-2.4.16-sparse/scripts/kconfig.tk
    2.28 -xen/include/xeno/physdisk.h~
     3.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java	Fri Jul 04 11:22:06 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,32 +0,0 @@
     3.4 -/*
     3.5 - * Extent.java
     3.6 - * 03.03.26 aho creation
     3.7 - */
     3.8 -
     3.9 -package uk.ac.cam.cl.xeno.xenctl;
    3.10 -
    3.11 -public class
    3.12 -Extent
    3.13 -{
    3.14 -  int disk;
    3.15 -  long offset;                                           /* offset into disk */
    3.16 -  long size;                      /* size of this extent in 512 byte sectors */
    3.17 -
    3.18 -  public int
    3.19 -  getDisk()
    3.20 -  {
    3.21 -    return disk;
    3.22 -  }
    3.23 -
    3.24 -  public long
    3.25 -  getOffset()
    3.26 -  {
    3.27 -    return offset;
    3.28 -  }
    3.29 -
    3.30 -  public long
    3.31 -  getSize()
    3.32 -  {
    3.33 -    return size;
    3.34 -  }
    3.35 -}
     4.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java	Fri Jul 04 11:22:06 2003 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,129 +0,0 @@
     4.4 -/*
     4.5 - * Library.java
     4.6 - * 03.03.28 aho creation
     4.7 - */
     4.8 -
     4.9 -package uk.ac.cam.cl.xeno.xenctl;
    4.10 -
    4.11 -public class
    4.12 -Library
    4.13 -{
    4.14 -  /*
    4.15 -   * convert a number to a fixed width string
    4.16 -   */
    4.17 -  static String
    4.18 -  format (long input, int width, int prefix)
    4.19 -  {
    4.20 -    String sss = Long.toString(input);
    4.21 -    String space = "                                ";
    4.22 -
    4.23 -    if (width < sss.length())
    4.24 -    {
    4.25 -      width = sss.length();
    4.26 -    }
    4.27 -
    4.28 -    if (prefix == 0)
    4.29 -    {
    4.30 -      return space.substring(0, width - sss.length()) + sss;
    4.31 -    }
    4.32 -    else
    4.33 -    {
    4.34 -      return sss + space.substring(0, width - sss.length());
    4.35 -    }
    4.36 -  }
    4.37 -
    4.38 -  /*
    4.39 -   * convert a string to a fixed width string
    4.40 -   */
    4.41 -  static String
    4.42 -  format (String input, int width, int prefix)
    4.43 -  {
    4.44 -    String space = "                                ";
    4.45 -
    4.46 -    if (width < input.length())
    4.47 -    {
    4.48 -      width = input.length();
    4.49 -    }
    4.50 -
    4.51 -    if (prefix == 0)
    4.52 -    {
    4.53 -      return space.substring(0, width - input.length()) + input;
    4.54 -    }
    4.55 -    else
    4.56 -    {
    4.57 -      return input + space.substring(0, width - input.length());
    4.58 -    }
    4.59 -  }
    4.60 -
    4.61 -  /*
    4.62 -   * convert a number (string format) into 
    4.63 -   * the corresponding integer value.
    4.64 -   */
    4.65 -  static long
    4.66 -  parse_size(String size)
    4.67 -  {
    4.68 -    String substring = size;
    4.69 -    int    suffix = 1;
    4.70 -    long   value = 0;
    4.71 -
    4.72 -    if (size == null)
    4.73 -    {
    4.74 -      return 0;
    4.75 -    }
    4.76 -
    4.77 -    if ((substring = check(size, 'm')) != null)
    4.78 -    {
    4.79 -      suffix = 1024 * 1024;
    4.80 -    }
    4.81 -    else if ((substring = check(size, 'M')) != null)
    4.82 -    {
    4.83 -      suffix = 1024 * 1024;
    4.84 -    }
    4.85 -    else if ((substring = check(size, 'k')) != null)
    4.86 -    {
    4.87 -      suffix = 1024;
    4.88 -    }
    4.89 -    else if ((substring = check(size, 'K')) != null)
    4.90 -    {
    4.91 -      suffix = 1024;
    4.92 -    }
    4.93 -    else if ((substring = check(size, 'g')) != null)
    4.94 -    {
    4.95 -      suffix = 1024 * 1024 * 1024;
    4.96 -    }
    4.97 -    else if ((substring = check(size, 'G')) != null)
    4.98 -    {
    4.99 -      suffix = 1024 * 1024 * 1024;
   4.100 -    }
   4.101 -    else
   4.102 -    {
   4.103 -      substring = size;
   4.104 -    }
   4.105 -
   4.106 -    try
   4.107 -    {
   4.108 -      value = Long.decode(substring).longValue() * suffix;
   4.109 -    }
   4.110 -    catch (NumberFormatException e)
   4.111 -    {
   4.112 -      value = 0;
   4.113 -    }
   4.114 -
   4.115 -    return value;
   4.116 -  }
   4.117 -
   4.118 -  static String
   4.119 -  check(String size, char suffix)
   4.120 -  {
   4.121 -    int index = size.indexOf(suffix);
   4.122 -
   4.123 -    if (index != -1)
   4.124 -    {
   4.125 -      return size.substring(0, index);
   4.126 -    }
   4.127 -    else
   4.128 -    {
   4.129 -      return null;
   4.130 -    }
   4.131 -  }
   4.132 -}
     5.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Mode.java	Fri Jul 04 11:22:06 2003 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,22 +0,0 @@
     5.4 -/*
     5.5 - * Mode.java
     5.6 - * 03.03.27 aho creation
     5.7 - *
     5.8 - * until we have jdk1.5, we're left with this mess...
     5.9 - */
    5.10 -
    5.11 -package uk.ac.cam.cl.xeno.xenctl;
    5.12 -
    5.13 -public class 
    5.14 -Mode 
    5.15 -{
    5.16 -  private final String name;
    5.17 -
    5.18 -  private Mode(String name) { this.name = name; }
    5.19 -
    5.20 -  public String toString()  { return name; }
    5.21 -
    5.22 -  public static final Mode READ_ONLY  = new Mode("ro");
    5.23 -  public static final Mode READ_WRITE = new Mode("rw");
    5.24 -}
    5.25 -
     6.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Partition.java	Fri Jul 04 11:22:06 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,125 +0,0 @@
     6.4 -/*
     6.5 - * Partition.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 -
    6.13 -public class
    6.14 -Partition
    6.15 -{
    6.16 -  int major;
    6.17 -  int minor;
    6.18 -  long blocks;
    6.19 -  long start_sect;
    6.20 -  long nr_sects;
    6.21 -  String name;
    6.22 -  boolean xeno;
    6.23 -
    6.24 -  boolean 
    6.25 -  identical (Partition p)
    6.26 -  {
    6.27 -    return (major == p.major &&
    6.28 -	    minor == p.minor &&
    6.29 -	    blocks == p.blocks &&
    6.30 -	    start_sect == p.start_sect &&
    6.31 -	    nr_sects == p.nr_sects &&
    6.32 -	    name.equals(p.name));
    6.33 -  }
    6.34 -
    6.35 -  Partition
    6.36 -  duplicate ()
    6.37 -  {
    6.38 -    Partition p = new Partition();
    6.39 -
    6.40 -    p.major = major;
    6.41 -    p.minor = minor;
    6.42 -    p.blocks = blocks;
    6.43 -    p.start_sect = start_sect;
    6.44 -    p.nr_sects = nr_sects;
    6.45 -    p.name = name;
    6.46 -    p.xeno = xeno;
    6.47 -
    6.48 -    return p;
    6.49 -  }
    6.50 -
    6.51 -  String 
    6.52 -  dump (boolean title)
    6.53 -  {
    6.54 -    if (title)
    6.55 -    {
    6.56 -      return ("maj:min " + 
    6.57 -	      "    blocks " +
    6.58 -	      "start sect " +
    6.59 -	      " num sects " +
    6.60 -	      "name");
    6.61 -    }
    6.62 -    else
    6.63 -    {
    6.64 -      return (Library.format(major,3,0) + ":" + 
    6.65 -	      Library.format(minor,3,1) + " " +
    6.66 -	      Library.format(blocks,10,0) + " " +
    6.67 -	      Library.format(start_sect,10,0) + " " +
    6.68 -	      Library.format(nr_sects,10,0) + " " +
    6.69 -	      Library.format(name,7,1));
    6.70 -    }
    6.71 -  }
    6.72 -
    6.73 -  void
    6.74 -  dump_xml(PrintWriter out)
    6.75 -  {
    6.76 -    out.println ("  <partition>\n" +
    6.77 -		 "    <major>" + major + "</major>\n" +
    6.78 -		 "    <minor>" + minor + "</minor>\n" +
    6.79 -		 "    <blocks>" + blocks + "</blocks>\n" +
    6.80 -		 "    <start_sect>" + start_sect + "</start_sect>\n" +
    6.81 -		 "    <nr_sects>" + nr_sects + "</nr_sects>\n" +
    6.82 -		 "    <name>" + name + "</name>\n" +
    6.83 -		 "  </partition>");
    6.84 -  }
    6.85 -
    6.86 -  public int
    6.87 -  getMajor()
    6.88 -  {
    6.89 -    return major;
    6.90 -  }
    6.91 -
    6.92 -  public int
    6.93 -  getMinor()
    6.94 -  {
    6.95 -    return minor;
    6.96 -  }
    6.97 -
    6.98 -  public long
    6.99 -  getBlocks()
   6.100 -  {
   6.101 -    return blocks;
   6.102 -  }
   6.103 -  
   6.104 -  public long
   6.105 -  getStartSect()
   6.106 -  {
   6.107 -    return start_sect;
   6.108 -  }
   6.109 -
   6.110 -  public long
   6.111 -  getNumSects()
   6.112 -  {
   6.113 -    return nr_sects;
   6.114 -  }
   6.115 -  
   6.116 -  public String
   6.117 -  getName()
   6.118 -  {
   6.119 -    return name;
   6.120 -  }
   6.121 -
   6.122 -  public boolean
   6.123 -  getIsXeno()
   6.124 -  {
   6.125 -    return xeno;
   6.126 -  }
   6.127 -
   6.128 -}
     7.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/PartitionManager.java	Fri Jul 04 11:22:06 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,191 +0,0 @@
     7.4 -/*
     7.5 - * PartitionManager.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.*;
    7.12 -import java.util.Vector;
    7.13 -import java.util.Enumeration;
    7.14 -
    7.15 -public class
    7.16 -PartitionManager
    7.17 -{
    7.18 -  Vector partition_map;
    7.19 -
    7.20 -  static String proc_template =
    7.21 -    "major minor  #blocks  start_sect   nr_sects name";
    7.22 -
    7.23 -  /*
    7.24 -   * Initialize partition manager with source file.
    7.25 -   * Normally we read from /proc/partitions, but we can
    7.26 -   * specify an alternative file for debugging
    7.27 -   */
    7.28 -  PartitionManager (String filename)
    7.29 -  {
    7.30 -    String str;
    7.31 -    BufferedReader in;
    7.32 -
    7.33 -    partition_map = new Vector(100,10);
    7.34 -
    7.35 -    try
    7.36 -    {
    7.37 -      in = new BufferedReader(new FileReader(filename));
    7.38 -
    7.39 -      str = in.readLine();                                  /* skip headings */
    7.40 -      if (str.length() < proc_template.length() ||
    7.41 -	  !str.substring(0, proc_template.length()).equals(proc_template))
    7.42 -      {
    7.43 -	System.err.println ("Error: Incorrect /proc/partitions.");
    7.44 -	System.err.println ("       Is this Xeno?");
    7.45 -	System.exit (1);
    7.46 -      }
    7.47 -
    7.48 -      str = in.readLine();                                /* skip blank line */
    7.49 -
    7.50 -      str = in.readLine();
    7.51 -      while (str != null)
    7.52 -      {
    7.53 -	Partition partition = new Partition();
    7.54 -
    7.55 -	partition.major = Integer.parseInt(str.substring(0,5).trim());
    7.56 -	partition.minor = Integer.parseInt(str.substring(5,10).trim());
    7.57 -	partition.blocks = Integer.parseInt(str.substring(10,21).trim());
    7.58 -	partition.start_sect = Integer.parseInt(str.substring(21,32).trim());
    7.59 -	partition.nr_sects = Integer.parseInt(str.substring(32,43).trim());
    7.60 -	partition.name = str.substring(43).trim();
    7.61 -	partition.xeno = false;
    7.62 -
    7.63 -	partition_map.add(partition);
    7.64 -	str = in.readLine();
    7.65 -      }
    7.66 -    }
    7.67 -    catch (IOException io)
    7.68 -    {
    7.69 -      System.err.println ("PartitionManager: error reading partition file [" 
    7.70 -			  + filename + "]");
    7.71 -      System.err.println (io);
    7.72 -    }
    7.73 -  }
    7.74 -
    7.75 -  Partition
    7.76 -  get_partition (String name)
    7.77 -  {
    7.78 -    Partition partition = null;
    7.79 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
    7.80 -    {
    7.81 -      partition = (Partition) e.nextElement();
    7.82 -      if (partition.name.equals(name))
    7.83 -      {
    7.84 -	return partition;
    7.85 -      }
    7.86 -    }
    7.87 -    return null;
    7.88 -  }
    7.89 -
    7.90 -  Partition
    7.91 -  get_partition (int index)
    7.92 -  {
    7.93 -    return (Partition) partition_map.get(index);
    7.94 -  }
    7.95 -
    7.96 -  void
    7.97 -  add_xeno_partition (Partition p)
    7.98 -  {
    7.99 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
   7.100 -    {
   7.101 -      Partition partition = (Partition) e.nextElement();
   7.102 -      if (partition.identical(p))
   7.103 -      {
   7.104 -	partition.xeno = true;
   7.105 -      }
   7.106 -    }
   7.107 -  }
   7.108 -
   7.109 -  /*
   7.110 -   * dump the xeno partition list as xml
   7.111 -   */
   7.112 -  void
   7.113 -  dump_xml (PrintWriter out)
   7.114 -  {
   7.115 -    int loop;
   7.116 -
   7.117 -    out.println("<partitions>");
   7.118 -    for (Enumeration e = partition_map.elements() ; e.hasMoreElements() ;) 
   7.119 -    {
   7.120 -      Partition partition = (Partition) e.nextElement();
   7.121 -      if (partition.xeno == true)
   7.122 -      {
   7.123 -	partition.dump_xml(out);
   7.124 -      }
   7.125 -    }
   7.126 -
   7.127 -    out.println("</partitions>");
   7.128 -
   7.129 -    return;
   7.130 -  }
   7.131 -
   7.132 -  /*
   7.133 -   * dump the partition map as a string
   7.134 -   * mark: mark the current xeno partitions in the partition map
   7.135 -   */
   7.136 -  String
   7.137 -  dump (boolean mark)
   7.138 -  {
   7.139 -    int loop, idx;
   7.140 -    StringBuffer sb = new StringBuffer();
   7.141 -    Partition partition;
   7.142 -
   7.143 -    for (idx = 0; idx < partition_map.size(); idx++)
   7.144 -    {
   7.145 -      partition = (Partition) partition_map.get(idx);
   7.146 -
   7.147 -      if (idx == 0)
   7.148 -      {
   7.149 -	sb.append(" idx " + partition.dump(true) + "\n");
   7.150 -      }
   7.151 -      if (partition.xeno)
   7.152 -      {
   7.153 -	sb.append("[ ");
   7.154 -      }
   7.155 -      else
   7.156 -      {
   7.157 -	sb.append("  ");
   7.158 -      }
   7.159 -      sb.append(Library.format(idx,2,0) + " " + partition.dump(false));
   7.160 -      if (partition.xeno)
   7.161 -      {
   7.162 -	sb.append("]\n");
   7.163 -      }
   7.164 -      else
   7.165 -      {
   7.166 -	sb.append("\n");
   7.167 -      }
   7.168 -    }
   7.169 -
   7.170 -    return sb.toString();
   7.171 -  }
   7.172 -
   7.173 -  /**
   7.174 -   * get the number of partitions 
   7.175 -   */
   7.176 -
   7.177 -  int
   7.178 -  getPartitionCount ()
   7.179 -  {
   7.180 -    return partition_map.size();
   7.181 -  }
   7.182 -
   7.183 -  /**
   7.184 -   * get the details about a particular partition
   7.185 -   *
   7.186 -   */
   7.187 -  Partition
   7.188 -  getPartition (int index)
   7.189 -  {
   7.190 -    Partition partition = (Partition) partition_map.get(index);
   7.191 -    return partition;
   7.192 -  }
   7.193 -
   7.194 -}
     8.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/XML.java	Fri Jul 04 11:22:06 2003 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,126 +0,0 @@
     8.4 -/*
     8.5 - * XML.java
     8.6 - * 03.03.26 aho creation
     8.7 - */
     8.8 -
     8.9 -package uk.ac.cam.cl.xeno.xenctl;
    8.10 -
    8.11 -import java.io.File;
    8.12 -import java.io.IOException;
    8.13 -import java.io.PrintWriter;
    8.14 -import java.io.FileWriter;
    8.15 -import java.io.BufferedWriter;
    8.16 -import java.io.FileNotFoundException;
    8.17 -import javax.xml.parsers.DocumentBuilder; 
    8.18 -import javax.xml.parsers.DocumentBuilderFactory; 
    8.19 -import javax.xml.parsers.FactoryConfigurationError; 
    8.20 -import javax.xml.parsers.ParserConfigurationException;
    8.21 -import org.w3c.dom.Document;
    8.22 -import org.w3c.dom.DOMException;
    8.23 -import org.w3c.dom.NodeList;
    8.24 -import org.xml.sax.SAXException; 
    8.25 -import org.xml.sax.SAXParseException;
    8.26 - 
    8.27 -public class
    8.28 -XML
    8.29 -{
    8.30 -  static Document document = null;
    8.31 -
    8.32 -  /*
    8.33 -   * dump partition manager and virtual disk manager state to filename
    8.34 -   */
    8.35 -
    8.36 -  static void
    8.37 -  dump_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
    8.38 -  {
    8.39 -    PrintWriter out;
    8.40 -
    8.41 -    try
    8.42 -    {
    8.43 -      out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
    8.44 -    }
    8.45 -    catch (IOException e)
    8.46 -    {
    8.47 -      System.err.println ("XML.dump_state error [" + filename + "]");
    8.48 -      System.err.println (e);
    8.49 -      return;
    8.50 -    }
    8.51 -
    8.52 -    out.println("<?xml version=\"1.0\"?>");
    8.53 -    out.println("<vdmanager>");
    8.54 -    pm.dump_xml(out);
    8.55 -    vdm.dump_xml(out);
    8.56 -    out.println("</vdmanager>");
    8.57 -
    8.58 -    out.close();
    8.59 -    return;
    8.60 -  }
    8.61 -
    8.62 -  /*
    8.63 -   * load partition manager and virtual disk manager state from filename
    8.64 -   */
    8.65 -  static void
    8.66 -  load_state (PartitionManager pm, VirtualDiskManager vdm, String filename)
    8.67 -  {
    8.68 -    if (document == null)
    8.69 -    {
    8.70 -      load_file (filename);
    8.71 -    }
    8.72 -
    8.73 -    XMLHelper.parse(pm, vdm, document);
    8.74 -  }
    8.75 -
    8.76 -  /*
    8.77 -   * load XML from disk
    8.78 -   */
    8.79 -  static void
    8.80 -  load_file (String filename)
    8.81 -  {
    8.82 -    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    8.83 -    // factory.setNamespaceAware(true);
    8.84 -    // factory.setValidating(true);
    8.85 -
    8.86 -    try
    8.87 -    {
    8.88 -      File file = new File(filename);
    8.89 -
    8.90 -      DocumentBuilder builder = factory.newDocumentBuilder();
    8.91 -      document = builder.parse(file);
    8.92 -    }
    8.93 -    catch (SAXParseException spe)               /* error generated by parser */
    8.94 -    {
    8.95 -      System.err.println ("xml parser exception on line " + 
    8.96 -			  spe.getLineNumber() + 
    8.97 -			  " for uri " + spe.getSystemId());
    8.98 -      System.err.println (spe.getMessage());
    8.99 -
   8.100 -      Exception x = spe;
   8.101 -      if (spe.getException() != null)
   8.102 -	x = spe.getException();
   8.103 -      x.printStackTrace();
   8.104 -      System.exit(1);
   8.105 -    }
   8.106 -    catch (SAXException sxe)
   8.107 -    {
   8.108 -      Exception e = sxe;
   8.109 -      if (sxe.getException() != null)
   8.110 -	e = sxe.getException();
   8.111 -      e.printStackTrace();
   8.112 -      System.exit(1);
   8.113 -    }
   8.114 -    catch (ParserConfigurationException pce)
   8.115 -    {
   8.116 -      pce.printStackTrace();
   8.117 -    }
   8.118 -    catch (FileNotFoundException fnfe)
   8.119 -    {
   8.120 -      System.err.println ("warning: state file not found [" +
   8.121 -			  filename + "]");
   8.122 -    }
   8.123 -    catch (IOException ioe)
   8.124 -    {
   8.125 -      ioe.printStackTrace();
   8.126 -    }
   8.127 -    return;
   8.128 -  }
   8.129 -}
     9.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/XMLHelper.java	Fri Jul 04 11:22:06 2003 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,205 +0,0 @@
     9.4 -/*
     9.5 - * XMLHelper.java
     9.6 - * 03.03.27 aho creation
     9.7 - */
     9.8 -
     9.9 -package uk.ac.cam.cl.xeno.xenctl;
    9.10 -
    9.11 -import java.util.Date;
    9.12 -import org.w3c.dom.Document;
    9.13 -import org.w3c.dom.Element;
    9.14 -import org.w3c.dom.Node;
    9.15 -import org.w3c.dom.NodeList;
    9.16 -
    9.17 -public class
    9.18 -XMLHelper
    9.19 -{
    9.20 -  static void
    9.21 -  dump_document (Document document)
    9.22 -  {
    9.23 -    dump_element(document.getDocumentElement(), 0);
    9.24 -  }
    9.25 -
    9.26 -  static void
    9.27 -  dump_element (Element element, int indent)
    9.28 -  {
    9.29 -    NodeList nl = element.getChildNodes();
    9.30 -
    9.31 -    System.out.println ("<" + element.getTagName() + ">");
    9.32 -    dump_nodelist(nl, indent + 1);
    9.33 -    System.out.println("</" + element.getTagName() + ">");
    9.34 -  }
    9.35 -
    9.36 -  static void
    9.37 -  dump_nodelist (NodeList nl, int indent)
    9.38 -  {
    9.39 -    for (int loop = 0; loop < nl.getLength(); loop++)
    9.40 -    {
    9.41 -      Node node = nl.item(loop);
    9.42 -      switch (node.getNodeType())
    9.43 -      {
    9.44 -	case Node.ELEMENT_NODE : 
    9.45 -	{
    9.46 -	  dump_element((Element)node, indent);
    9.47 -	  break;
    9.48 -	}
    9.49 -	case Node.TEXT_NODE :
    9.50 -	{
    9.51 -	  System.out.println("TEXT: " + node.getNodeValue());
    9.52 -	  break;
    9.53 -	}
    9.54 -	default :
    9.55 -	{
    9.56 -	  System.out.println("NODE: " + node.getNodeType());
    9.57 -	}
    9.58 -      }
    9.59 -    }
    9.60 -  }
    9.61 -
    9.62 -  static Node 
    9.63 -  get_subnode (String name, Node node) 
    9.64 -  {
    9.65 -    if (node.getNodeType() != Node.ELEMENT_NODE) 
    9.66 -    {
    9.67 -      System.err.println("Error: Search node not of element type");
    9.68 -      return null;
    9.69 -    }
    9.70 -
    9.71 -    if (!node.hasChildNodes()) return null;
    9.72 -
    9.73 -    NodeList list = node.getChildNodes();
    9.74 -    for (int i=0; i < list.getLength(); i++) 
    9.75 -    {
    9.76 -      Node subnode = list.item(i);
    9.77 -      if (subnode.getNodeType() == Node.ELEMENT_NODE) 
    9.78 -      {
    9.79 -	if (subnode.getNodeName() == name) return subnode;
    9.80 -      }
    9.81 -    }
    9.82 -    return null;
    9.83 -  }
    9.84 -
    9.85 -  static String 
    9.86 -  get_text (Node node) 
    9.87 -  {
    9.88 -    StringBuffer result = new StringBuffer();
    9.89 -    if (node==null || !node.hasChildNodes()) return "";
    9.90 -
    9.91 -    NodeList list = node.getChildNodes();
    9.92 -    for (int i=0; i < list.getLength(); i++) 
    9.93 -    {
    9.94 -      Node subnode = list.item(i);
    9.95 -      if (subnode.getNodeType() == Node.TEXT_NODE) 
    9.96 -      {
    9.97 -	result.append(subnode.getNodeValue());
    9.98 -      }
    9.99 -    }
   9.100 -    return result.toString();
   9.101 -  }
   9.102 -
   9.103 -  static void
   9.104 -  parse (PartitionManager pm, VirtualDiskManager vdm, Document document)
   9.105 -  {
   9.106 -    if (document == null) return;
   9.107 -
   9.108 -    /* parse partitions */
   9.109 -    parse_partitions(pm, document.getElementsByTagName("partition"));
   9.110 -
   9.111 -    /* parse virtual disks */
   9.112 -    NodeList list = document.getElementsByTagName("virtual_disk");
   9.113 -    for (int i = 0; i < list.getLength(); i++)
   9.114 -    {
   9.115 -      Node subnode = list.item(i);
   9.116 -      String parent = subnode.getParentNode().getNodeName();
   9.117 -      VirtualDisk vd =  parse_virtual_disk(subnode);
   9.118 -
   9.119 -      if (parent.equals("free"))
   9.120 -      {
   9.121 -	vdm.add_free(vd);
   9.122 -      }
   9.123 -      else if (parent.equals("virtual_disks"))
   9.124 -      {
   9.125 -	vdm.add_virtual_disk(vd);
   9.126 -      }
   9.127 -      else
   9.128 -      {
   9.129 -	System.out.println ("XML parse error: unknown parent for virtual_disk "
   9.130 -			    + "[" + parent + "]");
   9.131 -      }
   9.132 -    }
   9.133 -
   9.134 -    /* parse virtual block devices */
   9.135 -    parse_virtual_block_devices(vdm, document.getElementsByTagName("virtual_block_device"));
   9.136 -
   9.137 -    return;
   9.138 -  }
   9.139 -
   9.140 -  static VirtualDisk
   9.141 -  parse_virtual_disk(Node node)
   9.142 -  {
   9.143 -    VirtualDisk vd;
   9.144 -    Date date = new Date();
   9.145 -    NodeList list;
   9.146 -
   9.147 -    date.setTime(Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("expiry", node))));
   9.148 -    vd = new VirtualDisk(XMLHelper.get_text(XMLHelper.get_subnode("name", node)),
   9.149 -			 date,
   9.150 -			 XMLHelper.get_text(XMLHelper.get_subnode("key", node)));
   9.151 -
   9.152 -    list = XMLHelper.get_subnode("extents", node).getChildNodes();
   9.153 -    for (int i = 0; i < list.getLength(); i++)
   9.154 -    {
   9.155 -      Node enode = list.item(i);
   9.156 -
   9.157 -      if (enode.getNodeType() == Node.ELEMENT_NODE &&
   9.158 -	  enode.getNodeName().equals("extent"))
   9.159 -      {
   9.160 -	Extent extent = new Extent();
   9.161 -
   9.162 -	extent.disk = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("disk", enode)));
   9.163 -	extent.size = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("size", enode)));
   9.164 -	extent.offset = Long.parseLong(XMLHelper.get_text(XMLHelper.get_subnode("offset", enode)));
   9.165 -	vd.add_extent(extent);
   9.166 -      }
   9.167 -    }
   9.168 -
   9.169 -    return vd;
   9.170 -  }
   9.171 -
   9.172 -  static void
   9.173 -  parse_partitions (PartitionManager pm, NodeList nl)
   9.174 -  {
   9.175 -    Partition partition;
   9.176 -
   9.177 -    for (int loop = 0; loop < nl.getLength(); loop++)
   9.178 -    {
   9.179 -      Node node = nl.item(loop);
   9.180 -
   9.181 -      partition = new Partition();
   9.182 -      partition.major = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("major", node)));
   9.183 -      partition.minor = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("minor", node)));
   9.184 -      partition.blocks = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("blocks", node)));
   9.185 -      partition.start_sect = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("start_sect", node)));
   9.186 -      partition.nr_sects = Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("nr_sects", node)));
   9.187 -      partition.name = XMLHelper.get_text(XMLHelper.get_subnode("name", node));
   9.188 -
   9.189 -      pm.add_xeno_partition(partition);
   9.190 -    }
   9.191 -  }
   9.192 -
   9.193 -  static void
   9.194 -  parse_virtual_block_devices (VirtualDiskManager vdm, NodeList nl)
   9.195 -  {
   9.196 -    VirtualBlockDevice vbd;
   9.197 -
   9.198 -    for (int loop = 0; loop < nl.getLength(); loop++)
   9.199 -    {
   9.200 -      Node node = nl.item(loop);
   9.201 -
   9.202 -      vdm.create_virtual_block_device(XMLHelper.get_text(XMLHelper.get_subnode("key", node)),
   9.203 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("domain", node))),
   9.204 -				      Integer.parseInt(XMLHelper.get_text(XMLHelper.get_subnode("vbdnum", node))),
   9.205 -				      XMLHelper.get_text(XMLHelper.get_subnode("mode", node)));
   9.206 -    }
   9.207 -  }
   9.208 -}