Skip to content

Commit

Permalink
xenopsd: fix Xen version comparison. 4.17 is > 4.2, not lower!
Browse files Browse the repository at this point in the history
Don't use string comparisons for versions, "17" < "2", but 17 > 2!

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Mar 12, 2024
1 parent 4e0d37c commit 3481a23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ocaml/xenopsd/lib/xenops_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ let _sys_hypervisor_version_major = "/sys/hypervisor/version/major"
let _sys_hypervisor_version_minor = "/sys/hypervisor/version/minor"

type hypervisor =
| Xen of string * string
| Xen of int * int
(* major, minor *)
| Other of string

Expand All @@ -601,7 +601,7 @@ let detect_hypervisor () =
let minor =
String.trim (Unixext.string_of_file _sys_hypervisor_version_minor)
in
Some (Xen (major, minor))
Some (Xen (int_of_string major, int_of_string minor))
| x ->
Some (Other x)
else
Expand Down
4 changes: 2 additions & 2 deletions ocaml/xenopsd/xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5148,10 +5148,10 @@ let init () =
let major, minor = look_for_xen () in
look_for_xenctrl () ;
if
major < "4" || ((major = "4" && minor < "2") && !Xenopsd.run_hotplug_scripts)
major < 4 || ((major = 4 && minor < 2) && !Xenopsd.run_hotplug_scripts)
then (
error
"This is xen version %s.%s. On all versions < 4.1 we must use \
"This is xen version %d.%d. On all versions < 4.2 we must use \
hotplug/udev scripts"
major minor ;
error
Expand Down

0 comments on commit 3481a23

Please sign in to comment.