Archive for the ‘Virtualization’ Category

Sharing a Host’s Directory Into Virtualbox Using NFS

Sunday, April 14th, 2013

(UPDATE: A reader has pointed out that the specific problem that I was trying to address is actually solvable using another workaround. Due to bugs in VirtualBox shared folders handling symlinks, they were actually disabled on purpose…and no check box was provided in the UI to turn them back on. But if you’re a “risk taker” and have read the issues and don’t think they affect you, you can use VBoxManage to enable it on a case by case basis…for particular shares in a particular VM.

So if you go to the directory where your virtual machine lives, and the VM name is VM_NAME with your share named SHARE_NAME, you just need to type:

VBoxManage setextradata VM_NAME
VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

That turns shared links back on, for that VM and that share. And if you don’t know how to mount VirtualBox shares from within the client in read/write, in my case you have to specify your user id as MY_ID in the following way:

 
sudo mount -t vboxsf -o uid=MY_ID,rw share /path/to/share

In my basic tests, this seems to work. If anyone has insights into what the actual dangers to doing this are, please add a comment.)


Before I mentioned how I had moved from VMWare to VirtualBox, so that more of the stack I use would be open source. Besides the “Genuine Windows” VM re-activation annoyance I mention (due to a perceived hardware change), everything seemed to go fine after that.

A couple months later I hit a snag. In my configuration I wanted to keep certain project directories on the host…and be able to read and write those directories in the guest. I expected to be able to use the “Shared Folders” feature, which does exactly this. It’s built into VirtualBox:

Shared Folders Feature in VirtualBox

But eventually I ran into a problem…

VirtualBox shared folders don’t support the creation of symbolic links by the guest in a directory owned by the host. Not even if the underlying file system on the host supports them.. :(

How to work around this? Networked filesystems were one answer, but have never been something I looked at favorably. They’ve always seemed overly complicated to set up, and platforms pull support for any given one at the drop of a hat. Plus, they offer ridiculously opaque error messages which give you no indication of what setting you might tweak to make them work.

So despite being the type of person who snarls at people who back up source code with zip files and demand they learn to use version control, I’ve been a luddite when it comes to networked filesystems. Rather than go through the pain of setting them up, I’d frequently resort to zipping up a directory…putting it on a ftp server…then downloading it to the other computer! :-/

But zipping the problem away wasn’t going to be an option in this case. So it was time to bite the bullet. I’m going to explain how I set up NFS on an OS/X host with a Debian VM.

(more…)

Initial Build of Rebol for the Haiku Operating System

Friday, December 28th, 2012

For those not in the know: Haiku OS is a binary-compatible open source reimplementation of the “Be” operating system. As with the Amiga community, Haiku users are driven partially by nostalgia…but also by an aesthetic of “small is beautiful”. As with the Amiga community’s anger that history took a detour by endorsing the PC architecture, the Haiku community probably in large part feels that Apple missed the boat by going with a traditional architecture of OS/X rather than buying Be.

Anyway kids, I hear it was a holiday or something. Instead of LumpOfCoal.exe I bring you a Rebol binary that runs on Haiku. (Well, I didn’t address terminal issues like cursor keys doing a proper command history or whatever…I just got it started as a basic POSIX build, looking at little details that despite their littleness can be a bit of a block.) You can download it from the community builds site at rebolsource:

http://rebolsource.net

More work is needed, and a proper binary would probably use a binding other than POSIX, which the source is designed to permit. But the question that people don’t know to ask is “can it be used to bootstrap”? In short: Rebol’s cross-compilation strategy is to use a Rebol executable to generate a bunch of per-platform ANSI C which is compiled in with the rest of the C sources. So really all you need is a Rebol executable (on any platform) and a passable C compiler.

I started with a Debian build and then put in a thumbtack here and there to get a HaikuOS build. And indeed, you can bootstrap. It’s this easy…

Install HaikuOS in your VirtualBox or what-have-you. I used R1 alpha 4.1, which is the latest at the time of writing. Once you have it, follow the instructions in this video…except get your Haiku binary from rebolsource and not my server. (I made the video before the changes had been accepted to the trunk.)

The video was intended as a draft that I made to solicit feedback. But I haven’t gotten around to redoing it yet, so I’m going ahead and pushing this blog entry out in the meantime.

Workaround for Broken Keys In TeamViewer with VirtualBox

Tuesday, June 26th, 2012

Having a remote desktop is pretty cool, although it can be a bit of a pain to set up. Especially if you’re dealing with multiple platforms. So I was pleased to find a free (for non-commercial use) turnkey solution called TeamViewer. You don’t even have to install the client or the host software…it runs straight out of the package, so administrative privileges aren’t required.

In a matter of minutes I was controlling my quad-core i7 server from my little netbook. It wasn’t blazingly fast even though the data is only carried on the local WiFi network, and I doubt their protocol is all that efficient under the hood. But for free I was happy.

Only problem is that one of my big things to do on the server is run lots of virtual machines, and number keys weren’t getting fed properly into VirtualBox machines on the host. I wasn’t the first person to hit this, and hk42 on experts-exchange tried a list of suggestions that didn’t resolve the issue. (BTW: I will continue to urge everyone to *not* use ExpertSexChange…popups and login nonsense, the StackExchange network is more elegant by far.)

So I decided to try using the event-monitoring program xev to see what was going on. It turned out that pressing ordinary number keys on the client generated numeric keypad events inside the virtual machine. Since there were no such problems in ordinary programs on the host, it must be some kind of impedance mismatch between the virtualized keyboard and the remote keyboard. (Neither my client nor my host have a hardware numeric keypad.)

To fix this, I used a little set of xmodmap commands. I didn’t bother making it a permanent thing in an `.xmodmap` file, because I don’t know if I’m always going to want to do this remapping.

# teamviewerkeys.sh
 
# KP_End
xmodmap -e "keycode 87 = 1"
 
# KP_Down
xmodmap -e "keycode 88 = 2"
 
# KP_Next
xmodmap -e "keycode 89 = 3"
 
# KP_Left
xmodmap -e "keycode 83 = 4"
 
# KP_Begin
xmodmap -e "keycode 84 = 5"
 
# KP_Right
xmodmap -e "keycode 85 = 6"
 
# KP_Home
xmodmap -e "keycode 79 = 7"
 
# KP_Up
xmodmap -e "keycode 80 = 8"
 
# KP_Prior
xmodmap -e "keycode 81 = 9"
 
# KP_Insert
xmodmap -e "keycode 90 = 0"
 
# KP_Delete
xmodmap -e "keycode 91 = period"

Hopefully the authors of the products involved will fix this issue in a less hacky way. But for now this works for me!

Virtual Machines and the *Very* Genuine Windows Dis- Advantage

Friday, June 17th, 2011

Over the years I have come a long way toward a close philosophical alignment with the Free Software movement. Yet I’ll shamefully admit that my two computers are an iMac running OS/X and a Acer running Windows 7. Of course, nearly all of my projects are undertaken in Linux virtual machines which I fire up in the host environment. I just didn’t want to cope with issues of finding drivers for the proprietary hardware of machines that were already “working”.

This week I took one more token step toward a free software stack, by migrating from proprietary-ol’ VMWare over into open-source VirtualBox. Although they use different virtual disk formats (VMDK vs. VDI) it is possible to convert between them using a free tool, just like this:

VBoxManage clonehd image.vmdk image.vdi --format VDI

Yet the format of the virtual disk file is a minor hurdle in the scheme of things. The real problem with switching from one virtualization system to another is that all the “virtual hardware” changes. You basically have a whole new video card, processor, BIOS, sound device, keyboard, ethernet interface—everything changes. There can be problems booting after the switch if the operating system tailored the installation for only the hardware you had at the moment you ran the setup.

Fortunately modern operating systems were designed to roll with such punches. Manufacturers and users alike will pull parts out of the computer and put new ones in. So there’s enough of a “lowest common denominator” lingo that even super-futuristic graphics cards can go into a 640×480 mode long enough to let you see the dialog boxes for installing a smarter driver designed for it. My Linux installs came through just fine.

But I keep a VM for Windows XP too, that I pull out in those circumstances when I need such a thing. Predictably…Windows had some esoteric trouble on VirtualBox with agp440.sys and intelppm.sys. A helpful article I found suggested to essentially delete them and it starts working. I did a little reading and agp440.sys is related to a deprecated standard called the Accelerated Graphics Port; it seems that removing it does not seem to prevent the Virtual Machine from having accelerated 3D services. intelppm.sys is related to power management and turns off the processor if the CPU is effectively idle, so it is likely superfluous to a virtual machine.

(Note: I did have to turn on the VirtualBox setting for enabling “‘IO APIC” to appease mup.sys but did not see the CPU utilization bug mentioned in Ticket #638. So I decided not to follow the convoluted process of using SysPrep to rewire things so that I could turn that check box off.)

So after a couple hours of tinkering, my Windows VM came up under VirtualBox…though it gave me a warning. My hardware had changed sufficiently that its “Genuine Windows” status was invalidated. It told me I would have to activate it again within 3 days.

“Or what?”, you may ask.

In this case the “or what” is “we won’t let you into your system”. You type in your password and it announces that you’ll be going into the activation process right now, else no soup for you. It didn’t even give me the 3 days it claimed; in the course of less than 24 hours it decided to jump me straight to OS death row.

(A long way to go, just to harass users of an operating system the company DOES NOT EVEN SELL ANYMORE.)

My one copy of XP is very old. The wily holographic disk has the orange license key sticker stuck directly on it. I’ve used it on several computers, all of which basically either died and got thrown away…or were formatted with Linux and given away to charitable causes sans any of my personal info. Yet I don’t know how many times I can push this magic “activate” button before it decides to say no. Plus I hadn’t even installed the VirtualBox tools that let Windows magically embrace things like integrating the mouse pointer with the host…what if I activated, then installed those, and it decided it was a new computer all over again?

As it happens, I restarted in Safe Mode and it decided to let me in. I installed the VirtualBox tools and rebooted and clicked “activate”. It let me activate (for now…at least while these activation servers happen to be around.) But this is another zen lesson about what it means for something to be Defective By Design. My small dependence on a few Windows tools and desire to assist people with problems (such as porting solutions to not need Windows) will hopefully be phased out before I should ever encounter another Genuine Windows Disadvantage!

Virtualization and the Integrated Circuit: Looking ahead

Saturday, November 3rd, 2007

This article is a written summary of a talk I gave at BarCamp LA #4, with some bugfixes. My presentation used a bunch of graphics swiped from google images since I was in a hurry, and I’d like to extend apologies/credit to my sources, all linked here: [highway barrier] [rc circuit] [resistor] [capacitor] [microcontroller] [grandparents] [moore’s law] [hanz/franz] [beos cortex]

Slideshow iconView the talk slides

Virtualization is a big deal these days; it’s in the news and there’s a lot of activity in the stock market surrounding the phenomenon. I want to briefly talk about ways I foresee virtualization being applied that are a bit more radical than how it’s generally being thought of today. In particular, I make the following claim:

Software applications are going to be increasingly built up from dozens of virtual machines per program.

To give some supporting evidence, I’ll relate an analogy with how problem-solving in electronics evolved over the past few decades.

A simple electronics problem

By degree, I’m an electrical engineer. And the kind of work that we used to be paid to do was that you’d have a mission like: “Make this highway construction barrier light blink every 3 seconds”:

A highway construction barrier with light.

How to solve it the E.E. way

To do this, you’re going to need a power source and a light. That’s a given. But electrical engineers can recognize the highway-barrier task as one of those problems that can be done with just 2 additional parts—a resistor and a capacitor. In fact, it’s a textbook case. So I’ll show you what that kind of problem looks like:

Textbook example of an RC circuit.

(taken from http://www.physics.byu.edu/faculty/berrondo/su442/ac.pdf)

Picking a resistor R and a capacitor C can give you the desired effect of a certain brightness and a certain amount of time between blinks. But it’s not like there’s a specific value of C which corresponds to “3 seconds”. And there’s not a value of R which matches “12,000V”. If you picked two components that satisfied your specification, you’d have to work the equations out again and replace both pieces if anything changed.

How to solve it the C.S. way

If you’re familiar with computer science, and someone told you to make a light blink periodically, your mind would probably jump to something like this:

const VOLTAGE_MAX = 12000;
const BLINK_PERIOD_SECONDS = 3;
const FLASH_TIME_MILLISECONDS = 500;
const UPDATE_INTERVAL = 100;
var lamp = HighwayBarrier.getLamp(this);
 
forever () {
   lamp.setVoltage(0);
   sleep_msec(
         BLINK_PERIOD_SECONDS * 1000 -
         FLASH_TIME_MILLISECONDS);
   lamp.setVoltage(VOLTAGE_MAX);
   sleep_msec(FLASH_TIME_MILLISECONDS);
}

I’m hand-waving here to say that these are functionally equivalent. The reality is a little too tied up with light & power to make this a “good” example. But it’s a simple and visceral way to see how digital signal processing (CS way) differs from analog circuit design (EE way).

Cost comparisons of the approaches

For the CS approach you’d you’d need some kind of compiler or interpreter. And you’d need a CPU to run that program. Typing “microcontroller” on Google Images I found this fellow as the first hit:

A twenty dollar microcontroller

Then I looked for a price on it and got $20.61. That’s a heavyweight unit for this humble task, and crazy expensive—but I’m going to run with it. By contrast, the EE way uses two parts that probably cost a few pennies. Let’s estimate 10 cents for the capacitor and 10 cents for the resistor. So off the cuff we might guess that the EE way is approximately 100 times cheaper per Highway Light manufactured.

Furthermore, integrated circuits that can run arbitrary programs are not built out of 2 parts, but rather millions of individual electronic components. So we see how grotesquely wasteful the CS way is. But let’s look at the big picture.

Looking at the bigger picture

It’s pretty obvious how the CS code works—and I didn’t even comment it. If I asked your grandparents to change it so that it would go to 13,000 volts instead of 12,000 volts… or to blink over a 10 second period instead of 3 seconds, they’d probably be able to point to the right lines. But who thinks their grandparents could make the necessary changes to the circuit?

Plus there’s flexibility with the microcontroller—if you decide you want the light to ramp up and ramp down in brightness instead of blip on briefly, it’s easy code to write. If you want there to be a special case where during daylight hours the lights turn off to save power, you can do that with an “if” statement. Though computer science is a deep and complex field in its own right… for things like this it takes a relatively trivial amount of education to do than analog circuit design. And modifying the program after the fact, once written by a competent programmer, can be extremely easy.

So even assuming a factor of 100 manufacturing cost difference—with an overkill microcontroller that can dance and sing (should your project ever get new requirements)—the $20 could pale in comparison to the labor charge difference.

Virtual machines are like Integrated Circuits

In the years during my EE degree and afterward, I watched analog circuit engineering become a niche discipline. In the meantime, the norm for hardware solutions is to use millions of electronic components to do a job that two or three well placed ones could do. This makes perfect sense—we know that a human time and ability to manage complexity doesn’t scale, but Moore’s Law has so far:

Moore's Law Graph

So now let’s start thinking of microprocessors as being like virtual machines. Then the parallel to resistors, capacitors, and inductors—the building blocks of analog circuits—would be lines of code. Just how a chip with a layout of components rivaling a large city was once seen as an overkill way of making a highway light blink… there are a lot of problems today that people wouldn’t even think of using a Virtual Machine for. It would be “crazy” and “wasteful”.

But I’m going to tell you my bet: software applications are going to be increasingly built up out of dozens of virtual machines per program. This will be due to a similar economy of scale to what happened with integrated circuits. So here are some radical ideas about those trends.

1. Porting and cross-platform libraries will die out

My hatred for porting comes partially from a deep-seated psychological issue of playing games like Pac-Man in the arcade as a kid, and then you’d buy the version for the Atari and it would look nothing like Pac-Man. So porting and I started out on the wrong foot, and my experiences with porting code have only reaffirmed my belief that you shouldn’t do it. Here’s a picture that makes me sad, a few of the first 60,000 google image hits for “Tetris Screenshot”:

Tetris Ports Screenshot

I really believe application developers are going to pick a platform, make their program really work on that particular platform, and ship it out to users with the expectation that they are going to run it in a virtual machine. When you run the application the details of the underlying OS will be hidden from you; it will already be configured.

I expect we’ll see virtual machine versions of programs catch on and replace the idea of installing the native versions within the next couple of years. An implication here is that we’ll be saying goodbye to things like the Windows and MacOS versions of the GIMP. People will learn and accept the idea that different applications have different “skins”, so if the program doesn’t look and act like their host OS they won’t be terribly concerned.

2. Operating systems that just do interfaces

We’re already seeing that some operating systems are succeeding based on their ability to have a nice user interface presentation. People are doing serious work on MacOS — using it basically as a glorified terminal. I can imagine that applications of the future will have a virtual machine in them which is for an OS specifically suited to the user interface needs of the application, while that OS may not actually run any of the program logic.

In other words, rather than using a GUI library and interfacing with a client, you’ll have a full blown OS whose sole purpose is to look snazzy. I think it will be a great place to see OSes that haven’t been gaining traction otherwise, perhaps a resurgence of things like BeOS and OS/2.

3. Libraries running in their own virtual machines

I’ve pushed the idea that many applications you install on your desktop will be running in virtual machines. That’s not outlandishly far off of what’s actually happening. But how about something crazier: would you ever use a string library that had its own daemons and filesystem? Perhaps even something esoteric, like QNX?

Where we once used libraries, or even a few lines of custom code…we will see a rise in the usage of whole entire operating systems. You might laugh at that, but as Hanz and Franz would say: “hear me now and believe me later”.

When performance and memory usage are less of a concern than security and the leveraging of human effort—you really might want to use heavily debugged and peer-reviewed systems that are maintained by a group that has standardized on a completely different platform from your project. It will be typical, if not expected, that your project will wire together virtual machines with all the casualness that people pipe together commands in the unix toolkit paradigm.

This is similar to how people are thinking with web services…taken to an extreme. There are already web apps that do their image manipulation, spell checking, or other bits of functionality by sending requests over TCP/IP to a web server and getting XML back. Web standards have been one force for untying people from using any particular operating system, and I think this will keep pushing on that. But you don’t need to invoke a network—and I think the most common case will be VM components that are run on the local machine as active libraries with access to the WAN disabled.

(Though if you wanted to, you’d sometimes log into it, and let it connect to the internet to update itself—all in its own sandbox.)

Further thoughts

These ideas push away from goals that we consider important today, like user interface consistency standards. We could have “Night of the Living Dead Operating Systems”, where a virtual machine running BeOS on the front end uses an OS/2 codebase to do its computational work, and packages it all up as if it were a “normal” application. This sounds really scary to some people—am I actually advocating this?

Well I’m not even saying that this is the way I think development should be done (besides the part about not wasting effort porting things!). One engineer I talked to sheepishly admitted he’d used a whole chip where basically a flip-flop would have sufficed… but it was easier to plug the part in, especially since he couldn’t predict what he might want that subsystem to do later. Similarly, with VMs, I think this convenience of using hardened elaborate components is going to pop up in all kinds of places we’d use two or three lines of carefully chosen code today.

Valid XHTML 1.0 Transitional


Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported