There are registry entries that are needed to add some other drivers.
Extracting them into a function will help adding SUSE VMDP support.
---
v2v/windows_virtio.ml | 311 ++++++++++++++++++++++++++++----------------------
1 file changed, 176 insertions(+), 135 deletions(-)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 14ffc51..8a0b529 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -146,48 +146,50 @@ and add_viostor_to_critical_device_database g root current_cs =
* NB: All these edits are in the HKLM\SYSTEM hive. No other
* hive may be modified here.
*)
+ let driver = "viostor.sys" in
+ let driver_name = Filename.chop_extension driver in
let regedits = [
[ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00000000" ],
- [ "Service", REG_SZ "viostor";
+ [ "Service", REG_SZ driver_name;
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
[ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00020000" ],
- [ "Service", REG_SZ "viostor";
+ [ "Service", REG_SZ driver_name;
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
[ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4" ],
- [ "Service", REG_SZ "viostor";
+ [ "Service", REG_SZ driver_name;
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
[ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4&rev_00" ],
- [ "Service", REG_SZ "viostor";
+ [ "Service", REG_SZ driver_name;
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
- [ current_cs; "Services"; "viostor" ],
+ [ current_cs; "Services"; driver_name ],
[ "Type", REG_DWORD 0x1_l;
"Start", REG_DWORD 0x0_l;
"Group", REG_SZ "SCSI miniport";
"ErrorControl", REG_DWORD 0x1_l;
- "ImagePath", REG_EXPAND_SZ "system32\\drivers\\viostor.sys";
+ "ImagePath", REG_EXPAND_SZ ("system32\\drivers\\" ^ driver);
"Tag", REG_DWORD 0x21_l ];
- [ current_cs; "Services"; "viostor"; "Parameters" ],
+ [ current_cs; "Services"; driver_name; "Parameters" ],
[ "BusType", REG_DWORD 0x1_l ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"MaxTransferSize" ],
+ [ current_cs; "Services"; driver_name; "Parameters";
"MaxTransferSize" ],
[ "ParamDesc", REG_SZ "Maximum Transfer Size";
"type", REG_SZ "enum";
"default", REG_SZ "0" ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"MaxTransferSize"; "enum" ],
+ [ current_cs; "Services"; driver_name; "Parameters";
"MaxTransferSize"; "enum" ],
[ "0", REG_SZ "64 KB";
"1", REG_SZ "128 KB";
"2", REG_SZ "256 KB" ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"PnpInterface" ],
+ [ current_cs; "Services"; driver_name; "Parameters";
"PnpInterface" ],
[ "5", REG_DWORD 0x1_l ];
- [ current_cs; "Services"; "viostor"; "Enum" ],
+ [ current_cs; "Services"; driver_name; "Enum" ],
[ "0", REG_SZ
"PCI\\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00\\3&13c0b0c5&0&20";
"Count", REG_DWORD 0x1_l;
"NextInstance", REG_DWORD 0x1_l ];
@@ -199,8 +201,10 @@ and add_viostor_to_driver_database g root arch current_cs driverdir
=
(* Windows >= 8 doesn't use the CriticalDeviceDatabase. Instead
* one must add keys into the DriverDatabase.
*)
+ let driver = "viostor.sys" in
+ let driver_name = Filename.chop_extension driver in
- let viostor_inf =
+ let inf_full =
let arch =
match arch with
| "x86_64" -> "amd64"
@@ -210,145 +214,39 @@ and add_viostor_to_driver_database g root arch current_cs driverdir
=
(* XXX I don't know what the significance of the c863.. string is. It
* may even be random.
*)
- sprintf "viostor.inf_%s_%s" arch "c86329aaeb0a7904" in
+ sprintf "%s.inf_%s_%s" driver_name arch "c86329aaeb0a7904" in
let scsi_adapter_guid = "{4d36e97b-e325-11ce-bfc1-08002be10318}" in
- let oem_inf = set_free_oem_inf g root scsi_adapter_guid "viostor.inf"
driverdir in
- (* There should be a key
- * HKLM\SYSTEM\ControlSet001\Control\Class\<scsi_adapter_guid>
- * There may be subkey(s) of this called "0000", "0001" etc. We
want
- * to create the next free subkey. MSFT covers the key here:
- *
https://technet.microsoft.com/en-us/library/cc957341.aspx
- * That page incorrectly states that the key has the form "000n".
- * In fact we observed from real registries that the key is a
- * decimal number that goes 0009 -> 0010 etc.
- *)
- let controller_path =
- [ current_cs; "Control"; "Class"; scsi_adapter_guid ] in
- let controller_offset = get_controller_offset g root controller_path in
+ let driverdesc = "Red Hat VirtIO SCSI controller" in
+ let provider = "Red Hat, Inc." in
- let regedits = [
- controller_path @ [ controller_offset ],
- [ "DriverDate", REG_SZ "6-4-2014";
- "DriverDateData", REG_BINARY
"\x00\x40\x90\xed\x87\x7f\xcf\x01";
- "DriverDesc", REG_SZ "Red Hat VirtIO SCSI controller";
- "DriverVersion", REG_SZ "62.71.104.8600" (* XXX *);
- "InfPath", REG_SZ oem_inf;
- "InfSection", REG_SZ "rhelscsi_inst";
- "MatchingDeviceId", REG_SZ
"PCI\\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00";
- "ProviderName", REG_SZ "Red Hat, Inc." ];
-
- [ current_cs; "Enum"; "PCI";
"VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00\\3&13c0b0c5&0&38"
],
- [ "Capabilities", REG_DWORD 0x6_l;
- "ClassGUID", REG_SZ scsi_adapter_guid;
- "CompatibleIDs", REG_MULTI_SZ [
- "PCI\\VEN_1AF4&DEV_1001&REV_00";
- "PCI\\VEN_1AF4&DEV_1001";
- "PCI\\VEN_1AF4&CC_010000";
- "PCI\\VEN_1AF4&CC_0100";
- "PCI\\VEN_1AF4";
- "PCI\\CC_010000";
- "PCI\\CC_0100";
- ];
- "ConfigFlags", REG_DWORD 0_l;
- "ContainerID", REG_SZ
"{00000000-0000-0000-ffff-ffffffffffff}";
- "DeviceDesc", REG_SZ (sprintf "(a)%s,%%rhelscsi.devicedesc%%;Red Hat
VirtIO SCSI controller" oem_inf);
- "Driver", REG_SZ (sprintf "%s\\%s" scsi_adapter_guid
controller_offset);
- "HardwareID", REG_MULTI_SZ [
-
"PCI\\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00";
- "PCI\\VEN_1AF4&DEV_1001&SUBSYS_00021AF4";
- "PCI\\VEN_1AF4&DEV_1001&CC_010000";
- "PCI\\VEN_1AF4&DEV_1001&CC_0100";
- ];
- "LocationInformation", REG_SZ
"(a)System32\\drivers\\pci.sys,#65536;PCI bus %1, device %2, function
%3;(0,7,0)";
- "Mfg", REG_SZ (sprintf "@%s,%%rhel%%;Red Hat, Inc."
oem_inf);
- "ParentIdPrefix", REG_SZ "4&87f7bfb&0";
- "Service", REG_SZ "viostor";
- "UINumber", REG_DWORD 0x7_l ];
-
- [ current_cs; "Services"; "viostor" ],
- [ "ErrorControl", REG_DWORD 0x1_l;
- "Group", REG_SZ "SCSI miniport";
- "ImagePath", REG_EXPAND_SZ "system32\\drivers\\viostor.sys";
- "Owners", REG_MULTI_SZ [ oem_inf ];
- "Start", REG_DWORD 0x0_l;
- "Tag", REG_DWORD 0x58_l;
- "Type", REG_DWORD 0x1_l ];
-
- [ current_cs; "Services"; "viostor"; "Parameters" ],
- [ "BusType", REG_DWORD 0x1_l ];
+ let driver_inst = (sprintf "%s_inst" driver_name) in
- [ current_cs; "Services"; "viostor"; "Parameters";
"PnpInterface" ],
- [ "5", REG_DWORD 0x1_l ];
+ let device_id = "VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" in
+ let device_subkey = "3&13c0b0c5&0&38" in
+ let device_alt = "CC_010000" in
- [ "DriverDatabase"; "DriverInfFiles"; oem_inf ],
- [ "", REG_MULTI_SZ [ viostor_inf ];
- "Active", REG_SZ viostor_inf;
- "Configurations", REG_MULTI_SZ [ "rhelscsi_inst" ]
- ];
-
- [ "DriverDatabase"; "DeviceIds"; "PCI";
"VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" ],
- [ oem_inf, REG_BINARY "\x01\xff\x00\x00" ];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf ],
- [ "", REG_SZ oem_inf;
- "F6", REG_DWORD 0x1_l;
- "InfName", REG_SZ "viostor.inf";
- "OemPath", REG_SZ
("X:\\windows\\System32\\DriverStore\\FileRepository\\" ^ viostor_inf);
- "Provider", REG_SZ "Red Hat, Inc.";
- "SignerName", REG_SZ "Microsoft Windows Hardware Compatibility
Publisher";
- "SignerScore", REG_DWORD 0x0d000005_l;
- "StatusFlags", REG_DWORD 0x00000012_l;
- (* NB: scsi_adapter_guid appears inside this string. *)
- "Version", REG_BINARY
"\x00\xff\x09\x00\x00\x00\x00\x00\x7b\xe9\x36\x4d\x25\xe3\xce\x11\xbf\xc1\x08\x00\x2b\xe1\x03\x18\x00\x40\x90\xed\x87\x7f\xcf\x01\x98\x21\x68\x00\x47\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00"
];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations" ],
- [];
+ let service_group = "SCSI miniport" in
+ (* NB: scsi_adapter_guid appears inside this string. *)
+ let driver_version =
"\x00\xff\x09\x00\x00\x00\x00\x00\x7b\xe9\x36\x4d\x25\xe3\xce\x11\xbf\xc1\x08\x00\x2b\xe1\x03\x18\x00\x40\x90\xed\x87\x7f\xcf\x01\x98\x21\x68\x00\x47\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00"
in
+ let device_addr = "(0,7,0)" in
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst" ],
- [ "ConfigFlags", REG_DWORD 0_l;
- "Service", REG_SZ "viostor" ];
+ let common_regedits = get_common_regedits g root current_cs scsi_adapter_guid driverdir
driver driverdesc driver_version service_group inf_full device_id device_subkey device_alt
device_addr provider in
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Device" ],
+ let regedits = common_regedits @ [
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Device" ],
[];
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Device"; "Interrupt
Management" ],
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Device"; "Interrupt
Management" ],
[];
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Device"; "Interrupt
Management"; "Affinity Policy" ],
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Device"; "Interrupt
Management"; "Affinity Policy" ],
[ "DevicePolicy", REG_DWORD 0x00000005_l ];
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Device"; "Interrupt
Management"; "MessageSignaledInterruptProperties" ],
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Device"; "Interrupt
Management"; "MessageSignaledInterruptProperties" ],
[ "MSISupported", REG_DWORD 0x00000001_l;
"MessageNumberLimit", REG_DWORD 0x00000002_l ];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Services" ],
- [];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Services";
"viostor" ],
- [];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Services";
"viostor"; "Parameters" ],
- [ "BusType", REG_DWORD 0x00000001_l ];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Configurations"; "rhelscsi_inst"; "Services";
"viostor"; "Parameters"; "PnpInterface" ],
- [ "5", REG_DWORD 0x00000001_l ];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Descriptors" ],
- [];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Descriptors"; "PCI" ],
- [];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Descriptors"; "PCI";
"VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" ],
- [ "Configuration", REG_SZ "rhelscsi_inst";
- "Description", REG_SZ "%rhelscsi.devicedesc%";
- "Manufacturer", REG_SZ "%rhel%" ];
-
- [ "DriverDatabase"; "DriverPackages"; viostor_inf;
"Strings" ],
- [ "rhel", REG_SZ "Red Hat, Inc.";
- "rhelscsi.devicedesc", REG_SZ "Red Hat VirtIO SCSI
controller" ];
] in
reg_import g root regedits;
@@ -402,6 +300,149 @@ and get_controller_offset g root controller_path =
in
loop node 0
+and get_common_regedits g root current_cs adapter_guid driverdir driver driverdesc
driver_version service_group inf_full device_id device_subkey device_alt device_addr
provider =
+
+ let driver_name = Filename.chop_extension driver in
+ let driver_inf = sprintf "%s.inf" driver_name in
+
+ let driverdesc_key = (sprintf "%s.devicedesc" driver_name) in
+ let driver_inst = (sprintf "%s_inst" driver_name) in
+
+ let device_parts = Str.split (Str.regexp "&") device_id in
+ let get_device_part_n n = try
+ List.nth device_parts n
+ with _ ->
+ error (f_"Code problem: badly formed device id") in
+ let device_id0 = get_device_part_n 0 in
+ let device_id1 = get_device_part_n 1 in
+ let device_id2 = get_device_part_n 2 in
+ let device_id3 = get_device_part_n 3 in
+
+ let device_alt_short = String.sub device_alt 0 7 in
+
+
+ let oem_inf = set_free_oem_inf g root adapter_guid driver_inf driverdir in
+
+ (* There should be a key
+ * HKLM\SYSTEM\ControlSet001\Control\Class\<scsi_adapter_guid>
+ * There may be subkey(s) of this called "0000", "0001" etc. We
want
+ * to create the next free subkey. MSFT covers the key here:
+ *
https://technet.microsoft.com/en-us/library/cc957341.aspx
+ * That page incorrectly states that the key has the form "000n".
+ * In fact we observed from real registries that the key is a
+ * decimal number that goes 0009 -> 0010 etc.
+ *)
+ let controller_path =
+ [ current_cs; "Control"; "Class"; adapter_guid ] in
+ let controller_offset = get_controller_offset g root controller_path in
+
+ [ controller_path @ [ controller_offset ],
+ [ "DriverDate", REG_SZ "6-4-2014";
+ "DriverDateData", REG_BINARY
"\x00\x40\x90\xed\x87\x7f\xcf\x01";
+ "DriverDesc", REG_SZ driverdesc;
+ "DriverVersion", REG_SZ "62.71.104.8600" (* XXX *);
+ "InfPath", REG_SZ oem_inf;
+ "InfSection", REG_SZ driver_inst;
+ "MatchingDeviceId", REG_SZ ("PCI\\" ^ device_id);
+ "ProviderName", REG_SZ provider ];
+
+ [ current_cs; "Enum"; "PCI"; device_id; device_subkey ],
+ [ "Capabilities", REG_DWORD 0x6_l;
+ "ClassGUID", REG_SZ adapter_guid;
+ "CompatibleIDs", REG_MULTI_SZ [
+ sprintf "PCI\\%s&%s&%s" device_id0
device_id1 device_id3;
+ sprintf "PCI\\%s&%s" device_id0 device_id1;
+ sprintf "PCI\\%s&%s" device_id0 device_alt;
+ sprintf "PCI\\%s&%s" device_id0
device_alt_short;
+ "PCI\\" ^ device_id0;
+ "PCI\\" ^ device_alt;
+ "PCI\\" ^ device_alt_short;
+ ];
+ "ConfigFlags", REG_DWORD 0_l;
+ "ContainerID", REG_SZ
"{00000000-0000-0000-ffff-ffffffffffff}";
+ "DeviceDesc", REG_SZ (sprintf "@%s,%%%s%%;%s" oem_inf
driverdesc_key driverdesc);
+ "Driver", REG_SZ (sprintf "%s\\%s" adapter_guid
controller_offset);
+ "HardwareID", REG_MULTI_SZ [
+ "PCI\\" ^ device_id;
+ sprintf "PCI\\%s&%s&%s" device_id0 device_id1
device_id2;
+ sprintf "PCI\\%s&%s&%s" device_id0 device_id1
device_alt;
+ sprintf "PCI\\%s&%s&%s" device_id0 device_id1
device_alt_short;
+ ];
+ "LocationInformation", REG_SZ
("(a)System32\\drivers\\pci.sys,#65536;PCI bus %1, device %2, function %3;" ^
device_addr);
+ "Mfg", REG_SZ (sprintf "(a)%s,%%provider.desc%%;%s" oem_inf
provider);
+ "Service", REG_SZ driver_name;
+ "UINumber", REG_DWORD 0x7_l ];
+
+ [ current_cs; "Services"; driver_name ],
+ [ "ErrorControl", REG_DWORD 0x1_l;
+ "Group", REG_SZ service_group;
+ "ImagePath", REG_EXPAND_SZ (sprintf "system32\\drivers\\%s"
driver);
+ "Owners", REG_MULTI_SZ [ oem_inf ];
+ "Start", REG_DWORD 0x0_l;
+ "Tag", REG_DWORD 0x58_l;
+ "Type", REG_DWORD 0x1_l ];
+
+ [ current_cs; "Services"; driver_name; "Parameters" ],
+ [ "BusType", REG_DWORD 0x1_l ];
+
+ [ current_cs; "Services"; driver_name; "Parameters";
"PnpInterface" ],
+ [ "5", REG_DWORD 0x1_l ];
+
+ [ "DriverDatabase"; "DriverInfFiles"; oem_inf ],
+ [ "", REG_MULTI_SZ [ inf_full ];
+ "Active", REG_SZ inf_full;
+ "Configurations", REG_MULTI_SZ [ driver_inst ]
+ ];
+
+ [ "DriverDatabase"; "DeviceIds"; "PCI"; device_id ],
+ [ oem_inf, REG_BINARY "\x01\xff\x00\x00" ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full ],
+ [ "", REG_SZ oem_inf;
+ "F6", REG_DWORD 0x1_l;
+ "InfName", REG_SZ driver_inf;
+ "OemPath", REG_SZ
("X:\\windows\\System32\\DriverStore\\FileRepository\\" ^ inf_full);
+ "Provider", REG_SZ provider;
+ "SignerName", REG_SZ "Microsoft Windows Hardware Compatibility
Publisher";
+ "SignerScore", REG_DWORD 0x0d000005_l;
+ "StatusFlags", REG_DWORD 0x00000012_l;
+ "Version", REG_BINARY driver_version ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations" ],
+ [];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst ],
+ [ "ConfigFlags", REG_DWORD 0_l;
+ "Service", REG_SZ driver_name ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Services" ],
+ [];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Services"; driver_name ],
+ [];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Services"; driver_name;
"Parameters" ],
+ [ "BusType", REG_DWORD 0x00000001_l ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Configurations"; driver_inst; "Services"; driver_name;
"Parameters"; "PnpInterface" ],
+ [ "5", REG_DWORD 0x00000001_l ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Descriptors" ],
+ [];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Descriptors"; "PCI" ],
+ [];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Descriptors"; "PCI"; device_id ],
+ [ "Configuration", REG_SZ driver_inst;
+ "Description", REG_SZ (sprintf "%%%s%%" driverdesc_key);
+ "Manufacturer", REG_SZ "%provider.desc%" ];
+
+ [ "DriverDatabase"; "DriverPackages"; inf_full;
"Strings" ],
+ [ "provider.desc", REG_SZ provider;
+ driverdesc_key, REG_SZ driverdesc ];
+ ]
+
(* Copy the matching drivers to the driverdir; return true if any have
* been copied.
*)
--
2.6.2