direct-io.hg
changeset 487:09249a3c5206
bitkeeper revision 1.261 (3f0430625OUEzfLrVsVrTUKyml9mhA)
Remove old domctl code in order to explicitly break anything that still depends on it. =)
Remove old domctl code in order to explicitly break anything that still depends on it. =)
author | rac61@labyrinth.cl.cam.ac.uk |
---|---|
date | Thu Jul 03 13:32:18 2003 +0000 (2003-07-03) |
parents | 1f82aa25c8c7 |
children | fd8bf35bb913 |
files | .rootkeys tools/control/src/uk/ac/cam/cl/xeno/domctl/Command.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandDestroy.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandHelp.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandList.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandNew.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStart.java tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStop.java tools/control/src/uk/ac/cam/cl/xeno/domctl/Defaults.java tools/control/src/uk/ac/cam/cl/xeno/domctl/Domain.java tools/control/src/uk/ac/cam/cl/xeno/domctl/InetAddressPattern.java tools/control/src/uk/ac/cam/cl/xeno/domctl/Main.java tools/control/src/uk/ac/cam/cl/xeno/domctl/Settings.java tools/control/src/uk/ac/cam/cl/xeno/domctl/StringPattern.java |
line diff
1.1 --- a/.rootkeys Thu Jul 03 13:18:21 2003 +0000 1.2 +++ b/.rootkeys Thu Jul 03 13:32:18 2003 +0000 1.3 @@ -36,19 +36,6 @@ 3ec41f7cQ7Ug739JBDrsVH-7KJ5MvQ tools/con 1.4 3eb781fdDeZEopemXIVg_ARCGKSmBw tools/control/src/org/xenoserver/control/InetAddressPattern.java 1.5 3eb781fdmMkFbyb2SAGR0vsuFtl9Lw tools/control/src/org/xenoserver/control/Settings.java 1.6 3eb781fdpgi83RpUvQWVccWjsDJK7w tools/control/src/org/xenoserver/control/StringPattern.java 1.7 -3eb781fcffCXkrcWLBxUTOfQFa3Saw tools/control/src/uk/ac/cam/cl/xeno/domctl/Command.java 1.8 -3eb781fcOLcVAcqnZOAikur6sAP0rA tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandDestroy.java 1.9 -3eb781fcQuQVSKxKtp4fBgPOwx7DDw tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandHelp.java 1.10 -3ec41f7czS8UBqCsIi-nmojTBtg_iQ tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandList.java 1.11 -3eb781fcRYdxK1HbjBX7r7VlO5PS0w tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandNew.java 1.12 -3eb781fcbp9IAHTl40CoMavY1FNd_g tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStart.java 1.13 -3eb781fdRXSsyEre7LxCmPJMpB5BaQ tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStop.java 1.14 -3eb781fdX_thm9iHSxQ8vqQ0fL7Ncg tools/control/src/uk/ac/cam/cl/xeno/domctl/Defaults.java 1.15 -3ec41f7cALw7QY_whiAsucUUb006Gg tools/control/src/uk/ac/cam/cl/xeno/domctl/Domain.java 1.16 -3eb781fdTWJr8RPdfuG20IC0CzYL2A tools/control/src/uk/ac/cam/cl/xeno/domctl/InetAddressPattern.java 1.17 -3eb781fdA8LFQEYE2fXg1JDB9OceYA tools/control/src/uk/ac/cam/cl/xeno/domctl/Main.java 1.18 -3eb781fd_CgRvlaIBkJjxUSnuvCuHQ tools/control/src/uk/ac/cam/cl/xeno/domctl/Settings.java 1.19 -3eb781fdFDS4lap1-3ZVDtbKZfpVZA tools/control/src/uk/ac/cam/cl/xeno/domctl/StringPattern.java 1.20 3ec41f7csVaMDEEUMZBotpSftCy0rg tools/control/src/uk/ac/cam/cl/xeno/xenctl/Extent.java 1.21 3ec41f7cO5uUI4qZmJ29jsammoZP4Q tools/control/src/uk/ac/cam/cl/xeno/xenctl/Library.java 1.22 3ec41f7civcv4mQiYK0DeX9Zvsxhrw tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig
2.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/Command.java Thu Jul 03 13:18:21 2003 +0000 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,76 +0,0 @@ 2.4 -package uk.ac.cam.cl.xeno.domctl; 2.5 - 2.6 -public abstract class Command 2.7 -{ 2.8 - public abstract int doCommand(Defaults d, String args[]); 2.9 - public abstract String getName(); 2.10 - public abstract String getUsage(); 2.11 - public abstract String getHelpText(); 2.12 - 2.13 - public String getStringParameter(String args[], char key, String def) 2.14 - { 2.15 - String r = getParameter (args, key); 2.16 - return (r == null) ? def : r; 2.17 - } 2.18 - 2.19 - public int getIntParameter(String args[], char key, int def) 2.20 - { 2.21 - String r = getParameter (args, key); 2.22 - return (r == null) ? def : (Integer.parseInt (r)); 2.23 - } 2.24 - 2.25 - public boolean getFlagParameter(String args[], char key) 2.26 - { 2.27 - String r = getParameter (args, key); 2.28 - return (r == null) ? false : true; 2.29 - } 2.30 - 2.31 - public String getParameter (String args[], char key) 2.32 - { 2.33 - int i; 2.34 - String result = null; 2.35 - for (i = 0; i < args.length; i ++) 2.36 - { 2.37 - if (args[i].startsWith("-" + key)) 2.38 - { 2.39 - if (args[i].length() > 2) 2.40 - { 2.41 - result = args[i].substring(2, args[i].length()); 2.42 - } 2.43 - else 2.44 - { 2.45 - result = ""; 2.46 - } 2.47 - } 2.48 - } 2.49 - return result; 2.50 - } 2.51 - 2.52 - public String reportXIError (String message, String cmd_array[]) 2.53 - { 2.54 - StringBuffer sb = new StringBuffer(); 2.55 - int i; 2.56 - sb.append (message + " using: "); 2.57 - for (i = 0; i < cmd_array.length; i ++) { 2.58 - sb.append (cmd_array[i] + " "); 2.59 - } 2.60 - sb.append (System.getProperty("line.separator")); 2.61 - return sb.toString(); 2.62 - } 2.63 - 2.64 - public String reportError (String message) 2.65 - { 2.66 - return (message); 2.67 - } 2.68 - 2.69 - public String reportCommand (String cmd_array[]) 2.70 - { 2.71 - StringBuffer sb = new StringBuffer(); 2.72 - int i; 2.73 - for (i = 0; i < cmd_array.length; i ++) { 2.74 - sb.append (cmd_array[i] + " "); 2.75 - } 2.76 - sb.append (System.getProperty("line.separator")); 2.77 - return sb.toString(); 2.78 - } 2.79 -}
3.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandDestroy.java Thu Jul 03 13:18:21 2003 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,84 +0,0 @@ 3.4 -package uk.ac.cam.cl.xeno.domctl; 3.5 - 3.6 -import java.io.*; 3.7 -import java.net.*; 3.8 - 3.9 -public class CommandDestroy extends Command 3.10 -{ 3.11 - public int doCommand(Defaults d, String args[]) 3.12 - { 3.13 - int domain_id = getIntParameter(args, 'n', 0); 3.14 - boolean force = getFlagParameter(args, 'f'); 3.15 - int rc = 0; 3.16 - String output; 3.17 - 3.18 - if (domain_id == 0) { 3.19 - System.err.println ("Expected -n<domain_id>"); 3.20 - rc = -1; 3.21 - return rc; 3.22 - } 3.23 - 3.24 - output = executeCommand(d, domain_id, force); 3.25 - if (output != null) 3.26 - { 3.27 - System.err.println(output); 3.28 - return -1; 3.29 - } 3.30 - return 0; 3.31 - } 3.32 - 3.33 - public String 3.34 - executeCommand(Defaults d, 3.35 - int domain_id, 3.36 - boolean force) 3.37 - { 3.38 - Runtime r = Runtime.getRuntime (); 3.39 - String output = null; 3.40 - 3.41 - try 3.42 - { 3.43 - Process destroy_p; 3.44 - String destroy_cmdarray[] = force ? new String[3] : new String[2]; 3.45 - int destroy_rc; 3.46 - int idx = 0; 3.47 - destroy_cmdarray[idx++] = d.XIToolsDir + "xi_destroy"; 3.48 - if (force) { 3.49 - destroy_cmdarray[idx++] = "-f"; 3.50 - } 3.51 - destroy_cmdarray[idx++] = "" + domain_id; 3.52 - 3.53 - if (Settings.TEST) { 3.54 - output += reportCommand (destroy_cmdarray); 3.55 - } else { 3.56 - destroy_p = r.exec (destroy_cmdarray); 3.57 - destroy_rc = destroy_p.waitFor (); 3.58 - 3.59 - if (destroy_rc != 0) { 3.60 - return reportXIError ("Could not destroy domain", destroy_cmdarray); 3.61 - } 3.62 - } 3.63 - } 3.64 - catch (Exception e) 3.65 - { 3.66 - return ("Could not destroy domain (" + e + ")"); 3.67 - } 3.68 - 3.69 - return output; 3.70 - } 3.71 - 3.72 - public String getName() 3.73 - { 3.74 - return "destroy"; 3.75 - } 3.76 - 3.77 - public String getUsage() 3.78 - { 3.79 - return "[-f] [-n<domain_id>]"; 3.80 - } 3.81 - 3.82 - public String getHelpText() 3.83 - { 3.84 - return 3.85 - "Destory the specified domain. -f forcibly destroys it."; 3.86 - } 3.87 -}
4.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandHelp.java Thu Jul 03 13:18:21 2003 +0000 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,58 +0,0 @@ 4.4 -package uk.ac.cam.cl.xeno.domctl; 4.5 - 4.6 -public class CommandHelp extends Command 4.7 -{ 4.8 - public int doCommand(Defaults d, String args[]) 4.9 - { 4.10 - if (args.length <= 1) 4.11 - { 4.12 - System.out.println ("Usage:"); 4.13 - for (int i = 0; i < Main.commands.length; i ++) 4.14 - { 4.15 - String name = Main.commands[i].getName (); 4.16 - String usage = Main.commands[i].getUsage (); 4.17 - while (name.length() < 12) name = name + " "; 4.18 - System.out.println (" " + name + usage); 4.19 - } 4.20 - } 4.21 - else 4.22 - { 4.23 - for (int i = 0; i < Main.commands.length; i ++) 4.24 - { 4.25 - String name = Main.commands[i].getName (); 4.26 - String usage = Main.commands[i].getUsage (); 4.27 - if (name.equals (args[1])) 4.28 - { 4.29 - doHelpFor (Main.commands[i]); 4.30 - break; 4.31 - } 4.32 - } 4.33 - } 4.34 - 4.35 - System.out.println (""); 4.36 - return 0; 4.37 - } 4.38 - 4.39 - public int doHelpFor (Command c) 4.40 - { 4.41 - System.out.println ("domctl " + c.getName() + " " + c.getUsage()); 4.42 - System.out.println (); 4.43 - System.out.println (c.getHelpText ()); 4.44 - return 0; 4.45 - } 4.46 - 4.47 - public String getName() 4.48 - { 4.49 - return "help"; 4.50 - } 4.51 - 4.52 - public String getUsage() 4.53 - { 4.54 - return ""; 4.55 - } 4.56 - 4.57 - public String getHelpText() 4.58 - { 4.59 - return "This message"; 4.60 - } 4.61 -}
5.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandList.java Thu Jul 03 13:18:21 2003 +0000 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,139 +0,0 @@ 5.4 -package uk.ac.cam.cl.xeno.domctl; 5.5 - 5.6 -import java.io.*; 5.7 -import java.net.*; 5.8 -import java.util.Vector; 5.9 -import java.util.StringTokenizer; 5.10 - 5.11 -public class CommandList extends Command 5.12 -{ 5.13 - public int doCommand(Defaults d, String args[]) 5.14 - { 5.15 - Domain [] domains = executeCommand(d); 5.16 - 5.17 - for (int loop = 0; loop < domains.length; loop++) 5.18 - { 5.19 - System.out.println ("id: " + domains[loop].id + 5.20 - " (" + domains[loop].name+ ")"); 5.21 - System.out.println (" processor: " + domains[loop].processor); 5.22 - System.out.println (" has cpu: " + domains[loop].cpu); 5.23 - System.out.println (" state: " + domains[loop].nstate + " " + 5.24 - domains[loop].state); 5.25 - System.out.println (" mcu advance: " + domains[loop].mcu); 5.26 - System.out.println (" total pages: " + domains[loop].pages); 5.27 - } 5.28 - 5.29 - return 0; 5.30 - } 5.31 - 5.32 - public Domain[] 5.33 - executeCommand(Defaults d) 5.34 - { 5.35 - Runtime r = Runtime.getRuntime (); 5.36 - int rc = 0; 5.37 - Vector v = new Vector(); 5.38 - String outline; 5.39 - BufferedReader in; 5.40 - Domain[] array; 5.41 - String output = null; 5.42 - 5.43 - try 5.44 - { 5.45 - Process start_p; 5.46 - String start_cmdarray[] = new String[1]; 5.47 - int start_rc; 5.48 - start_cmdarray[0] = d.XIToolsDir + "xi_list"; 5.49 - 5.50 - if (Settings.TEST) { 5.51 - output += reportCommand (start_cmdarray); 5.52 - } else { 5.53 - start_p = r.exec (start_cmdarray); 5.54 - start_rc = start_p.waitFor (); 5.55 - if (start_rc != 0) { 5.56 - return null; 5.57 - } 5.58 - 5.59 - in = new BufferedReader( 5.60 - new InputStreamReader(start_p.getInputStream())); 5.61 - 5.62 - outline = in.readLine(); 5.63 - while (outline != null) 5.64 - { 5.65 - Domain domain = new Domain(); 5.66 - 5.67 - StringTokenizer st = new StringTokenizer(outline); 5.68 - if (st.hasMoreTokens()) 5.69 - { 5.70 - domain.id = Integer.parseInt(st.nextToken()); 5.71 - } 5.72 - if (st.hasMoreTokens()) 5.73 - { 5.74 - domain.processor = Integer.parseInt(st.nextToken()); 5.75 - } 5.76 - if (st.hasMoreTokens()) 5.77 - { 5.78 - if (st.nextToken().equals("1")) 5.79 - { 5.80 - domain.cpu = true; 5.81 - } 5.82 - else 5.83 - { 5.84 - domain.cpu = false; 5.85 - } 5.86 - } 5.87 - if (st.hasMoreTokens()) 5.88 - { 5.89 - domain.nstate = Integer.parseInt(st.nextToken()); 5.90 - } 5.91 - if (st.hasMoreTokens()) 5.92 - { 5.93 - domain.state = st.nextToken().toLowerCase(); 5.94 - } 5.95 - if (st.hasMoreTokens()) 5.96 - { 5.97 - domain.mcu = Integer.parseInt(st.nextToken()); 5.98 - } 5.99 - if (st.hasMoreTokens()) 5.100 - { 5.101 - domain.pages = Integer.parseInt(st.nextToken()); 5.102 - } 5.103 - if (st.hasMoreTokens()) 5.104 - { 5.105 - domain.name = st.nextToken(); 5.106 - } 5.107 - 5.108 - v.add(domain); 5.109 - 5.110 - outline = in.readLine(); 5.111 - } 5.112 - 5.113 - } 5.114 - } 5.115 - catch (Exception e) 5.116 - { 5.117 - System.err.println ("Could not get domain list(" + e + ")"); 5.118 - e.printStackTrace (); 5.119 - return null; 5.120 - } 5.121 - 5.122 - array = new Domain[v.size()]; 5.123 - v.toArray(array); 5.124 - return array; 5.125 - } 5.126 - 5.127 - public String getName() 5.128 - { 5.129 - return "list"; 5.130 - } 5.131 - 5.132 - public String getUsage() 5.133 - { 5.134 - return ""; 5.135 - } 5.136 - 5.137 - public String getHelpText() 5.138 - { 5.139 - return 5.140 - "List domain information"; 5.141 - } 5.142 -}
6.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandNew.java Thu Jul 03 13:18:21 2003 +0000 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,291 +0,0 @@ 6.4 -package uk.ac.cam.cl.xeno.domctl; 6.5 - 6.6 -import java.io.*; 6.7 -import java.util.zip.*; 6.8 -import java.net.*; 6.9 - 6.10 -public class CommandNew extends Command 6.11 -{ 6.12 - public int doCommand(Defaults d, String args[]) 6.13 - { 6.14 - String name = getStringParameter(args, 'n', d.domainName); 6.15 - int size = getIntParameter(args, 'k', d.domainSizeKB); 6.16 - String image = getStringParameter(args, 'i', d.domainImage); 6.17 - String initrd = getStringParameter (args, 'r', d.domainInitRD); 6.18 - int vifs = getIntParameter(args, 'v', d.domainVIFs); 6.19 - String bargs = getStringParameter (args, 'a', d.args) + " "; 6.20 - String root_dev = getStringParameter (args, 'd', d.rootDevice); 6.21 - String nfs_root_path = getStringParameter (args, 'f', d.NWNFSRoot); 6.22 - String nw_ip = getStringParameter (args, '4', d.NWIP); 6.23 - String nw_gw = getStringParameter (args, 'g', d.NWGW); 6.24 - String nw_mask = getStringParameter (args, 'm', d.NWMask); 6.25 - String nw_nfs_server = getStringParameter (args, 's', d.NWNFSServer); 6.26 - String nw_host = getStringParameter (args, 'h', d.NWHost); 6.27 - String output; 6.28 - 6.29 - d.describe (); 6.30 - 6.31 - output = executeCommand(d, name, size, image, initrd, vifs, 6.32 - bargs, root_dev, nfs_root_path, 6.33 - nw_ip, nw_gw, nw_mask, nw_nfs_server, nw_host); 6.34 - if (output != null) 6.35 - { 6.36 - System.err.println(output); 6.37 - return -1; 6.38 - } 6.39 - return 0; 6.40 - } 6.41 - 6.42 - public String 6.43 - executeCommand(Defaults d, 6.44 - String name, 6.45 - int size, 6.46 - String image, 6.47 - String initrd, 6.48 - int vifs, 6.49 - String bargs, 6.50 - String root_dev, 6.51 - String nfs_root_path, 6.52 - String nw_ip, 6.53 - String nw_gw, 6.54 - String nw_mask, 6.55 - String nw_nfs_server, 6.56 - String nw_host) 6.57 - { 6.58 - Runtime r = Runtime.getRuntime (); 6.59 - int domain_id = -1; 6.60 - BufferedReader br; 6.61 - int idx; 6.62 - int i; 6.63 - File image_tmp = null; 6.64 - File initrd_tmp = null; 6.65 - String domain_ip = ""; 6.66 - String output = ""; 6.67 - 6.68 - String create_cmdarray[] = new String[3]; 6.69 - String build_cmdarray[] = new String[6]; 6.70 - String vifinit_cmdarray[] = new String[4]; 6.71 - 6.72 - try 6.73 - { 6.74 - try 6.75 - { 6.76 - /* Some initial sanity checks */ 6.77 - if (root_dev.equals ("/dev/nfs") && (vifs == 0)) { 6.78 - return reportError ("Cannot use NFS root without VIFs configured"); 6.79 - } 6.80 - 6.81 - /* Uncompress the image and initrd */ 6.82 - if (image.endsWith (".gz")) { 6.83 - image_tmp = getUncompressed ("xen-image-", image); 6.84 - image = image_tmp.getPath (); 6.85 - } 6.86 - 6.87 - if (initrd != null && initrd.endsWith (".gz")) { 6.88 - initrd_tmp = getUncompressed ("xen-initrd-", initrd); 6.89 - initrd = initrd_tmp.getPath (); 6.90 - } 6.91 - 6.92 - /* Create a new empty domain */ 6.93 - Process create_p; 6.94 - int create_rc; 6.95 - create_cmdarray[0] = d.XIToolsDir + "xi_create"; 6.96 - create_cmdarray[1] = "" + size; 6.97 - create_cmdarray[2] = name; 6.98 - if (Settings.TEST) { 6.99 - reportCommand (create_cmdarray); 6.100 - domain_id=1; 6.101 - create_rc=0; 6.102 - } else { 6.103 - create_p = r.exec (create_cmdarray); 6.104 - br = new BufferedReader ( 6.105 - new InputStreamReader (create_p.getInputStream ())); 6.106 - domain_id = Integer.parseInt (br.readLine ()); 6.107 - create_rc = create_p.waitFor (); 6.108 - } 6.109 - 6.110 - if (create_rc != 0) { 6.111 - return reportXIError("Failed to create domain", create_cmdarray); 6.112 - } else if (domain_id > d.MaxDomainNumber) { 6.113 - return reportError ("Cannot configure more than " + 6.114 - d.MaxDomainNumber + " domains"); 6.115 - } 6.116 - 6.117 - /* Set up boot parameters to pass to xi_build. */ 6.118 - if (root_dev.equals ("/dev/nfs")) { 6.119 - if (vifs == 0) { 6.120 - return reportError ("Cannot use NFS root without VIFs configured"); 6.121 - } 6.122 - if (nfs_root_path == null) { 6.123 - return reportError ("No NFS root specified"); 6.124 - } 6.125 - if (nw_nfs_server == null) { 6.126 - return reportError ("No NFS server specified"); 6.127 - } 6.128 - bargs = (bargs + 6.129 - " root=/dev/nfs " + 6.130 - "nfsroot=" + StringPattern.parse(nfs_root_path).resolve(domain_id) + 6.131 - " "); 6.132 - } else { 6.133 - bargs = (bargs + 6.134 - " root=" + StringPattern.parse(root_dev).resolve(domain_id) + 6.135 - " "); 6.136 - 6.137 - } 6.138 - 6.139 - if (vifs > 0) { 6.140 - domain_ip = InetAddressPattern.parse(nw_ip).resolve(domain_id); 6.141 - if (nw_host == null) { 6.142 - try { 6.143 - nw_host = InetAddress.getByName(domain_ip).getHostName(); 6.144 - } catch (UnknownHostException uhe) { 6.145 - nw_host = "" + nw_ip; 6.146 - } 6.147 - 6.148 - } 6.149 - bargs = ("ip=" + domain_ip + 6.150 - ":" + ((nw_nfs_server == null) ? "" : (InetAddressPattern.parse(nw_nfs_server).resolve(domain_id))) + 6.151 - ":" + ((nw_gw == null) ? "" : (InetAddressPattern.parse(nw_gw).resolve(domain_id))) + 6.152 - ":" + ((nw_mask == null) ? "" : InetAddressPattern.parse(nw_mask).resolve(domain_id)) + 6.153 - ":" + ((nw_host == null) ? "" : nw_host) + 6.154 - ":eth0:off " + bargs); 6.155 - } 6.156 - 6.157 - /* Build the domain */ 6.158 - Process build_p; 6.159 - int build_rc; 6.160 - idx = 0; 6.161 - for (i = 0; i < build_cmdarray.length; i ++) 6.162 - build_cmdarray[i] = ""; 6.163 - build_cmdarray[idx ++] = d.XIToolsDir + "xi_build"; 6.164 - build_cmdarray[idx ++] = "" + domain_id; 6.165 - build_cmdarray[idx ++] = "" + image; 6.166 - build_cmdarray[idx ++] = "" + vifs; 6.167 - if (initrd != null) build_cmdarray[idx ++] = "initrd=" + initrd; 6.168 - build_cmdarray[idx ++] = "" + bargs; 6.169 - System.out.println ("Build args: " + bargs); 6.170 - if (Settings.TEST) { 6.171 - reportCommand (build_cmdarray); 6.172 - build_rc = 0; 6.173 - } else { 6.174 - build_p = r.exec (build_cmdarray); 6.175 - build_rc = build_p.waitFor (); 6.176 - } 6.177 - 6.178 - if (build_rc != 0) { 6.179 - return reportXIError ("Failed to build domain", build_cmdarray); 6.180 - } 6.181 - 6.182 - /* Set up the first VIF if necessary */ 6.183 - if (vifs > 0) { 6.184 - Process vifinit_p; 6.185 - int vifinit_rc; 6.186 - vifinit_cmdarray[0] = d.XIToolsDir + "xi_vifinit"; 6.187 - vifinit_cmdarray[1] = "" + domain_id; 6.188 - vifinit_cmdarray[2] = "0"; 6.189 - vifinit_cmdarray[3] = domain_ip; 6.190 - if (Settings.TEST) { 6.191 - reportCommand (vifinit_cmdarray); 6.192 - vifinit_rc = 0; 6.193 - } else { 6.194 - vifinit_p = r.exec (vifinit_cmdarray); 6.195 - vifinit_rc = vifinit_p.waitFor (); 6.196 - } 6.197 - 6.198 - if (vifinit_rc != 0) { 6.199 - return reportXIError ("Failed to initialise VIF 0", vifinit_cmdarray); 6.200 - } 6.201 - } 6.202 - } finally { 6.203 - if (image_tmp != null) image_tmp.delete(); 6.204 - if (initrd_tmp != null) initrd_tmp.delete (); 6.205 - } 6.206 - } 6.207 - catch (Exception e) 6.208 - { 6.209 - e.printStackTrace(); 6.210 - return ("Could not create new domain (" + e + ")"); 6.211 - } 6.212 - 6.213 - output += "\n<b>domain created</b> with arguments:<br>\n"; 6.214 - for (i = 0; i < create_cmdarray.length; i ++) 6.215 - output += create_cmdarray[i] + "<br>"; 6.216 - output += "\n<b>domain built</b> with arguments:<br>\n"; 6.217 - for (i = 0; i < build_cmdarray.length; i ++) 6.218 - output += build_cmdarray[i] + "<br>"; 6.219 - output += "\n<b>VIF 0 initialized</b> with arguments:<br>\n"; 6.220 - for (i = 0; i < vifinit_cmdarray.length; i ++) 6.221 - output += vifinit_cmdarray[i] + "<br>"; 6.222 - 6.223 - return output; 6.224 - } 6.225 - 6.226 - File getUncompressed (String prefix, String original) throws IOException { 6.227 - FileOutputStream fos; 6.228 - GZIPInputStream gis; 6.229 - File result; 6.230 - byte buffer[] = new byte[1024]; 6.231 - int l; 6.232 - 6.233 - result = File.createTempFile (prefix, null); 6.234 - 6.235 - try { 6.236 - fos = new FileOutputStream (result); 6.237 - gis = new GZIPInputStream (new FileInputStream (original)); 6.238 - while ((l = gis.read(buffer, 0, buffer.length)) != -1) { 6.239 - fos.write (buffer, 0, l); 6.240 - } 6.241 - } catch (IOException ioe) { 6.242 - result.delete (); 6.243 - throw ioe; 6.244 - } 6.245 - 6.246 - return result; 6.247 - } 6.248 - 6.249 - public String getName() 6.250 - { 6.251 - return "new"; 6.252 - } 6.253 - 6.254 - public String getUsage() 6.255 - { 6.256 - return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>]"; 6.257 - } 6.258 - 6.259 - public String getHelpText() 6.260 - { 6.261 - return 6.262 - "Create a new domain. Note that most of the parameters will assume\n" + 6.263 - "default values: it should not be necessary to specify them all. See\n" + 6.264 - "domctl.xml for the current default settings.\n" + 6.265 - "\n" + 6.266 - "General command line options:\n" + 6.267 - " -n Domain name domain_name\n" + 6.268 - " -k Domain size (kb) domain_size_kb\n" + 6.269 - " -i Domain image name domain_image\n" + 6.270 - " -v Number of VIFs domain_vifs\n" + 6.271 - " -r InitRD (if required) domain_init_rd\n" + 6.272 - " -d Root device (e.g /dev/nfs, /dev/hda3) root_device\n" + 6.273 - " -a Additional boot parameters\n" + 6.274 - "\n" + 6.275 - "Networking options:\n" + 6.276 - " -f NFS root (if /dev/nfs specified) nw_nfs_root\n" + 6.277 - " -s NFS server nw_nfs_server\n" + 6.278 - " -4 Domain IPv4 address nw_ip\n" + 6.279 - " -g Domain gateway nw_gw\n" + 6.280 - " -m Domain net mask nw_mask\n" + 6.281 - " -h Domain hostname nw_host\n" + 6.282 - "\n" + 6.283 - "Parameters to -d, -f, -4, -g, -h can be specified as patterns into\n" + 6.284 - "which the allocated domain ID will be incorporated. e.g. for\n" + 6.285 - "domain 1 patterns would expand as follows:\n" + 6.286 - "\n" + 6.287 - " /dev/hda+ /dev/hda1\n" + 6.288 - " /dev/hda7+ /dev/hda8\n" + 6.289 - " 128.232.8.50+ 128.232.8.51\n" + 6.290 - "\n" + 6.291 - "Additionally, patterns for -4 -g -m can include an = which is\n" + 6.292 - "expanded to the corresponding setting from the calling domain.\n"; 6.293 - } 6.294 -}
7.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStart.java Thu Jul 03 13:18:21 2003 +0000 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,76 +0,0 @@ 7.4 -package uk.ac.cam.cl.xeno.domctl; 7.5 - 7.6 -import java.io.*; 7.7 -import java.net.*; 7.8 - 7.9 -public class CommandStart extends Command 7.10 -{ 7.11 - public int doCommand(Defaults d, String args[]) 7.12 - { 7.13 - int domain_id = getIntParameter(args, 'n', 0); 7.14 - String output; 7.15 - 7.16 - if (domain_id == 0) { 7.17 - System.err.println ("Expected -n<domain_id>"); 7.18 - return -1; 7.19 - } 7.20 - 7.21 - output = executeCommand(d, domain_id); 7.22 - if (output != null) 7.23 - { 7.24 - System.err.println(output); 7.25 - return -1; 7.26 - } 7.27 - 7.28 - return 0; 7.29 - } 7.30 - 7.31 - 7.32 - public String 7.33 - executeCommand(Defaults d, int domain_id) 7.34 - { 7.35 - Runtime r = Runtime.getRuntime (); 7.36 - String output = null; 7.37 - 7.38 - try 7.39 - { 7.40 - Process start_p; 7.41 - String start_cmdarray[] = new String[2]; 7.42 - int start_rc; 7.43 - start_cmdarray[0] = d.XIToolsDir + "xi_start"; 7.44 - start_cmdarray[1] = "" + domain_id; 7.45 - 7.46 - if (Settings.TEST) { 7.47 - output += reportCommand (start_cmdarray); 7.48 - } else { 7.49 - start_p = r.exec (start_cmdarray); 7.50 - start_rc = start_p.waitFor (); 7.51 - if (start_rc != 0) { 7.52 - return reportXIError ("Could not start domain", start_cmdarray); 7.53 - } 7.54 - } 7.55 - } 7.56 - catch (Exception e) 7.57 - { 7.58 - return ("Could not start new domain (" + e + ")"); 7.59 - } 7.60 - 7.61 - return output; 7.62 - } 7.63 - 7.64 - public String getName() 7.65 - { 7.66 - return "start"; 7.67 - } 7.68 - 7.69 - public String getUsage() 7.70 - { 7.71 - return "[-n<domain_id>]"; 7.72 - } 7.73 - 7.74 - public String getHelpText() 7.75 - { 7.76 - return 7.77 - "Start the specified domain."; 7.78 - } 7.79 -}
8.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/CommandStop.java Thu Jul 03 13:18:21 2003 +0000 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,76 +0,0 @@ 8.4 -package uk.ac.cam.cl.xeno.domctl; 8.5 - 8.6 -import java.io.*; 8.7 -import java.net.*; 8.8 - 8.9 -public class CommandStop extends Command 8.10 -{ 8.11 - public int doCommand(Defaults d, String args[]) 8.12 - { 8.13 - int domain_id = getIntParameter(args, 'n', 0); 8.14 - String output; 8.15 - 8.16 - if (domain_id == 0) { 8.17 - System.err.println ("Expected -n<domain_id>"); 8.18 - return -1; 8.19 - } 8.20 - 8.21 - output = executeCommand(d, domain_id); 8.22 - if (output != null) 8.23 - { 8.24 - System.err.println(output); 8.25 - return -1; 8.26 - } 8.27 - return 0; 8.28 - } 8.29 - 8.30 - public String 8.31 - executeCommand(Defaults d, 8.32 - int domain_id) 8.33 - { 8.34 - Runtime r = Runtime.getRuntime (); 8.35 - String output = null; 8.36 - 8.37 - try 8.38 - { 8.39 - Process stop_p; 8.40 - String stop_cmdarray[] = new String[2]; 8.41 - int stop_rc; 8.42 - stop_cmdarray[0] = d.XIToolsDir + "xi_stop"; 8.43 - stop_cmdarray[1] = "" + domain_id; 8.44 - 8.45 - if (Settings.TEST) { 8.46 - output += reportCommand (stop_cmdarray); 8.47 - } else { 8.48 - stop_p = r.exec (stop_cmdarray); 8.49 - stop_rc = stop_p.waitFor (); 8.50 - 8.51 - if (stop_rc != 0) { 8.52 - return reportXIError ("Could not stop domain", stop_cmdarray); 8.53 - } 8.54 - } 8.55 - } 8.56 - catch (Exception e) 8.57 - { 8.58 - return ("Could not stop new domain (" + e + ")"); 8.59 - } 8.60 - 8.61 - return output; 8.62 - } 8.63 - 8.64 - public String getName() 8.65 - { 8.66 - return "stop"; 8.67 - } 8.68 - 8.69 - public String getUsage() 8.70 - { 8.71 - return "[-n<domain_id>]"; 8.72 - } 8.73 - 8.74 - public String getHelpText() 8.75 - { 8.76 - return 8.77 - "Stop the specified domain."; 8.78 - } 8.79 -}
9.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/Defaults.java Thu Jul 03 13:18:21 2003 +0000 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,196 +0,0 @@ 9.4 -package uk.ac.cam.cl.xeno.domctl; 9.5 - 9.6 -import java.net.InetAddress; 9.7 -import java.io.*; 9.8 -import org.xml.sax.*; 9.9 -import org.xml.sax.helpers.*; 9.10 - 9.11 -/* these values are used in xenctl & domctl, so they need to be public */ 9.12 - 9.13 -public class Defaults 9.14 -{ 9.15 - public String domainName; 9.16 - 9.17 - public int domainSizeKB; 9.18 - public String domainImage; 9.19 - public String domainInitRD; 9.20 - public int domainVIFs; 9.21 - 9.22 - public String rootDevice; 9.23 - 9.24 - public String NWIP; 9.25 - public String NWGW; 9.26 - public String NWMask; 9.27 - public String NWHost; 9.28 - 9.29 - public String NWNFSServer; 9.30 - public String NWNFSRoot; 9.31 - 9.32 - int MaxDomainNumber = Integer.MAX_VALUE; 9.33 - String args = ""; 9.34 - 9.35 - public String XIToolsDir = ""; 9.36 - 9.37 - /***********************************************************************/ 9.38 - 9.39 - public Defaults () 9.40 - { 9.41 - File f = Settings.getDefaultsFile (); 9.42 - 9.43 - if (f == null) 9.44 - { 9.45 - return; 9.46 - } 9.47 - 9.48 - try 9.49 - { 9.50 - XMLReader xr = new org.apache.crimson.parser.XMLReaderImpl(); 9.51 - Handler handler = new Handler (); 9.52 - xr.setContentHandler (handler); 9.53 - xr.setErrorHandler (handler); 9.54 - xr.parse (new InputSource(new FileReader (f))); 9.55 - } 9.56 - catch (Exception e) 9.57 - { 9.58 - System.err.println ("Could not read defaults file " + f + 9.59 - "\nException: " + e); 9.60 - e.printStackTrace(); 9.61 - return; 9.62 - } 9.63 - } 9.64 - 9.65 - public void describe () { 9.66 - System.out.println ("Domain defaults:"); 9.67 - System.out.println (" name " + domainName); 9.68 - System.out.println (" size " + domainSizeKB); 9.69 - System.out.println (" vifs " + domainVIFs); 9.70 - System.out.println (" domainImage " + domainImage); 9.71 - System.out.println (" domainInitRD " + domainInitRD); 9.72 - System.out.println (" rootDevice " + rootDevice); 9.73 - System.out.println (" NWIP " + NWIP); 9.74 - System.out.println (" NWGW " + NWGW); 9.75 - System.out.println (" NWMask " + NWMask); 9.76 - System.out.println (" MaxDomainNumber " + MaxDomainNumber); 9.77 - System.out.println (" NWNFSServer " + NWNFSServer); 9.78 - System.out.println (" NWNFSRoot " + NWNFSRoot); 9.79 - System.out.println (" XIToolsDir " + XIToolsDir); 9.80 - System.out.println (" args " + args); 9.81 - } 9.82 - 9.83 - /***********************************************************************/ 9.84 - 9.85 - class Handler extends DefaultHandler 9.86 - { 9.87 - boolean inDomctlDefaults; 9.88 - String lastName; 9.89 - 9.90 - public void startDocument () 9.91 - { 9.92 - } 9.93 - 9.94 - public void endDocument () 9.95 - { 9.96 - } 9.97 - 9.98 - public void startElement (String uri, String name, 9.99 - String qname, Attributes atts) 9.100 - { 9.101 - if (qname.equals ("domctl_defaults")) { 9.102 - inDomctlDefaults = true; 9.103 - } else { 9.104 - lastName = qname; 9.105 - } 9.106 - } 9.107 - 9.108 - public void endElement (String uri, String name, String qname) 9.109 - { 9.110 - lastName = ""; 9.111 - if (qname.equals ("domctl_defaults")) { 9.112 - inDomctlDefaults = false; 9.113 - } 9.114 - } 9.115 - 9.116 - public void characters (char ch[], int start, int length) 9.117 - { 9.118 - String s = new String (ch, start, length); 9.119 - if (lastName != null) 9.120 - { 9.121 - if (lastName.equals ("domain_size_kb")) { 9.122 - domainSizeKB = Integer.parseInt (s); 9.123 - } else if (lastName.equals ("domain_image")) { 9.124 - domainImage = s; 9.125 - } else if (lastName.equals ("domain_name")) { 9.126 - domainName = s; 9.127 - } else if (lastName.equals ("domain_init_rd")) { 9.128 - domainInitRD = s; 9.129 - } else if (lastName.equals ("domain_vifs")) { 9.130 - domainVIFs = Integer.parseInt (s); 9.131 - } else if (lastName.equals ("root_device")) { 9.132 - rootDevice = s; 9.133 - } else if (lastName.equals ("nw_ip")) { 9.134 - NWIP = expandDefault (s, runCommand(XIToolsDir+Settings.XI_HELPER+" ip").trim()); 9.135 - } else if (lastName.equals ("nw_gw")) { 9.136 - NWGW = expandDefault (s, runCommand(XIToolsDir+Settings.XI_HELPER+" route").trim()); 9.137 - } else if (lastName.equals ("nw_mask")) { 9.138 - NWMask = expandDefault (s, runCommand(XIToolsDir+Settings.XI_HELPER+" mask").trim()); 9.139 - } else if (lastName.equals ("nw_host")) { 9.140 - NWHost = s; 9.141 - } else if (lastName.equals ("nw_nfs_server")) { 9.142 - NWNFSServer = s; 9.143 - } else if (lastName.equals ("nw_nfs_root")) { 9.144 - NWNFSRoot = s; 9.145 - } else if (lastName.equals ("args")) { 9.146 - args = s; 9.147 - } else if (lastName.equals ("max_domain_number")) { 9.148 - MaxDomainNumber = Integer.parseInt(s); 9.149 - } else if (lastName.equals ("xi_tools_dir")) { 9.150 - XIToolsDir = s; 9.151 - } 9.152 - } 9.153 - } 9.154 - } 9.155 - 9.156 - public String expandDefault (String supplied, String self) 9.157 - { 9.158 - if (supplied.startsWith ("=")) { 9.159 - if (supplied.length() > 1) { 9.160 - return self + supplied.substring (1, supplied.length()); 9.161 - } else { 9.162 - return self; 9.163 - } 9.164 - } else { 9.165 - return supplied; 9.166 - } 9.167 - } 9.168 - 9.169 - 9.170 - public String 9.171 - runCommand (String command) 9.172 - { 9.173 - Runtime runtime = Runtime.getRuntime(); 9.174 - String outline; 9.175 - StringBuffer output = new StringBuffer(); 9.176 - 9.177 - try 9.178 - { 9.179 - Process process = runtime.exec(command); 9.180 - BufferedReader in = new BufferedReader( 9.181 - new InputStreamReader(process.getInputStream())); 9.182 - 9.183 - outline = in.readLine(); 9.184 - while (outline != null) 9.185 - { 9.186 - output.append("\n" + outline); 9.187 - outline = in.readLine(); 9.188 - } 9.189 - } 9.190 - catch (IOException e) 9.191 - { 9.192 - return e.toString(); 9.193 - } 9.194 - 9.195 - return output.toString(); 9.196 - } 9.197 - 9.198 - 9.199 -}
10.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/Domain.java Thu Jul 03 13:18:21 2003 +0000 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,27 +0,0 @@ 10.4 -package uk.ac.cam.cl.xeno.domctl; 10.5 - 10.6 -public class 10.7 -Domain 10.8 -{ 10.9 - public int id; /* domain id */ 10.10 - public int processor; /* processor */ 10.11 - public boolean cpu; /* has cpu */ 10.12 - public int nstate; /* state */ 10.13 - public String state; /* running, interruptable, uninterruptable, 10.14 - wait, suspended, dying */ 10.15 - public int mcu; /* mcu advances */ 10.16 - public int pages; /* total pages */ 10.17 - public String name; /* name */ 10.18 - 10.19 - Domain() 10.20 - { 10.21 - id = 0; 10.22 - processor = 0; 10.23 - cpu = false; 10.24 - nstate = 0; 10.25 - state = ""; 10.26 - mcu = 0; 10.27 - pages = 0; 10.28 - name = "none"; 10.29 - } 10.30 -}
11.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/InetAddressPattern.java Thu Jul 03 13:18:21 2003 +0000 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,60 +0,0 @@ 11.4 -package uk.ac.cam.cl.xeno.domctl; 11.5 - 11.6 -import java.net.*; 11.7 - 11.8 -public class InetAddressPattern 11.9 -{ 11.10 - InetAddress base; 11.11 - boolean addDom; 11.12 - 11.13 - static InetAddressPattern parse (String t) 11.14 - { 11.15 - InetAddressPattern result = new InetAddressPattern (); 11.16 - char[] ca = t.toCharArray (); 11.17 - int idx = 0; 11.18 - int len = ca.length; 11.19 - 11.20 - try { 11.21 - if (len == 0) { 11.22 - result.base = null; 11.23 - result.addDom = false; 11.24 - } else if (ca[len - 1] == '+') { 11.25 - result.base = InetAddress.getByName(t.substring(0, len - 1)); 11.26 - result.addDom = true; 11.27 - } else { 11.28 - result.base = InetAddress.getByName(t); 11.29 - result.addDom = false; 11.30 - } 11.31 - } catch (UnknownHostException uhe) { 11.32 - result.base = null; 11.33 - result.addDom = false; 11.34 - } 11.35 - 11.36 - return result; 11.37 - } 11.38 - 11.39 - public String resolve (int domain_id) { 11.40 - byte b[] = base.getAddress (); 11.41 - if (addDom) { 11.42 - if (((int)b[3]) + domain_id > 255) { 11.43 - if (((int)b[2]) + domain_id > 255) { 11.44 - if (((int)b[1]) + domain_id > 255) { 11.45 - b[0] ++; 11.46 - } 11.47 - b[1] ++; 11.48 - } 11.49 - b[2] ++; 11.50 - } 11.51 - b[3] += domain_id; 11.52 - } 11.53 - return "" + 11.54 - (b[0] + (b[0] < 0 ? 256 : 0)) + "." + 11.55 - (b[1] + (b[1] < 0 ? 256 : 0)) + "." + 11.56 - (b[2] + (b[2] < 0 ? 256 : 0)) + "." + 11.57 - (b[3] + (b[3] < 0 ? 256 : 0)); 11.58 - } 11.59 - 11.60 - public String toString () { 11.61 - return "[" + base + (addDom ? "+dom_id" : "") + "]"; 11.62 - } 11.63 -}
12.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/Main.java Thu Jul 03 13:18:21 2003 +0000 12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 12.3 @@ -1,40 +0,0 @@ 12.4 -package uk.ac.cam.cl.xeno.domctl; 12.5 - 12.6 -public class Main 12.7 -{ 12.8 - static CommandHelp help = new CommandHelp (); 12.9 - static CommandNew newdom = new CommandNew (); 12.10 - static CommandStart start = new CommandStart (); 12.11 - static CommandStop stop = new CommandStop (); 12.12 - static CommandDestroy destroy = new CommandDestroy (); 12.13 - static CommandList list = new CommandList (); 12.14 - static Command commands[] = { help, newdom, start, stop, destroy, list }; 12.15 - 12.16 - public static void main (String[] args) 12.17 - { 12.18 - Defaults d = new Defaults (); 12.19 - int ec = -1; 12.20 - 12.21 - if (args.length == 0) { 12.22 - ec = help.doCommand (d, args); 12.23 - } else { 12.24 - String c = args[0]; 12.25 - int i; 12.26 - for (i = 0; i < commands.length; i ++) { 12.27 - if (commands[i].getName().equals(c)) { 12.28 - if (commands[i].getFlagParameter (args, '?')) { 12.29 - ec = help.doHelpFor (commands[i]); 12.30 - } else { 12.31 - ec = commands[i].doCommand (d, args); 12.32 - } 12.33 - break; 12.34 - } 12.35 - } 12.36 - if (i == commands.length) { 12.37 - System.out.println ("Unknown command " + c); 12.38 - } 12.39 - } 12.40 - 12.41 - System.exit (ec); 12.42 - } 12.43 -}
13.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/Settings.java Thu Jul 03 13:18:21 2003 +0000 13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 13.3 @@ -1,38 +0,0 @@ 13.4 -package uk.ac.cam.cl.xeno.domctl; 13.5 - 13.6 -import java.util.*; 13.7 -import java.io.*; 13.8 -import org.xml.sax.*; 13.9 - 13.10 -public final class Settings 13.11 -{ 13.12 - public static final String DEFAULTS_FILE = System.getProperty ("DEFAULTS_FILE", "domctl.xml"); 13.13 - public static final String DEFAULTS_PATH = System.getProperty ("DEFAULTS_PATH", ".:/etc:/var/lib/xen"); 13.14 - public static final String LOCAL_IP = System.getProperty ("LOCAL_IP"); 13.15 - public static final String LOCAL_MASK = System.getProperty ("LOCAL_MASK"); 13.16 - public static final String LOCAL_GW = System.getProperty ("LOCAL_ROUTE"); 13.17 - public static final boolean TEST = (System.getProperty ("TEST") != null); 13.18 - public static final String XI_HELPER = System.getProperty ("XI_HELPER", "xi_helper"); 13.19 - 13.20 - 13.21 - public static File getDefaultsFile() { 13.22 - StringTokenizer tok = new StringTokenizer (DEFAULTS_PATH, ":"); 13.23 - File result = null; 13.24 - File probe; 13.25 - 13.26 - while (tok.hasMoreTokens ()) { 13.27 - String probe_dir = tok.nextToken (); 13.28 - probe = new File (probe_dir, DEFAULTS_FILE); 13.29 - if (probe.exists ()) { 13.30 - result = probe; 13.31 - break; 13.32 - } 13.33 - } 13.34 - 13.35 - if (result == null) { 13.36 - System.err.println ("Could not find " + DEFAULTS_FILE + " in path " + DEFAULTS_PATH); 13.37 - } 13.38 - 13.39 - return result; 13.40 - } 13.41 -}
14.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/domctl/StringPattern.java Thu Jul 03 13:18:21 2003 +0000 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,59 +0,0 @@ 14.4 -package uk.ac.cam.cl.xeno.domctl; 14.5 - 14.6 -public class StringPattern 14.7 -{ 14.8 - String base; 14.9 - int bn; 14.10 - boolean addDom; 14.11 - boolean appendDom; 14.12 - 14.13 - static StringPattern parse (String t) 14.14 - { 14.15 - StringPattern result = new StringPattern (); 14.16 - char[] ca = t.toCharArray (); 14.17 - int idx = 0; 14.18 - int len = ca.length; 14.19 - 14.20 - if (len == 0) { 14.21 - result.base = ""; 14.22 - result.bn = 0; 14.23 - result.addDom = false; 14.24 - } else if (ca[len - 1] == '+') { 14.25 - idx = len - 2; 14.26 - if ((idx >= 0) && (ca[idx] >= '0') && (ca[idx] <= '9')) { 14.27 - while ((idx >= 0) && (ca[idx] >= '0') && (ca[idx] <= '9')) { 14.28 - idx --; 14.29 - } 14.30 - result.base = t.substring(0, idx + 1); 14.31 - result.bn = Integer.parseInt (t.substring (idx + 1, len - 1)); 14.32 - result.addDom = true; 14.33 - } else { 14.34 - result.base = t.substring(0, len - 1); 14.35 - result.appendDom = true; 14.36 - } 14.37 - } else { 14.38 - result.base = t; 14.39 - } 14.40 - 14.41 - return result; 14.42 - } 14.43 - 14.44 - public String resolve (int domain_id) { 14.45 - if (addDom) { 14.46 - return base + (bn + domain_id); 14.47 - } else if (appendDom) { 14.48 - return base + domain_id; 14.49 - } else { 14.50 - return base; 14.51 - } 14.52 - } 14.53 - 14.54 - public String toString () { 14.55 - return ("[" + 14.56 - base + 14.57 - (addDom ? "+" + bn : "") + 14.58 - ((addDom || appendDom) ? "+ID" : "") + 14.59 - "]"); 14.60 - } 14.61 - 14.62 -}