Converting Applications Written for Pipes

Microsoft SQL Server Virtual Backup

Microsoft SQL Server Virtual Backup Device Specification

Converting Applications Written for Pipes

Currently, an application written to use named pipes must perform basic Open, Close, Read, and Write processing on a pipe. With the VDI, these operations are performed with the following function calls:

  • Read

  • Write

  • Flush

  • ClearError

Initialization

For pipes, the WIN32 interfaces attempt to open and wait for the pipe interface to become available:

while(1) {
   h = CreateFile( <pipename>, OPEN_EXISTING...)
   if (h != INVALID_HANDLE_VALUE)
      break;  // continue with active phase
   WaitNamedPipe( <some interval of time>)
}

With the VDI, the client obtains a COM interface, creates the virtual device set, and then waits for the server to finish configuring it:

VDConfig config;
IClientVirtualDeviceSet2 *vds;
memset (&config, 0, sizeof(config));
config.deviceCount = 1;
CoCreateInstance(CLSID_MSSQL_ClientVirtualDeviceSet,
       NULL, CLSCTX_INPROC_SERVER, 
       IID_IClientVirtualDeviceSet2,
       &vds );
vds-> Create( <VDNAME>, &config)
vds-> GetConfiguration( &newConfig, timeout)

The invocation of the BACKUP or RESTORE command was not shown. The only difference in the command syntax is to specify VIRTUAL_DEVICE rather than pipe and the names of the devices themselves.