[Esbox-commits] r2193 - in branches/work_Ed: org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware

eswartz at garage.maemo.org eswartz at garage.maemo.org
Thu Sep 17 23:34:06 EEST 2009


Author: eswartz
Date: 2009-09-17 23:34:03 +0300 (Thu, 17 Sep 2009)
New Revision: 2193

Modified:
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java
Log:
Don't use NAT vmnet8 address for VMware.

Also, provide immediate launch progress dialogs and make them minimizable and non-modal.

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-09-17 16:39:38 UTC (rev 2192)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-09-17 20:34:03 UTC (rev 2193)
@@ -138,10 +138,13 @@
 		if (!WorkspaceUtils.isJUnitRunning()) {
 			Display.getDefault().asyncExec(new Runnable() {
 				public void run() {
+					// wait 15 seconds before showing the dialog,
+					// just in case the configuration is so broken that
+					// the VM or engine cannot even start. 
 					monitorDialog[0] = new SlowVirtualMachineLaunchMonitorDialog(
 							machine, BaseVirtualMachineController.this, 
 							WorkbenchUtils.getSafeShell(),
-							1000 * 60);
+							1000 * 15);
 					launchMonitor.setProgressPart(monitorDialog[0].getProgressPart());
 					launchMonitor.beginTask("", IProgressMonitor.UNKNOWN);
 				}

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java	2009-09-17 16:39:38 UTC (rev 2192)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java	2009-09-17 20:34:03 UTC (rev 2193)
@@ -61,7 +61,7 @@
 			int defaultIndex) {
 		super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
 				dialogImageType, dialogButtonLabels, defaultIndex);
-		setShellStyle(getShellStyle() | SWT.RESIZE);
+		setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MIN);
 		this.helpMessage = helpMessage;
 		this.lookHereProviders = providers;
 	}

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java	2009-09-17 16:39:38 UTC (rev 2192)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java	2009-09-17 20:34:03 UTC (rev 2193)
@@ -37,9 +37,8 @@
 				helpMessage,
 				providers,
 				new String[] { "Launch", IDialogConstants.CANCEL_LABEL }, 0);
-	
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()
 	 */

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java	2009-09-17 16:39:38 UTC (rev 2192)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java	2009-09-17 20:34:03 UTC (rev 2193)
@@ -47,7 +47,7 @@
 			IMachine machine_, IMachineController machineController, Shell parent,
 			int longOperationTime) {
 		super(parent, "Launching Virtual Machine", null,
-				"Still waiting for " + machine_.getName() + " to fully boot...",
+				"Waiting for " + machine_.getName() + " to boot up...",
 				MessageDialog.INFORMATION,
 				getHelpMessage(machineController),
 				machineController.createLookHereProviders(),
@@ -55,9 +55,17 @@
 				0);
 		this.machine = machine_;
 		
-		setShellStyle(getShellStyle() | SWT.RESIZE);
+		setShellStyle(getShellStyle() & ~(SWT.APPLICATION_MODAL + SWT.SYSTEM_MODAL));
 		setBlockOnOpen(false);
 		
+		// create immediately but do not open until later
+		Display.getDefault().syncExec(new Runnable() {
+			public void run() {
+				create();
+				getButton(IDialogConstants.OK_ID).setText(IDialogConstants.CLOSE_LABEL);
+			}
+		});
+		
 		timer = new Timer(true);
 		timer.schedule(new TimerTask() {
 
@@ -90,14 +98,6 @@
 			
 		}, longOperationTime);
 		
-		// create immediately but do not open until later
-		Display.getDefault().syncExec(new Runnable() {
-			public void run() {
-				create();
-				getButton(IDialogConstants.OK_ID).setText(IDialogConstants.CLOSE_LABEL);
-			}
-		});
-				
 	}
 	
 	

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java	2009-09-17 16:39:38 UTC (rev 2192)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java	2009-09-17 20:34:03 UTC (rev 2193)
@@ -121,7 +121,7 @@
 			networkType = VMwareUtils.getNetworkConfig(config);
 			if (networkType.equals(VMwareUtils.NETWORK_CONFIG_NAT)) {
 				vmnet = "vmnet8";
-				reporter.logInfo("Configuring for NAT networking.");
+				reporter.logInfo("Configuring for NAT networking on " + vmnet + ".");
 				isNAT = true;
 			} 
 			else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_HOSTONLY)) {
@@ -158,16 +158,46 @@
 				reporter.log(Activator.createStatus(IStatus.ERROR,
 						"Could not find the " + vmnet + " interface.  The VMX file may be referencing a missing, misconfigured, or unknown interface."));
 			}
-			else if (!canAccessAddress(hostAddr)) {
-				reporter.log(Activator.createStatus(IStatus.ERROR,
-						"Could not access the address of the " + vmnet + " interface."));
+			else if (isNAT && HostUtils.isWindows()) {
+				// supposedly, VMware creates a network interface where you can access the guest
+				// from the host... but it almost never works in Windows.
+				// http://communities.vmware.com/thread/153905;jsessionid=718043D50BAB7B5E4614ABBDBD0ECCF2?start=0&tstart=0
 				
-				if (HostUtils.isWindows()) {
-					reporter.log(Activator.createStatus(IStatus.ERROR,
-							"You may need to go to Control Panel > Network Connections and edit the Properties of this interface (VMware Virtual Ethernet Adapter for " + vmnet + ") and enable the 'Internet Protocol (TCP/IP)' item."));
+				vmnet = null;
+
+				// Bah, let's not bother boring the user
+				
+				/*
+				byte[] targetAddr = hostAddr.getAddress();
+				targetAddr[3] = (byte) 128;
+				InetAddress expectedTarget;
+				try {
+					expectedTarget = InetAddress.getByAddress(targetAddr);
+				} catch (UnknownHostException e) {
+					// unlikely
+					expectedTarget = hostAddr;
 				}
+				String expectedAddr = expectedTarget.getHostAddress();
 				reporter.log(Activator.createStatus(IStatus.WARNING,
-						"Configuring for an unknown network."));
+							"We could try to use the " + vmnet + " interface to connect to the guest from the host, "+
+							"but it's a known issue that is unreliable in Windows: "+
+							"<http://communities.vmware.com/thread/153905;jsessionid=718043D50BAB7B5E4614ABBDBD0ECCF2?start=0&tstart=0>.\n \n"+
+							"If you want to try, go to Control Panel > Network Connections and edit the Properties of this interface "+
+							" (VMware Virtual Ethernet Adapter for " + vmnet + ") and enable the 'Internet Protocol (TCP/IP)' item.\n \n"+
+							"Launch the machine and see if you can ping the VMnet8 address that the machine is using (e.g. " + expectedAddr +").  " +
+							"If that works, feel free to use that Target Address, and a Target SSH port of 22.\n \n"+
+							"Since this is unreliable, though, I will recommend the NAT configuration using virtual ports.  " +
+							"This assumes you have a Port Forwarding entry for SSH under " +
+							"Edit > Virtual Network Editor... > NAT > Edit > Port Forwarding... and added an entry with Host Port = 2222 " +
+							"and Virtual Machine IP Address = " + expectedAddr + "."));
+				*/
+				
+			} else if (!canAccessAddress(hostAddr)) {
+				reporter.log(Activator.createStatus(IStatus.WARNING,
+						"Could not access the address of the " + vmnet + " interface."));
+				
+				reporter.log(Activator.createStatus(IStatus.WARNING,
+						"Not using vmnet address to access machine."));
 				vmnet = null;
 			}
 		}
@@ -186,7 +216,7 @@
 	 */
 	private boolean canAccessAddress(InetAddress hostAddr) {
 		try {
-			return hostAddr.isReachable(1000);
+			return hostAddr.isReachable(2500);
 		} catch (IOException e) {
 			return false;
 		}
@@ -253,53 +283,61 @@
 		
 		String port = null;
 
-		// the host is the default in non-NAT, non-bridged modes
 		try {
 			hostAddr = InetAddress.getLocalHost();
 			commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
 			
 			reporter.logInfo("Set Host Address to LAN address " + hostAddr);
 
-			// Dunno target -- it's DHCP.  Reset the low byte if it's not on the same subnet.
-			targetAddr = commonPrefPage.getSSHTargetAddr().getAddress();
-			if (targetAddr instanceof Inet4Address) {
-				IPNetmaskFilter filter;
+			if (isNAT) {
 				try {
-					filter = new IPNetmaskFilter(hostAddr);
-					if (!filter.accept(targetAddr))
-						targetAddr = null;
-				} catch (MicaException e) {
-					targetAddr = null;
+					targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
+					
+					port = commonPrefPage.getSSHTargetPort().getStringValue();
+					if (port == null || port.length() == 0 || port.equals("22")) {
+						port = "2222";
+						reporter.logInfo("Set Target Port to the NAT default (" + port + ")");
+						commonPrefPage.getSSHTargetPort().setStringValue(port);
+					}
+				} catch (UnknownHostException e) {
+					// unlikely...
+					// guess the target address as being on the same subnet as the host
+					targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
 				}
-			}
+			} 
 			
 			if (targetAddr == null) {
-				if (isNAT) {
+				// Dunno target -- it's DHCP.  Reset the low byte if it's not on the same subnet.
+				targetAddr = commonPrefPage.getSSHTargetAddr().getAddress();
+				if (targetAddr instanceof Inet4Address) {
+					IPNetmaskFilter filter;
 					try {
-						targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
-						
-						port = "2222";
-						reporter.logInfo("Set Target Port to the NAT default (2222)");
-						commonPrefPage.getSSHTargetPort().setStringValue("2222");
-					} catch (UnknownHostException e) {
-						// unlikely...
-						// guess the target address as being on the same subnet as the host
-						targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
+						filter = new IPNetmaskFilter(hostAddr);
+						if (!filter.accept(targetAddr))
+							targetAddr = null;
+					} catch (MicaException e) {
+						targetAddr = null;
 					}
-				} else {
-					targetAddr = InetAddress.getLocalHost();
-					if (targetAddr instanceof Inet4Address) {
-						byte[] addrBytes = targetAddr.getAddress();
-						addrBytes[3] = 0;
-						targetAddr = InetAddress.getByAddress(addrBytes);
-					}
 				}
-				
-				commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
-				reporter.logInfo("Set Target Address to LAN address " + targetAddr + " (please edit)");
 			}
-			reporter.log(Activator.createStatus(IStatus.WARNING, 
+			
+			if (targetAddr == null) {
+				targetAddr = InetAddress.getLocalHost();
+				if (targetAddr instanceof Inet4Address) {
+					byte[] addrBytes = targetAddr.getAddress();
+					addrBytes[3] = 0;
+					targetAddr = InetAddress.getByAddress(addrBytes);
+				}
+			}
+			
+			commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
+			reporter.logInfo("Set Target Address to " + targetAddr +
+					(isNAT ? "" : " (please edit)"));
+			
+			if (!isNAT) {
+				reporter.log(Activator.createStatus(IStatus.WARNING, 
 					"You will need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
+			}
 			
 			if (port == null) {
 				port = "22";



More information about the Esbox-commits mailing list