From fb0ddeafbc3334a5d7acff44e8f32887b3ee8cc6 Mon Sep 17 00:00:00 2001 From: Matthew Fioravante Date: Fri, 5 Oct 2012 14:34:27 +0100 Subject: libxl: make devid a type so it is initialized properly Previously device ids in libxl were treated as integers meaning they were being initialized to 0, which is a valid device id. This patch makes devid its own type in libxl and initializes it to -1, an invalid value. This fixes a bug where if you try to do a xl DEV-attach multiple time it will continuously try to reattach device 0 instead of generating a new device id. Signed-off-by: Matthew Fioravante Reviewed-by: George Dunlap Acked-by: Ian Campbell Committed-by: Ian Campbell --- tools/ocaml/libs/xl/genwrap.py | 5 +++-- tools/ocaml/libs/xl/xenlight.ml.in | 1 + tools/ocaml/libs/xl/xenlight.mli.in | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'tools/ocaml') diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py index 42f374eaee..97d088ddf8 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -10,6 +10,7 @@ builtins = { "int": ("int", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), "char *": ("string", "%(c)s = dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"), "libxl_domid": ("domid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "libxl_devid": ("devid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), "libxl_defbool": ("bool option", "%(c)s = Defbool_val(%(o)s)", "Val_defbool(%(c)s)" ), "libxl_uuid": ("int array", "Uuid_val(gc, lg, &%(c)s, %(o)s)", "Val_uuid(&%(c)s)"), "libxl_key_value_list": ("(string * string) list", None, None), @@ -41,8 +42,8 @@ def stub_fn_name(ty, name): return "stub_xl_%s_%s" % (ty.rawname,name) def ocaml_type_of(ty): - if ty.rawname == "domid": - return "domid" + if ty.rawname in ["domid","devid"]: + return ty.rawname elif isinstance(ty,idl.UInt): if ty.width in [8, 16]: # handle as ints diff --git a/tools/ocaml/libs/xl/xenlight.ml.in b/tools/ocaml/libs/xl/xenlight.ml.in index c47623c3fc..dcc1a38bb7 100644 --- a/tools/ocaml/libs/xl/xenlight.ml.in +++ b/tools/ocaml/libs/xl/xenlight.ml.in @@ -16,6 +16,7 @@ exception Error of string type domid = int +type devid = int (* @@LIBXL_TYPES@@ *) diff --git a/tools/ocaml/libs/xl/xenlight.mli.in b/tools/ocaml/libs/xl/xenlight.mli.in index 4717bac3f7..3fd0165796 100644 --- a/tools/ocaml/libs/xl/xenlight.mli.in +++ b/tools/ocaml/libs/xl/xenlight.mli.in @@ -16,6 +16,7 @@ exception Error of string type domid = int +type devid = int (* @@LIBXL_TYPES@@ *) -- cgit v1.2.3