win-pvdrivers

changeset 631:bf13631a5054

avoid 7b bsod by better defining installation and driver loading order so xenpci won't hide the boot disk before xenvbd is properly installed
- only hide devices once the pv driver to load their counterpart device is installed (move hide_device list creation from xenpci.inf to xenscsi.inf, xenvbd.inf, xennet.inf)
- remove default hiding list (in case no drivers were installed yet)
- force a reboot after xenvbd installation to avoid having both it and the drivers it should replace running at the same time causing disk corruption
- hide more xenvbd conflicting devices
author Amir Szekely <amir@neocleus.com>
date Tue Aug 18 17:37:27 2009 +0300 (2009-08-18)
parents 51012d703b75
children 4c7db3f810f7
files coinst/coinst.c coinst/coinst.def coinst/coinst.rc coinst/makefile coinst/sources dirs installer.wxs sign.bat xennet/xennet.inx xenpci/xenpci.inx xenscsi/xenscsi.inx xenvbd/xenvbd.inx
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/coinst/coinst.c	Tue Aug 18 17:37:27 2009 +0300
     1.3 @@ -0,0 +1,54 @@
     1.4 +/*
     1.5 +PV Drivers for Windows Xen HVM Domains
     1.6 +Copyright (C) 2009 Neocleus Inc., Amir Szekely (amir@neocleus.com)
     1.7 +
     1.8 +This program is free software; you can redistribute it and/or
     1.9 +modify it under the terms of the GNU General Public License
    1.10 +as published by the Free Software Foundation; either version 2
    1.11 +of the License, or (at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU General Public License
    1.19 +along with this program; if not, write to the Free Software
    1.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    1.21 +*/
    1.22 +
    1.23 +#include <windows.h>
    1.24 +#include <setupapi.h>
    1.25 +
    1.26 +DWORD
    1.27 +__stdcall CoRequireReboot (
    1.28 +               IN     DI_FUNCTION               InstallFunction,
    1.29 +               IN     HDEVINFO                  DeviceInfoSet,
    1.30 +               IN     PSP_DEVINFO_DATA          DeviceInfoData,
    1.31 +               IN OUT PCOINSTALLER_CONTEXT_DATA Context
    1.32 +               )
    1.33 +{
    1.34 +	UNREFERENCED_PARAMETER(Context);
    1.35 +
    1.36 +	OutputDebugString(TEXT("CoRequireReboot"));
    1.37 +
    1.38 +	if (InstallFunction == DIF_INSTALLDEVICE)
    1.39 +	{
    1.40 +		SP_DEVINSTALL_PARAMS DevInstallParams;
    1.41 +		OutputDebugString(TEXT("  CoRequireReboot: DIF_INSTALLDEVICE"));
    1.42 +		DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
    1.43 +		
    1.44 +		if (SetupDiGetDeviceInstallParams(DeviceInfoSet, DeviceInfoData, &DevInstallParams))
    1.45 +		{
    1.46 +			OutputDebugString(TEXT("  CoRequireReboot: SetupDiGetDeviceInstallParams"));
    1.47 +			DevInstallParams.Flags |= DI_DONOTCALLCONFIGMG;
    1.48 +			DevInstallParams.Flags |= DI_NEEDREBOOT;
    1.49 +			if (SetupDiSetDeviceInstallParams(DeviceInfoSet, DeviceInfoData, &DevInstallParams))
    1.50 +			{
    1.51 +				OutputDebugString(TEXT("  CoRequireReboot: SetupDiSetDeviceInstallParams"));
    1.52 +			}
    1.53 +		}
    1.54 +	}
    1.55 +
    1.56 +    return NO_ERROR;
    1.57 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/coinst/coinst.def	Tue Aug 18 17:37:27 2009 +0300
     2.3 @@ -0,0 +1,7 @@
     2.4 +LIBRARY  NEOCOINST
     2.5 +
     2.6 +EXPORTS   
     2.7 +   CoRequireReboot
     2.8 +   
     2.9 +
    2.10 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/coinst/coinst.rc	Tue Aug 18 17:37:27 2009 +0300
     3.3 @@ -0,0 +1,14 @@
     3.4 +#include <windows.h>
     3.5 +
     3.6 +//
     3.7 +// Version resources
     3.8 +//
     3.9 +#include <ntverp.h>
    3.10 +#define VER_FILETYPE                VFT_DLL
    3.11 +#define VER_FILESUBTYPE             VFT2_UNKNOWN
    3.12 +#define VER_FILEDESCRIPTION_STR     "CoInstaller: Xen GPL PV"
    3.13 +#define VER_INTERNALNAME_STR        "XENCOINST.DLL"
    3.14 +#define VER_ORIGINALFILENAME_STR    "XENCOINST.DLL"
    3.15 +#include <common.ver>
    3.16 +
    3.17 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/coinst/makefile	Tue Aug 18 17:37:27 2009 +0300
     4.3 @@ -0,0 +1,9 @@
     4.4 +#
     4.5 +# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
     4.6 +# file to this component.  This file merely indirects to the real make file
     4.7 +# that is shared by all the driver components of the Windows NT DDK
     4.8 +#
     4.9 +
    4.10 +!INCLUDE $(NTMAKEENV)\makefile.def
    4.11 +
    4.12 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/coinst/sources	Tue Aug 18 17:37:27 2009 +0300
     5.3 @@ -0,0 +1,17 @@
     5.4 +TARGETNAME=coinst
     5.5 +TARGETTYPE=DYNLINK
     5.6 +USE_MSVCRT=1
     5.7 +
     5.8 +_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WIN2K)
     5.9 +
    5.10 +SOURCES=coinst.c \
    5.11 +        coinst.rc
    5.12 +
    5.13 +TARGETLIBS= $(SDK_LIB_PATH)\setupapi.lib \
    5.14 +            $(SDK_LIB_PATH)\kernel32.lib \
    5.15 +            $(SDK_LIB_PATH)\advapi32.lib \
    5.16 +            $(SDK_LIB_PATH)\user32.lib
    5.17 +
    5.18 +DLLBASE=0x2000000
    5.19 +
    5.20 +
     6.1 --- a/dirs	Tue Aug 18 15:16:41 2009 +1000
     6.2 +++ b/dirs	Tue Aug 18 17:37:27 2009 +0300
     6.3 @@ -1,1 +1,1 @@
     6.4 -DIRS=xenpci xenvbd xennet xenscsi copyconfig shutdownmon
     6.5 \ No newline at end of file
     6.6 +DIRS=xenpci xenvbd xennet xenscsi copyconfig shutdownmon coinst
     7.1 --- a/installer.wxs	Tue Aug 18 15:16:41 2009 +1000
     7.2 +++ b/installer.wxs	Tue Aug 18 17:37:27 2009 +0300
     7.3 @@ -53,6 +53,7 @@
     7.4                  <File Id='xenvbd.cat' Name='xenvbd.cat' DiskId='1' Source='xenvbd\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenvbd.cat' />
     7.5                  <File Id='xenvbd.inf' Name='xenvbd.inf' DiskId='1' Source='xenvbd\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenvbd.inf' />
     7.6                  <File Id='xenvbd.sys' Name='xenvbd.sys' DiskId='1' Source='xenvbd\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\xenvbd.sys' />
     7.7 +                <File Id='xencoinst.dll' Name='xencoinst.dll' DiskId='1' Source='coinst\obj$(env.BUILD_ALT_DIR)\$(var.ARCHDIR)\coinst.dll' />
     7.8                  <difx:Driver Sequence='1' Legacy='yes' PlugAndPlayPrompt='no' ForceInstall='yes'/>
     7.9                </Component>
    7.10              </Directory>
     8.1 --- a/sign.bat	Tue Aug 18 15:16:41 2009 +1000
     8.2 +++ b/sign.bat	Tue Aug 18 17:37:27 2009 +0300
     8.3 @@ -11,7 +11,8 @@ ECHO _BUILDARCH=%_BUILDARCH%
     8.4  ECHO BUILDDIR=%BUILDDIR%
     8.5  ECHO SIGN_OS=%SIGN_OS%
     8.6  
     8.7 -xcopy /D xenhide\%BUILDDIR%\xenhide.sys xenpci\%BUILDDIR%
     8.8 +xcopy /D coinst\%BUILDDIR%\coinst.dll xenvbd\%BUILDDIR%
     8.9 +move xenvbd\%BUILDDIR%\coinst.dll xenvbd\%BUILDDIR%\xencoinst.dll
    8.10  xcopy /D %BASEDIR%\redist\wdf\%_BUILDARCH%\WdfCoInstaller01007.dll xenpci\%BUILDDIR%
    8.11  
    8.12  IF NOT EXIST SIGN_CONFIG.BAT GOTO DONT_SIGN
    8.13 @@ -23,7 +24,7 @@ CALL SIGN_CONFIG.BAT
    8.14  %DDK_PATH%\bin\selfsign\signtool sign /v /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xennet\%BUILDDIR%\xennet.sys xennet\%BUILDDIR%\xennet.cat
    8.15  
    8.16  %DDK_PATH%\bin\selfsign\inf2cat /driver:xenvbd\%BUILDDIR% /os:%SIGN_OS%
    8.17 -%DDK_PATH%\bin\selfsign\signtool sign /v /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.sys xenvbd\%BUILDDIR%\xenvbd.cat
    8.18 +%DDK_PATH%\bin\selfsign\signtool sign /v /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenvbd\%BUILDDIR%\xenvbd.sys xenvbd\%BUILDDIR%\xencoinst.dll xenvbd\%BUILDDIR%\xenvbd.cat
    8.19  
    8.20  %DDK_PATH%\bin\selfsign\inf2cat /driver:xenscsi\%BUILDDIR% /os:%SIGN_OS%
    8.21  %DDK_PATH%\bin\selfsign\signtool sign /v /n %CERT_NAME% /t http://timestamp.verisign.com/scripts/timestamp.dll xenscsi\%BUILDDIR%\xenscsi.sys xenscsi\%BUILDDIR%\xenscsi.cat
     9.1 --- a/xennet/xennet.inx	Tue Aug 18 15:16:41 2009 +1000
     9.2 +++ b/xennet/xennet.inx	Tue Aug 18 17:37:27 2009 +0300
     9.3 @@ -77,7 +77,7 @@ HKR, Ndi\Params\NetworkAddress, Default,
     9.4  HKR, Ndi\Params\NetworkAddress, Optional, , "1"
     9.5  
     9.6  [XenNet.CopyFiles]
     9.7 -xennet.sys
     9.8 +xennet.sys,,0x00001000 ; COPYFLG_REPLACE_BOOT_FILE
     9.9  
    9.10  [SourceDisksFiles]
    9.11  xennet.sys=1
    9.12 @@ -103,6 +103,8 @@ AddReg = XenNet_Service_AddReg
    9.13  [XenNet_Service_AddReg]
    9.14  ; 5 = PciBus, 0 = Internal, 15 = PnpBus
    9.15  HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
    9.16 +; hide Qemu Network in XenPCI
    9.17 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "VEN_10EC&DEV_8139"
    9.18  
    9.19  [Strings]
    9.20  XenGplPv = "Xen GPL PV Driver Developers"
    10.1 --- a/xenpci/xenpci.inx	Tue Aug 18 15:16:41 2009 +1000
    10.2 +++ b/xenpci/xenpci.inx	Tue Aug 18 17:37:27 2009 +0300
    10.3 @@ -52,12 +52,6 @@ HKR,"Parameters", "veto_devices", 0x0001
    10.4  HKR,"Parameters", "veto_devices", 0x00010008, "vfb"
    10.5  HKR,"Parameters", "veto_devices", 0x00010008, "vkbd"
    10.6  HKR,"Parameters", "veto_devices", 0x00010008, "suspend"
    10.7 -; Qemu IDE
    10.8 -HKR,"Parameters", "hide_devices", 0x00010008, "VEN_8086&DEV_7010"
    10.9 -; Qemu SCSI
   10.10 -HKR,"Parameters", "hide_devices", 0x00010008, "VEN_1000&DEV_0012"
   10.11 -; Qemu Network
   10.12 -HKR,"Parameters", "hide_devices", 0x00010008, "VEN_10EC&DEV_8139"
   10.13  ; Add XenHide as a filter to IDE Controllers
   10.14  HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenPci
   10.15  ; Add XenHide as a filter to SCSI Controllers
    11.1 --- a/xenscsi/xenscsi.inx	Tue Aug 18 15:16:41 2009 +1000
    11.2 +++ b/xenscsi/xenscsi.inx	Tue Aug 18 17:37:27 2009 +0300
    11.3 @@ -37,6 +37,8 @@ AddReg = XenScsi_Service_AddReg
    11.4  
    11.5  [XenScsi_Service_AddReg]
    11.6  HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
    11.7 +; hide Qemu SCSI in XenPCI
    11.8 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "VEN_1000&DEV_0012"
    11.9  
   11.10  [XenScsi_EventLog]
   11.11  AddReg = XenScsi_EventLog_AddReg
    12.1 --- a/xenvbd/xenvbd.inx	Tue Aug 18 15:16:41 2009 +1000
    12.2 +++ b/xenvbd/xenvbd.inx	Tue Aug 18 17:37:27 2009 +0300
    12.3 @@ -21,7 +21,7 @@ ExcludeFromSelect=*
    12.4  CopyFiles=XenVbd.CopyFiles
    12.5  
    12.6  [XenVbd.CopyFiles]
    12.7 -xenvbd.sys
    12.8 +xenvbd.sys,,0x00001000 ; COPYFLG_REPLACE_BOOT_FILE
    12.9  
   12.10  [XenVbd_Inst.NT.Services]
   12.11  AddService=XenVbd,2,XenVbd_Service, XenVbd_EventLog
   12.12 @@ -37,6 +37,11 @@ AddReg = XenVbd_Service_AddReg
   12.13  
   12.14  [XenVbd_Service_AddReg]
   12.15  HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
   12.16 +; hide Qemu IDE in XenPCI
   12.17 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "VEN_8086&DEV_7010"
   12.18 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "primary_ide_channel"
   12.19 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "secondary_ide_channel"
   12.20 +HKLM,"SYSTEM\CurrentControlSet\Services\XenPCI\Parameters", "hide_devices", 0x00010008, "*pnp0600"
   12.21  
   12.22  [XenVbd_EventLog]
   12.23  AddReg = XenVbd_EventLog_AddReg
   12.24 @@ -45,8 +50,22 @@ AddReg = XenVbd_EventLog_AddReg
   12.25  HKR,,EventMessageFile,0x00020000,"%SystemRoot%\System32\IoLogMsg.dll;%SystemRoot%\System32\drivers\XenVbd.sys"
   12.26  HKR,,TypesSupported,0x00010001,7
   12.27  
   12.28 +[DestinationDirs]
   12.29 +XenVbd_Inst_CoInstaller_CopyFiles = 11
   12.30 +
   12.31 +[XenVbd_Inst.NT.CoInstallers]
   12.32 +AddReg=XenVbd_Inst_CoInstaller_AddReg
   12.33 +CopyFiles=XenVbd_Inst_CoInstaller_CopyFiles
   12.34 +
   12.35 +[XenVbd_Inst_CoInstaller_AddReg]
   12.36 +HKR,,CoInstallers32,0x00010000, "xencoinst.dll,CoRequireReboot"
   12.37 +
   12.38 +[XenVbd_Inst_CoInstaller_CopyFiles]
   12.39 +xencoinst.dll
   12.40 +
   12.41  [SourceDisksFiles]
   12.42  xenvbd.sys=1
   12.43 +xencoinst.dll=1
   12.44  
   12.45  [SourceDisksNames]
   12.46  1 = %DISK_NAME%