More Seamless then seamless ...

This is for discussing general topics about how to use VirtualBox.
Post Reply
sfranzyshen
Posts: 8
Joined: 9. Mar 2009, 07:08

More Seamless then seamless ...

Post by sfranzyshen »

Using Virtualization to support propriety software within the Linux User Desktop Environment.

VirtualBox (and other Hypervisor) permit a guest OS to operate simultaneously within the existing host OS. However, the primary goal is to provide compatibility on the OS level and not on an application level. VirtualBox offers “seamless mode” that allows for merging of the host and guest desktops together (sort of) … but falls short of integrating into the host user desktop environment. (In fairness, they don't even try)

Here is a method of using “VirtualBox” to start a VM with a minimalistic filesystem that has the proprietary application installed in it. Allowing you to create menu entries or desktop icons within your host user desktop environment to start the application. Seamlessly displaying and functioning within the host user desktop environment … without using the guest UI.

For the purpose of this paper I will be working from a Ubuntu 10.10 host OS and merging a Windows XP proprietary application into my gnome user desktop environment.

Video: http://www.youtube.com/watch?v=5KJJmmrHlg0]

Prerequisites:
Host OS with VirtualBox installed and working
Guest OS with additions installed and working

First, we need to setup the guest OS to be used as a embedded VM. To do this we need to setup auto login. This will allow our WinXP to just start into a desktop. If you used a user name and password, you will need to remember these credentials for latter use. If you have setup using blank passwords, you will need to read this.
Also, to use accounts without or with an empty password, the guest's group policy must be changed. To do so, open the group policy editor on the command line by typing gpedit.msc, open the key Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options and change the value of Accounts: Limit local account use of blank passwords to console logon only to Disabled.
To make everything nice and clean, there are three little utilities for the XP guest OS. The first two make the taskbar and progman invisible. The third creates a small window to fix a problem with seamless window mode and the background getting refreshed correctly. Each of these programs are created using Autoit3 and compiled. Put them into the c:\windows\system32 folder so that they are in the path. Here are the scripts;

taskbar.au3:

Code: Select all

; Check the state of the taskbar
$state = WinGetState("[CLASS:Shell_TrayWnd]", "")

; Is the taskbar "visible"?
If BitAnd($state, 2) Then
    WinSetState("[CLASS:Shell_TrayWnd]", "", @SW_HIDE)
Else
    WinSetState("[CLASS:Shell_TrayWnd]", "", @SW_SHOW)
EndIf
hidepman.au3:

Code: Select all

; Check the state of the progman
$state = WinGetState("[CLASS:Progman]", "")

; Is the progman "visible"?
If BitAnd($state, 2) Then
    WinSetState("[CLASS:Progman]", "", @SW_HIDE)
Else
    WinSetState("[CLASS:Progman]", "", @SW_SHOW)
EndIf
seamless.au3:

Code: Select all

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Seamless = GUICreate("Seamless", 1, 1, 0, 26, $WS_POPUP, 0)
GUISetState(@SW_SHOW)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
Wend
After these utilities have been installed into the guest OS, create links to them into the startup folder so that they get executed each time the VM starts.

Finally, we want to close the guest OS while in the seamless window mode. In the guest OS, switch into seamless window mode. Then use the start->shutdown to shutdown the VM. You will also want to disable the mini toolbar. In VM Settings->General->Advanced->Mini Toolbar find “show in fullscreen/seamless” and uncheck it. Restart the VM … after it restarts everything should disappear and only show you the Linux desktop.

Next, we need to create shell scripts on the host OS to start our software on the VM (since we have hidden the windows user interface.) Here is an example for the notepad.exe application. (~user is you user folder)

~user/bin/notepad:

Code: Select all

#/bin/sh 
VBoxManage guestcontrol execute WinXP "notepad.exe" --username Administrator
As you can see we use the “VBoxManage guestcontrol execute” feature to call executables within our VM. If you used a different set of credentials when setting up your guest OS, you will need to change the username and password accordingly. After scripts have been created for our applications, we can create menu entries or desktop icons that execute our scripts. The VMM should get started each time the x session starts. This can be done in gnome using the System->Preferences->Startup Applications. I recommend something like; VBoxManage startvm WinXP See this post about starting VB silentlyhttp://forums.virtualbox.org/viewtopic. ... 53#p171353

The biggest drawback to this setup is if you minimize the guest application … it is invisible and unaccessible. As a work around, I use autoit3 (in the guest OS) to prevent the guest application from being minimized. You can also create a shell script for the taskbar.exe utility to expose the windows taskbar when needed.

~user/bin/taskbar:

Code: Select all

#/bin/sh 
VBoxManage guestcontrol execute WinXP "taskbar.exe" --username Administrator
Ideally, I would like to see the guest additions to be more aggressive at integrating (merging) the guest OS into the host OS user environment. Making it a true seamless “OS” mode. Guess things are coming ...
ichat
Posts: 2
Joined: 20. Jan 2011, 01:16
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: windows 7, Debian, Slackware, *bsd, other

Re: More Seamless then seamless ...

Post by ichat »

In general i like the idea you put in here, in a way its a reasonable solution.

However there might be easier ways to get this one,

For instance we could replace the windows gui shell (desktop) with an alternative like aston, litestep or other. in the end i would prefere to be able to 'see' the os's taskbar, and a launch bar.

Since its already nearly impossible to script a filehandler to (for example) open a psd file from /home/username/example.psd (in ubuntu) with photohop (on windows xp).

there is really not mutch of a reason why you wouldn't just use a 'aplication' launcher inside your vm. (for a example i refer to the quicklauncher of OpenOffice.org)

i may at some point (if people are interested), script sutch anaplication launcher. including instructions on what winshell to use and how to make it the least intrusive, whill still being availible all the time...
endolith
Posts: 10
Joined: 5. Mar 2009, 07:40

Re: More Seamless then seamless ...

Post by endolith »

Now how do you do the opposite and run Ubuntu programs inside Windows 7? :) One possibility is something like a headless virtual machine and connecting to it using http://winswitch.org/ or NX or xpra etc. I haven't been able to get this to work, though. I've been able to connect to another physical machine, but not to the virtual machine. Also the apps are missing pretty buttons and stuff, and just show a rudimentary theme.
sfranzyshen
Posts: 8
Joined: 9. Mar 2009, 07:08

Re: More Seamless then seamless ...

Post by sfranzyshen »

The purpose of this experiment is to integrate a proprietary application into the "Linux Desktop environment". Eliminating the need to even know
that there is an actual windows OS running at all. Our intention here is to present alternative ways of using the VirtualBox VM , to provide
compatibility on the "Application level" rather then on the (Desktop) "OS level". This is a alternative to the Wine environment, when Wine fails to fully support the application.
ichat wrote: we could replace the windows gui shell (desktop) with an alternative
Our goal is to eliminate the guest OS's GUI all together, passing everything down, to be handled by the host OS's GUI.
ichat wrote: in the end i would prefere to be able to 'see' the os's taskbar, and a launch bar.
We would rather have a single "user environment" handled by the host OS.
ichat wrote: Since its already nearly impossible to script a filehandler ...
We don't feel it is "nearly impossible" but we do agree that the filesystem mapping will be a hurdle ...
ichat wrote: there is really not mutch of a reason why you wouldn't just use a 'aplication' launcher inside your vm.
We disagree. At least not a GUI one (Application launcher) ...
sfranzyshen
Posts: 8
Joined: 9. Mar 2009, 07:08

Re: More Seamless then seamless ...

Post by sfranzyshen »

endolith wrote:Now how do you do the opposite and run Ubuntu programs inside Windows 7? :)
I personally haven't tried to do this in reverse, but it should be possible. The idea is to make the Guest OS's User Environment invisible (and auto login). Then use the Host OS to execute apps on the guest OS. Using gconf, maybe we can configure not to have a gnome desktop somehow. Then use the VBoxManage.exe to pass commands to the Guest (Linux) OS in the same manner we did from Linux. And of course using the VBox seamless mode.
endolith wrote:One possibility is something like a headless virtual machine and connecting to it using http://winswitch.org/ or NX or xpra etc.
The headless Guest OS is a very promising method of supporting application seamlessly. https://help.ubuntu.com/community/Seaml ... ualization
However, the OpenGL & DirectX support is lost.

There is a great need to be filled here! The guest Addition need to be greatly expanded to address compatibility on the "Application Level" rather then on the "Desktop Level" We need a clean "Remote Application" interface where we handle the WM_ (window manager functions) by the Host OS rather then by the Guest OS. Similar to the clipping method used by rdesktop+seamlessRDP. We could pass window scrapes (for each window separately) to the host OS to then draw the window in the host OS's Desktop (using the host OS's window manger). We could also scrape the Chromium 1.9 (on the guest OS) windows (or fullscreen) to render into the Host OS's desktop, rather then rendering in the Guest OS desktop.

I don't know how VBox seamless windows works now, but I suspect it is using a clipping method to clear (transparent) the Guest OS's background, and overlaying it onto the Host OS's desktop. The problem with this is it isn't truly merging the guest OS's windows into the host OS's desktop. Rather it overlays the Guest OS's desktop (in a single layer with the background transparent) over the host OS's desktop.

If I need to run the Windows Desktop (choke) I will just run Windows. If I need to support proprietary software within the Linux Desktop, I try to use Wine. If that don't work, I use virtualization. Always trying to eliminate Windows software altogether. Go Native!
scrollpane
Posts: 3
Joined: 25. Apr 2011, 15:45
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Win 7, Ubuntu

Re: More Seamless then seamless ...

Post by scrollpane »

sfranzyshen, I love this info and am looking to do exactly this. I will try out your code and report back on any success or issues. Have you seen this post http://forums.virtualbox.org/viewtopic. ... 67#p184467 ? It discusses a number of related ideas as feature requests.

I am very interested in making this work and would be happy to contribute to the effort. Please let me know if you have made any further progress in this area or have any further info.

Thanks!
scrollpane
Posts: 3
Joined: 25. Apr 2011, 15:45
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Win 7, Ubuntu

Re: More Seamless then seamless ...

Post by scrollpane »

OK, I followed the instructions here and they worked pretty well. There are still a few issues, however that I'm going to keep working on. The main problem, I guess is that all of the guest windows from VB are actually part of the same Gnome window and therefore have the same Z order. This means, for example, that if I create a menu shortcut to launch notepad.exe from Ubuntu, it may launch but not be visible because the VBox window is below some native windows. I suppose it should be possible to change the start script to bring the VBox window into focus as well...

Another problem which I found a bit more annoying is that the Ubuntu Applications, Places and System menus don't work when a VBox guest window has focus. It seems like the menu gets activated, but the actual dropdown is below the VBox guest layer and so hidden. Again, it should be possible to somehow check this and force a change of focus when the menu is clicked.

I would also like to find a way to make the minimized VBox guest app appear in the host taskbar (in my case I'm using Docky, actually). Not sure how to go about this.

Finally, it would be nice to make the whole VirtualBox run silently. I follow the suggestions in the other post on this, but it still flashes at first. It would be great if there were a little service icon at the top right, that you could click to bring up some options.

If anybody else is interested in this topic, please let me know. I am happy to work on solving some of these issues.

By the way, it seems to me that the real way to solve this, is to grab the contents of each guest window, strip off its chrome in Windows, wrap it in a Gnome window and make it a first class Gnome app. This of course would require some more intense Windows (and Gnome) hacking, but would provide a truly seamless experience.
Post Reply