No Virtual Mahines were found on this server

Right… This has been driving me crazy today. Not really sure why it happened but I’ve managed to sort if out now and wanted to share!

Our hyper-v server hosting our domain controller and a couple of Linux machines decided today that it didn’t want to admit to having any machines hosted on it. When opening hte hyper-v management tools on my Win 7 laptop I was getting the message “No Virtual Mahines were found on this server”. That was quite a worry and made me reluctant to re-boot the host machine through fear of not being able to control the hosted machines any more.

My first hurdle was getting access to the Hyper-v R2 Event Log. For some reason the firewall was not configured to allow me to access this. This was a simple fix of opening the fiewall on the hyper-v server to allow WMI access. The alternative is to drop the fire wall for the duration of this fix (netsh firewall set opmode disable) and re-enable it after (netsh firewall set opmode enable).

Ok the real crux of the problem. For some reason the security permissions on the hyper-v configuration files had been lost or reset. It took me an age to fix this but finally managed to piece together enough information to fix it.

The Virtual Machine Management Service uses some configuration files from the directory %SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\. The xml files in this directory are in fact symlinks and should be named the same as the xml configuration files for the virtual machines them selves.

We store our virtual machines in the directory v:\VMs. So for example our machine test-01 has it’s xml file stored as V:\VMs\test-01\Virtual Machines\<guid>.xml.

Each virtual machine on the host has a similar set up. To fix the permissions you need to recreate the symlinks in the directory %SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\. To do that you need to execute the following commands for each machine.

mklink “%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\<vm_guid>.xml” “V:\VMs\win2k8r2\Virtual Machines\<vm_guid>.xml”

icacls “%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\<vm_guid>.xml” /grant “NT VIRTUAL MACHINE\<vm_guid>”:F /l

The one part that I missed initially was the “/l” on the end of the icacls command. This is very important and tells icacls to apply the security permission to the link rather than the destination file.

If any of your VM’s have snapshots you need to repeat a similar procedure for the snapshots directory.

mklink “%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots\<snapshot_guid>.xml” “V:\VMs\test-01\Snapshots\<snapshot_guid>.xml”

icacls “%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots\<snapshot_guid>.xml” /grant “NT VIRTUAL MACHINE\<vm_guid>”:F /l

When you have repaired all the files in the directories simply restart the Virtual Machine Management Service” by using the following two commands:

net stop vmms

net start vmms

You should now be able to view the files in the Hyper-v management console.

Sandbach Bound

Tonight I’m heading up North for 2 days with work. It’s a two part trip really (at least for me!).

Part 1 is to sit an Agile Project Management Practitioner exam. Should be good and am feeling not too bad about it.

Part 2 is to collect my shiny new work laptop. I’ve got a HP Pavilion DV7-4040sa waiting for me at headquarters! I’ll post some pictures and some feedback on what I think of the machine. It’s going to replace my work PC so I will truly be a mobile worker now. I’ve got a few accessories arriving over the next few days as well (laptop bag, desktop power cable) so I should hopefully have a complete laptop set-up very soon.

PHP xdiff (libxdiff) on Windows

Not this is a tricky little bugger to get working. Xdiff is a fantastic set of difference libraries for obtaining differences between files or strings. The installation on Linux was covered in a previous post but Windows was a completely different ball game. I’ve finally managed to get it working however… so here we go.

Process Overview

To install this you need to compile a php_xdiff.dll file. To do this you will need to obtain Visual Studio 2008 (a.k.a VC9). This opens up several problems however. To run the compiled xdiff dll file you will need to have a VC9 version of php installed. If you install a VC9 version of PHP and use apache you will need a VC9 version of Apache. See where the problems start?!!!

PHP

There is no getting away from the fact that you are going to require a VC9 version of PHP if you compile a php_xdiff.dll file. VC6 is not available any more and it makes sense to compile this with the most updated version available. This is reasonably easily fixed as PHP offer a VC9 compiled version of PHP (http://windows.php.net/download/)

Apache

This is reasonably easily fixed as well. The guys at ApacheLounge compile VC9 versions of Apache and make them readily available. See http://www.apachelounge.com/download/.

Compiling php_xdiff.dll

This is the more troublesome stretch of the process. There is a good guide available at http://wiki.php.net/internals/windows/stepbystepbuild for getting started. If you follow this up to the point of adding extensions you should be on good ground. One word of advice would be to download all the extensions headers and libraries available. Just make sure you have everything available. If you’ve managed to compile a version of PHP with no extensions added you’re a good way there!

When you’ve got the PHP build available it’s now time to start working on xdiff. First of all you need to obtain and compile libxdiff. The source can be obtained from http://www.xmailserver.org/xdiff-lib.html. Once you have this you need to compile it using the visual studio tools. If you’ve still got your compiler window open from compiling PHP, change to the directly where you have libxdiff extracted to and run “nmake”. This should compile some headers and library files. Once compiled you need to copy all the headers and libraries into the appropriate PHP library directories.

From here you need to follow the steps at the bottom of the PHP internals page regarding installing additional PECL extensions. This should then compile. As a note. When you give the additional “configure” command use “–with-xdiff=shared”. This will cause the library to be built as a dll file rather than compiled into php5ts.dll file.

Putting it all together

Finally you need to add the dll to the php install you insatlled earlier. Copy the dll file to the “ext” directory under the php install (with the other extensions). Edit php.ini and add the line “extension=php_xdiff.dll” into the extensions section.

Finally restart apache and you should now have xdiff functionality within PHP. If you’ve managed this… give your self a pat on the back!

UPDATE:

I’ve uploaded the xdiff file that I compiled. If you want to use this simply install VC9 versions of PHP and Apache and place this file into the ext directory, edit the php.ini file and you’re away. It’s available here: php_xdiff.