From: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
To: Ian Campbell <Ian.Campbell@citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: PATCH [base vtpm and libxl patches 5/6] make devid a libxl type
Date: Fri, 21 Sep 2012 15:35:01 -0400 [thread overview]
Message-ID: <505CC165.4070008@jhuapl.edu> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 7664 bytes --]
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
* Copy and paste error in email title
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 = " ", parent = None):
passby=idl.PASS_BY_REFERENCE))
elif ty.typename in ["libxl_uuid", "libxl_mac", "libxl_hwcap"]:
s += "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 += "%s = 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)
typedef uint32_t libxl_domid;
+typedef int libxl_devid;
/*
* 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 = Builtin("defbool", passby=PASS_BY_REFERENCE)
libxl_domid = Builtin("domid", json_fn = "yajl_gen_integer", autogenerate_json = False)
+libxl_devid = Builtin("devid", json_fn = "yajl_gen_integer", autogenerate_json = False, signed = True, init_val="-1")
libxl_uuid = Builtin("uuid", passby=PASS_BY_REFERENCE)
libxl_mac = Builtin("mac", passby=PASS_BY_REFERENCE)
libxl_bitmap = Builtin("bitmap", dispose_fn="libxl_bitmap_dispose", passby=PASS_BY_REFERENCE)
@@ -343,7 +344,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
libxl_device_vfb = 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 = Struct("device_vfb", [
libxl_device_vkb = Struct("device_vkb", [
("backend_domid", libxl_domid),
- ("devid", integer),
+ ("devid", libxl_devid),
])
libxl_device_disk = Struct("device_disk", [
@@ -369,7 +370,7 @@ libxl_device_disk = Struct("device_disk", [
libxl_device_nic = 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 = 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 = 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.ml
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -16,6 +16,7 @@
(** *)
type domid = int
+type devid = int
(* ** xenctrl.h ** *)
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 @@
*)
type domid = int
+type devid = int
type vcpuinfo = {
online : bool;
blocked : bool;
diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
--- 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
--- 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
--- 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@@ *)
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 = Xsraw.perms
type con = Xsraw.con
type domid = int
+type devid = int
type xsh =
{
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 = Xsraw.perms
type domid = int
+type devid = int
type con
type xsh = {
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;
}
+int attrib__libxl_devid_set(PyObject *v, libxl_devid *devid) {
+ *devid = 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);
}
+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");
[-- Attachment #1.1.2: Type: text/html, Size: 8110 bytes --]
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 1459 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
reply other threads:[~2012-09-21 19:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=505CC165.4070008@jhuapl.edu \
--to=matthew.fioravante@jhuapl.edu \
--cc=Ian.Campbell@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.