Error: specifying non-vhd SourcePath for CreateVirtualDisk
-
26 เมษายน 2555 22:55
according to http://msdn.microsoft.com/en-us/library/windows/desktop/dd323661(v=vs.85).aspx,
the SoucePath in the CREATE_VIRTUAL_DISK_PARAMETERS structure is
"Optional fully qualified path to pre-populate the new virtual disk object with block data from an existing disk.
This path may refer to a virtual disk or a physical disk."I was able to specify SourcePath as an existing .vhd file and it works fine.
However, I was not able to specify SourcePath as any of the followings (vss shadowcopy):
1. \\\\?\\GLOBALROOT\Device\\HarddiskVolumeShadowCopy31
CreateVirtualDisk returns error 0x57, the parameter is incorrect
The shadowcopy was created by using vshadow.exe2. \\Device\\HarddiskVolumeShadowCopy31
CreateVirtualDisk returns error 0x57, the parameter is incorrect
The shadowcopy was created by using vshadow.exe3. \\\\?\Volume{71591178-04af-11e1-9ebf-806e6f6e6963}\\
CreateVirtualDisk returns either error 0x5, access denied when mount point has been created, or
error 0x15, device is not ready when no mount point has ever been created.
This volume is either a volume on physical disk, or an exposed shadow copy volume.My question is how to specify SourcePath to a VSS snapshot? or to a physical disk?
or anything other than .vhd?
If SourcePath only supports .vhd (or .vhdx), should the manual be revised accordingly?Found similar posts with identical question without answers.
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/5e37d0c7-8c76-4547-a3f0-41ffa8dc2ea4/
http://social.technet.microsoft.com/Forums/zh/winserverhyperv/thread/a4d9af1f-6e21-491b-9d4f-e3bc2426555f
http://stackoverflow.com/questions/6485579/creating-vhd-files-with-the-virtualdisk-api
http://stackoverflow.com/questions/3205811/error-access-denied-when-using-the-function-createvirtualdisk-in-win7
http://go4answers.webhost4life.com/Example/error-access-denied-function-25070.aspxThanks.
p.s.
env: VS2010 + sp1, Windows SDK 7.1 and 7.0a, on Windows 7 professional x64 + sp1,
running with elevated privileges
source code: assign the fully qualified path to "params.Version1.SourcePath" in the following code.BOOL CreateVHD_Fixed(PCWSTR pszVhdPath, ULONG sizeInMB)
{
BOOL bRet = FALSE;
HANDLE hvhd = NULL;
CREATE_VIRTUAL_DISK_PARAMETERS params;
VIRTUAL_DISK_ACCESS_MASK mask;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};wprintf(L"CreateVHD_Fixed %s, size (MB) %d\n", pszVhdPath, sizeInMB);
params.Version1.UniqueId = GUID_NULL;
params.Version1.BlockSizeInBytes = CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE;
params.Version1.MaximumSize = sizeInMB * 1024 * 1024;
params.Version1.ParentPath = NULL;
params.Version1.SourcePath = NULL;
params.Version1.SectorSizeInBytes = CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_SECTOR_SIZE;
params.Version = CREATE_VIRTUAL_DISK_VERSION_1;
mask = VIRTUAL_DISK_ACCESS_CREATE;DWORD ret = CreateVirtualDisk(&vst,
pszVhdPath,
mask,
NULL,
// To create a dynamic disk, use CREATE_VIRTUAL_DISK_FLAG_NONE instead.
CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION,
0,
¶ms,
NULL,
&hvhd);if (ret == ERROR_SUCCESS)
{
bRet = TRUE;
if (INVALID_HANDLE_VALUE != hvhd)
{
CloseHandle(hvhd);
}
}
else
{
bRet = FALSE;
printf("failed to create vdisk...err 0x%x\n", ret);
PrintErrorMessage(ret);
}return bRet;
}
ตอบทั้งหมด
-
27 เมษายน 2555 1:42
-
27 เมษายน 2555 2:51ผู้ดูแล
Hi,
According to the description, it seems that you want to develop some application. If so, it is recommend you to get further support in the corresponding community so that you can get the most qualified pool of respondents. Thanks for your understanding.
For your convenience, I have list the related link as followed.
MSDN Forums
http://social.msdn.microsoft.com/Forums/en/categories
- ทำเครื่องหมายเป็นคำตอบโดย Vincent HuModerator 2 พฤษภาคม 2555 8:55
-
27 เมษายน 2555 14:41ผู้ดูแล
Also note that VHD and VHDX differencing disks support vastly different parent options. They are not interchangeable.
Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat.
Disclaimer: Attempting change is of your own free will. -
27 เมษายน 2555 18:00
try something like
several more tries without luck:
(harddisk1 is present and has one partition)\\\\.\\PHYSICALDISK1
error 0x2, the system cannot find the file specified\\Device\\Harddisk1
error 0x6, the handle is invalid\\Device\\Harddisk1\\DR1
error 0x57, the parameter is incorrect\\\\?\\GLOBALROOT\\Device\\Harddisk1Partition1
error 0x2, the system cannot find the file specified\\Device\\Harddisk1Partition1
error 0x2, the system cannot find the file specified\\\\?\\GLOBALROOT\\Device\\HarddiskVolume4
error 0x57, the parameter is incorrect\\Device\\HarddiskVolume4
error 0x57, the parameter is incorrectany suggestions?
-
27 เมษายน 2555 18:11
Hi,
According to the description, it seems that you want to develop some application. If so, it is recommend you to get further support in the corresponding community so that you can get the most qualified pool of respondents. Thanks for your understanding.
For your convenience, I have list the related link as followed.
MSDN Forums
http://social.msdn.microsoft.com/Forums/en/categories
I already submit to
Server Virtualization, Windows Desktop SDK, General Windows Desktop Development Issues.
So far, no luck yet.
- แก้ไขโดย likong 27 เมษายน 2555 18:13
-
27 เมษายน 2555 18:20
Also note that VHD and VHDX differencing disks support vastly different parent options. They are not interchangeable.
Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat.
Disclaimer: Attempting change is of your own free will.version2 (for Windows 8) of the CREATE_VIRTUAL_DISK_PARAMETERS structure now has SourceVirtualStorageType, which is "A VIRTUAL_STORAGE_TYPE structure describing the source virtual disk specified in the SourcePath member". Within VIRTUAL_STORAGE_TYPE, the valid device type includes iso, vhd, and vhdx. This seems to suggest physical disk and vss shadow volumes are not valid type for SourcePath???
-
30 เมษายน 2555 19:59
This works: \\\\.\\PHYSICALDRIVE1
(Note it is drive, not disk.)
The other part I am working on is to create VHD from a VSS snapshot. It seems SourcePath cannot be a VSS snapshot (which is at volume level). In order to create a VHD from a VSS snapshot, one needs to copy directory tree and meta data (ACLs, NTFS streams, etc.) from VSS snapshot to VHD. Is there any efficient way to do this? Any pointers are welcome.
- ทำเครื่องหมายเป็นคำตอบโดย Vincent HuModerator 2 พฤษภาคม 2555 8:55