1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
opStatus = MirrorVirtualDisk(
vhdHandle,
MIRROR_VIRTUAL_DISK_FLAG_NONE,
&mirrorParameters,
&overlapped
);
if ((opStatus == ERROR_SUCCESS) || (opStatus == ERROR_IO_PENDING))
{
//
// The mirror is completed once the "CurrentValue" reaches the "CompletionValue".
//
// Every subsequent write will be forward to both the source and destination until the
// mirror is broken.
//
for (;;)
{
memset(&progress, 0, sizeof(progress));
opStatus = GetVirtualDiskOperationProgress(vhdHandle, &overlapped, &progress);
/*
if (opStatus != ERROR_SUCCESS)
{
goto Cleanup;
}*/
opStatus = progress.OperationStatus;
if (opStatus == ERROR_IO_PENDING)
{
if (progress.CurrentValue == progress.CompletionValue)
{
break;
}
}
else
{
//
// Any status other than ERROR_IO_PENDING indicates the mirror failed.
//
goto Cleanup;
}
Sleep(1000);
}
}
else
{
printf("%s","error MirrorVirtualDisk\n");
goto Cleanup;
}
resoverlapped=GetOverlappedResult(vhdHandle,&overlapped,&octets,TRUE);
//res=CancelIo(vhdHandle);
goto Cleanup;
Cleanup:
if (opStatus == ERROR_SUCCESS)
{
wprintf(L"success\n");
}
else
{
wprintf(L"error = %u\n", opStatus);
Sleep(10000);
}
if (vhdHandle != INVALID_HANDLE_VALUE)
{
CloseHandle(vhdHandle);
}
if (overlapped.hEvent != NULL)
{
CloseHandle(overlapped.hEvent);
}
return opStatus;
} |
Partager