@@ -29,8 +29,15 @@ let print_host_pcis () =
2929 (fun p ->
3030 let x_to_str = Printf. sprintf " %04Lx" in
3131 Printf. printf " %s " (String. concat " "
32- [p.id; x_to_str p.vendor_id; p.vendor_name; x_to_str p.device_id;
33- p.device_name; x_to_str p.class_id; p.class_name]);
32+ [
33+ p.pci_id;
34+ x_to_str p.vendor.id;
35+ p.vendor.name;
36+ x_to_str p.device.id;
37+ p.device.name;
38+ x_to_str p.pci_class.id;
39+ p.pci_class.name
40+ ]);
3441 List. iter (fun s -> print_string (s ^ " , " )) p.related;
3542 print_newline () )
3643 pcis
@@ -55,14 +62,20 @@ module ParseLspciLine = Generic.Make(struct
5562 let string_of_input_t str = str
5663 let string_of_output_t pci = Xapi_pci_helpers. (
5764 Printf. sprintf
58- " {%s; %Lx; %s; %Lx; %s; %Lx; %s; [%s]}"
59- pci.id
60- pci.vendor_id
61- pci.vendor_name
62- pci.device_id
63- pci.device_name
64- pci.class_id
65- pci.class_name
65+ " {%s; %Lx; %s; %Lx; %s; %Lx; %s; %s; %s; [%s]}"
66+ pci.pci_id
67+ pci.vendor.id
68+ pci.vendor.name
69+ pci.device.id
70+ pci.device.name
71+ pci.pci_class.id
72+ pci.pci_class.name
73+ (match pci.subsystem_vendor with
74+ | Some vendor -> Printf. sprintf " Some {%Lx; %s}" vendor.id vendor.name
75+ | None -> " None" )
76+ (match pci.subsystem_device with
77+ | Some device -> Printf. sprintf " Some {%Lx; %s}" device.id device.name
78+ | None -> " None" )
6679 (String. concat " ; " pci.related))
6780 end
6881
@@ -77,50 +90,70 @@ module ParseLspciLine = Generic.Make(struct
7790 * subvendor IDs can be parsed. *)
7891 " 0000:44:00.0 \" 0001\" \" 0003\" \" 0001\" -ra1 \" 0001\" \" 0002\" " ,
7992 Xapi_pci_helpers. ({
80- id = " 0000:44:00.0" ;
81- vendor_id = 0x0003L ;
82- vendor_name = " SimpleVendorName3" ;
83- device_id = 0x0001L ;
84- device_name = " SimpleDeviceName-3-1" ;
85- class_id = 0x00L ;
86- class_name = " Class Name" ;
93+ pci_id = " 0000:44:00.0" ;
94+ vendor = {id = 0x0003L ; name = " SimpleVendorName3" };
95+ device = {id = 0x0001L ; name = " SimpleDeviceName-3-1" };
96+ pci_class = {id = 0x00L ; name = " Class Name" };
97+ subsystem_vendor = Some {id = 0x0001L ; name = " SimpleVendorName1" };
98+ subsystem_device = Some {id = 0x0002L ; name = " SimpleSubDeviceName-3-1-1-2" };
8799 related = []
88100 });
89101 (* Test that a device present in pci.ids without subdevice or
90102 * subvendor IDs can be parsed. *)
91103 " 0000:45:00.0 \" 0001\" \" 0003\" \" 0001\" -ra1 \"\" \"\" " ,
92104 Xapi_pci_helpers. ({
93- id = " 0000:45:00.0" ;
94- vendor_id = 0x0003L ;
95- vendor_name = " SimpleVendorName3" ;
96- device_id = 0x0001L ;
97- device_name = " SimpleDeviceName-3-1" ;
98- class_id = 0x00L ;
99- class_name = " Class Name" ;
105+ pci_id = " 0000:45:00.0" ;
106+ vendor = {id = 0x0003L ; name = " SimpleVendorName3" };
107+ device = {id = 0x0001L ; name = " SimpleDeviceName-3-1" };
108+ pci_class = {id = 0x00L ; name = " Class Name" };
109+ subsystem_vendor = None ;
110+ subsystem_device = None ;
100111 related = []
101112 });
113+ (* Test that a device present in pci.ids with an unknown subsystem device
114+ * ID can be parsed. *)
115+ " 0000:0a:00.0 \" 0001\" \" 0003\" \" 0001\" -ra1 \" 0001\" \" 0123\" " ,
116+ Xapi_pci_helpers. ({
117+ pci_id = " 0000:0a:00.0" ;
118+ vendor = {id = 0x0003L ; name = " SimpleVendorName3" };
119+ device = {id = 0x0001L ; name = " SimpleDeviceName-3-1" };
120+ pci_class = {id = 0x00L ; name = " Class Name" };
121+ subsystem_vendor = Some {id = 0x0001L ; name = " SimpleVendorName1" };
122+ subsystem_device = Some {id = 0x0123L ; name = " Unknown (0123)" };
123+ related = [] ;
124+ });
125+ (* Test that a device present in pci.ids with an unknown subsystem vendor
126+ * ID and an unknown subsystem device ID can be parsed. *)
127+ " 0000:0a:00.0 \" 0001\" \" 0003\" \" 0001\" -ra1 \" 0123\" \" 0123\" " ,
128+ Xapi_pci_helpers. ({
129+ pci_id = " 0000:0a:00.0" ;
130+ vendor = {id = 0x0003L ; name = " SimpleVendorName3" };
131+ device = {id = 0x0001L ; name = " SimpleDeviceName-3-1" };
132+ pci_class = {id = 0x00L ; name = " Class Name" };
133+ subsystem_vendor = Some {id = 0x0123L ; name = " Unknown (0123)" };
134+ subsystem_device = Some {id = 0x0123L ; name = " Unknown (0123)" };
135+ related = [] ;
136+ });
102137 (* Test that a device not preset in pci.ids can be parsed. *)
103138 " 0000:46:00.0 \" 0001\" \" 0055\" \" abcd\" -ra1 \"\" \"\" " ,
104139 Xapi_pci_helpers. ({
105- id = " 0000:46:00.0" ;
106- vendor_id = 0x0055L ;
107- vendor_name = " Unknown (0055)" ;
108- device_id = 0xabcdL ;
109- device_name = " Unknown (abcd)" ;
110- class_id = 0x00L ;
111- class_name = " Class Name" ;
140+ pci_id = " 0000:46:00.0" ;
141+ vendor = {id = 0x0055L ; name = " Unknown (0055)" };
142+ device = {id = 0xabcdL ; name = " Unknown (abcd)" };
143+ pci_class = {id = 0x00L ; name = " Class Name" };
144+ subsystem_vendor = None ;
145+ subsystem_device = None ;
112146 related = [] ;
113147 });
114148 (* Test that an unknown device from a known vendor can be parsed. *)
115149 " 0000:47:00.0 \" 0001\" \" 0003\" \" abcd\" -ra1 \"\" \"\" " ,
116150 Xapi_pci_helpers. ({
117- id = " 0000:47:00.0" ;
118- vendor_id = 0x0003L ;
119- vendor_name = " SimpleVendorName3" ;
120- device_id = 0xabcdL ;
121- device_name = " Unknown (abcd)" ;
122- class_id = 0x00L ;
123- class_name = " Class Name" ;
151+ pci_id = " 0000:47:00.0" ;
152+ vendor = {id = 0x0003L ; name = " SimpleVendorName3" };
153+ device = {id = 0xabcdL ; name = " Unknown (abcd)" };
154+ pci_class = {id = 0x00L ; name = " Class Name" };
155+ subsystem_vendor = None ;
156+ subsystem_device = None ;
124157 related = [] ;
125158 });
126159 ]
0 commit comments