Skip to content

Commit 1bb4973

Browse files
author
Akanksha Mathur
committed
CP-26717: Remove Camlp4 dependency, add rules to make gpumon CLI
Signed-off-by: Akanksha Mathur <[email protected]> fixup! CP-26717: Minor edits and refactoring - no global opens in Gpumon_client - reformatted Gpumon_interface - rewrote compatibility type docstring in Gpumon_interface Signed-off-by: Akanksha Mathur <[email protected]>
1 parent e65473a commit 1bb4973

File tree

3 files changed

+75
-70
lines changed

3 files changed

+75
-70
lines changed

gpumon/gpumon_client.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15-
open Gpumon_interface
16-
open Xcp_client
17-
18-
let xml_url () = "file:" ^ xml_path
15+
let xml_url () = "file:" ^ Gpumon_interface.xml_path
1916

2017
let rpc call =
21-
if !use_switch
22-
then json_switch_rpc queue_name call
23-
else xml_http_rpc
24-
~srcstr:(get_user_agent ())
18+
if !Xcp_client.use_switch
19+
then Xcp_client.json_switch_rpc Gpumon_interface.queue_name call
20+
else Xcp_client.xml_http_rpc
21+
~srcstr:(Xcp_client.get_user_agent ())
2522
~dststr:"gpumon"
2623
xml_url
2724
call
28-
module Client = RPC_API(Idl.GenClientExnRpc(struct let rpc=rpc end))
29-
include Client
25+
module Client = Gpumon_interface.RPC_API(Idl.GenClientExnRpc(struct let rpc=rpc end))

gpumon/gpumon_interface.ml

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type incompatibility_reason =
3535
| Other
3636
[@@deriving rpcty]
3737

38-
(** Boolean: compatible? *)
38+
(** Compatibility between virtual and physical GPU *)
3939
type compatibility =
4040
| Compatible
4141
| Incompatible of incompatibility_reason list
@@ -90,69 +90,83 @@ module RPC_API(R : RPC) = struct
9090
; description =
9191
[ "This interface is used by Xapi and Gpumon to monitor "
9292
; "physical and virtual GPUs."]
93-
;
94-
version=(1,0,0)
93+
; version=(1,0,0)
9594
}
9695

9796
let implementation = implement description
9897

99-
(** common API call parameters *)
98+
(** Compatibility checking interface for Nvidia vGPUs *)
99+
module Nvidia = struct
100100

101-
let debug_info_p = param ~description:
102-
["Uninterpreted string used for debugging."]
103-
debug_info
101+
(** common API call parameters *)
104102

105-
let domid_p = param ~description:
106-
["Domain ID of the VM in which the vGPU(s) is running."]
107-
domid
103+
let debug_info_p = param ~description:
104+
["Uninterpreted string used for debugging."]
105+
debug_info
108106

109-
let pgpu_address_p = param ~description:
110-
["PCI bus ID of the pGPU in which the VM is currently running"
111-
;"in the form `domain:bus:device.function` PCI identifier."]
112-
pgpu_address
107+
let domid_p = param ~description:
108+
["Domain ID of the VM in which the vGPU(s) is running."]
109+
domid
113110

114-
let nvidia_pgpu_metadata_p = param ~description:
115-
["Metadata of Nvidia physical GPU."]
116-
nvidia_pgpu_metadata
111+
let pgpu_address_p = param ~description:
112+
["PCI bus ID of the pGPU in which the VM is currently running"
113+
;"in the form `domain:bus:device.function` PCI identifier."]
114+
pgpu_address
117115

118-
let nvidia_vgpu_metadata_p = param ~description:
119-
["Metadata of Nvidia virtual GPU."]
120-
nvidia_vgpu_metadata
116+
let nvidia_pgpu_metadata_p = param ~description:
117+
["Metadata of Nvidia physical GPU."]
118+
nvidia_pgpu_metadata
121119

122-
let nvidia_vgpu_metadata_list_p = param ~description:
123-
["Metadata list of Nvidia virtual GPU."]
124-
nvidia_vgpu_metadata_list
120+
let nvidia_vgpu_metadata_p = param ~description:
121+
["Metadata of Nvidia virtual GPU."]
122+
nvidia_vgpu_metadata
125123

126-
let compatibility_p = param ~description:
127-
["Value indicating whether two or more GPUs are compatible with each other."]
128-
compatibility
124+
let nvidia_vgpu_metadata_list_p = param ~description:
125+
["Metadata list of Nvidia virtual GPU."]
126+
nvidia_vgpu_metadata_list
129127

130-
(** Compatibility checking interface for Nvidia vGPUs *)
131-
module Nvidia = struct
128+
let compatibility_p = param ~description:
129+
[ "Value indicating whether two or more GPUs are compatible with each other." ]
130+
compatibility
132131

133132
let get_pgpu_metadata =
134133
declare "get_pgpu_metadata"
135-
["Gets the metadata for a pGPU, given its address (PCI bus ID)."]
136-
(debug_info_p @-> pgpu_address_p @-> returning nvidia_pgpu_metadata_p gpu_err )
134+
[ "Gets the metadata for a pGPU, given its address (PCI bus ID)." ]
135+
(debug_info_p
136+
@-> pgpu_address_p
137+
@-> returning nvidia_pgpu_metadata_p gpu_err
138+
)
137139

138140
let get_pgpu_vm_compatibility =
139141
declare "get_pgpu_vm_compatibility"
140-
["Checks compatibility between a VM's vGPU(s) and another pGPU."]
141-
(debug_info_p @-> pgpu_address_p @-> domid_p @-> nvidia_pgpu_metadata_p @-> returning compatibility_p gpu_err )
142+
[ "Checks compatibility between a VM's vGPU(s) and another pGPU." ]
143+
(debug_info_p
144+
@-> pgpu_address_p
145+
@-> domid_p
146+
@-> nvidia_pgpu_metadata_p
147+
@-> returning compatibility_p gpu_err
148+
)
142149

143150
let get_vgpu_metadata =
144151
declare "get_vgpu_metadata"
145-
["Obtains metadata for all vGPUs running in a domain."]
146-
( debug_info_p @-> domid_p @-> pgpu_address_p @-> returning nvidia_vgpu_metadata_list_p gpu_err )
147-
148-
(** The use case is VM.suspend/VM.resume: before
149-
* VM.resume [nvidia_vgpu_metadata] of the suspended VM is checked
150-
* against the [nvidia_pgpu_metadata] on the host where the VM is
151-
* resumed.
152-
* *)
152+
[ "Obtains metadata for all vGPUs running in a domain." ]
153+
( debug_info_p
154+
@-> domid_p
155+
@-> pgpu_address_p
156+
@-> returning nvidia_vgpu_metadata_list_p gpu_err
157+
)
158+
153159
let get_pgpu_vgpu_compatibility =
154160
declare "get_pgpu_vgpu_compatibility"
155-
["Checks compatibility between a pGPU (on a host) and a list of vGPUs (assigned to a VM). Note: A VM may use several vGPUs."]
156-
( debug_info_p @-> nvidia_pgpu_metadata_p @-> nvidia_vgpu_metadata_list_p @-> returning compatibility_p gpu_err )
161+
[ "Checks compatibility between a pGPU (on a host) and a list of vGPUs "
162+
; "(assigned to a VM). Note: A VM may use several vGPUs."
163+
; "The use case is VM.suspend/VM.resume:"
164+
; "before VM.resume [nvidia_vgpu_metadata] of the suspended VM is "
165+
; "checked against the [nvidia_pgpu_metadata] on the host where the VM "
166+
; "is resumed." ]
167+
( debug_info_p
168+
@-> nvidia_pgpu_metadata_p
169+
@-> nvidia_vgpu_metadata_list_p
170+
@-> returning compatibility_p gpu_err)
157171
end
158172
end

gpumon/jbuild

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,30 @@ let coverage_rewriter =
2222
else
2323
""
2424

25-
let rewriters_camlp4 = ["rpclib.idl -syntax camlp4o"]
26-
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv"]
25+
let rewriters = ["ppx_deriving_rpc"]
2726

2827
let () = Printf.ksprintf Jbuild_plugin.V1.send {|
2928
(jbuild_version 1)
3029

31-
(library
32-
((name xapi_gpumon_interface)
33-
(public_name xcp.gpumon.interface)
34-
(modules (gpumon_interface))
35-
(flags (:standard -w -39 %s))
36-
(libraries
37-
(rpclib
38-
threads
39-
xcp))
40-
(wrapped false)
41-
%s))
42-
4330
(library
4431
((name xapi_gpumon)
4532
(public_name xcp.gpumon)
46-
(modules (:standard \ gpumon_interface))
4733
(flags (:standard -w -39-33 %s))
34+
(modules (:standard \ gpumon_cli ))
4835
(libraries
4936
(rpclib
5037
threads
51-
xcp
52-
xapi_gpumon_interface))
38+
xcp))
5339
(wrapped false)
5440
%s))
5541

56-
|} (flags rewriters_camlp4) coverage_rewriter (flags rewriters_ppx) coverage_rewriter
42+
(executable
43+
((name gpumon_cli)
44+
(modules (gpumon_cli))
45+
(libraries
46+
(cmdliner
47+
rpclib.cmdliner
48+
rpclib.markdown
49+
xcp.gpumon))))
50+
51+
|} (flags rewriters) coverage_rewriter

0 commit comments

Comments
 (0)