private void CheckOpenDeviceContext(Smb2CreateContextResponse[] servercreatecontexts) { // <9> Section 3.2.5.1: Windows Server 2012 R2 without [MSKB-3025091] doesn't return SVHDX_OPEN_DEVICE_CONTEXT_RESPONSE. if (TestConfig.Platform == Platform.WindowsServer2012R2) { return; } foreach (var context in servercreatecontexts) { Type type = context.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContext") { Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponse; VerifyFieldInResponse("ServerVersion", TestConfig.ServerServiceVersion, openDeviceContext.Version); } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponseV2; VerifyFieldInResponse("ServerVersion", TestConfig.ServerServiceVersion, openDeviceContext.Version); VerifyFieldInResponse("SectorSize", TestConfig.PhysicalSectorSize, openDeviceContext.PhysicalSectorSize); VerifyFieldInResponse("VirtualSize", TestConfig.VirtualSize, openDeviceContext.VirtualSize); } } }
public void BVT_Resize() { 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 the tunnel operation SVHDX_META_OPERATION_START_REQUEST to resize a VHDSet file and expects success."); SVHDX_META_OPERATION_START_REQUEST startRequest = new SVHDX_META_OPERATION_START_REQUEST(); startRequest.TransactionId = System.Guid.NewGuid(); startRequest.OperationType = Operation_Type.SvhdxMetaOperationTypeResize; SVHDX_META_OPERATION_RESIZE_VIRTUAL_DISK resizeStructure = new SVHDX_META_OPERATION_RESIZE_VIRTUAL_DISK(); resizeStructure.NewSize = NewSize; byte[] payload = client.CreateTunnelMetaOperationStartResizeRequest( startRequest, resizeStructure); 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); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Client reopens the virtual disk file and expects VirtualSize is changed to 2G."); RequestIdentifier = 0; Smb2CreateContextResponse[] serverContextResponse; OpenSharedVHD(TestConfig.NameOfSharedVHDS, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2, null, true, null, out serverContextResponse); foreach (var context in serverContextResponse) { System.Type type = context.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponseV2; VerifyFieldInResponse("VirtualSize", NewSize, openDeviceContext.VirtualSize); } } client.CloseSharedVirtualDisk(); }
private bool CheckOpenDeviceContext(Smb2CreateContextResponse[] servercreatecontexts, RSVD_PROTOCOL_VERSION expectVersion) { if (servercreatecontexts == null) { return(false); } foreach (var context in servercreatecontexts) { Type type = context.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContext") { Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponse; if ((openDeviceContext != null) && (openDeviceContext.Version == (uint)expectVersion)) { return(true); } } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponseV2; if ((openDeviceContext != null) && (openDeviceContext.Version == (uint)expectVersion)) { return(true); } } } return(false); }
private bool CheckOpenDeviceContext(Smb2CreateContextResponse[] servercreatecontexts, RSVD_PROTOCOL_VERSION expectVersion) { if (servercreatecontexts == null) { if (expectVersion == RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1) { // <10> Section 3.2.5.1: Windows Server 2012 R2 without [MSKB-3025091] doesn't return SVHDX_OPEN_DEVICE_CONTEXT_RESPONSE. // So if the open device context returns success, but without SVHDX_OPEN_DEVICE_CONTEXT_RESPONSE, the SUT may still support RSVD version 1. return(true); } else { return(false); } } try { foreach (var context in servercreatecontexts) { Type type = context.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponse") { Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponse; if ((openDeviceContext != null) && (openDeviceContext.Version == (uint)expectVersion)) { return(true); } } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponseV2; if ((openDeviceContext != null) && (openDeviceContext.Version == (uint)expectVersion)) { return(true); } } } } catch { return(false); } return(false); }
private void CheckOpenDeviceContext(Smb2CreateContextResponse[] servercreatecontexts) { foreach (var context in servercreatecontexts) { Type type = context.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContext") { Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponse; VerifyFieldInResponse("ServerVersion", TestConfig.ServerServiceVersion, openDeviceContext.Version); } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = context as Smb2CreateSvhdxOpenDeviceContextResponseV2; VerifyFieldInResponse("ServerVersion", TestConfig.ServerServiceVersion, openDeviceContext.Version); VerifyFieldInResponse("SectorSize", TestConfig.PhysicalSectorSize, openDeviceContext.PhysicalSectorSize); VerifyFieldInResponse("VirtualSize", TestConfig.VirtualSize, openDeviceContext.VirtualSize); } } }
/// <summary> /// Connect to the share VHD file. /// </summary> private bool TestRsvdVersion( string vhdxName, string share, RSVD_PROTOCOL_VERSION version) { using (RsvdClient client = new RsvdClient(new TimeSpan(0, 0, defaultTimeoutInSeconds))) { CREATE_Response response; Smb2CreateContextResponse[] serverContexts; client.Connect(SUTName, SUTIpAddress, Credential.DomainName, Credential.AccountName, Credential.Password, SecurityPackageType, true, share); Smb2CreateContextRequest[] contexts; if (version == RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2) { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContextV2 { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2), // InitiatorHostName is a null-terminated Unicode UTF-16 string VirtualDiskPropertiesInitialized = 0, ServerServiceVersion = 0, VirtualSectorSize = 0, PhysicalSectorSize = 0, VirtualSize = 0 } }; foreach (Smb2CreateSvhdxOpenDeviceContextV2 context in contexts) { logWriter.AddLog(DetectLogLevel.Information, @"OpenSharedVirtualDisk request was sent with context: "); logWriter.AddLog(DetectLogLevel.Information, @"Version: " + context.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"OriginatorFlags: " + context.OriginatorFlags.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName: " + context.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength: " + context.InitiatorHostNameLength.ToString()); } } else { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContext { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2) // InitiatorHostName is a null-terminated Unicode UTF-16 string } }; foreach (Smb2CreateSvhdxOpenDeviceContext context in contexts) { logWriter.AddLog(DetectLogLevel.Information, @"OpenSharedVirtualDisk request was sent with context: "); logWriter.AddLog(DetectLogLevel.Information, @"Version: " + context.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"OriginatorFlags: " + context.OriginatorFlags.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName: " + context.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength: " + context.InitiatorHostNameLength.ToString()); } } uint status; status = client.OpenSharedVirtualDisk( vhdxName, TestTools.StackSdk.FileAccessService.FsCreateOption.FILE_NO_INTERMEDIATE_BUFFERING, contexts, out serverContexts, out response); logWriter.AddLog(DetectLogLevel.Information, @"Get OpenSharedVirtualDisk response with status: " + status); if (serverContexts == null) { logWriter.AddLog(DetectLogLevel.Information, @"The response does not contain any server contexts."); } else { foreach (Smb2CreateContextResponse ctx in serverContexts) { Type type = ctx.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponse") { logWriter.AddLog(DetectLogLevel.Information, @"Server response context is Smb2CreateSvhdxOpenDeviceContextResponse. "); Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = ctx as Smb2CreateSvhdxOpenDeviceContextResponse; logWriter.AddLog(DetectLogLevel.Information, @"Version is: " + openDeviceContext.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName is: " + openDeviceContext.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength is: " + openDeviceContext.InitiatorHostNameLength.ToString()); } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { logWriter.AddLog(DetectLogLevel.Information, @"Server response context is Smb2CreateSvhdxOpenDeviceContextResponseV2. "); Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = ctx as Smb2CreateSvhdxOpenDeviceContextResponseV2; logWriter.AddLog(DetectLogLevel.Information, @"Version is: " + openDeviceContext.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName is: " + openDeviceContext.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength is: " + openDeviceContext.InitiatorHostNameLength.ToString()); } } } bool result = false; if (status != Smb2Status.STATUS_SUCCESS) { result = false; logWriter.AddLog(DetectLogLevel.Information, @"Get status " + status + @" from server response."); logWriter.AddLog(DetectLogLevel.Information, @"The RSVD version " + version + @" is found not supported by server."); return(result); } result = CheckOpenDeviceContext(serverContexts, version); client.CloseSharedVirtualDisk(); return(result); } }