Skip to contentSkip to conversation

libxl API updates backlog

GIT PULL Ian Campbell 2 participants 4 messages Jan 31, 2012 – Feb 7, 2012

lore
Share & tools
lore
#0 lore raw

I've built up a rather large backlog of patches. Many of them have been posted before and acked so rather than spam the list with another big mail bomb I am sending as a git pull request a large batch of those patches which have been acked.

These were all posted before as part of either "libxl: drop device_model_info" or "libxl: API updates + xl: JSON" (which in turn were previously split out of "libxl: drop device_model_info, better defaults support, stubdoms by default", the rest of which will come later). A small number have been posted individually here or there.

FYI after this I have ~20 patches which form the "better defaults" part of the series mentioned above. However this portion has been somewhat heavily reworked since last time and would therefore benefit from a repost, which I'll do soon, I hope.

The following changes since commit 175a8a1275de58cd67aa2ff9b617270b7697e08b:

xen: do not remap pirqs if !is_hvm_pv_evtchn_domain (2012-01-31 11:39:37 +0000)

are available in the git repository at:
git://xenbits.xen.org/people/ianc/xen-unstable.git for-ianj/libxl

Ian Campbell (34):
libxl: remove libxl_domain_create_info.poolname
libxl: name libxl_create_cpupool consistent with other functions
libxl: do not write/maintain "pool_name" in XenStore
libxl: remove comment support from IDL
libxl: use keyword arguments for field definitions in aggregate types
ocaml: use libxl IDL type helpers for C argument passing
libxl: define libxl_vnc_info to hold all info about the vnc info
libxl: define libxl_spice_info to hold all info about the spice server
libxl: define libxl_sdl_info to hold all info about the SDL config
libxl: plumb libxl_domain_config down into device model creation
libxl: now that dm creation takes domain_config stop passing down devices
libxl: remove redundant info from dm info
libxl: drop dm_info.dom_name
libxl: use vfb[0] directly for xenpv device model
libxl: move HVM emulated GFX support into b_info->u.hvm
libxl: HVM device configuration info build_info->u.hvm
libxl: move gfx_passthru setting to b_info->u.hvm
libxl: Remove libxl_device_model_info.type
libxl: remove uuid from device model info
libxl: move device model selection variables to b_info
libxl: move "saved_state" to libxl__domain_build_state
libxl: remove libxl_device_model_info
libxl: only write "disable_pf" key to xenstore when it makes sense
libxl: Rename libxl IDL infrastructure
libxl: de-hard-tabbify idl.txt
libxl: remove libxl_button_press in favour of libxl_send_trigger
ocaml: add helpers for Some/None option types
ocaml: Topology.get returns an array not a single element
libxl: expose cpu topology as a single list of cpu->{node, core, socket} maps
libxl: drop libxl_cpuarray -- topology was the only user
libxl: add named enum for timer mode
xl: use json output by default
docs: document /etc/xen/xl.conf
xl: allow enable automatic fallback to ACPI events if PV control not available

 docs/man/xl.conf.pod.5                |   93 +++++
 docs/man/xl.pod.1                     |   38 ++-
 tools/hotplug/Linux/init.d/xendomains |   21 +-
 tools/libxl/Makefile                  |    4 +-
 tools/libxl/gentest.py                |   40 +--
 tools/libxl/gentypes.py               |   57 +--
 tools/libxl/{libxltypes.py => idl.py} |   26 +-
 tools/libxl/idl.txt                   |   83 ++---
 tools/libxl/libxl.c                   |  267 ++++++-------
 tools/libxl/libxl.h                   |   28 +-
 tools/libxl/libxl_create.c            |  111 ++----
 tools/libxl/libxl_dm.c                |  718 ++++++++++++++++++---------------
 tools/libxl/libxl_dom.c               |   19 +-
 tools/libxl/libxl_internal.h          |   23 +-
 tools/libxl/libxl_json.c              |  173 +++++++-
 tools/libxl/libxl_json.h              |    3 +
 tools/libxl/libxl_types.idl           |  206 +++++-----
 tools/libxl/libxl_utils.c             |   32 +--
 tools/libxl/libxl_utils.h             |    2 -
 tools/libxl/libxl_uuid.c              |    4 +-
 tools/libxl/libxl_uuid.h              |    2 +-
 tools/libxl/xl.c                      |   10 +
 tools/libxl/xl.h                      |    8 +
 tools/libxl/xl_cmdimpl.c              |  507 ++++++++++-------------
 tools/libxl/xl_sxp.c                  |  220 ++++++++++
 tools/ocaml/libs/xl/Makefile          |    2 +-
 tools/ocaml/libs/xl/genwrap.py        |   63 ++--
 tools/ocaml/libs/xl/xenlight.ml.in    |   15 +-
 tools/ocaml/libs/xl/xenlight.mli.in   |   14 +-
 tools/ocaml/libs/xl/xenlight_stubs.c  |   82 ++---
 tools/python/Makefile                 |    2 +-
 tools/python/genwrap.py               |   35 +-
 tools/python/xen/lowlevel/xl/xl.c     |   24 --
 33 files changed, 1626 insertions(+), 1306 deletions(-)
 create mode 100644 docs/man/xl.conf.pod.5
 rename tools/libxl/{libxltypes.py => idl.py} (92%)
 create mode 100644 tools/libxl/xl_sxp.c
#1 lore raw

Ian Campbell writes ("[GIT PULL] libxl API updates backlog"):

Quoted 4 lines

I've built up a rather large backlog of patches. Many of them have been posted before and acked so rather than spam the list with another big mail bomb I am sending as a git pull request a large batch of those patches which have been acked.

Thanks.

This one had conflicts:

Quoted 1 line

xl: use json output by default

I have applied the rest:

Quoted 25 lines

libxl: remove libxl_domain_create_info.poolname
libxl: name libxl_create_cpupool consistent with other functions
libxl: do not write/maintain "pool_name" in XenStore
libxl: remove comment support from IDL
libxl: use keyword arguments for field definitions in aggregate types
ocaml: use libxl IDL type helpers for C argument passing
libxl: define libxl_vnc_info to hold all info about the vnc info
libxl: define libxl_spice_info to hold all info about the spice server
libxl: define libxl_sdl_info to hold all info about the SDL config
libxl: plumb libxl_domain_config down into device model creation
libxl: now that dm creation takes domain_config stop passing down devices
libxl: remove redundant info from dm info
libxl: drop dm_info.dom_name
libxl: use vfb[0] directly for xenpv device model
libxl: move HVM emulated GFX support into b_info->u.hvm
libxl: HVM device configuration info build_info->u.hvm
libxl: move gfx_passthru setting to b_info->u.hvm
libxl: Remove libxl_device_model_info.type
libxl: remove uuid from device model info
libxl: move device model selection variables to b_info
libxl: move "saved_state" to libxl__domain_build_state
libxl: remove libxl_device_model_info
libxl: only write "disable_pf" key to xenstore when it makes sense
libxl: Rename libxl IDL infrastructure
libxl: de-hard-tabbify idl.txt

Quoted 8 lines

libxl: remove libxl_button_press in favour of libxl_send_trigger
ocaml: add helpers for Some/None option types
ocaml: Topology.get returns an array not a single element
libxl: expose cpu topology as a single list of cpu->{node, core, socket} maps
libxl: drop libxl_cpuarray -- topology was the only user
libxl: add named enum for timer mode
docs: document /etc/xen/xl.conf
xl: allow enable automatic fallback to ACPI events if PV control not ava

Thanks,
Ian.

author Acked-by Ian Jackson
#2 lore raw
Quoted 11 lines · Ian Jackson

Ian Campbell writes ("[GIT PULL] libxl API updates backlog"):

Quoted 4 lines

I've built up a rather large backlog of patches. Many of them have been posted before and acked so rather than spam the list with another big mail bomb I am sending as a git pull request a large batch of those patches which have been acked.

Thanks.

This one had conflicts:

Quoted 1 line

xl: use json output by default

Rebased version below.

Quoted 1 line

I have applied the rest:

Thanks!

8<----------------------------------

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1328115855 0
# Node ID 5926f25e1d8a847ad3dc74ab9bc582b365f352ec # Parent 512bd9cd537d3846a12eebc255760fa7a2064a86
xl: use json output by default

Move the sxp producing code off into a separate file. It is supported for legacy reasons and needn't be updated other than the improve compatibility with xm.

libxl_domain_config is not currently generated by the IDL (adding the necessary support for Array types is on my to do list) so hand code the json generation function for now.

Since this rather directly exposes a libxl data structure it's not clear what sort of forward compatibility guarantees we can make. However it seems like it should be as stable as libxl's own API (which we are looking to stabilise)

(Gratuitous string.h include needed for memset in libxl_util.h)

[since last version -- update xendomains script patch merged in]
docs/man/xl.pod.1 +1 -1
diff -r 512bd9cd537d -r 5926f25e1d8a docs/man/xl.pod.1
@@ -219,7 +219,7 @@ B<OPTIONS>
 =item B<-l>, B<--long>
 
 The output for B<xl list> is not the table view shown below, but 
-instead presents the data in SXP compatible format.
+instead presents the data in as a JSON data structure.
 
 =item B<-Z>, B<--context>
 Also prints the security labels.
tools/hotplug/Linux/init.d/xendomains +13 -8
diff -r 512bd9cd537d -r 5926f25e1d8a tools/hotplug/Linux/init.d/xendomains
@@ -202,15 +202,20 @@ rdnames()
     done
 }
 
+LIST_GREP='((domain\|(domid\|(name\|^{$\|"name":\|"domid":'
 parseln()
 {
-    if [[ "$1" =~ '(domain' ]]; then
+    if [[ "$1" =~ '(domain' ]] || [[ "$1" = "{" ]]; then
         name=;id=
-    else if [[ "$1" =~ '(name' ]]; then
+    elif [[ "$1" =~ '(name' ]]; then
         name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
-    else if [[ "$1" =~ '(domid' ]]; then
+    elif [[ "$1" =~ '(domid' ]]; then
         id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
-    fi; fi; fi
+    elif [[ "$1" =~ '"name":' ]]; then
+        name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/')
+    elif [[ "$1" =~ '"domid":' ]]; then
+        id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/')
+    fi
 
     [ -n "$name" -a -n "$id" ] && return 0 || return 1
 }
@@ -228,7 +233,7 @@ is_running()
 		RC=0
 		;;
 	esac
-    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    done < <($CMD list -l | grep $LIST_GREP)
     return $RC
 }
 
@@ -310,7 +315,7 @@ all_zombies()
 	if test "$state" != "-b---d" -a "$state" != "-----d"; then
 	    return 1;
 	fi
-    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    done < <($CMD list -l | grep $LIST_GREP)
     return 0
 }
 
@@ -441,7 +446,7 @@ stop()
 	    fi
 	    kill $WDOG_PID >/dev/null 2>&1
 	fi
-    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    done < <($CMD list -l | grep $LIST_GREP)
 
     # NB. this shuts down ALL Xen domains (politely), not just the ones in
     # AUTODIR/*
@@ -478,7 +483,7 @@ check_domain_up()
 		return 0
 		;;
 	esac
-    done < <($CMD list -l | grep '(\(domain\|domid\|name\)')
+    done < <($CMD list -l | grep $LIST_GREP)
     return 1
 }
 
tools/libxl/Makefile +1 -1
diff -r 512bd9cd537d -r 5926f25e1d8a tools/libxl/Makefile
@@ -66,7 +66,7 @@ LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_
 
 CLIENTS = xl testidl
 
-XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o
+XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o xl_sxp.o
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 
tools/libxl/libxl.h +2 -0
diff -r 512bd9cd537d -r 5926f25e1d8a tools/libxl/libxl.h
@@ -130,6 +130,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <string.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <sys/wait.h> /* for pid_t */
@@ -304,6 +305,7 @@ typedef struct {
     libxl_action_on_shutdown on_watchdog;
     libxl_action_on_shutdown on_crash;
 } libxl_domain_config;
+char *libxl_domain_config_to_json(libxl_ctx *ctx, libxl_domain_config *p);
 
 /* context functions */
 int libxl_ctx_alloc(libxl_ctx **pctx, int version,
tools/libxl/libxl_json.c +152 -0

158 lines not on this page · raw message

tools/libxl/libxl_json.h +3 -0
diff -r 512bd9cd537d -r 5926f25e1d8a tools/libxl/libxl_json.h
@@ -70,4 +70,7 @@ static inline yajl_gen libxl__yajl_gen_a
 
 #endif /* !HAVE_YAJL_V2 */
 
+yajl_gen_status libxl_domain_config_gen_json(yajl_gen hand,
+                                             libxl_domain_config *p);
+
 #endif /* LIBXL_JSON_H */
tools/libxl/xl.c +10 -0
diff -r 512bd9cd537d -r 5926f25e1d8a tools/libxl/xl.c
@@ -38,6 +38,7 @@ int dryrun_only;
 int autoballoon = 1;
 char *lockfile;
 char *default_vifscript = NULL;
+enum output_format default_output_format = OUTPUT_FORMAT_JSON;
 
 static xentoollog_level minmsglevel = XTL_PROGRESS;
 
@@ -78,6 +79,15 @@ static void parse_global_config(const ch
     if (!xlu_cfg_get_string (config, "vifscript", &buf, 0))
         default_vifscript = strdup(buf);
 
+    if (!xlu_cfg_get_string (config, "output_format", &buf, 0)) {
+        if (!strcmp(buf, "json"))
+            default_output_format = OUTPUT_FORMAT_JSON;
+        else if (!strcmp(buf, "sxp"))
+            default_output_format = OUTPUT_FORMAT_SXP;
+        else {
+            fprintf(stderr, "invalid default output format \"%s\"\n", buf);
+        }
+    }
     xlu_cfg_destroy(config);
 }
 
tools/libxl/xl.h +8 -0
diff -r 512bd9cd537d -r 5926f25e1d8a tools/libxl/xl.h
@@ -111,6 +111,14 @@ extern int dryrun_only;
 extern char *lockfile;
 extern char *default_vifscript;
 
+enum output_format {
+    OUTPUT_FORMAT_JSON,
+    OUTPUT_FORMAT_SXP,
+};
+extern enum output_format default_output_format;
+
+extern void printf_info_sexp(int domid, libxl_domain_config *d_config);
+
 #endif /* XL_H */
 
 /*
tools/libxl/xl_cmdimpl.c +61 -181

275 lines not on this page · raw message

tools/libxl/xl_sxp.c new file +220 -0

220 lines not on this page · raw message