ia64/xen-unstable

changeset 709:ad58e3192187

bitkeeper revision 1.420 (3f5f3de2nYFce7cUg2vR08Q7Y_E2XA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/tlh20/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Wed Sep 10 15:06:10 2003 +0000 (2003-09-10)
parents f6f8ca2fa8d4 5627b762b3be
children 2266cd4dd7ec
files .rootkeys tools/control/src/org/xenoserver/cmdline/Main.java tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java tools/control/src/org/xenoserver/cmdline/ParseScript.java tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java tools/control/src/org/xenoserver/control/CommandDomainNew.java tools/control/src/org/xenoserver/control/Defaults.java tools/control/src/org/xenoserver/control/Settings.java tools/control/xenctl
line diff
     1.1 --- a/.rootkeys	Wed Sep 10 09:57:56 2003 +0000
     1.2 +++ b/.rootkeys	Wed Sep 10 15:06:10 2003 +0000
     1.3 @@ -30,6 +30,7 @@ 3f05631djnPcaqmzMFSa8RLmGCZ-0Q tools/con
     1.4  3f05631dswxJX_TpcuG6tBstyHSetg tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java
     1.5  3f05631dMY7PMkwSY7zBFelGJ8goVg tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java
     1.6  3f05631dYDFXv6mwNFAgz3ta9kShJA tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java
     1.7 +3f5f3d95BlaPZ2JHfpjHuHscx2SJow tools/control/src/org/xenoserver/cmdline/ParseScript.java
     1.8  3f0bdfabfXM4tMbvmV06di5U-5FfqA tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java
     1.9  3f0bec93F_VDIcn9oeXwJYwydX20kg tools/control/src/org/xenoserver/cmdline/ParseVbdShow.java
    1.10  3f098761TRsbDk9woUM846Q6_F7EmA tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java
     2.1 --- a/tools/control/src/org/xenoserver/cmdline/Main.java	Wed Sep 10 09:57:56 2003 +0000
     2.2 +++ b/tools/control/src/org/xenoserver/cmdline/Main.java	Wed Sep 10 15:06:10 2003 +0000
     2.3 @@ -43,12 +43,23 @@ public class Main {
     2.4        new ParseGroup( "domain", domaincommands ),
     2.5        new ParseGroup( "partitions", partitioncommands ),
     2.6        new ParseGroup( "physical", physicalcommands ),
     2.7 +      new ParseScript(),
     2.8        new ParseGroup( "vd", vdcommands ),
     2.9        new ParseGroup( "vbd", vbdcommands )
    2.10      };
    2.11    /** The top-level parser. */
    2.12    static final CommandParser parser = new ParseGroup( null, commands );
    2.13  
    2.14 +  public static void executeArgList (Defaults d, LinkedList arglist)
    2.15 +     throws ParseFailedException, CommandFailedException 
    2.16 +  {
    2.17 +    if (arglist.size() == 0) {
    2.18 +      help.parse(null, null);
    2.19 +    } else {
    2.20 +      parser.parse(d, arglist);
    2.21 +    }
    2.22 +  }
    2.23 +
    2.24    public static void main(String[] args) {
    2.25      Defaults d = new Defaults();
    2.26      int ec = -1;
    2.27 @@ -57,20 +68,15 @@ public class Main {
    2.28        arglist.add( args[i] );
    2.29      }
    2.30  
    2.31 -    if (args.length == 0) {
    2.32 +    try {
    2.33 +      executeArgList (d, arglist);
    2.34 +      ec = 0;
    2.35 +    } catch (NoSuchElementException e) {
    2.36        help.parse(null, null);
    2.37 -    } else {
    2.38 -      try
    2.39 -      {
    2.40 -        parser.parse(d, arglist);
    2.41 -        ec = 0;
    2.42 -      } catch (NoSuchElementException e) {
    2.43 -          help.parse(null, null);
    2.44 -      } catch (ParseFailedException e) {
    2.45 -        System.err.println( e.getMessage() );
    2.46 -      } catch (CommandFailedException e) {
    2.47 -        System.err.println( e.getMessage() );
    2.48 -      }
    2.49 +    } catch (ParseFailedException e) {
    2.50 +      System.err.println( e.getMessage() );
    2.51 +    } catch (CommandFailedException e) {
    2.52 +      System.err.println( e.getMessage() );
    2.53      }
    2.54  
    2.55      System.exit(ec);
     3.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java	Wed Sep 10 09:57:56 2003 +0000
     3.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java	Wed Sep 10 15:06:10 2003 +0000
     3.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
     3.4  public class ParseDomainDestroy extends CommandParser {
     3.5      public void parse(Defaults d, LinkedList args)
     3.6          throws ParseFailedException, CommandFailedException {
     3.7 -        int domain_id = getIntParameter(args, 'n', 0);
     3.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     3.9          boolean force = getFlagParameter(args, 'f');
    3.10  
    3.11          if (domain_id == 0) {
    3.12 @@ -27,7 +27,7 @@ public class ParseDomainDestroy extends 
    3.13      }
    3.14  
    3.15      public String getUsage() {
    3.16 -        return "-n<domain_id> [-f]";
    3.17 +        return "[-n<domain_id>] [-f]";
    3.18      }
    3.19  
    3.20      public String getHelpText() {
     4.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java	Wed Sep 10 09:57:56 2003 +0000
     4.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java	Wed Sep 10 15:06:10 2003 +0000
     4.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
     4.4  public class ParseDomainStart extends CommandParser {
     4.5      public void parse(Defaults d, LinkedList args)
     4.6          throws ParseFailedException, CommandFailedException {
     4.7 -        int domain_id = getIntParameter(args, 'n', 0);
     4.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     4.9  
    4.10          if (domain_id == 0) {
    4.11              throw new ParseFailedException("Expected -n<domain_id>");
    4.12 @@ -25,7 +25,7 @@ public class ParseDomainStart extends Co
    4.13      }
    4.14  
    4.15      public String getUsage() {
    4.16 -        return "-n<domain_id>";
    4.17 +        return "[-n<domain_id>]";
    4.18      }
    4.19  
    4.20      public String getHelpText() {
     5.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java	Wed Sep 10 09:57:56 2003 +0000
     5.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java	Wed Sep 10 15:06:10 2003 +0000
     5.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
     5.4  public class ParseDomainStop extends CommandParser {
     5.5      public void parse(Defaults d, LinkedList args)
     5.6          throws ParseFailedException, CommandFailedException {
     5.7 -        int domain_id = getIntParameter(args, 'n', 0);
     5.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     5.9  
    5.10          if (domain_id == 0) {
    5.11              throw new ParseFailedException("Expected -n<domain_id>");
    5.12 @@ -25,7 +25,7 @@ public class ParseDomainStop extends Com
    5.13      }
    5.14  
    5.15      public String getUsage() {
    5.16 -        return "-n<domain_id>";
    5.17 +        return "[-n<domain_id>]";
    5.18      }
    5.19  
    5.20      public String getHelpText() {
     6.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Wed Sep 10 09:57:56 2003 +0000
     6.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Wed Sep 10 15:06:10 2003 +0000
     6.3 @@ -10,7 +10,7 @@ import org.xenoserver.control.Mode;
     6.4  public class ParsePhysicalGrant extends CommandParser {
     6.5      public void parse(Defaults d, LinkedList args)
     6.6          throws ParseFailedException, CommandFailedException {
     6.7 -        int domain_id = getIntParameter(args, 'n', 0);
     6.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     6.9          boolean force = getFlagParameter(args, 'f');
    6.10          String partition_name = getStringParameter(args, 'p', "");
    6.11          boolean write = getFlagParameter(args, 'w');
    6.12 @@ -44,7 +44,7 @@ public class ParsePhysicalGrant extends 
    6.13      }
    6.14  
    6.15      public String getUsage() {
    6.16 -        return "-n<domain_id> -p<partition_name> [-f] [-w]";
    6.17 +        return "-p<partition_name> [-n<domain_id>] [-f] [-w]";
    6.18      }
    6.19  
    6.20      public String getHelpText() {
     7.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java	Wed Sep 10 09:57:56 2003 +0000
     7.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java	Wed Sep 10 15:06:10 2003 +0000
     7.3 @@ -15,7 +15,7 @@ import org.xenoserver.control.PartitionM
     7.4  public class ParsePhysicalList extends CommandParser {
     7.5      public void parse(Defaults d, LinkedList args)
     7.6          throws ParseFailedException, CommandFailedException {
     7.7 -        int domain_id = getIntParameter(args, 'n', 0);
     7.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     7.9          if (domain_id == 0) {
    7.10              throw new ParseFailedException("Expected -n<domain_id>");
    7.11          }
     8.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Wed Sep 10 09:57:56 2003 +0000
     8.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Wed Sep 10 15:06:10 2003 +0000
     8.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
     8.4  public class ParsePhysicalRevoke extends CommandParser {
     8.5      public void parse(Defaults d, LinkedList args)
     8.6          throws ParseFailedException, CommandFailedException {
     8.7 -        int domain_id = getIntParameter(args, 'n', 0);
     8.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
     8.9          String partition_name = getStringParameter(args, 'p', "");
    8.10  
    8.11          if (domain_id == 0) {
    8.12 @@ -32,7 +32,7 @@ public class ParsePhysicalRevoke extends
    8.13      }
    8.14  
    8.15      public String getUsage() {
    8.16 -        return "-n<domain_id> -p<partition_name>";
    8.17 +        return "-p<partition_name> [-n<domain_id>]";
    8.18      }
    8.19  
    8.20      public String getHelpText() {
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseScript.java	Wed Sep 10 15:06:10 2003 +0000
     9.3 @@ -0,0 +1,79 @@
     9.4 +package org.xenoserver.cmdline;
     9.5 +
     9.6 +import java.util.Iterator;
     9.7 +import java.util.LinkedList;
     9.8 +import java.util.StringTokenizer;
     9.9 +
    9.10 +import java.io.BufferedReader;
    9.11 +import java.io.FileReader;
    9.12 +import java.io.Reader;
    9.13 +import java.io.InputStreamReader;
    9.14 +import java.io.IOException;
    9.15 +
    9.16 +import org.xenoserver.control.CommandFailedException;
    9.17 +import org.xenoserver.control.Defaults;
    9.18 +import org.xenoserver.control.Extent;
    9.19 +import org.xenoserver.control.Library;
    9.20 +import org.xenoserver.control.Settings;
    9.21 +import org.xenoserver.control.VirtualDisk;
    9.22 +import org.xenoserver.control.VirtualDiskManager;
    9.23 +
    9.24 +public class ParseScript extends CommandParser {
    9.25 +  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    9.26 +    String filename = getStringParameter(args,'f',null);
    9.27 +
    9.28 +    try
    9.29 +      {
    9.30 +	Reader r;
    9.31 +	BufferedReader br;
    9.32 +	String next_line;
    9.33 +	boolean stdin;
    9.34 +
    9.35 +	if (filename == null) {
    9.36 +	  r = new InputStreamReader (System.in);
    9.37 +	  stdin = true;
    9.38 +	} else {
    9.39 +	  r = new FileReader (filename);
    9.40 +	  stdin = false;
    9.41 +	}
    9.42 +	br = new BufferedReader (r);
    9.43 +	
    9.44 +	if (stdin) prompt();
    9.45 +	while ((next_line = br.readLine()) != null) 
    9.46 +	  {
    9.47 +	    StringTokenizer tok = new StringTokenizer(next_line, " ");
    9.48 +	    LinkedList arglist = new LinkedList();
    9.49 +	    while (tok.hasMoreTokens()) {
    9.50 +	      arglist.add (tok.nextToken ());
    9.51 +	    }
    9.52 +	    Main.executeArgList (d, arglist);
    9.53 +	    if (stdin) prompt();
    9.54 +	  }
    9.55 +      }
    9.56 +    catch (IOException ioe)
    9.57 +      {
    9.58 +	throw new ParseFailedException ("Could not read script \"" + filename + "\"", ioe);
    9.59 +      }
    9.60 +  }
    9.61 +
    9.62 +  void prompt() {
    9.63 +    System.out.print ("$ ");
    9.64 +    System.out.flush ();
    9.65 +  }
    9.66 +
    9.67 +  public String getName() {
    9.68 +    return "script";
    9.69 +  }
    9.70 +
    9.71 +  public String getUsage() {
    9.72 +    return "[-f<filename>]";
    9.73 +  }
    9.74 +
    9.75 +  public String getHelpText() {
    9.76 +    return ("Execute a series of xenctl command lines found in the specified file\n" +
    9.77 +	    "(or from standard input if no filename is given).  Execution terminates\n" +
    9.78 +	    "if any command fails.  If a command requires a domain ID then, if\n" +
    9.79 +	    "ommitted, the domain most recently created by the script will be used\n" +
    9.80 +	    "by default.\n");
    9.81 +  }
    9.82 +}
    10.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java	Wed Sep 10 09:57:56 2003 +0000
    10.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java	Wed Sep 10 15:06:10 2003 +0000
    10.3 @@ -13,7 +13,7 @@ public class ParseVbdCreate extends Comm
    10.4          throws ParseFailedException, CommandFailedException {
    10.5          String vd_key = getStringParameter(args, 'k', "");
    10.6          String partition_name = getStringParameter(args, 'p', "");
    10.7 -        int domain_id = getIntParameter(args, 'n', 0);
    10.8 +        int domain_id = getIntParameter(args, 'n', d.domainNumber);
    10.9          int vbd_num = getIntParameter(args, 'v', -1);
   10.10          boolean write = getFlagParameter(args, 'w');
   10.11  
   10.12 @@ -53,7 +53,7 @@ public class ParseVbdCreate extends Comm
   10.13      }
   10.14  
   10.15      public String getUsage() {
   10.16 -        return "-n<domain_id> {-k<key>|-p<partition} -v<vbd_num> [-w]";
   10.17 +        return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w]";
   10.18      }
   10.19  
   10.20      public String getHelpText() {
    11.1 --- a/tools/control/src/org/xenoserver/control/CommandDomainNew.java	Wed Sep 10 09:57:56 2003 +0000
    11.2 +++ b/tools/control/src/org/xenoserver/control/CommandDomainNew.java	Wed Sep 10 15:06:10 2003 +0000
    11.3 @@ -185,6 +185,7 @@ public class CommandDomainNew extends Co
    11.4                      domain_id = Integer.parseInt(br.readLine());
    11.5                      create_rc = create_p.waitFor();
    11.6                  }
    11.7 +		d.domainNumber = domain_id;
    11.8  
    11.9                  if (create_rc != 0) {
   11.10                      throw CommandFailedException.xiCommandFailed(
    12.1 --- a/tools/control/src/org/xenoserver/control/Defaults.java	Wed Sep 10 09:57:56 2003 +0000
    12.2 +++ b/tools/control/src/org/xenoserver/control/Defaults.java	Wed Sep 10 15:06:10 2003 +0000
    12.3 @@ -49,6 +49,8 @@ public class Defaults {
    12.4      public String args = "";
    12.5      /** Directory to find XI tools. */
    12.6      public String xiToolsDir = "";
    12.7 +    /** Domain number */
    12.8 +    public int domainNumber;
    12.9  
   12.10      
   12.11      /**
   12.12 @@ -143,6 +145,8 @@ public class Defaults {
   12.13                      domainImage = s;
   12.14                  } else if (lastName.equals("domain_name")) {
   12.15                      domainName = s;
   12.16 +                } else if (lastName.equals("domain_number")) {
   12.17 +                    domainNumber = Integer.parseInt(s);
   12.18                  } else if (lastName.equals("domain_init_rd")) {
   12.19                      domainInitRD = s;
   12.20                  } else if (lastName.equals("domain_vifs")) {
    13.1 --- a/tools/control/src/org/xenoserver/control/Settings.java	Wed Sep 10 09:57:56 2003 +0000
    13.2 +++ b/tools/control/src/org/xenoserver/control/Settings.java	Wed Sep 10 15:06:10 2003 +0000
    13.3 @@ -14,12 +14,6 @@ public final class Settings {
    13.4      /** Path to search for the defaults file. */
    13.5      public static final String DEFAULTS_PATH =
    13.6          System.getProperty("DEFAULTS_PATH", ".:/etc:/var/lib/xen");
    13.7 -    /** IP address of domain 0. */
    13.8 -    public static final String LOCAL_IP = System.getProperty("LOCAL_IP");
    13.9 -    /** Network mask of domain 0. */
   13.10 -    public static final String LOCAL_MASK = System.getProperty("LOCAL_MASK");
   13.11 -    /** Gateway of domain 0. */
   13.12 -    public static final String LOCAL_GW = System.getProperty("LOCAL_ROUTE");
   13.13      /** If set, do not call any xi_ commands, just print their command lines. */
   13.14      public static final boolean TEST = (System.getProperty("TEST") != null);
   13.15      /** Name of xi_helper utility. */
    14.1 --- a/tools/control/xenctl	Wed Sep 10 09:57:56 2003 +0000
    14.2 +++ b/tools/control/xenctl	Wed Sep 10 15:06:10 2003 +0000
    14.3 @@ -7,27 +7,7 @@ if [ -z "$IFCONFIG" ] ; then IFCONFIG=/s
    14.4  if [ -z "$ROUTE" ] ; then ROUTE=/sbin/route ; fi
    14.5  if [ -z "$JAVA" ] ; then JAVA=java ; fi
    14.6  
    14.7 -if [ "$1" = "domain" -a "$2" = "new" ] ; then
    14.8 -  if [ ! -x "$IFCONFIG" ]; then  
    14.9 -    echo Could not find executable $IFCONFIG
   14.10 -    exit 1
   14.11 -  fi
   14.12 -
   14.13 -  if [ ! -x "$ROUTE" ]; then
   14.14 -    echo Could not find executable $ROUTE
   14.15 -    exit 1
   14.16 -  fi
   14.17  
   14.18 -  # Try to determine dom0 network settings to avoid hard-coding
   14.19 -  # particular machines in the defaults file
   14.20 -  LOCAL_IP=$(/sbin/ifconfig $QUERY_DEV | grep 'inet addr' | tr ':' '\t' | awk '{print $3}')
   14.21 -  LOCAL_MASK=$(/sbin/ifconfig $QUERY_DEV | grep 'Mask' | tr ':' '\t' | awk '{print $7}')
   14.22 -  LOCAL_ROUTE=$(/sbin/route -n | grep $QUERY_DEV | grep 'G' | awk '{print $2}')
   14.23 -fi
   14.24 -
   14.25 -
   14.26 -#ARGS="-DTEST -DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE"
   14.27 -ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE"
   14.28 -
   14.29 +ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH"
   14.30  
   14.31  $JAVA $ARGS -jar $(dirname $0)/xenctl-cmdline.jar $*