Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello
I am trying to create a Net 5.0 application for Hyper-v Backup and I would like to use Resilient Change Tracking for backup virtual disk's Blocks changing.
I am using a Wrapper to library VirtDisk.h (https://docs.microsoft.com/en-us/windows/win32/api/virtdisk/) from C# to access Win32 Resilient Change Tracking functions and also I am testing with Windows server 2016 version 1607 with Hyper-v version 8.0, by default when I create a virtual machine Resilient Change Tracking is disabled, so I have to enable it, but never gets activated.

What I have tried:

To activate Resilient Change Tracking through VirtDisk.h, I am calling the function SetVirtualDiskInformation:
```
[DllImport("VirtDisk.h", CharSet = CharSet.Unicode)]
public static Win32Error SetVirtualDiskInformation(VIRTUAL_DISK_HANDLE VirtualDiskHandle, in SET_VIRTUAL_DISK_INFO VirtualDiskInfo);

```
VIRTUAL_DISK_HANDLE is a pointer (SafeHandler) to a VirtualDisk that was obtained by calling the OpenVirtualDisk method of the VirtDisk.h
```
[DllImport("VirtDisk.h", CharSet = CharSet.Unicode)]
public static Win32Error OpenVirtualDisk(in VIRTUAL_STORAGE_TYPE VirtualStorageType, string Path, VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask, OPEN_VIRTUAL_DISK_FLAG Flags, OPEN_VIRTUAL_DISK_PARAMETERS Parameters, out SafeVIRTUAL_DISK_HANDLE Handle);

```
Code to open virtual disk:
```
string vhdxPath = @"A:\VirtualMachine\VirtualDisk.vhdx";
OPEN_VIRTUAL_DISK_PARAMETERS parameters = new OPEN_VIRTUAL_DISK_PARAMETERS(1)
{
    Version = OPEN_VIRTUAL_DISK_VERSION.OPEN_VIRTUAL_DISK_VERSION_1,
};
parameters.Version1.RWDepth = 1;
var vhd = VirtualDisk.Open(vhdxPath, OPEN_VIRTUAL_DISK_FLAG.OPEN_VIRTUAL_DISK_FLAG_NONE, parameters, VIRTUAL_DISK_ACCESS_MASK.VIRTUAL_DISK_ACCESS_ALL);

```
VIRTUAL_DISK_HANDLE is a pointer that is obtained without problems and I can access the virtual disk information through all the functions of VirtDisk.h, however when I try to activate Resilient Change Tracking with the following code, it never works
```
var si = new SET_VIRTUAL_DISK_INFO { Version = SET_VIRTUAL_DISK_INFO_VERSION.SET_VIRTUAL_DISK_INFO_CHANGE_TRACKING_STATE, ChangeTrackingEnabled = true };
var result = SetVirtualDiskInformation(Handle, si);
result.ThrowIfFailed();

```
Finally, I validate the ChangeTrackingEnabled property after activating it and it always has a false value, also the files with the .rct extension are never generated.
I wonder if there is another way or example code or documentation for activate Resilient Change Tracking inside a virtual machine?
NOTE: I tried activate Resilient Change Tracking using powershell with the command Update-VMVersion and I get the following message;
WARNING: No update was performed for the virtual machine "MVWinRctTest" because its configuration version is already at the maximum level supported by this server. For clustered servers, the maximum supported configuration version can be limited by the cluster functional level.
Any thoughts will be greatly appreciated.
Best
Posted
Updated 16-Feb-22 13:45pm
v2
Comments
[no name] 16-Feb-22 22:43pm    
https://docs.microsoft.com/en-us/powershell/module/failoverclusters/update-clusterfunctionallevel?view=windowsserver2022-ps

https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/deploy/upgrade-virtual-machine-version-in-hyper-v-on-windows-or-windows-server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900