From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Fioravante Subject: Re: [PATCH xm/xl enhancements for vptm 5/6] make devid a libxl type Date: Fri, 21 Sep 2012 15:20:29 -0400 Message-ID: <505CBDFD.5070408@jhuapl.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7368445545268721159==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a cryptographically signed message in MIME format. --===============7368445545268721159== Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms010502040707090806020203" This is a cryptographically signed message in MIME format. --------------ms010502040707090806020203 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This fixes a bug in libxl where device ids are not initialized properly. The devid field for each device is set to be an integer type which are always initialized to 0. This makes the xl DEV-attach commands always fail to add more than one device, because each time the device id is initialized to 0, when it should be initialized to -1, which in the code will trigger a search for free id. Signed off by Matthew Fioravante matthew.fioravante@jhuapl.edu --- * Rebased off of latest xen-unstable * Fixed whitespace errors diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py --- a/tools/libxl/gentest.py +++ b/tools/libxl/gentest.py @@ -60,7 +60,7 @@ def gen_rand_init(ty, v, indent =3D " ", parent =3D = None): passby=3Didl.PASS_BY_REFERENCE))= elif ty.typename in ["libxl_uuid", "libxl_mac", "libxl_hwcap"]: s +=3D "rand_bytes((uint8_t *)%s, sizeof(*%s));\n" % (v,v) - elif ty.typename in ["libxl_domid"] or isinstance(ty, idl.Number): + elif ty.typename in ["libxl_domid", "libxl_devid"] or isinstance(ty, idl.Number): s +=3D "%s =3D rand() %% (sizeof(%s)*8);\n" % \ (ty.pass_arg(v, parent is None), ty.pass_arg(v, parent is None)) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -307,6 +307,7 @@ void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list); #define LIBXL_PCI_FUNC_ALL (~0U) =20 typedef uint32_t libxl_domid; +typedef int libxl_devid; =20 /* * Formatting Enumerations. diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -8,6 +8,7 @@ namespace("libxl_") libxl_defbool =3D Builtin("defbool", passby=3DPASS_BY_REFERENCE) =20 libxl_domid =3D Builtin("domid", json_fn =3D "yajl_gen_integer", autogenerate_json =3D False) +libxl_devid =3D Builtin("devid", json_fn =3D "yajl_gen_integer", autogenerate_json =3D False, signed =3D True, init_val=3D"-1") libxl_uuid =3D Builtin("uuid", passby=3DPASS_BY_REFERENCE) libxl_mac =3D Builtin("mac", passby=3DPASS_BY_REFERENCE) libxl_bitmap =3D Builtin("bitmap", dispose_fn=3D"libxl_bitmap_dispose", passby=3DPASS_BY_REFERENCE) @@ -343,7 +344,7 @@ libxl_domain_build_info =3D Struct("domain_build_info= ",[ =20 libxl_device_vfb =3D Struct("device_vfb", [ ("backend_domid", libxl_domid), - ("devid", integer), + ("devid", libxl_devid), ("vnc", libxl_vnc_info), ("sdl", libxl_sdl_info), # set keyboard layout, default is en-us keyboard @@ -352,7 +353,7 @@ libxl_device_vfb =3D Struct("device_vfb", [ =20 libxl_device_vkb =3D Struct("device_vkb", [ ("backend_domid", libxl_domid), - ("devid", integer), + ("devid", libxl_devid), ]) =20 libxl_device_disk =3D Struct("device_disk", [ @@ -369,7 +370,7 @@ libxl_device_disk =3D Struct("device_disk", [ =20 libxl_device_nic =3D Struct("device_nic", [ ("backend_domid", libxl_domid), - ("devid", integer), + ("devid", libxl_devid), ("mtu", integer), ("model", string), ("mac", libxl_mac), @@ -399,7 +400,7 @@ libxl_diskinfo =3D Struct("diskinfo", [ ("backend_id", uint32), ("frontend", string), ("frontend_id", uint32), - ("devid", integer), + ("devid", libxl_devid), ("state", integer), ("evtch", integer), ("rref", integer), @@ -410,7 +411,7 @@ libxl_nicinfo =3D Struct("nicinfo", [ ("backend_id", uint32), ("frontend", string), ("frontend_id", uint32), - ("devid", integer), + ("devid", libxl_devid), ("state", integer), ("evtch", integer), ("rref_tx", integer), diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl= =2Eml --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -16,6 +16,7 @@ =20 (** *) type domid =3D int +type devid =3D int =20 (* ** xenctrl.h ** *) =20 diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -15,6 +15,7 @@ *) =20 type domid =3D int +type devid =3D int type vcpuinfo =3D { online : bool; blocked : bool; diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap= =2Epy --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -10,6 +10,7 @@ builtins =3D { "int": ("int", "%(c)s =3D Int_val(%(o)s)", "Val_int(%(c)s)" ), "char *": ("string", "%(c)s =3D dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"), "libxl_domid": ("domid", "%(c)s =3D Int_val(%(o)s)", "Val_int(%(c)s)" ), + "libxl_devid": ("devid", "%(c)s =3D Int_val(%(o)s)", "Val_int(%(c)s)" ), "libxl_defbool": ("bool option", "%(c)s =3D 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) =20 def ocaml_type_of(ty): - if ty.rawname =3D=3D "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 --- a/tools/ocaml/libs/xl/xenlight.ml.in +++ b/tools/ocaml/libs/xl/xenlight.ml.in @@ -16,6 +16,7 @@ exception Error of string =20 type domid =3D int +type devid =3D int =20 (* @@LIBXL_TYPES@@ *) =20 diff --git a/tools/ocaml/libs/xl/xenlight.mli.in b/tools/ocaml/libs/xl/xenlight.mli.in --- a/tools/ocaml/libs/xl/xenlight.mli.in +++ b/tools/ocaml/libs/xl/xenlight.mli.in @@ -16,6 +16,7 @@ exception Error of string =20 type domid =3D int +type devid =3D int =20 (* @@LIBXL_TYPES@@ *) =20 diff --git a/tools/ocaml/libs/xs/xs.ml b/tools/ocaml/libs/xs/xs.ml --- a/tools/ocaml/libs/xs/xs.ml +++ b/tools/ocaml/libs/xs/xs.ml @@ -17,6 +17,7 @@ type perms =3D Xsraw.perms type con =3D Xsraw.con type domid =3D int +type devid =3D int =20 type xsh =3D { diff --git a/tools/ocaml/libs/xs/xs.mli b/tools/ocaml/libs/xs/xs.mli --- a/tools/ocaml/libs/xs/xs.mli +++ b/tools/ocaml/libs/xs/xs.mli @@ -27,6 +27,7 @@ exception Failed_to_connect type perms =3D Xsraw.perms =20 type domid =3D int +type devid =3D int type con =20 type xsh =3D { diff --git a/tools/python/xen/lowlevel/xl/xl.c b/tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c +++ b/tools/python/xen/lowlevel/xl/xl.c @@ -281,6 +281,11 @@ int attrib__libxl_domid_set(PyObject *v, libxl_domid *domid) { return 0; } =20 +int attrib__libxl_devid_set(PyObject *v, libxl_devid *devid) { + *devid =3D PyInt_AsLong(v); + return 0; +} + int attrib__struct_in_addr_set(PyObject *v, struct in_addr *pptr) { PyErr_SetString(PyExc_NotImplementedError, "Setting in_addr"); @@ -342,6 +347,10 @@ PyObject *attrib__libxl_domid_get(libxl_domid *domid= ) { return PyInt_FromLong(*domid); } =20 +PyObject *attrib__libxl_devid_get(libxl_devid *devid) { + return PyInt_FromLong(*devid); +} + PyObject *attrib__struct_in_addr_get(struct in_addr *pptr) { PyErr_SetString(PyExc_NotImplementedError, "Getting in_addr"); --------------ms010502040707090806020203 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDyjCC A8YwggMvoAMCAQICBD/xyf0wDQYJKoZIhvcNAQEFBQAwLzELMAkGA1UEBhMCVVMxDzANBgNV BAoTBkpIVUFQTDEPMA0GA1UECxMGQklTRENBMB4XDTEwMDYxMTE4MjIwNloXDTEzMDYxMTE4 NTIwNlowZjELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkpIVUFQTDEPMA0GA1UECxMGUGVvcGxl MTUwFgYDVQQLEw9WUE5Hcm91cC1CSVNEQ0EwGwYDVQQDExRNYXR0aGV3IEUgRmlvcmF2YW50 ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnpbwVSP6o1Nb5lcW7dd3yTo9iBJdi7qz 4nANOMFPK7JOy5npKN1iiousl28U/scUJES55gPwAWYJK3uVyQAsA4adgDKi5DoD1UHDQEwp bY7iHLJeq0NPr4BqYNqnCFPbE6HC8zSJrr4qKn+gVUQT39SIFqdiIPJwZL8FYTRQ/zsCAwEA AaOCAbYwggGyMAsGA1UdDwQEAwIHgDArBgNVHRAEJDAigA8yMDEwMDYxMTE4MjIwNlqBDzIw MTIwNzE3MjI1MjA2WjAbBg0rBgEEAbMlCwMBAQEBBAoWCGZpb3JhbWUxMBsGDSsGAQQBsyUL AwEBAQIEChIIMDAxMDQyNjEwWAYJYIZIAYb6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Yc8X oBEcd8mpyzeLamn+XUyT+ujM9+OZFVCkGXn0rs7qHF5a7XbDBkuiqIiBFyp9/ZOFskohecIL HRPsR0Z12Ik+khHXbLwvcYw/h/T5M4Y/a0k408u4ntyl3t60+TisK7vkMyzcQldxzwAAAAAA AA== --------------ms010502040707090806020203-- --===============7368445545268721159== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7368445545268721159==--