/// <summary> /// Create an SVHDX_META_OPERATION_START_EXTRACT_REQUEST structure and marshal it to a byte array /// </summary> /// <param name="startRequest">Struct SVHDX_META_OPERATION_START_REQUEST includes TransactionId and OperationType</param> /// <param name="extract">Struct SVHDX_META_OPERATION_EXTRACT</param> /// <returns>The marshalled byte array</returns> public byte[] CreateTunnelMetaOperationStartExtractRequest( SVHDX_META_OPERATION_START_REQUEST startRequest, SVHDX_META_OPERATION_EXTRACT extract) { SVHDX_META_OPERATION_START_EXTRACT_REQUEST extractRequest = new SVHDX_META_OPERATION_START_EXTRACT_REQUEST(); extractRequest.startRequest = startRequest; extractRequest.extract = extract; return(TypeMarshal.ToBytes(extractRequest)); }
public void BVT_Extract_VHDSet() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDS, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. Client sends tunnel operation SVHDX_META_OPERATION_START_REQUEST to server and expects success."); System.Guid snapshotId = System.Guid.NewGuid(); CreateSnapshot(snapshotId); SVHDX_META_OPERATION_START_REQUEST startRequest = new SVHDX_META_OPERATION_START_REQUEST(); startRequest.TransactionId = System.Guid.NewGuid(); startRequest.OperationType = Operation_Type.SvhdxMetaOperationTypeExtractVHD; SVHDX_META_OPERATION_EXTRACT extract = new SVHDX_META_OPERATION_EXTRACT(); extract.snapshotType = Snapshot_Type.SvhdxSnapshotTypeVM; extract.flags = ExtractSnapshot_Flags.SVHDX_EXTRACT_SNAPSHOTS_FLAG_ZERO; extract.SourceSnapshotId = snapshotId; //Zero indicates that there MUST be no base snapshot and that the extracted disk will not be a differencing VHD. extract.SourceLimitSnapshotId = System.Guid.Empty; extract.DestinationFileName = Encoding.Unicode.GetBytes(System.Guid.NewGuid().ToString() + "\0"); extract.DestinationFileNameLength = (uint)extract.DestinationFileName.Length; byte[] payload = client.CreateTunnelMetaOperationStartExtractRequest( startRequest, extract); SVHDX_TUNNEL_OPERATION_HEADER?header; SVHDX_TUNNEL_OPERATION_HEADER?response; //For RSVD_TUNNEL_META_OPERATION_START operation code, the IOCTL code should be FSCTL_SVHDX_ASYNC_TUNNEL_REQUEST uint status = client.TunnelOperation <SVHDX_TUNNEL_OPERATION_HEADER>( true, //true for Async operation, false for non-async operation RSVD_TUNNEL_OPERATION_CODE.RSVD_TUNNEL_META_OPERATION_START, ++RequestIdentifier, payload, out header, out response); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Ioctl should succeed, actual status: {0}", GetStatus(status)); VerifyTunnelOperationHeader(header.Value, RSVD_TUNNEL_OPERATION_CODE.RSVD_TUNNEL_META_OPERATION_START, (uint)RsvdStatus.STATUS_SVHDX_SUCCESS, RequestIdentifier); DeleteSnapshot(snapshotId); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Client closes the file."); client.CloseSharedVirtualDisk(); }