Hyper-v can’t open created VM

Windows 2008 Hyper-V worked fine.  I was able to create and run virtual machines.  I decided to upgrade to Windows 2008 R2 RTM for lab testing.  Available articles said you can leave Hyper-V installed in Windows 2008 even though there is a warning during installation of R2.  I exported a VM for importing back into W2008 R2.  Installed W2008R2.  The imported VM will not start.  Created new VM’s and they will not start.  Event log shows two errors occurring whenever an attempt is made to start a VM.  Event log follows. 

I have spent a couple of days trying to figure out what happened.  Nothing changed in the BIOS to disable VM’s and the upgrade went without error.  I sure could use some words of wisdom from someone who might know what the problem is.  Research indicates the problem is security related, but I can’t find specific information about security settings for Hyper-V in W2008 R2.  The Hyper-V folders holding files have full privileges for System and Administrator and the Virtual Machines group is assigned successfully when a VM is created.  I am working under the administrator account.  The server is a domain controller.  I also removed Hyper-V in W2008 R2 and reinstalled it, but that had no effect.

Log Name:      Microsoft-Windows-Hyper-V-Worker-Admin
Source:        Microsoft-Windows-Hyper-V-Worker
Date:          9/12/2009 2:13:15 PM
Event ID:      3040
Task Category: None
Level:         Error
Keywords:     
User:          NETWORK SERVICE
Computer:      PNS-SERVER.pronetserv.lcl
Description:
‘Symantec AV Manager’ could not initialize. (Virtual machine ID 9C99D5D2-34A1-45A5-814D-30F9145D3D6D)

Log Name:      Microsoft-Windows-Hyper-V-Worker-Admin
Source:        Microsoft-Windows-Hyper-V-Worker
Date:          9/12/2009 2:13:15 PM
Event ID:      3080
Task Category: None
Level:         Error
Keywords:     
User:          NETWORK SERVICE
Computer:      PNS-SERVER.pronetserv.lcl
Description:
‘Symantec AV Manager’ could not create or access saved state file F:\Hyper-V\Symantec AV Manager\Virtual Machines\9C99D5D2-34A1-45A5-814D-30F9145D3D6D\9C99D5D2-34A1-45A5-814D-30F9145D3D6D.vsv. (Virtual machine ID 9C99D5D2-34A1-45A5-814D-30F9145D3D6D)

    Solution:
     Hello,

    I had the same problem after Win2k8 RTM to R2 upgrade.

    In my case it was NTFS permissions problem (which actually wasn’t a problem for Hyper-V in Win2k8 RTM).

    Previously, I have changed default D: drive permissions to only allow ‘Full Access’ for Administrators and SYSTEM group to root of the D: drive.

    I solved my problem by adding ‘Authenticated Users’ group to the root of D: drive and allowed ‘List’ permission with a scope ‘This folder only’ (You should do this via Advanced permission management).
    Just in case: do NOT check ‘replace all child object permissions’, otherwise you will need to recreate all your VMs configurations from scratch.

Hyper-V File Storage and Permissions

Introduction

Hyper-V takes a different approach to virtual machine file storage than Virtual Server 2005 R2. The default locations are different, the storage approach is different, and the configuration files are different. What does this mean to the seasoned Virtual Server 2005 R2 administrator? It means that you will need to start with a fresh slate and learn how it all works. So let us dive in.

Service SIDS

To allow all of the file storage and access changes, Hyper-V leverages a new type of SID added to Windows Server 2008 called a Service SID to control access to virtual machine files. A virtual machine gets a GUID when created and a corresponding unique Service SID is created for the virtual machine using a combination of the Service SID “”NT VIRTUAL MACHINE” and the VMGUID.

Example: “NT VIRTUAL MACHINE\ C64FB013-6D92-4B9B-B106-690182B00FFA ”

If you look at the files of a virtual machine you will see the permissions show an entry for the VMGUID with security permissions assigned, this is the Service SID that is assigned to the virtual machine. Let’s refer to this service SID as the VMSID.

You can use iCACLS to set and view the permissions on files:

icacls “C:\Programdata\Microsoft\Windows\Hyper-V\Virtual Machines\ C64FB013-6D92-4B9B-B106-690182B00FFA.xml” /grant “NT VIRTUAL MACHINE\ C64FB013-6D92-4B9B-B106-690182B00FFA”:(F) /L

The figure below shows an example of a VMSID assigned permissions to a virtual hard disk.


Figure 1

If the VMSID is ever removed from the security permissions of a file that makes up the virtual machine, taking the virtual hard disk as an example, the virtual machine cannot power on.

A special group called Virtual Machines is also created to contain all the virtual machines Service SIDS registered on the Hyper-V server.

Default File Locations

Hyper-V consists of the following default file configuration locations for storing virtual machine files:

  • Default virtual hard disk storage location – C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks
  • Default virtual machine storage location – C:\ProgramData\Microsoft\Windows\Hyper-V

These can be modified using the Hyper-V Settings option in the Hyper-V Manager MMC shown below:


Figure 2

When Hyper-V is installed, these folders are created. The Virtual Hard Disks folder is initially empty but the default virtual machine storage location folder contains two subfolders:

  1. Virtual Machines – Stores the virtual machine configuration files
  2. Snapshots – Stores the snapshot files taken of a virtual machine

It is your choice to use the default locations or to specify a different path to store the virtual machine files when creating a virtual machine using the wizard. Your selection results in different actions being taken from a file security perspective.

Let us discuss the two scenarios of the default locations and specifying a different storage location.

Scenario 1: Using the default locations

If you use the default locations during the creation of a virtual machine using the New Virtual Machine wizard, the following happens.

  1. A GUID is generated and assigned to the virtual machine and a VMSID is generated for permissions use. The term VMGUID will be used to refer to the virtual machines GUID in this article.
  2. The virtual hard disk (VHD) for the virtual machine is placed in the C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks directory using the filename you specified.
  3. The VHD security permissions are modified to add the VMSID with Read and Write access to the VHD.
  4. A XML configuration file a filename consisting of the VMGUID with an XML extension is created in the C:\ProgramData\Microsoft\Windows\Hyper-V folder.
  5. A subfolder is created in the C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines directory consisting of the VMGUID as the folder name and the following permissions are assigned. This folder is used to store the saved state files (VSV and BIN).

    a.       Virtual Machines group is assigned the following special permissions that inherit to the folder and sub folders

    i.      List folder / read data
    ii.     Read attributes
    iii.    Read extended attributes
    iv.    Create files /  write data
    v.     Create folders / append data
    vi.    Read

    b.      The VMSID is assigned and given Full control special permissions for the folder only.


Figure 3

If you save the state of the virtual machine, the save state files are stored in the C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\[VMGUID] folder.

This approach has the following advantages:

  1. You do not have to think about where you store files – the defaults are used automatically.
  2. Everything is stored in two directories.

This approach also has the following disadvantages:

  1. The virtual machine VHD, configuration files, save state files and snapshots are all stored on the system drive. This will cause the drive to run out of disk space quickly.
  2. Different virtual machines files are stored together making it harder to track the associations and troubleshoot permissions.

Scenario 2: Using a different storage location

When you use the New Virtual Machine wizard, you have the option of specifying a different location to store the virtual machine files. You enable this option by enabling the checkbox called Store the virtual machine in a different location and then provide the alternate path in the Location text box.


Figure 4

When you use an alternate storage location for your virtual machine files, permissions and files are created differently.

  1. The VMGUID is still generated and assigned to the virtual machine and a VMSID is generated for permissions use.
  2. Instead of folders being created in the default locations, a subfolder is created in the alternate location specified using the name of the virtual machine as the folder name.

    a.       So if you had specified a virtual machine name of VMTEST and an alternate location of D:\VMs, a new folder called D:\VMs\VMTEST would be created.

  3. The VMTEST folder is assigned the following special permissions

    a.       Virtual Machines group is assigned the following special permissions that inherit to the folder and sub folders.

    i.      List folder / read data
    ii.     Read attributes
    iii.    Read extended attributes
    iv.     Create files /  write data
    v.      Create folders / append data
    vi.     Read

  4. Inside the VMTEST folder, the two subfolders Virtual Machines and Snapshots are created and assigned the following permissions: The VMSID is assigned and given Full control special permissions for the folder only
  5. The VHD created by the New Virtual machine Wizard is placed in the D:\VMs\VMTEST folder and assigned the following permissions: The VMSID is given Read and Write permissions
  6. The virtual machine XML configuration file consisting of the VMGUID with an XML extension is created in the D:\VMs\VMTEST\Virtual Machines folder and assigned the following permissions: The VMSID is assigned Full Control permissions
  7. A subfolder with the name VMGUID is created in the D:\VMs\VMTEST\Virtual Machines folder and assigned the following permissions:

    a.       The subfolder inherits the Virtual Machines group permissions

    i.      List folder / read data
    ii.     Read attributes
    iii.    Read extended attributes
    iv.    Create files /  write data
    v.     Create folders / append data
    vi.    Read

    b.      The VMSID is assigned Full control special permissions for the folder only

Hyper-V looks for the configuration file in the default folder C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines, but since the configuration file is stored in the D:\VMs\VMTest\Virtual Machines folder Hyper-V needs a way to reference the configuration file from the default location. This is where symbolic links are employed. If the virtual machine is not stored in the default location, Hyper-V will create a symbolic link to the actual location of the xml configuration file.

Symbolic links are created with the MKLINK command:

mklink “C:\Programdata\Microsoft\Windows\Hyper-V\Virtual Machines\C64FB013-6D92-4B9B-B106-690182B00FFA.xml” “D:\VMTEST\Virtual Machines\C64FB013-6D92-4B9B-B106-690182B00FFA.xml”

For example, if the configuration is stored in D:\VMs\VMTest\Virtual Machines, Hyper-V will create a symbolic link in the C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines folder using the VMGUID as the name of the link. The link will have a pointer to the actual storage location.

If you create a snapshot, then Hyper-V will also create a symbolic link in the C:\ProgramData\Microsoft\Windows\Hyper-V\Snapshots folder to the snapshot version of the configuration xml file in the D:\VMs\VMTest\Snapshots folder.

This approach has the following advantages:

  1. All files for a virtual machine are stored in one folder hierarchy that is rooted with the name of the virtual machine
  2. You can place the virtual machine files on any available drive
  3. Automatic organization of the folders.

This approach has the following disadvantages:

  1. The additional symbolic links that need to be created and managed
  2. You must remember to use the different storage path when you create a new virtual machine

Conclusion

Hyper-V virtual machine file storage and permissions provides two approaches to managing the virtual machine files. Using the default folders makes it easy to create virtual machines, but places the Hyper-V server at constant risk of running out of disk space on the system volume. Using the alternate storage location eliminates the system volume disk issue and provides better organization of the virtual machines storage, but increases the complexity of the storage approach. I personally would always recommend the use of the different storage path