Tag Archives: VMware

Review Board

Reviewing code can suck

The open source world has given developers great tools to make their lives easier. We have editors, bug trackers, source code management tools, repository viewers. Bugzilla, for example, is a very popular bug tracker used by many open source projects and companies alike.

While the life of a developer has in many ways been improved by these tools, there’s one key area of software development that people still do the hard way: Code reviews.

You’re probably familiar with this. A contributor puts a patch up on Bugzilla, Trac, or your project’s listserv. It’s large and spans several files. Eventually you get around to it (if you haven’t lost it in your inbox yet). You open an e-mail or the Bugzilla page to respond, put the diff where you can see it, and start going through the changes, line by line, making comments as you go. It’s tedious. You have to make it clear what function you’re talking about, make references to the general area in the diff. It’s a pain for the contributor too, because they have to figure out what you’re referring to. This leaves room for error.

We’ve been working this way for years in open source projects and at VMware. Code reviews are important to us, and help to keep our code clean and our products stable. It keeps us honest prevents us from cutting corners unnecessarily. However, the process is a bit time-consuming and not at all optimal.

  1. Generate an htmldiff showing the old code and the new code side-by-side, highlighting the changes.
  2. Write an e-mail to the target reviewers/listservs explaining what changes we made, the testing that was done, links to screenshots we put up on a file server, a link to the diff, and whatever else.
  3. Wait for someone to go through the htmldiff and comment on the changes in a new e-mail.
  4. Go through the comments, try to find the lines they referred to in the diff, and fix them up.
  5. Make another diff if necessary, repeat.

David Trowbridge and I finally got tired of it. We spent too long preparing review requests and we lost too many of them in our e-mail. As our personal projects and our team grew in size, it became harder to keep track of all the open review request e-mails on the listservs. So we fixed that.

Review Board

We built a code review system called Review Board. Like most projects, it started out simple, but grew to be pretty powerful and useful quickly. It was designed to automate and simplify the process of creating review requests and actually reviewing code.

Management at VMware was excited about this from the beginning. We weren’t being asked to write it, and it was a personal project and all, but when they found out we were doing this, they fully supported us. It didn’t take long for the excitement to spread across many teams, and we had 40 people signed up and playing before we were even ready to announce our phase 1 beta.

One of the things we decided from the beginning is that this must be open source and it must work with other version control systems. For example, we use Perforce internally, but there’s no reason not to include Subversion or anything else.

So we worked and worked in our spare time. After weeks of trial runs and lots of dogfooding, we decided it was time to announce what we had so far.

Enough yapping, details already!

Details? Alright.

Review Board is an open source program licensed under the MIT license. It was designed using Python and Django. It’s compatible with Subversion and Perforce, and can be extended to support other version control systems.

Review Board has a lot of useful features…

Multiple Repositories and Projects

Review Board can generate and display diffs against multiple repositories on multiple servers, each with their own version control system. At VMware, we have a repository for each Perforce server we use, and will soon be adding a Subversion repository for our libview project.

This would be particularly useful for umbrella projects where some parts are available in one repository and others in other repositories.

Writing version control system backends is easy. They’re simple Python modules that can be referenced in the Review Board database entry for the particular backend. We currently ship Subversion and Perforce backends, as well as a subclass of the Perforce backend making use of special extensions we use at VMware.

Review Requests

Posting review requests is fairly easy. If you use Perforce, it’s especially easy. A post-review tool is provided that allows you to post a review request with nothing other than a change number as a parameter.

If you use Subversion, a little more work is required, though we’re working on a tool to automate this as well. You’ll need to generate a unified diff. Click “New Review Request,” select the repository, enter the base path (the path relative to the root of your Subversion repository where you generated the diff), and then select the diff. Click “Create Review Request.”

You’ll be taken to your review request page where you can fill in description and other information. Click “Publish” when you’re done.

Review Request

Powerful Diff Viewer

Diff Viewer
  • Inline commenting: Instead of jumping to your bug tracker or e-mail client and describing where you’re commenting on, just comment directly on the line! Click the line number or click and drag to select multiple line numbers and a comment dialog will pop up allowing you to type. When you finally publish your review, the lines in the diff you commented on will be shown inline with the rest of your review.
  • Inter-line diffs: Sometimes a small change is made to a line and it’s not readily apparent what the change was. In these cases, we highlight the regions between two lines that have changed.
  • Revisioned Diffs: Each revision of the diff is saved and can be accessed. In the future, we will make it possible to show differences between two revisions, to ease review of incremental patches.
  • Whitespace highlighting: Trailing whitespace is automatically highlighted. Trailing whitespace is a pet peeve of many developers and this helps to catch it early.
  • Collapsing/expanding of files: By default, only the changed chunks and some lines of context around them are displayed. This can be quickly changed to show the entire file, in case there’s something you want to look at or comment on elsewhere.
  • Keyboard shortcuts: Convenient shortcut keys allow quick navigation around the diff. For example, pressing “n” will jump to the next changed chunk, and pressing “p” will jump to the previous chunk. This will be further improved and documented soon.

Comment Dialog

Interactive Screenshots

  • Screenshots can be easily added to the review request page, and will show up as thumbnails.
  • Screenshots can be commented on by clicking and dragging an area on the image. A comment box will pop up, like in the diff viewer. While the clipped part of the screenshot does not yet appear on the review, it will soon.

Contextual Discussions

Review Discussions

  • Commented lines in the diff are displayed with their comments on the review page.
  • Commented areas of a screenshot will be displayed with their comments on the review page.
  • Discussion of reviews take place on the reviews themselves, making it possible to read the whole discussion of a change from top to bottom.

E-mail Support

All discussions and updates get sent automatically to the individual reviewers and listservs. This makes it easy for people to see any and all changes. This is configurable and can be disabled if it doesn’t fit in with your setup.

NIS Support

Review Board can use an NIS server as an authentication backend, making it easy to integrate into companies that use NIS. Everyone’s accounts will Just Work in Review Board without any registration required.

User Dashboard

Dashboard

All incoming and outgoing reviews can be seen on the Dashboard page. You can look at incoming reviews sent directly to you, sent to a group, or to either (all incoming reviews).

In the future, this will show more information on what’s going on with the review requests in your list. Recent discussions and updates will be shown, making it easier to keep track of things.

JSON API

Review Board has a JSON-based API for accessing nearly every aspect of the system. This makes it easy to build tools around Review Board. Our post-review tool uses this, as does much of the web UI.

Hopefully in time, developers will make use of this to better integrate with existing systems such as Eclipse, vim, emacs, or other IDEs.

Looking Forward

There’s a lot we have planned. Review Board is still just an early beta and a lot will happen.

  • Improved tools: We’ll soon be working on a single tool that understands how to post review requests to both Perforce and Subversion. It will also be able to integrate with multiple projects. For example, if three projects you’re contributing to all use Review Board, post-review will ask once for the Review Board servers and use them from then on when run in the project directories.
  • Interdiffs: We plan to include the ability to show changes between revisions of diffs, aiding in reviewing incremental changes to patches.
  • Statistics: Information will be available showing how many review requests, reviews, and comments have been made between specified time periods, complete with fancy graphs. We’re working on ideas for what can be displayed here.
  • Status Reports: This is perhaps more useful inside companies. At VMware, we’re supposed to submit weekly status reports discussing what we’ve done. Often this consists mostly of review requests made and bugs fixed. Review Board will be offering a page showing this information in several forms so that it can be easily copied and pasted into a weekly status report.
  • Integrated Help: To simplify usage for first-time users, we’d like to add help information to all pages explaining simply how to use the interface.
  • “Effective Lines” Display Many diffs are easier to review than they seem, as there could be hundreds of lines with nothing more than a function or variable name change. We would like to make this clear before even opening the diff by showing the number of effective lines changed, factoring out the simple redundant changes.

Wrapping Up, and Contributing

This was a bit long, but I hope it gave a good overview of what we’re putting together here. You can see it in action or visit the project page. If you decide to use it in your project, please let us know! Check the Wiki for install instructions.

Hopefully this will become useful to others as well. We’ll post periodic updates as this project progresses.

May I present VMware Workstation 6.0

Good news, everyone! After several months of hard work, many late nights, and thousands of caffeinated beverages, we have finally released VMware Workstation 6.0. You may have already heard this on the news, but I’m here to tell you exactly what we spent so much time on. Or a glimpse of it, anyway.

  • Windows Vista support

    We’ve added much improved support for Windows Vista. Yes, you could run it before, but not this well. We have VMware Tools support for many things in Vista now, providing for a smoother experience. A warning, though. Vista is pretty heavy on resources and may still be slower than you’re used to. Not to mention the fact that Microsoft will make you buy the really expensive version in order to legally run in a VM. Still, if you’ve been wanting to see what Vista is like, have a decent machine, and an MSDN license or legal access to a legal version of Vista, install it in a VM and give it a try.

  • USB 2.0

    We now support USB 2.0. Your fancy USB 2.0 devices should now work just fine in your VMs.

  • Headless VMs

    Starting in Workstation 6.0, your VMs are no longer tied to your UI. Previously, any time you closed Workstation, you would be asked if you wanted to power off your VMs. Now you’re given the choice of continuing to run your VM in the background. It will continue to run without a UI.

    This is greatly useful when you have a service running in your VM that you may want to connect to. This is similar to VMware Server, except your VMs will not automatically start when the computer starts.

    While the VMs are running, an icon will appear in the system notification area that, when clicked, will display a list of all powered on VMs. Clicking a VM will launch the UI and focus the tab for that VM. A list of running VMs will also appear in the sidebar under “Powered On.”

  • Multi-monitor support

    Users of multi-monitor setups will love this feature. Your monitor layout is now exposed to the guest OS, giving it the ability to make use of more than one monitor when going fullscreen. You can full screen over one monitor, two, three, whatever you happen to have.

    In many ways, this feature is still experimental on Linux. It’s currently very difficult to maximize over multiple heads, given the lack of official support in X and window managers to do so. We’ve had to perform some creative tricks to make this feature possible. We’re working on getting official support in so that we can do this properly in future versions.

  • Improved full screen

    Full screen has been improved. You can now full screen over multiple heads or set one of several modes. You can opt to change the guest resolution to match the host, stretch the guest (as you would an image), or center the guest on the monitor. We no longer change the host resolution to match the guest, which used to cause some issues and “jumpiness” on Linux.

  • Multiple windows and tab drag-and-drop

    The Linux version of Workstation 6 now allows for multiple windows to appear on the screen at once within the same process. Now, older versions had a File -> New -> Window, which also created a new window, but it did so by launching a second instance of the application. We now keep this all in the same instance.

    Part of the benefit here is that you can now drag tabs between windows in order to better arrange them. You can place two windows side-by-side and view a Linux VM in one window and a Windows VM in another. You can also rearrange tabs within a window.

  • Drag and drop

    Here’s a feature Windows users have enjoyed for a while now, which we’re finally getting on Linux. It’s now possible to drag files from your host into your guest, or files from your guest into your host. Need to copy some documents from your Documents folder on Linux into your My Documents in your Windows guest? Just select them and drag into the VM.

  • Interrupt Record and Replay

    Workstation 6 is the first product to ship with the experimental Interrupt Record and Replay functionality. This allows you to capture everything happening to a VM — network packets, disk I/O, mouse events, etc. — into a log and replay it later. It’s very useful when doing debugging. Ever hit a crash that you can only reproduce one out of every 10 times? This should make it easier to track down.

    The first version of this is a bit limited, but we’re working on improvements for the next release of Workstation that will help make this invaluable to developers.

  • Eclipse IDE Integration

    We now ship extensions to Eclipse to ease development of applications and testing in a VM. See this blog post from the developer for more information.

  • Message log and notifications

    Many of our error dialogs that would block a VM from powering on have become passive popup notifications. We suspect the elves did it. Now little things like your sound device being blocked won’t prevent the VM from powering on when you ask it to.

    If you miss a notification or wonder why your device was disabled after coming back from a coffee break, you can check the new message log and see the contents of the notification. It’s accessible through a non-intrusive icon in the bottom-right of the Workstation window.

  • Tools auto-upgrade

    VMware Tools are essential to the smooth operation of a VM. They help to accelerate video, provide more natural mouse support, and end all of life’s problems (results may vary, not typical of average use). However, they’ve always had to be upgraded manually.

    Starting in Workstation 6, tools are capable of auto-upgrading when a new version is available. This can be configured globally or on a per-VM basis. One less thing to think about, and this is a Good Thing.

  • VM upgrade/downgrade

    To take advantage of all the features that a new VM hardware version gives you, you have to upgrade. This has always been true, and we’ve always provided a quick way of upgrading VMs. However, there are times when you may want to downgrade instead in order to distribute a VM that more people can take advantage of, or to make it ESX-compatible.

    We’ve added a new wizard that quickly guides you through upgrading or downgrading a VM. You can make the VM Workstation 4, 5, or 6 compatible, and choose whether or not it must also be ESX-compatible. The wizard will give you the option to either modify the VM in-place or to clone it first. No longer does upgrading to a new version of Workstation lock you in to a particular hardware version!

  • VNC

    Ever want to run SimCity 2000 in a DOS VM and access it across the network? Okay, well, maybe an older Windows install or something? You can now make any VM VNC-enabled. Simply toggle the option, set an optional password, the port (on the host computer) to connect to, and you’re done! You should be able to access your VM through VNC on any other computer on the network. You can even see how many people are connected and boot them off, just in case they’re sending Godzilla after your city.

  • Appliance View

    VMs are becoming a big thing for application distribution. It’s possible to download virtual appliances for all kinds of things. Need a pre-configured e-mail server or a development environment for an embedded device? Chances are you’ll find it nowadays. Simply download it, power it on, and go.

    There’s a lot of things we’re planning to do to make virtual appliances better and easier for both the developer and the end user. The Appliance View in Workstation 6 is the first step in this. It features a cover page that can be displayed as the VM powers on (instead of the console view) and can contain the appliance name, version, author, logo, and descriptive text.

    A status area at the bottom of the Appliance View indicates when the VM is powering on, waiting for the services to start, or that the appliance is ready to use. When it’s ready, a button will be available for easily launching a browser to connect to the web UI for the appliance.

    Watch this space. We have some cool things we’re planning.

  • Paravirtualization

    Paravirtualization is getting a lot of buzz. A paravirtualized kernel performs better in a VM than a non-paravirtualized kernel. The VMI interface we helped to create is now a part of version 2.6.20 of the Linux kernel. Ubuntu Feisty ships with this kernel, meaning it should perform better in a VM when paravirtualization is enabled (in VM Settings -> Advanced).

  • Better Linux look-and-feel

    The icons in the Linux version of Workstation got a complete makeover. We’re now following the Tango style for all icons, including the launcher icons. We’ve released most of these icons (the ones that don’t include trademarked logos) under the Creative Commons license. People are welcome to use these icons in their programs and icon theme designers are also welcome to provide alternatives in order to better style Workstation and Player.

Of course, a lot more went into this release than just the above features. It’s been a huge effort and I’m personally pretty happy with the result. A big thanks to everyone who’s worked on this release and to the people who helped keep me sane at 2 in the morning during our crunch times ๐Ÿ™‚

Also, a big shout out to the developers of VMware Fusion, the new virtualization app for MacOS X. They’re working hard to produce some awesome features and are undergoing their own crunch time right now. If you’re a Mac user, you might be interested in reading the CompFusion and Infusion blogs by a couple of our Fusion developers.

VMware Workstation 6 RC2

Release!

Well I dropped the ball on this one, but we released VMware Workstation 6.0 RC2 last week. This is our second release candidate, and for those using our betas in the past, you should know that that means a final release isn’t too far away!

Not much has really changed in RC2, aside from more bug fixes. We’ve taken care of a lot of critical issues that have affected some users and ourselves. If you used the Workstation betas in the past and haven’t tried an RC release, you should notice a huge speed increase when using the guest. Feels a lot more native with all that debugging turned off.

The betas are of course free to use, but Workstation 6 itself must be purchased. If you’re in school, you should be able to get a nice academic discount, and if you’ve bought Workstation 5.5 since January 1, 2007, you can get a free upgrade.

Desktop Integration

One of my personal goals has been to improve integration with the GNOME desktop. I feel we’ve made a lot of progress since Workstation 5. The big highlight of 6 has been the Tango icons (I’m biased, as I made most of them). Even the product icons on Linux are in Tango style now. This definitely cleans up the look and feel of the product and helps it to feel like it’s just any other GNOME app, rather than some big proprietary product half-ported to Linux (of which there are many).

There’s more that we could do, though. I’d like to hear from GNOME developers and users about other ideas to better integrate with the desktop.

VMware Tango Icons รขโ„ขยฅ Creative Commons

The VMware Workstation 6 betas have been out for a while now, so I’m sure those using it have noticed that we’ve been trying to make our icon theme fit in with the Tango icon style (well, to the best of my current abilities). So far this has proven to be a dramatic improvement over our older icon style used in Workstation 5.x, and it really fits in a lot better on modern GNOME desktops. The overall look feels clean and polished, mostly thanks to the hard work of the Tango project.

We’ve been lucky in that the Tango project has provided such a good variety of high-quality icons. I haven’t had to do nearly as much work as I expected in designing these icons. There were several existing VMware icons that we needed to move to the Tango style still, such as power icons, USB, serial port, message log, etc. Just a handful, but while many of them may be somewhat VMware-specific, there are some that we felt could be useful to other software projects, icon designers, and, perhaps, to Tango itself.

So we’re releasing our non-trademarked icons (everything the lawyers are okay with) under the Creative Commons Attribution-ShareAlike 2.5 license. It’s only fair that we give back, afterall. There will be a dedicated page for this later, but for now, you can download it directly from here:

Download: vmware-tango-icons-0.5.tar.gz

You can see what we currently have available in the image below. I’ll put out updates as we come up with new icons and tidy up some of the remaining ones that we still want to release.

Thanks again to the Tango project for all your work in making the Linux desktop a more beautiful place, and if any of these icons look at all useful to the project, please feel free to use them, modify them, or have me tweak them.

VMware Tango Icons

VMware Workstation 6.0 beta 3

We’ve just put out VMware Workstation 6.0 beta 3. As per the ancient traditions set forth by the VMware founders, we decided to make this release awesome. I’ll go over a couple of my favorite, but for the rest, read the release notes.

  • Record/Replay

    Workstation 6 beta 3 is the first release to support our new Record/Replay functionality that we mentioned at VMworld. Essentially, it allows for making a recording of (almost) everything that happens to a VM between the time you hit Record and the time you hit Stop. This is not a movie recording, but more of an execution recording. You can play it back however many times you like.

    What is this good for? Well, have you ever tried testing a program only to encounter a bug that you just can’t reproduce? Maybe there was some memory corruption that happened under some specific case that you just can’t seem to diagnose. Or maybe it’s a network packet that came in in some form that your application didn’t expect. Under normal circumstances, you’d have to do a lot of guesswork in order to find out what exactly happened. Far too often, it’s just too hard to reproduce the bug and it goes unfixed for some time.

    Now imagine instead that you’re testing the program in Workstation and, before your testing, you hit Record. You attempt the test and the program crashes in some weird manner. No problem. Hit Stop and replay the recording. Just before the crash occurs, stop the playback and attach a debugger. Messed up? Didn’t find the cause? Replay that recording again.

    It should be pointed out that these recording logs take up a lot of space, so you don’t want to keep too many around. Also, the feature is very experimental, so don’t be surprised if there are problems. Some things are not yet supported, like 64-bit guests, Virtual SMP, and certain devices (USB, for example). We plan to change the UI around a little bit, and it’s likely that future Workstation releases will improve the usability and usefulness of this feature.

  • Debug guest apps from the host using Eclipse

    We now offer the ability to debug applications inside the guest from Eclipse on the host. This provides for a nice sandbox for the application. Your app can crash the computer during a debug session and your host won’t even feel it! There’s a good blog post from the developer of the Eclipse support discussing this feature and some of its many uses.

  • Fullscreen improvements

    A previous beta introduced the new combined Fullscreen mode. We used to have separate Fullscreen and Quick Switch buttons on the toolbar, each useful for certain purposes. The new combined mode is closer to Quick Switch, but until now has missed the nice aspect of Fullscreen where the image would actually by the size of the monitor (due to changing the screen resolution).

    Now, when in fullscreen, you have the option of changing the view mode (from the drop-down toolbar). The guest resolution can be changed to match the host’s screen resolution, the guest can be stretched (emulating the original fullscreen), or the guest’s screen can be centered on the monitor.

  • Tab dragging

    The Linux UI now supports tab dragging, thanks to the new support in GTK+ 2.10 and some hacks to get around some bugs. Combined with the multiple window support we put in a previous beta, you can now have as many windows open as you like and drag and drop VM tabs between them. While not a major feature itself, it is a nice usability thing we’ve wanted to do for a while now.

  • Many many bug fixes

    The new feature list may not be huge, but at this point in the beta cycle there shouldn’t necessarily be a lot of new features. So what have we been doing? Why, fixing just tons of bugs of course. A lot of crashers have been fixed, work has gone into improving multiple monitor support, the UI has improved in various areas, and code has been cleaned up. All in all, we’re in good shape, and will be mostly staying in bug fix mode until the final release to ensure that the result is a product we can all be proud of.

I should also point out that if you are not a Workstation user but have been contemplating a purchase, you don’t need to wait for Workstation 6. You can now buy Workstation 5.5 and get a free upgrade to 6. This only applies to new purchases, so if you’ve been a Workstation 5 user for a while, you’ll have to purchase 6 separately.

VMware IPO news, and 3D in VMware demoed

VMware IPO

Wow, exciting day for VMware. For those who haven’t yet seen the news, our parent company, EMC, announced a VMware IPO. Approximately 10% of VMware is being sold. This is all news to me too, but it’s damn exciting.

“VMware is one of the fastest-growing businesses in the history of the software industry. We expect the IPO to unlock more of VMware’s value for EMC shareholders while also strengthening its ability to retain and attract the software industry’s top talent.”
— Joe Tucci

I know many people have said they would invest in VMware if it had its own stock symbol rather than sharing EMC’s. Now you have no excuse! ๐Ÿ˜‰

3D in VMware Fusion

Some people, including a couple of competitors, are of the belief that nobody to date has supported 3D in a virtualized environment in any usable way, and have made claims that they’ll be the first. It’s not their fault, this wasn’t so widely known. Afterall, we’ve only had this supported and documented for two years now.

Well, cat’s out of the bag now. I was doing my usual search for VMware on Digg, and this post came up showing a video of 3D in VMware Fusion. As you can see from the video that it links to, 3D in VMware is quite usable. ๐Ÿ™‚

Update: The URL for the digg post has moved. Fixed the link.

Happy New Year!

Another year come and gone. Hopefully everybody is out having a good time or recovering from a good time. I just finished up for the night and am planning to get some reading done before bed, but thought a quick blog post summarizing the year was in order.

  • This year marks my second year living in the Bay Area and working at VMware, and my first year really heading up some larger projects. I began the year by working on what would in time be known as VMware Server, and spent the first half of the year head down at my desk working on each release. Following that, I’ve been working on specifications, feature implementations, and even Tango-style icons for VMware Workstation 6.0, which I will continue with for some time.
  • Jamie and I have now been dating for just over two years.
  • For the first time, I was invited to FooCamp, hosted by Tim O’Reilly. Awesome event that I really hope to be invited back to next year.
  • I learned to boogie board with a couple of friends in Santa Cruz. Later in the summer, Jamie and I took a nice vacation in Santa Cruz and spent most of it at the Santa Cruz Beach Boardwalk.
  • I had my second trip to Boston this year for the GNOME Summit. I went with Jamie to Salem and explored the touristy little town. Fun place, and I’d definitely like to spend more time there in the next couple of years.
  • I went with some friends to Castro St. in San Francisco for the first time for the big Halloween costume party that they have every year. We found out the following day that there was a shooting not too far from us, which was unnerving.
  • I got a Nintendo DS and a Wii, and have spent far too much money on both. I’m going to just start signing over my paychecks to Nintendo.

I’m sure I’m missing a few things. ๐Ÿ™‚

Now, New Years Eve doubles as my mom’s birthday, which I imagine was not fun when growing up. I think the only day worse for a birthday is Christmas. It was certainly fun tonight, though. The night was spent with my mom, stepdad, brothers, sister, and Jamie. We watched Cars and played Scrabble, Bomberman Touch! for the DS (fun game!), and Cranium. We ended up spending most of the evening on Cranium, which has to be my favorite family game. We kept laughing so hard that we got ourselves sick.

Jamie brought over a bottle of champagne for us to drink. It was a late Christmas present, intended for New Years. We’re not heavy drinkers, so we only finished half the bottle, but it was very nummy. Along with that, we had a variety of snacks, including cheeses, beef sausages, vegetables, sodas, and pizza. This was, I think, my first New Years with my sister Jenna, as she had always been visiting cousins on New Years. She was pretty good most of the night, considering she had to stay up until midnight ๐Ÿ™‚

January 1, 2007. With any luck, this year will be more exciting and eventful than last year. There are changes I hope to make, projects to abandon, projects to take up, and places to go. I think I’ll get some sleep so that I can get a head start on that.

Happy New Year!

Time to rethink GTK+ Tab Dragging

I’ve been planning on adding tab drag-and-drop functionality to VMware Workstation 6.0. Rather than implementing this ability from scratch (which I did with Gaim, and would rather not do again), I took the sane approach and started investigating the GTK+ 2.10 API for GtkNotebook tab drag-and-drop.

This is functionality that many applications have had to implement themselves, so it’s great that support had finally gone into GTK+ 2.10. So I must wonder, with all the various applications that would benefit from this new API, how did we get it so wrong?

Now, before I continue, let me say that I applaud the effort in getting this into GTK+ in the first place. Reordering tabs looks smooth, it’s only one API call, and the basics are trivial. Where this all falls down is when you try to do anything complicated with it, and by complicated I mean anything beyond a simple text editor.

Before starting, I investigated how many projects were using this API. A quick Google Code search shows that almost nobody does, aside from maybe the tab reordering API. I did find this list of complaints, which I remember reading before. I won’t repeat everything on this list, but I will list what I’ve ran into, and how I think we can improve this API.

Global functions are very bad. (Bug 386935)

In order to allow for a tab to be dragged out and form a new window, the application must call gtk_notebook_set_window_creation_hook and pass a callback function. When a tab marked as detachable is dragged to the root window, this function will be called. It is expected that the function create a new window, position it as per the x and y coordinates of the drop (if it so desires), show it, and return the resulting notebook. GTK+ will then add the tab to that notebook.

While useful, this suffers from a major design flaw. You can’t set a window creation hook per-notebook. You get exactly one window creation hook function, which must be responsible for any and all notebooks in the program. The hook function can only distinguish between them using the notebook’s group ID.

For smaller programs, this isn’t a huge limitation. Simple text editors and the like only need one function. However, imagine if your application has multiple notebooks that each need to be dragged, and imagine if the code for those notebooks are in two separate parts of the tree. Maybe you have a nice separation of the different parts of the project. Regardless, now you have to have one common function that knows about both and handles their window creations.

The problem gets far worse for applications separated into different libraries, or those using widget utility libraries. Two separate libraries both providing a notebook with drag-and-drop with their own window creation won’t be able to set up a hook. They would require that the main application handle determining the group IDs of the notebook widgets they care about and then calling the proper functions in the libraries. While doable, it’s a horrible burden on the application, and it doesn’t always work.

Of course, the whole thing completely breaks down when you’re writing a plugin with a notebook rather than an application. The plugin won’t be able to offer its own window creation, due to possible conflicts with the main application and other plugins.

The solution, of course, is to have per-notebook window creation hooks. GTK+ could attempt to call one of these and then fall back to the global hook, if it exists. If calling the global hook, GTK+ could spit out a warning informing the user that the program should be upgraded to the new API and that the existing method is deprecated.

Rather than functions, though, a signal handler may make more sense. It could use a collector and call the handlers until it finds one that returns a GtkNotebook. I could see this being useful if a widget component library (as part of a larger project) provides a default window creation handler that the calling application wants to override for a specific case.

Numeric group IDs lead to namespace collisions. (Bug 386930)

Right now, in order to indicate which notebooks are compatible for drag-and-drop operations, each GtkNotebook gets a group ID. This is an unsigned integer with absolutely no rules on how an ID should be picked. This is very dangerous, as it could cause namespace collisions in larger applications, resulting in tabs being droppable onto incompatible notebooks. This could easily crash such applications.

There’s no reason for us to be using integers. Take a look at GtkRadioButton. They also have groups, but they work a bit differently. The first GtkRadioButton defines the group, and the rest get passed that as the group identifier. In gtkmm, you actually have a Gtk::RadioButtonGroup object that you simply instantiate and then pass to each radio button.

Now, in any well-designed program, there should be only one place creating the notebook for a certain type of window, and usually that’s the only type of notebook capable of accepting tabs from the same class of notebook. So, why not do something like what gtkmm does and have some sort of static object that represents that group, define it once, and pass it to each notebook? This is guaranteed to be unique, and solves the namespace collision issue.

Signals need to be more clear. (Bug 386943)

You can determine if a page was added to a notebook or removed from it, but there’s no clear way of determining if it was due to an API call, or a drag-and-drop operation. We worked around it in VMware Workstation, but it would have been very helpful to know precisely that a page was added due to drag-and-drop. Same with the removed signal. I know they wanted to condense the signals and figured it would work in all cases, but it doesn’t, so please, give us some more specific signals!

Drop operations should be able to be programatically rejected. (Bug 386950)

There are times when you want to allow a tab to be draggable, but want to reject it in notebooks under certain circumstances. For example, in VMware Workstation, we have the “Home” tab. I would like to be able to drag this to empty windows, but if that window has a “Home” tab already, I want to reject the drag. To my knowledge, there is no way to do this currently.

Detaching tabs into new windows requires a drag to the desktop. (Bug 360225)

In most any program with tab drag-and-drop, you can drag a tab off into any area not in the tab bar and it will detach into a new window. With the GTK+ tab dragging, you have to actually drag it to the root desktop. Even dragging off into another window isn’t good enough. This sucks. Let’s fix this properly. We’re not doing anybody any favors.

I’m missing a few annoyances I ran into, but I’ll be blogging about them separately once I remember.

So, to recap, I believe we should:

  • Deprecate gtk_notebook_set_window_creation_hook and add a new create_window signal, returning a GtkNotebook.
  • Ditch the numeric group IDs and use some sort of identifier object or generic pointer to a static variable and pass that in instead.
  • Add new signals or something telling us specifically how the tab was added/removed.
  • Provide a way to reject a tab drop on a particular notebook programatically.
  • Call the window creation hook any time the tab is dragged off the tab portion of the notebook.

It would be great to see these things fixed so that more applications can actually use this API without major headaches. Anyone up for the task?

I plan to put up a new post soon giving a couple of tips for using the current API.

Update: Bugs have been filed for the above. They’re in the topic headers.

Planet VMware, Planet V12n

We officially announced two new planets last night at VMware: Planet VMware and Planet V12n, both powered by Planet.

Planet VMware is a Planet for VMware employees, in the spirit of Planet GNOME and such. There are currently ten VMware bloggers on there. This will of course increase in time.

Planet V12n is designed to be the go-to source for virtualization news. Blogs and sites such as virtualization.info and Virtual Strategy Magazine are included, with news covering all things virtualization, VMware and otherwise. The VMware employee blogs are also shown alongside the virtualization blogs.

The planets are very new, so there’s a couple of bugs to work out. The Planet VMware atom feed is busted right now, but it’s a known problem and will be fixed shortly. Please let us know if there are any other glaring problems.

Gallery Virtual Appliance

Virtual machines used to be all about managing your data center or server consolidation or running applications that only run on some other operating system. Lately, virtual machines have been gaining momentum in a new area: software distribution.

This is actually quite powerful. Instead of a giving a user a complex set of instructions for installing some application or web service, and telling them what they need to install beforehand and what distros or operating systems it works on, the distributor or project can instead provide a bare-bones virtual machine containing the application or service pre-configured, and users can simply download it and power it on. It’s a great way of previewing applications or even running them day-to-day (depending on the application).

There’s a wonderful service out there called Gallery. It’s a web-based photo gallery that users can install on their server in order to share photos with the world. There’s a number of modules available. Many programs work with it. You can do things like order prints through the web. Great program.

And it’s now available in a virtual appliance! They have a description and instructions for setting it up, and I’ve been informed that they plan to keep it updated with each new release. It contains both Gallery 1 and Gallery 2, giving users a chance to see the differences between the versions and decide which suits them best. It can be used in VMware Player, Server, Workstation, and probably ESX (I haven’t tried). It’s downloadable from their website or from VMTN. You can see h0bbel’s blog post for more information on the appliance.

I think this is awesome and I hope it works out well for them and for the users. I’d love to see more projects go this route, and with any luck, Gallery will have set a precedent in the web services world. And for the developers creating these appliances, please feel free to let us know what VMware could do to make your lives easier. We welcome feedback, and you can send it directly to me.