示例#1
0
 static void testEnumeration(VirtualBoxManager mgr, IVirtualBox vbox) {
   List<IMachine> machs = vbox.getMachines();
   for (IMachine m : machs) {
     String name;
     Long ram = 0L;
     boolean hwvirtEnabled = false, hwvirtNestedPaging = false;
     boolean paeEnabled = false;
     boolean inaccessible = false;
     try {
       name = m.getName();
       ram = m.getMemorySize();
       hwvirtEnabled = m.getHWVirtExProperty(HWVirtExPropertyType.Enabled);
       hwvirtNestedPaging = m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging);
       paeEnabled = m.getCPUProperty(CPUPropertyType.PAE);
       String osType = m.getOSTypeId();
       IGuestOSType foo = vbox.getGuestOSType(osType);
     } catch (VBoxException e) {
       name = "<inaccessible>";
       inaccessible = true;
     }
     System.out.println("VM name: " + name);
     if (!inaccessible) {
       System.out.println(
           " RAM size: "
               + ram
               + "MB"
               + ", HWVirt: "
               + hwvirtEnabled
               + ", Nested Paging: "
               + hwvirtNestedPaging
               + ", PAE: "
               + paeEnabled);
     }
   }
 }
示例#2
0
  static void testStart(VirtualBoxManager mgr, IVirtualBox vbox) {
    IMachine m = vbox.getMachines().get(0);
    String name = m.getName();
    System.out.println("\nAttempting to start VM '" + name + "'");

    ISession session = mgr.getSessionObject();
    IProgress p = m.launchVMProcess(session, "gui", "");
    progressBar(mgr, p, 10000);
    session.unlockMachine();
  }
示例#3
0
 static void testReadLog(VirtualBoxManager mgr, IVirtualBox vbox) {
   IMachine m = vbox.getMachines().get(0);
   long logNo = 0;
   long off = 0;
   long size = 16 * 1024;
   while (true) {
     byte[] buf = m.readLog(logNo, off, size);
     if (buf.length == 0) break;
     System.out.print(new String(buf));
     off += buf.length;
   }
 }