Example #1
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();
  }
Example #2
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;
   }
 }
Example #3
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);
     }
   }
 }
Example #4
0
  static void testMultiServer() {
    VirtualBoxManager mgr1 = VirtualBoxManager.createInstance(null);
    VirtualBoxManager mgr2 = VirtualBoxManager.createInstance(null);

    try {
      mgr1.connect("http://i7:18083", "", "");
      mgr2.connect("http://main:18083", "", "");

      IMachine m1 = mgr1.getVBox().getMachines().get(0);
      IMachine m2 = mgr2.getVBox().getMachines().get(0);
      String name1 = m1.getName();
      String name2 = m2.getName();
      ISession session1 = mgr1.getSessionObject();
      ISession session2 = mgr2.getSessionObject();
      IProgress p1 = m1.launchVMProcess(session1, "gui", "");
      IProgress p2 = m2.launchVMProcess(session2, "gui", "");
      progressBar(mgr1, p1, 10000);
      progressBar(mgr2, p2, 10000);
      session1.unlockMachine();
      session2.unlockMachine();
    } finally {
      mgr1.cleanup();
      mgr2.cleanup();
    }
  }