Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 0 of 9] libxl: various IDL cleanups + some misc bits
The following consists of vaqrious libxl IDL cleanups, plus some other misc bits. Previously this series had a patch on the end to add ..._to_string and ..._gen_json functions but I have omitted that this time round since I need to rebase onto / synchornise with the JSON stuff Anthony is doing for QMP support. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 1 of 9] build: define "move-if-changed" make macro
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646155 -3600
# Node ID 8fc1e177b38aa07a29525fe0d26bfb2f5fe2fc33
# Parent 2f14754868462d173a46d47c710db01aecedd3f4
build: define "move-if-changed" make macro.
Use it to replace various places which (should) use the
if ! cmp -s ...; then mv ....; fi
pattern.
Also add an else clause to cleanup the unchanged temporary file.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 2f1475486846 -r 8fc1e177b38a Config.mk
--- a/Config.mk Thu Jul 14 13:22:35 2011 +0100
+++ b/Config.mk Thu Jul 14 13:22:35 2011 +0100
@@ -118,6 +118,16 @@ define buildmakevars2shellvars
export XEN_ROOT="$(XEN_ROOT)"
endef
+#
+# Compare $(1) and $(2) and replace $(2) with $(1) if they differ
+#
+# Typically $(1) is a newly generated file and $(2) is the target file
+# being regenerated. This prevents changing the timestamp of $(2) only
+# due to being auto regenereated with the same contents.
+define move-if-changed
+ if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
+endef
+
buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1)))
define buildmakevars2file-closure
.PHONY: genpath
@@ -134,7 +144,7 @@ define buildmakevars2file-closure
echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >>
$(1).tmp; \
echo "XEN_LOCK_DIR=\"$(XEN_LOCK_DIR)\"" >> $(1).tmp;
\
echo "XEN_RUN_DIR=\"$(XEN_RUN_DIR)\"" >> $(1).tmp;
\
- if ! cmp $(1).tmp $(1); then mv -f $(1).tmp $(1); fi
+ $(call move-if-changed,$(1).tmp,$(1))
endef
ifeq ($(debug),y)
diff -r 2f1475486846 -r 8fc1e177b38a tools/libxl/Makefile
--- a/tools/libxl/Makefile Thu Jul 14 13:22:35 2011 +0100
+++ b/tools/libxl/Makefile Thu Jul 14 13:22:35 2011 +0100
@@ -75,7 +75,8 @@ genpath-target = $(call buildmakevars2fi
_libxl_paths.h: genpath
sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@.tmp >$@.2.tmp
- if ! cmp -s $@.2.tmp $@; then mv -f $@.2.tmp $@; fi
+ rm -f $@.tmp
+ $(call move-if-changed,$@.2.tmp,$@)
libxl_paths.c: _libxl_paths.h
@@ -85,8 +86,8 @@ libxl.h: _libxl_types.h
_libxl_%.h _libxl_%.c: libxl.idl gen%.py libxl%.py
$(PYTHON) gen$*.py libxl.idl __libxl_$*.h __libxl_$*.c
- mv __libxl_$*.h _libxl_$*.h
- mv __libxl_$*.c _libxl_$*.c
+ $(call move-if-changed,__libxl_$*.h,_libxl_$*.h)
+ $(call move-if-changed,__libxl_$*.c,_libxl_$*.c)
libxenlight.so: libxenlight.so.$(MAJOR)
ln -sf $< $@
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 2 of 9] libxl: IDL: s/anonynous/anonymous/
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID 7e8ce32eda26230ce34476172d8a5f77596bb62b
# Parent 8fc1e177b38aa07a29525fe0d26bfb2f5fe2fc33
libxl: IDL: s/anonynous/anonymous/
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 8fc1e177b38a -r 7e8ce32eda26 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:35 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -101,7 +101,7 @@ def libxl_C_type_destroy(ty, v, indent elif
isinstance(ty, libxltypes.Struct) and (parent is None or ty.destructor_fn is
None):
for f in [f for f in ty.fields if not f.const]:
- if f.name is None: # Anonynous struct
+ if f.name is None: # Anonymous struct
s += libxl_C_type_destroy(f.type, deref, "", deref)
else:
s += libxl_C_type_destroy(f.type, deref + f.name, "",
deref)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 3 of 9] libxl: IDL: handle generation of pass-by-reference arguments
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID 3b2827da23585a7fa93d1e6fc4db4d196706ebf8
# Parent 7e8ce32eda26230ce34476172d8a5f77596bb62b
libxl: IDL: handle generation of pass-by-reference arguments.
Up until now everything with a destructor function happened to be
pass-by-reference so the current code worked but this will not be the case for
*_to_string and *_to_json. Put some infrastructure in place and use it.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 7e8ce32eda26 -r 3b2827da2358 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -178,10 +178,10 @@ if __name__ == ''__main__'':
for ty in types:
f.write(libxl_C_type_define(ty) + ";\n")
if ty.destructor_fn is not None:
- f.write("void %s(%s *p);\n" % (ty.destructor_fn,
ty.typename))
+ f.write("void %s(%s);\n" % (ty.destructor_fn,
ty.make_arg("p")))
if isinstance(ty, libxltypes.Enumeration):
- f.write("const char *%s_to_string(%s e);\n" %
(ty.typename, ty.typename))
- f.write("int %s_from_string(const char *s, %s *e);\n" %
(ty.typename, ty.typename))
+ f.write("const char *%s_to_string(%s);\n" % (ty.typename,
ty.make_arg("p")))
+ f.write("int %s_from_string(const char *s, %s);\n" %
(ty.typename, ty.make_arg("e", passby=libxltypes.PASS_BY_REFERENCE)))
f.write("extern libxl_enum_string_table
%s_string_table[];\n" % (ty.typename))
f.write("\n")
@@ -213,7 +213,7 @@ if __name__ == ''__main__'':
""" % " ".join(sys.argv))
for ty in [t for t in types if t.destructor_fn is not None and
t.autogenerate_destructor]:
- f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename))
+ f.write("void %s(%s)\n" % (ty.destructor_fn,
ty.make_arg("p")))
f.write("{\n")
f.write(libxl_C_type_destroy(ty, "p"))
f.write(" memset(p, LIBXL_DTOR_POISON, sizeof(*p));\n")
diff -r 7e8ce32eda26 -r 3b2827da2358 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/libxl.idl Thu Jul 14 13:22:36 2011 +0100
@@ -4,8 +4,8 @@
#
libxl_domid = Builtin("domid")
-libxl_uuid = Builtin("uuid")
-libxl_mac = Builtin("mac")
+libxl_uuid = Builtin("uuid", passby=PASS_BY_REFERENCE)
+libxl_mac = Builtin("mac", passby=PASS_BY_REFERENCE)
libxl_cpumap = Builtin("cpumap",
destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
libxl_cpuarray = Builtin("cpuarray",
destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
libxl_cpuid_policy_list = Builtin("cpuid_policy_list",
destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE)
diff -r 7e8ce32eda26 -r 3b2827da2358 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -42,6 +42,14 @@ class Type(object):
def marshal_out(self):
return self.dir in [DIR_OUT, DIR_BOTH]
+ def make_arg(self, n, passby=None):
+ if passby is None: passby = self.passby
+
+ if passby == PASS_BY_REFERENCE:
+ return "%s *%s" % (self.typename, n)
+ else:
+ return "%s %s" % (self.typename, n)
+
class Builtin(Type):
"""Builtin type"""
def __init__(self, typename, **kwargs):
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 4 of 9] libxl: IDL: refactor code to massage a type into a function argument
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID 2c49e182becc028a95d67363dd06654c7f717eec
# Parent 3b2827da23585a7fa93d1e6fc4db4d196706ebf8
libxl: IDL: refactor code to massage a type into a function argument
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -84,11 +84,6 @@ def libxl_C_type_destroy(ty, v, indent else:
deref = v + "."
- if ty.passby == libxltypes.PASS_BY_REFERENCE and parent is not None:
- makeref = "&"
- else:
- makeref = ""
-
s = ""
if isinstance(ty, libxltypes.KeyedUnion):
if parent is None:
@@ -107,7 +102,7 @@ def libxl_C_type_destroy(ty, v, indent s +=
libxl_C_type_destroy(f.type, deref + f.name, "", deref)
else:
if ty.destructor_fn is not None:
- s += "%s(%s);\n" % (ty.destructor_fn, makeref + v)
+ s += "%s(%s);\n" % (ty.destructor_fn, ty.pass_arg(v,
parent is None))
if s != "":
s = indent + s
diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -50,6 +50,21 @@ class Type(object):
else:
return "%s %s" % (self.typename, n)
+ def pass_arg(self, n, isref=None, passby=None):
+ if passby is None: passby = self.passby
+ if isref is None: isref = self.passby == PASS_BY_REFERENCE
+
+ if passby == PASS_BY_REFERENCE:
+ if isref:
+ return "%s" % (n)
+ else:
+ return "&%s" % (n)
+ else:
+ if isref:
+ return "*%s" % (n)
+ else:
+ return "%s" % (n)
+
class Builtin(Type):
"""Builtin type"""
def __init__(self, typename, **kwargs):
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 5 of 9] libxl: IDL: remove libxl_C_type_of
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID 5601d0ddb75d62643312dfc71da6715d42d7186f
# Parent 2c49e182becc028a95d67363dd06654c7f717eec
libxl: IDL: remove libxl_C_type_of
It''s not really adding much...
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 2c49e182becc -r 5601d0ddb75d tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -17,10 +17,7 @@ def format_comment(level, comment):
s += "%s */" % indent
s += "\n"
return s
-
-def libxl_C_type_of(ty):
- return ty.typename
-
+
def libxl_C_instance_of(ty, instancename):
if isinstance(ty, libxltypes.Aggregate) and ty.typename is None:
if instancename is None:
@@ -28,7 +25,7 @@ def libxl_C_instance_of(ty, instancename
else:
return libxl_C_type_define(ty) + " " + instancename
else:
- return libxl_C_type_of(ty) + " " + instancename
+ return ty.typename + " " + instancename
def libxl_C_type_define(ty, indent = ""):
s = ""
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 6 of 9] libxl: IDL: add helper to generate references to Aggregate type members
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID df13bcff8d7ddedbce11f7e096d5756beb3f913b
# Parent 5601d0ddb75d62643312dfc71da6715d42d7186f
libxl: IDL: add helper to generate references to Aggregate type members.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 5601d0ddb75d -r df13bcff8d7d tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -76,27 +76,21 @@ def libxl_C_type_define(ty, indent = "")
return s.replace("\n", "\n%s" % indent)
def libxl_C_type_destroy(ty, v, indent = " ", parent = None):
- if parent is None:
- deref = v + "->"
- else:
- deref = v + "."
s = ""
if isinstance(ty, libxltypes.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
for f in ty.fields:
+ (nparent,fexpr) = ty.member(v, f, parent is None)
keyvar_expr = f.keyvar_expr % (parent + ty.keyvar_name)
s += "if (" + keyvar_expr + ") {\n"
- s += libxl_C_type_destroy(f.type, deref + f.name, indent + "
", deref)
+ s += libxl_C_type_destroy(f.type, fexpr, indent + " ",
nparent)
s += "}\n"
elif isinstance(ty, libxltypes.Struct) and (parent is None or
ty.destructor_fn is None):
for f in [f for f in ty.fields if not f.const]:
-
- if f.name is None: # Anonymous struct
- s += libxl_C_type_destroy(f.type, deref, "", deref)
- else:
- s += libxl_C_type_destroy(f.type, deref + f.name, "",
deref)
+ (nparent,fexpr) = ty.member(v, f, parent is None)
+ s += libxl_C_type_destroy(f.type, fexpr, "", nparent)
else:
if ty.destructor_fn is not None:
s += "%s(%s);\n" % (ty.destructor_fn, ty.pass_arg(v,
parent is None))
diff -r 5601d0ddb75d -r df13bcff8d7d tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -147,6 +147,24 @@ class Aggregate(Type):
n,t,const,comment = f
self.fields.append(Field(t,n,const=const,comment=comment))
+ # Returns a tuple (stem, field-expr)
+ #
+ # field-expr is a C expression for a field "f" within the struct
+ # "v".
+ #
+ # stem is the stem common to both "f" and any other sibbling
field
+ # within the "v".
+ def member(self, v, f, isref):
+ if isref:
+ deref = v + "->"
+ else:
+ deref = v + "."
+
+ if f.name is None: # Anonymous
+ return (deref, deref)
+ else:
+ return (deref, deref + f.name)
+
class Struct(Aggregate):
def __init__(self, name, fields, **kwargs):
kwargs.setdefault(''passby'', PASS_BY_REFERENCE)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 7 of 9] libxl: IDL: bring command line handling in genwrap.py into one place
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646156 -3600
# Node ID 73832fb92268d5a975cfe5e2f2b2b44dd59cc9db
# Parent df13bcff8d7ddedbce11f7e096d5756beb3f913b
libxl: IDL: bring command line handling in genwrap.py into one place.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r df13bcff8d7d -r 73832fb92268 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
+++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100
@@ -137,14 +137,14 @@ def libxl_C_enum_from_string(ty, str, e,
if __name__ == ''__main__'':
- if len(sys.argv) < 4:
+ if len(sys.argv) != 4:
print >>sys.stderr, "Usage: gentypes.py <idl>
<header> <implementation>"
sys.exit(1)
- idl = sys.argv[1]
+ (_, idl, header, impl) = sys.argv
+
(_,types) = libxltypes.parse(idl)
- header = sys.argv[2]
print "outputting libxl type definitions to %s" % header
f = open(header, "w")
@@ -174,7 +174,6 @@ if __name__ == ''__main__'':
f.write("""#endif /* __LIBXL_TYPES_H */\n""")
f.close()
- impl = sys.argv[3]
print "outputting libxl type implementations to %s" % impl
f = open(impl, "w")
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 8 of 9] libxl: rename testenum->testidl
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1310646251 -3600 # Node ID f3d8695e7b03a5a90d05380f7ed4aa5d9ad56dd4 # Parent 73832fb92268d5a975cfe5e2f2b2b44dd59cc9db libxl: rename testenum->testidl I plan to add some non-Enumeration tests. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 73832fb92268 -r f3d8695e7b03 .hgignore --- a/.hgignore Thu Jul 14 13:22:36 2011 +0100 +++ b/.hgignore Thu Jul 14 13:24:11 2011 +0100 @@ -187,8 +187,8 @@ ^tools/libxl/_.*\.c$ ^tools/libxl/libxlu_cfg_y\.output$ ^tools/libxl/xl$ -^tools/libxl/testenum$ -^tools/libxl/testenum\.c$ +^tools/libxl/testidl$ +^tools/libxl/testidl\.c$ ^tools/libaio/src/.*\.ol$ ^tools/libaio/src/.*\.os$ ^tools/misc/cpuperf/cpuperf-perfcntr$ diff -r 73832fb92268 -r f3d8695e7b03 tools/libxl/Makefile --- a/tools/libxl/Makefile Thu Jul 14 13:22:36 2011 +0100 +++ b/tools/libxl/Makefile Thu Jul 14 13:24:11 2011 +0100 @@ -45,16 +45,16 @@ LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_ libxlu_disk_l.o libxlu_disk.o $(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h -CLIENTS = xl testenum +CLIENTS = xl testidl XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o $(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h $(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight) -testenum.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight) -testenum.c: libxl.idl gentest.py libxl.h - $(PYTHON) gentest.py libxl.idl testenum.c.new - mv testenum.c.new testenum.c +testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight) +testidl.c: libxl.idl gentest.py libxl.h + $(PYTHON) gentest.py libxl.idl testidl.c.new + mv testidl.c.new testidl.c .PHONY: all all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \ @@ -116,8 +116,8 @@ libxlutil.a: $(LIBXLU_OBJS) xl: $(XL_OBJS) libxlutil.so libxenlight.so $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) -testenum: testenum.o libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ testenum.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) +testidl: testidl.o libxlutil.so libxenlight.so + $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) .PHONY: install install: all _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jul-14 16:02 UTC
[Xen-devel] [PATCH 9 of 9] libxl: add LIBXL_MAC_{FMT,FMTLEN,BYTES}
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1310646259 -3600
# Node ID 57e96d4f36b244faff9370d42c50355d9abd0494
# Parent f3d8695e7b03a5a90d05380f7ed4aa5d9ad56dd4
libxl: add LIBXL_MAC_{FMT,FMTLEN,BYTES}
Modelled after LIBXL_UUID_... (where I also add FMTLEN).
signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r f3d8695e7b03 -r 57e96d4f36b2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl.c Thu Jul 14 13:24:19 2011 +0100
@@ -1215,9 +1215,8 @@ int libxl_device_nic_add(libxl_ctx *ctx,
nic->script));
}
flexarray_append(back, "mac");
- flexarray_append(back, libxl__sprintf(&gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- nic->mac[0],
nic->mac[1], nic->mac[2],
- nic->mac[3],
nic->mac[4], nic->mac[5]));
+ flexarray_append(back,libxl__sprintf(&gc,
+ LIBXL_MAC_FMT,
LIBXL_MAC_BYTES(nic->mac)));
if (nic->ip) {
flexarray_append(back, "ip");
flexarray_append(back, libxl__strdup(&gc, nic->ip));
@@ -1235,9 +1234,8 @@ int libxl_device_nic_add(libxl_ctx *ctx,
flexarray_append(front, "handle");
flexarray_append(front, libxl__sprintf(&gc, "%d",
nic->devid));
flexarray_append(front, "mac");
- flexarray_append(front, libxl__sprintf(&gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- nic->mac[0],
nic->mac[1], nic->mac[2],
- nic->mac[3],
nic->mac[4], nic->mac[5]));
+ flexarray_append(front, libxl__sprintf(&gc,
+ LIBXL_MAC_FMT,
LIBXL_MAC_BYTES(nic->mac)));
libxl__device_generic_add(&gc, &device,
libxl__xs_kvs_of_flexarray(&gc, back,
back->count),
libxl__xs_kvs_of_flexarray(&gc, front,
front->count));
diff -r f3d8695e7b03 -r 57e96d4f36b2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl.h Thu Jul 14 13:24:19 2011 +0100
@@ -139,6 +139,9 @@
#include <libxl_uuid.h>
typedef uint8_t libxl_mac[6];
+#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
+#define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
+#define LIBXL_MAC_BYTES(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
typedef char **libxl_string_list;
void libxl_string_list_destroy(libxl_string_list *sl);
diff -r f3d8695e7b03 -r 57e96d4f36b2 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl_dm.c Thu Jul 14 13:24:19 2011 +0100
@@ -177,9 +177,8 @@ static char ** libxl__build_device_model
}
for (i = 0; i < num_vifs; i++) {
if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
- char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
- vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
+ char *smac = libxl__sprintf(gc,
+ LIBXL_MAC_FMT,
LIBXL_MAC_BYTES(vifs[i].mac));
char *ifname;
if (!vifs[i].ifname)
ifname = libxl__sprintf(gc, "tap%d.%d",
info->domid, vifs[i].devid);
@@ -368,9 +367,8 @@ static char ** libxl__build_device_model
}
for (i = 0; i < num_vifs; i++) {
if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
- char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
- vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
+ char *smac = libxl__sprintf(gc,
+ LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac));
char *ifname;
if (!vifs[i].ifname) {
ifname = libxl__sprintf(gc, "tap%d.%d",
info->domid, vifs[i].devid);
diff -r f3d8695e7b03 -r 57e96d4f36b2 tools/libxl/libxl_uuid.h
--- a/tools/libxl/libxl_uuid.h Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl_uuid.h Thu Jul 14 13:24:19 2011 +0100
@@ -16,6 +16,7 @@
#define __LIBXL_UUID_H__
#define LIBXL_UUID_FMT
"%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+#define LIBXL_UUID_FMTLEN ((2*16)+4) /* 16 hex bytes plus 4 hypens */
#define LIBXL__UUID_BYTES(uuid) uuid[0], uuid[1], uuid[2], uuid[3], \
uuid[4], uuid[5], uuid[6], uuid[7], \
uuid[8], uuid[9], uuid[10], uuid[11], \
diff -r f3d8695e7b03 -r 57e96d4f36b2 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Thu Jul 14 13:24:19 2011 +0100
@@ -3989,9 +3989,7 @@ int main_networklist(int argc, char **ar
/* Idx BE */
printf("%-3d %-2d ", nics[i].devid, nics[i].backend_id);
/* MAC */
- printf("%02x:%02x:%02x:%02x:%02x:%02x ",
- nics[i].mac[0], nics[i].mac[1], nics[i].mac[2],
- nics[i].mac[3], nics[i].mac[4], nics[i].mac[5]);
+ printf(LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nics[i].mac));
/* Hdl Sta evch txr/rxr BE-path */
printf("%6d %5d %6d %5d/%-11d %-30s\n",
nics[i].devid, nics[i].state, nics[i].evtch,
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jul-14 18:03 UTC
Re: [Xen-devel] [PATCH 0 of 9] libxl: various IDL cleanups + some misc bits
Ian Campbell writes ("[Xen-devel] [PATCH 0 of 9] libxl: various IDL
cleanups + some misc bits"):> The following consists of vaqrious libxl IDL cleanups, plus some
> other misc bits.
Thanks for the resend. I''ve applied all 9.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel