Freigeben über


Hyper-V: Background Merging of AVHD’s… When’s it done?

image

I think it might be best to start at ground zero with this topic and explain what a snapshot really is and how it work’s (if you already know skip a head…).  Hyper-V introduced a new feature called a snapshot – snapshots allow you to capture and save the point in time state of a running or saved virtual machine and then go back to that state at a latter point in time.  For example you can have a Windows XP RTM virtual machine running take a snapshot, install SP1, take a snapshot and install SP2 and then latter revert back to the SP1 snapshot and either discard the SP2 installation or keep it around so you can apply that state latter.  Snapshot’s are pretty handing in this regard – you can create pretty extensive tree’s of snapshots and you can rapidly apply specific states to virtual machines.  Under the covers snapshots primarily use a technology that was implemented back in the pre-Microsoft days of Virtual PC called differencing VHD’s.  What a differencing VHD effectively does is point back to a parent VHD for it’s data but any updates made to the VHD reside in the new differencing VHD and subsequent requests for that same data will be overridden by the child differencing VHD.  These parent child relationships can get many levels deep and a parent can have many children – however if a parent is ever modified it’s children's state is now invalid since the child was unaware of the changes.  So back to snapshots – when a snapshot is taken we create a new differencing disk to point the virtual machine to and we call it an AVHD or automatic VHD since it was created automatically by requesting the snapshot – at the same time we will save off the virtual machines running state if it’s running including it’s memory state and it’s device state (network adapter IP etc…).  When you revert back to a previous snapshot you reload the memory and device state and the VM is pointed at a new AVHD from the parent of that time.  And that’s snapshots in a nut shell…

OK now back to topic at hand – when you delete a snapshot the next time the virtual machine is off or saved we will merge the AVHD created by the snapshot back into it’s respective parent…  We do this automatically and in the background – so lets say you wanted to know when it’s was done programmatically…  It’s not too hard just run the following query to see if any merges are going on presently - PS C:\> Get-WmiObject -Namespace "root\virtualization" -Query "select * from Msvm_ConcreteJob" | Where {$_.ElementName - eq 'Merge in Progress'} .  Below you can see the full output of that query when a merge is occurring.  Hope this helps!

 

PS C:\> Get-WmiObject -Namespace "root\virtualization" -Query "select * from Msvm_ConcreteJob" | Where {$_.ElementName -eq 'Merge in Progress'}

__GENUS : 2 __CLASS : Msvm_ConcreteJob __SUPERCLASS : CIM_ConcreteJob __DYNASTY : CIM_ManagedElement __RELPATH : Msvm_ConcreteJob.InstanceID="E3675DEB-A13C-440D-AEAD-B6CEB5ADF1D7" __PROPERTY_COUNT : 36 __DERIVATION : {CIM_ConcreteJob, CIM_Job, CIM_LogicalElement, CIM_ManagedSystemElement...} __SERVER : TAYLORB __NAMESPACE : root\virtualization __PATH : \\TAYLORB\root\virtualization:Msvm_ConcreteJob.InstanceID="E3675DEB-A13C-440D-AEAD-B6CEB5ADF1D7" Cancellable : True Caption : Merge in Progress DeleteOnCompletion : False Description : Merge in Progress ElapsedTime : 00000000000000.000000:000 ElementName : Merge in Progress ErrorCode : 0 ErrorDescription : ErrorSummaryDescription : HealthState : 0 InstallDate : 16010101000000.000000-000 InstanceID : E3675DEB-A13C-440D-AEAD-B6CEB5ADF1D7 JobRunTimes : 1 JobState : 4 JobStatus : LocalOrUtcTime : 2 Name : Merge in Progress Notify : OperationalStatus : {0, 0, 0} OtherRecoveryAction : Owner : PercentComplete : 13 <----Percent Complete Priority : 0 RecoveryAction : 0 RunDay : 0 RunDayOfWeek : 0 RunMonth : 0 RunStartInterval : 00000000000000.000000:000 ScheduledStartTime : 16010101000000.000000-000 StartTime : 16010101000000.000000-000 Status : StatusDescriptions : {, , } TimeBeforeRemoval : 00000000000500.000000:000 TimeOfLastStateChange : 20090309234922.000000-000 TimeSubmitted : 16010101000000.000000-000 UntilTime : 16010101000000.000000-000

Taylor Brown
Hyper-V Integration Test Lead
https://blogs.msdn.com/taylorb

clip_image001

Comments

  • Anonymous
    March 10, 2009
    PingBack from http://www.clickandsolve.com/?p=20919

  • Anonymous
    November 26, 2009
    can we safely cancel the merge? is there a way to know how long it took? either an event in the application or system log of parent or host?

  • Anonymous
    September 08, 2010
    Get-WmiObject -Namespace "rootvirtualization" -Query "select * from Msvm_ConcreteJob" | Where {$_.ElementName - eq 'Merge in Progress'}


There should be no space after the eq Picky me :-)

  • Anonymous
    April 16, 2011
    The comment has been removed

  • Anonymous
    November 01, 2011
    Hey Taylor, I take it this is system-wide.  Is there a way to determine if there is a merge in progress for a particular virtual machine?  Does the InstanceID above refer to the GUID of the virtual machine? Thanks, -Mezz

  • Anonymous
    November 23, 2011
    can i run this query in CMD prompt, also it comes up with this error this cmd is not reconized as an internal external cmd Please help

  • Anonymous
    December 20, 2011
    The merge process on a VM happens when the vm is in a turned off state. You are also notified via the Hyper-V Manager that a Merge is in Progress. It should be very clear something is happening especially since the VM is in a turned off or Saved state. Maybe its just me that doesn't see the point of that command.

  • Anonymous
    December 20, 2011
    The comment has been removed

  • Anonymous
    June 28, 2015
    Hey Taylor, Repeating what Mezz said.. I take it this is system-wide.  Is there a way to determine if there is a merge in progress for a particular virtual machine? Thanks, Shanmuk