All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default
@ 2012-01-16 12:14 Ian Campbell
  2012-01-16 12:14 ` [PATCH 01 of 32 RFC] libxl: remove comment support from IDL Ian Campbell
                   ` (31 more replies)
  0 siblings, 32 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:14 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

My original intention with this series was to introduce the ability
for users of libxl to explicitly say "pick the default". Mainly by
introducing the libxl_defbool type but also by arranging more
generally that leaving a value set to zero means "default".

However it turned into something of a yakk shaving excercise and so
contains the following:

* Removes support for comments in the IDL language itself. Generating
  comments in the generated files is not all that useful so lets just
  use source level comments in the .idl instead.

* Switches to using keyword arguments for Fields in Aggregate types
  instead of a variadic tuple.

* Removes libxl_device_model_info from the library API. The use of
  a device model to supply specific features is really an
  implementation detail within the library and not something users of
  the library should need to be concerned with.

  Many of the fields of the struct we really guest configuration
  details, e.g. VNC setup and therefore belong in
  libxl_domain_build_info.

  This struct also contained a number of things which were duplicated
  from the build_info and which could never sensibly differ in this
  context (e.g. guest total RAM, ACPI on off etc).

  I have tried to make a determination whether something belongs in
  the global part of libxl_domain_build_info or whether it is HVM
  specific.

  This forms a big part of the series.

* Introduce libxl_defbool and switch to using it.

* Some other changes to arrange that the 0 value means "default". At
  least one instance of this (the timer_mode enum) introduces a wierd
  disconnect between the underlying values and the libxl exposed
  values. I'm not sure that I like this.

* Use device model stubdoms by default when possible.

One question which arised from this change is how we deal with
per-arch options in the future. Do we need to define
libxl_domain_build_info_x86? We could also tag fields with a list of
architectures.

This series has been lightly tested with PV domains (with and without
PVFB) and HVM domains (with and without stubdom).

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
@ 2012-01-16 12:14 ` Ian Campbell
  2012-01-16 16:23   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types Ian Campbell
                   ` (30 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:14 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326190542 0
# Node ID 485945937a27ea1d9736b8f9bf8d21183b928780
# Parent  f4956ec4b28602f512b69d07f5ea3d001dc688ad
libxl: remove comment support from IDL

People typically don't look for comments in generated source and the syntax for
specifying them in the IDL makes things harder to follow.

Instead just use source code comments in the IDL itself.

I dropped a bunch of "foo bool # enable or disable foo" type comments. A lot of
the remainder still aren't terribly useful though.

No change to the generate code other than the comments being removed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r f4956ec4b286 -r 485945937a27 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/libxl/gentypes.py	Tue Jan 10 10:15:42 2012 +0000
@@ -5,19 +5,6 @@ import re
 
 import libxltypes
 
-def format_comment(level, comment):
-    indent = reduce(lambda x,y: x + " ", range(level), "")
-    s  = "%s/*\n" % indent
-    s += "%s * " % indent
-    comment = comment.replace("\n", "\n%s * " % indent)
-    x = re.compile(r'^%s \* $' % indent, re.MULTILINE)
-    comment = x.sub("%s *" % indent, comment)
-    s += comment
-    s += "\n"
-    s += "%s */" % indent
-    s += "\n"
-    return s
-
 def libxl_C_instance_of(ty, instancename):
     if isinstance(ty, libxltypes.Aggregate) and ty.typename is None:
         if instancename is None:
@@ -30,17 +17,12 @@ def libxl_C_instance_of(ty, instancename
 def libxl_C_type_define(ty, indent = ""):
     s = ""
     if isinstance(ty, libxltypes.Enumeration):
-        if ty.comment is not None:
-            s += format_comment(0, ty.comment)
-
         if ty.typename is None:
             s += "enum {\n"
         else:
             s += "typedef enum %s {\n" % ty.typename
 
         for v in ty.values:
-            if v.comment is not None:
-                s += format_comment(4, v.comment)
             x = "%s = %d" % (v.name, v.value)
             x = x.replace("\n", "\n    ")
             s += "    " + x + ",\n"
@@ -50,17 +32,12 @@ def libxl_C_type_define(ty, indent = "")
             s += "} %s" % ty.typename
 
     elif isinstance(ty, libxltypes.Aggregate):
-        if ty.comment is not None:
-            s += format_comment(0, ty.comment)
-
         if ty.typename is None:
             s += "%s {\n" % ty.kind
         else:
             s += "typedef %s %s {\n" % (ty.kind, ty.typename)
 
         for f in ty.fields:
-            if f.comment is not None:
-                s += format_comment(4, f.comment)
             x = libxl_C_instance_of(f.type, f.name)
             if f.const:
                 x = "const " + x
diff -r f4956ec4b286 -r 485945937a27 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Tue Jan 10 10:15:42 2012 +0000
@@ -28,8 +28,8 @@ libxl_domain_type = Enumeration("domain_
     ])
 
 libxl_device_model_version = Enumeration("device_model_version", [
-    (1, "QEMU_XEN_TRADITIONAL", "Historical qemu-xen device model (qemu-dm)"),
-    (2, "QEMU_XEN", "Upstream based qemu-xen device model"),
+    (1, "QEMU_XEN_TRADITIONAL"), # Historical qemu-xen device model (qemu-dm)
+    (2, "QEMU_XEN"),             # Upstream based qemu-xen device model
     ])
 
 libxl_console_type = Enumeration("console_type", [
@@ -98,18 +98,18 @@ libxl_tsc_mode = Enumeration("tsc_mode",
 libxl_dominfo = Struct("dominfo",[
     ("uuid",        libxl_uuid),
     ("domid",       libxl_domid),
-    ("ssidref",      uint32),
+    ("ssidref",     uint32),
     ("running",     bool),
     ("blocked",     bool),
     ("paused",      bool),
     ("shutdown",    bool),
     ("dying",       bool),
 
-    ("shutdown_reason", uint8, False,
-"""Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying).
-
-Otherwise set to a value guaranteed not to clash with any valid
-SHUTDOWN_* constant."""),
+    # Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying).
+    #
+    # Otherwise set to a value guaranteed not to clash with any valid
+    # SHUTDOWN_* constant.
+    ("shutdown_reason", uint8),
     ("current_memkb",   uint64),
     ("shared_memkb", uint64),
     ("max_memkb",   uint64),
@@ -159,6 +159,11 @@ libxl_domain_create_info = Struct("domai
     ("poolname",     string),
     ])
 
+# Instances of libxl_file_reference contained in this struct which
+# have been mapped (with libxl_file_reference_map) will be unmapped
+# by libxl_domain_build/restore. If either of these are never called
+# then the user is responsible for calling
+# libxl_file_reference_unmap.
 libxl_domain_build_info = Struct("domain_build_info",[
     ("max_vcpus",       integer),
     ("cur_vcpus",       integer),
@@ -192,84 +197,87 @@ libxl_domain_build_info = Struct("domain
                                       ("cmdline", string),
                                       ("ramdisk", libxl_file_reference),
                                       ("features", string, True),
-                                      ("e820_host", bool, False, "Use host's E820 for PCI passthrough."),
+                                      # Use host's E820 for PCI passthrough.
+                                      ("e820_host", bool),
                                       ])),
                  ])),
     ],
-    comment =
-"""Instances of libxl_file_reference contained in this struct which
-have been mapped (with libxl_file_reference_map) will be unmapped
-by libxl_domain_build/restore. If either of these are never called
-then the user is responsible for calling
-libxl_file_reference_unmap.""")
+)
 
+# Device Model Information
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
-    ("uuid",             libxl_uuid,  False, "this is use only with stubdom, and must be different from the domain uuid"),
+    
+    # uuid is used only with stubdom, and must be different from the
+    # domain uuid
+    ("uuid",             libxl_uuid),
     ("dom_name",         string),
     ("device_model_version", libxl_device_model_version),
     ("device_model_stubdomain", bool),
-    ("device_model",     string, False, "if you set this you must set device_model_version too"),
+    # you set device_model you must set device_model_version too
+    ("device_model",     string),
     ("saved_state",      string),
     ("type",             libxl_domain_type),
     ("target_ram",       uint32),
-    ("videoram",         integer,           False, "size of the videoram in MB"),
-    ("stdvga",           bool,              False, "stdvga enabled or disabled"),
-    ("vnc",              bool,              False, "vnc enabled or disabled"),
-    ("vnclisten",        string,            False, "address:port that should be listened on for the VNC server if vnc is set"),
-    ("vncpasswd",        string,            False, "the VNC password"),
-    ("vncdisplay",       integer,           False, "set VNC display number"),
-    ("vncunused",        bool,              False, "try to find an unused port for the VNC server"),
-    ("keymap",           string,            False, "set keyboard layout, default is en-us keyboard"),
-    ("sdl",              bool,              False, "sdl enabled or disabled"),
-    ("opengl",           bool,              False, "opengl enabled or disabled (if enabled requires sdl enabled)"),
-    ("spice",            bool,              False,
-    "spice enabled or disabled"),
-    ("spiceport",        integer,           False,
-    "the port that should be listened on for the spice server"),
-    ("spicetls_port",    integer,           False, """the tls port
-that should be listened on for the spice server,
-at least one of the port or tls port must be given"""),
-    ("spicehost",        string,            False, """the interface
-that should be listened on if given otherwise any interface"""),
-    ("spicedisable_ticketing", bool,        False,
-    "enable client connection with no password"),
-    ("spicepasswd",      string,            False, """set ticket password
-witch must be used by a client for connection.
-The password never expires"""),
-    ("spiceagent_mouse", bool,              False,
-    "Whether spice agent is used for client mouse mode(default is on)"),
-    ("nographic",        bool,              False, "no graphics, use serial port"),
-    ("gfx_passthru",     bool,              False, "graphics passthrough enabled or disabled"),
-    ("serial",           string,            False, "serial port re-direct to pty deivce"),
-    ("boot",             string,            False, "boot order, for example dca"),
-    ("usb",              bool,              False, "usb support enabled or disabled"),
-    ("usbdevice",        string,            False, "enable usb mouse: tablet for absolute mouse, mouse for PS/2 protocol relative mouse"),
-    ("soundhw",          string,            False, "enable sound hardware"),
-    ("acpi",             bool,              False, "acpi enabled or disabled"),
-    ("vcpus",            integer,           False, "max number of vcpus"),
-    ("vcpu_avail",       integer,           False, "vcpus actually available"),
-    ("xen_platform_pci", bool,              False, "enable/disable the xen platform pci device"),
-    ("extra",            libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"),
-    ("extra_pv",         libxl_string_list, False, "extra parameters pass directly to qemu for PV guest, NULL terminated"),
-    ("extra_hvm",        libxl_string_list, False, "extra parameters pass directly to qemu for HVM guest, NULL terminated"),
+    # size of the videoram in MB
+    ("videoram",         integer), 
+    ("stdvga",           bool),
+    ("vnc",              bool),
+    # "address:port" that should be listened on for the VNC server
+    ("vnclisten",        string),
+    ("vncpasswd",        string),
+    # VNC display number
+    ("vncdisplay",       integer),
+    # If set then try to find an unused port for the VNC server
+    ("vncunused",        bool),
+    # keyboard layout, default is en-us keyboard
+    ("keymap",           string),
+    ("sdl",              bool),
+    ("opengl",           bool), # (requires sdl enabled)
+    ("spice",            bool),
+    # At least one of spice port or spicetls_post must be given
+    ("spiceport",        integer),
+    ("spicetls_port",    integer),
+    # Interface to bind to
+    ("spicehost",        string),
+    # enable client connection with no password
+    ("spicedisable_ticketing", bool),
+    ("spicepasswd",      string),
+    ("spiceagent_mouse", bool),
+    ("nographic",        bool),
+    ("gfx_passthru",     bool),
+    ("serial",           string),
+    ("boot",             string),
+    ("usb",              bool),
+    # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse
+    ("usbdevice",        string),
+    ("soundhw",          string),
+    ("acpi",             bool),
+    ("vcpus",            integer), # max number of vcpus
+    ("vcpu_avail",       integer), # vcpus actually available
+    ("xen_platform_pci", bool),
+    # extra parameters pass directly to qemu, NULL terminated
+    ("extra",            libxl_string_list),
+    # extra parameters pass directly to qemu for PV guest, NULL terminated
+    ("extra_pv",         libxl_string_list),
+    # extra parameters pass directly to qemu for HVM guest, NULL terminated
+    ("extra_hvm",        libxl_string_list),
     ],
-    comment=
-"""Device Model information.
-
-Network is missing""")
+)
 
 libxl_device_vfb = Struct("device_vfb", [
     ("backend_domid", libxl_domid),
     ("devid",         integer),
-    ("vnc",           bool,     False, "vnc enabled or disabled"),
-    ("vnclisten",     string,   False, "address:port that should be listened on for the VNC server if vnc is set"),
-    ("vncpasswd",     string,   False, "the VNC password"),
-    ("vncdisplay",    integer,  False, "set VNC display number"),
-    ("vncunused",     bool,     False, "try to find an unused port for the VNC server"),
-    ("keymap",        string,   False, "set keyboard layout, default is en-us keyboard"),
-    ("sdl",           bool,     False, "sdl enabled or disabled"),
-    ("opengl",        bool,     False, "opengl enabled or disabled (if enabled requires sdl enabled)"),
+    ("vnc",           bool),
+    # address:port that should be listened on for the VNC server if vnc is set
+    ("vnclisten",     string),
+    ("vncpasswd",     string),
+    ("vncdisplay",    integer),
+    ("vncunused",     bool),
+    # set keyboard layout, default is en-us keyboard
+    ("keymap",        string),
+    ("sdl",           bool),
+    ("opengl",        bool), # (if enabled requires sdl enabled)
     ("display",       string),
     ("xauthority",    string),
     ])
@@ -346,13 +354,13 @@ libxl_nicinfo = Struct("nicinfo", [
     ])
 
 libxl_vcpuinfo = Struct("vcpuinfo", [
-    ("vcpuid", uint32,              False, "vcpu's id"),
-    ("cpu", uint32,                 False, "current mapping"),
-    ("online", bool,                False, "currently online (not hotplugged)?"),
-    ("blocked", bool,               False, "blocked waiting for an event?"),
-    ("running", bool,               False, "currently scheduled on its CPU?"),
-    ("vcpu_time", uint64,           False, "total vcpu time ran (ns)"),
-    ("cpumap", libxl_cpumap,        False, "current cpu's affinities"),
+    ("vcpuid", uint32),
+    ("cpu", uint32),
+    ("online", bool),
+    ("blocked", bool),
+    ("running", bool),
+    ("vcpu_time", uint64), # total vcpu time ran (ns)
+    ("cpumap", libxl_cpumap), # current cpu's affinities
     ])
 
 libxl_physinfo = Struct("physinfo", [
@@ -373,9 +381,9 @@ libxl_physinfo = Struct("physinfo", [
     ], dispose_fn=None, dir=DIR_OUT)
 
 libxl_topologyinfo = Struct("topologyinfo", [
-    ("coremap", libxl_cpuarray,   False, "cpu to core map"),
-    ("socketmap", libxl_cpuarray, False, "cpu to socket map"),
-    ("nodemap", libxl_cpuarray,   False, "cpu to node map"),
+    ("coremap", libxl_cpuarray),   # cpu to core map
+    ("socketmap", libxl_cpuarray), # cpu to socket map
+    ("nodemap", libxl_cpuarray),   # cpu to node map
     ])
 
 libxl_sched_credit = Struct("sched_credit", [
diff -r f4956ec4b286 -r 485945937a27 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/libxl/libxltypes.py	Tue Jan 10 10:15:42 2012 +0000
@@ -22,7 +22,6 @@ def _get_default_namespace():
 
 class Type(object):
     def __init__(self, typename, **kwargs):
-        self.comment = kwargs.setdefault('comment', None)
         self.namespace = kwargs.setdefault('namespace',
                 _get_default_namespace())
         self.dir = kwargs.setdefault('dir', DIR_BOTH)
@@ -120,7 +119,6 @@ class EnumerationValue(object):
         self.rawname = str.upper(enum.rawname) + "_" + self.valuename
         self.name = str.upper(enum.namespace) + self.rawname
         self.value = value
-        self.comment = kwargs.setdefault("comment", None)
 
 class Enumeration(Type):
     def __init__(self, typename, values, **kwargs):
@@ -129,16 +127,9 @@ class Enumeration(Type):
 
         self.values = []
         for v in values:
-            # (value, name[, comment=None])
-            if len(v) == 2:
-                (num,name) = v
-                comment = None
-            elif len(v) == 3:
-                num,name,comment = v
-            else:
-                raise ""
+            # (value, name)
+            (num,name) = v
             self.values.append(EnumerationValue(self, num, name,
-                                                comment=comment,
                                                 typename=self.rawname))
     def lookup(self, name):
         for v in self.values:
@@ -152,7 +143,6 @@ class Field(object):
         self.type = type
         self.name = name
         self.const = kwargs.setdefault('const', False)
-        self.comment = kwargs.setdefault('comment', None)
         self.enumname = kwargs.setdefault('enumname', None)
 
 class Aggregate(Type):
@@ -164,19 +154,17 @@ class Aggregate(Type):
 
         self.fields = []
         for f in fields:
-            # (name, type[, const=False[, comment=None]])
+            # (name, type[, const=False])
             if len(f) == 2:
                 n,t = f
                 const = False
-                comment = None
             elif len(f) == 3:
                 n,t,const = f
-                comment = None
             else:
-                n,t,const,comment = f
+                raise ValueError
             if n is None:
                 raise ValueError
-            self.fields.append(Field(t,n,const=const,comment=comment))
+            self.fields.append(Field(t,n,const=const))
 
     # Returns a tuple (stem, field-expr)
     #

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
  2012-01-16 12:14 ` [PATCH 01 of 32 RFC] libxl: remove comment support from IDL Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:03   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 03 of 32 RFC] ocaml: use libxl IDL type helpers for C argument passing Ian Campbell
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326190542 0
# Node ID cf86bcb7c89568a2c60f246d0e2443acb756e1c1
# Parent  485945937a27ea1d9736b8f9bf8d21183b928780
libxl: use keyword arguments for field definitions in aggregate types.

The original code is not so bad now that the comments are gone but this is
still a bit cleaner.

No change in the generated code.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 485945937a27 -r cf86bcb7c895 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Tue Jan 10 10:15:42 2012 +0000
@@ -196,7 +196,7 @@ libxl_domain_build_info = Struct("domain
                                       ("bootloader_args", libxl_string_list),
                                       ("cmdline", string),
                                       ("ramdisk", libxl_file_reference),
-                                      ("features", string, True),
+                                      ("features", string, {'const': True}),
                                       # Use host's E820 for PCI passthrough.
                                       ("e820_host", bool),
                                       ])),
diff -r 485945937a27 -r cf86bcb7c895 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/libxl/libxltypes.py	Tue Jan 10 10:15:42 2012 +0000
@@ -154,17 +154,17 @@ class Aggregate(Type):
 
         self.fields = []
         for f in fields:
-            # (name, type[, const=False])
+            # (name, type[, {kw args}])
             if len(f) == 2:
                 n,t = f
-                const = False
+                kw = {}
             elif len(f) == 3:
-                n,t,const = f
+                n,t,kw = f
             else:
                 raise ValueError
             if n is None:
                 raise ValueError
-            self.fields.append(Field(t,n,const=const))
+            self.fields.append(Field(t,n,**kw))
 
     # Returns a tuple (stem, field-expr)
     #

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 03 of 32 RFC] ocaml: use libxl IDL type helpers for C argument passing
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
  2012-01-16 12:14 ` [PATCH 01 of 32 RFC] libxl: remove comment support from IDL Ian Campbell
  2012-01-16 12:15 ` [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 12:15 ` [PATCH 04 of 32 RFC] ocaml: Correct ocaml type name for Aggregate types Ian Campbell
                   ` (28 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326212333 0
# Node ID 07c4b8a8d50c8562472c8f6607ec145146c3828c
# Parent  cf86bcb7c89568a2c60f246d0e2443acb756e1c1
ocaml: use libxl IDL type helpers for C argument passing

Makes handling of nested structs more correct.

Only change to the generated code right now is that the FOO_Val
(C->ocamlC) function for Enumeration types now takes the C argument by
value instead of reference.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r cf86bcb7c895 -r 07c4b8a8d50c tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py	Tue Jan 10 10:15:42 2012 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py	Tue Jan 10 16:18:53 2012 +0000
@@ -110,11 +110,6 @@ def gen_ocaml_ml(ty, interface, indent="
     return s.replace("\n", "\n%s" % indent)
 
 def c_val(ty, c, o, indent="", parent = None):
-    if ty.passby == libxltypes.PASS_BY_REFERENCE:
-        makeref = ""
-    else:
-        makeref = "&"
-
     s = indent
     if isinstance(ty,libxltypes.UInt):
         if ty.width in [8, 16]:
@@ -146,17 +141,18 @@ def c_val(ty, c, o, indent="", parent = 
     elif isinstance(ty, libxltypes.Aggregate) and (parent is None):
         n = 0
         for f in ty.fields:
-            s += "%s\n" % c_val(f.type, "%s->%s" % (c, f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c))
+            (nparent,fexpr) = ty.member(c, f, parent is None)
+            s += "%s\n" % c_val(f.type, fexpr, "Field(%s, %d)" % (o,n), parent=nparent)
             n = n + 1
     else:
-        s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, makeref + c, o)
+        s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, ty.pass_arg(c, parent is None, passby=libxltypes.PASS_BY_REFERENCE), o)
     
     return s.replace("\n", "\n%s" % indent)
 
 def gen_c_val(ty, indent=""):
     s = "/* Convert caml value to %s */\n" % ty.rawname
     
-    s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s *c_val, value v)\n" % (ty.rawname, ty.typename)
+    s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s, value v)\n" % (ty.rawname, ty.make_arg("c_val", passby=libxltypes.PASS_BY_REFERENCE))
     s += "{\n"
     s += "\tCAMLparam1(v);\n"
     s += "\n"
@@ -169,11 +165,6 @@ def gen_c_val(ty, indent=""):
     return s.replace("\n", "\n%s" % indent)
 
 def ocaml_Val(ty, o, c, indent="", parent = None):
-    if ty.passby == libxltypes.PASS_BY_REFERENCE:
-        makeref = ""
-    else:
-        makeref = "&"
-    
     s = indent
     if isinstance(ty,libxltypes.UInt):
         if ty.width in [8, 16]:
@@ -196,7 +187,7 @@ def ocaml_Val(ty, o, c, indent="", paren
         s += "%s = %s;" % (o, fn % { "c": c })
     elif isinstance(ty,libxltypes.Enumeration) and (parent is None):
         n = 0
-        s += "switch(*%s) {\n" % c
+        s += "switch(%s) {\n" % c
         for e in ty.values:
             s += "    case %s: %s = Int_val(%d); break;\n" % (e.name, o, n)
             n += 1
@@ -210,20 +201,22 @@ def ocaml_Val(ty, o, c, indent="", paren
         
         n = 0
         for f in ty.fields:
+            (nparent,fexpr) = ty.member(c, f, parent is None)
+
             s += "\n"
-            s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c)
+            s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, ty.pass_arg(fexpr, c), parent=nparent)
             s += "\tStore_field(%s, %d, %s);\n" % (o, n, "%s_field" % ty.rawname)
             n = n + 1
         s += "}"
     else:
-        s += "%s = Val_%s(gc, lg, %s);" % (o, ty.rawname, makeref + c)
+        s += "%s = Val_%s(gc, lg, %s);" % (o, ty.rawname, ty.pass_arg(c, parent is None))
     
     return s.replace("\n", "\n%s" % indent).rstrip(indent)
 
 def gen_Val_ocaml(ty, indent=""):
     s = "/* Convert %s to a caml value */\n" % ty.rawname
 
-    s += "static value Val_%s (caml_gc *gc, struct caml_logger *lg, %s *%s_c)\n" % (ty.rawname, ty.typename, ty.rawname)
+    s += "static value Val_%s (caml_gc *gc, struct caml_logger *lg, %s)\n" % (ty.rawname, ty.make_arg(ty.rawname+"_c"))
     s += "{\n"
     s += "\tCAMLparam0();\n"
     s += "\tCAMLlocal1(%s_ocaml);\n" % ty.rawname

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 04 of 32 RFC] ocaml: Correct ocaml type name for Aggregate types
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (2 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 03 of 32 RFC] ocaml: use libxl IDL type helpers for C argument passing Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:49   ` [PATCH 04 of 32] " Ian Jackson
  2012-01-16 12:15 ` [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info Ian Campbell
                   ` (27 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326212349 0
# Node ID d5c8efa9ef9e55a08e06a6011681bdb827dd88c7
# Parent  07c4b8a8d50c8562472c8f6607ec145146c3828c
ocaml: Correct ocaml type name for Aggregate types.

No change to the generated code because this path isn't used yet.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 07c4b8a8d50c -r d5c8efa9ef9e tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py	Tue Jan 10 16:18:53 2012 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py	Tue Jan 10 16:19:09 2012 +0000
@@ -59,6 +59,8 @@ def ocaml_type_of(ty):
         if not typename:
             raise NotImplementedError("No typename for Builtin %s (%s)" % (ty.typename, type(ty)))
         return typename
+    elif isinstance(ty,libxltypes.Aggregate):
+        return ty.rawname.capitalize() + ".t"
     else:
         return ty.rawname

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (3 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 04 of 32 RFC] ocaml: Correct ocaml type name for Aggregate types Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:16   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server Ian Campbell
                   ` (26 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326212392 0
# Node ID ed7106b3f874d93e8ed8d05a8464099e611edd0b
# Parent  d5c8efa9ef9e55a08e06a6011681bdb827dd88c7
libxl: define libxl_vnc_info to hold all info about the vnc info

Reduces duplication in libxl_vfb and libxl_device_model.

Updated bindings but the python ones in particular are unlikely to be useful
until a user presents itself and fixes them up.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r d5c8efa9ef9e -r ed7106b3f874 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/libxl/libxl.c	Tue Jan 10 16:19:52 2012 +0000
@@ -1954,11 +1954,11 @@ int libxl_device_vfb_init(libxl_ctx *ctx
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
     vfb->display = NULL;
     vfb->xauthority = NULL;
-    vfb->vnc = 1;
-    vfb->vncpasswd = NULL;
-    vfb->vnclisten = strdup("127.0.0.1");
-    vfb->vncdisplay = 0;
-    vfb->vncunused = 1;
+    vfb->vnc.enable = 1;
+    vfb->vnc.passwd = NULL;
+    vfb->vnc.listen = strdup("127.0.0.1");
+    vfb->vnc.display = 0;
+    vfb->vnc.findunused = 1;
     vfb->keymap = NULL;
     vfb->sdl = 0;
     vfb->opengl = 0;
@@ -2004,11 +2004,14 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
     flexarray_append_pair(back, "online", "1");
     flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1));
     flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid));
-    flexarray_append_pair(back, "vnc", libxl__sprintf(gc, "%d", vfb->vnc));
-    flexarray_append_pair(back, "vnclisten", vfb->vnclisten);
-    flexarray_append_pair(back, "vncpasswd", vfb->vncpasswd);
-    flexarray_append_pair(back, "vncdisplay", libxl__sprintf(gc, "%d", vfb->vncdisplay));
-    flexarray_append_pair(back, "vncunused", libxl__sprintf(gc, "%d", vfb->vncunused));
+    flexarray_append_pair(back, "vnc",
+                          libxl__sprintf(gc, "%d", vfb->vnc.enable));
+    flexarray_append_pair(back, "vnclisten", vfb->vnc.listen);
+    flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd);
+    flexarray_append_pair(back, "vncdisplay",
+                          libxl__sprintf(gc, "%d", vfb->vnc.display));
+    flexarray_append_pair(back, "vncunused",
+                          libxl__sprintf(gc, "%d", vfb->vnc.findunused));
     flexarray_append_pair(back, "sdl", libxl__sprintf(gc, "%d", vfb->sdl));
     flexarray_append_pair(back, "opengl", libxl__sprintf(gc, "%d", vfb->opengl));
     if (vfb->xauthority) {
diff -r d5c8efa9ef9e -r ed7106b3f874 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/libxl/libxl_create.c	Tue Jan 10 16:19:52 2012 +0000
@@ -132,10 +132,10 @@ int libxl_init_dm_info(libxl_ctx *ctx,
     dm_info->vcpu_avail = b_info->cur_vcpus;
 
     dm_info->stdvga = 0;
-    dm_info->vnc = 1;
-    dm_info->vnclisten = strdup("127.0.0.1");
-    dm_info->vncdisplay = 0;
-    dm_info->vncunused = 1;
+    dm_info->vnc.enable = 1;
+    dm_info->vnc.listen = strdup("127.0.0.1");
+    dm_info->vnc.display = 0;
+    dm_info->vnc.findunused = 1;
     dm_info->keymap = NULL;
     dm_info->sdl = 0;
     dm_info->opengl = 0;
diff -r d5c8efa9ef9e -r ed7106b3f874 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Tue Jan 10 16:19:52 2012 +0000
@@ -100,31 +100,31 @@ static char ** libxl__build_device_model
     if (info->dom_name)
         flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL);
 
-    if (info->vnc) {
+    if (info->vnc.enable) {
         char *vncarg;
-        if (info->vncdisplay) {
-            if (info->vnclisten && strchr(info->vnclisten, ':') == NULL) {
+        if (info->vnc.display) {
+            if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) {
                 vncarg = libxl__sprintf(gc, "%s:%d",
-                                  info->vnclisten,
-                                  info->vncdisplay);
+                                  info->vnc.listen,
+                                  info->vnc.display);
             } else {
-                vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vncdisplay);
+                vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vnc.display);
             }
-        } else if (info->vnclisten) {
-            if (strchr(info->vnclisten, ':') != NULL) {
-                vncarg = info->vnclisten;
+        } else if (info->vnc.listen) {
+            if (strchr(info->vnc.listen, ':') != NULL) {
+                vncarg = info->vnc.listen;
             } else {
-                vncarg = libxl__sprintf(gc, "%s:0", info->vnclisten);
+                vncarg = libxl__sprintf(gc, "%s:0", info->vnc.listen);
             }
         } else {
             vncarg = "127.0.0.1:0";
         }
-        if (info->vncpasswd && (info->vncpasswd[0] != '\0'))
+        if (info->vnc.passwd && (info->vnc.passwd[0] != '\0'))
             vncarg = libxl__sprintf(gc, "%s,password", vncarg);
         flexarray_append(dm_args, "-vnc");
         flexarray_append(dm_args, vncarg);
 
-        if (info->vncunused) {
+        if (info->vnc.findunused) {
             flexarray_append(dm_args, "-vncunused");
         }
     }
@@ -137,7 +137,7 @@ static char ** libxl__build_device_model
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl && !info->vnc)) {
+    if (info->nographic && (!info->sdl && !info->vnc.enable)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -268,32 +268,32 @@ static char ** libxl__build_device_model
     if (info->dom_name) {
         flexarray_vappend(dm_args, "-name", info->dom_name, NULL);
     }
-    if (info->vnc) {
+    if (info->vnc.enable) {
         int display = 0;
         const char *listen = "127.0.0.1";
 
-        if (info->vncpasswd && info->vncpasswd[0]) {
+        if (info->vnc.passwd && info->vnc.passwd[0]) {
             assert(!"missing code for supplying vnc password to qemu");
         }
         flexarray_append(dm_args, "-vnc");
 
-        if (info->vncdisplay) {
-            display = info->vncdisplay;
-            if (info->vnclisten && strchr(info->vnclisten, ':') == NULL) {
-                listen = info->vnclisten;
+        if (info->vnc.display) {
+            display = info->vnc.display;
+            if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) {
+                listen = info->vnc.listen;
             }
-        } else if (info->vnclisten) {
-            listen = info->vnclisten;
+        } else if (info->vnc.listen) {
+            listen = info->vnc.listen;
         }
 
         if (strchr(listen, ':') != NULL)
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s%s", listen,
-                        info->vncunused ? ",to=99" : ""));
+                        info->vnc.findunused ? ",to=99" : ""));
         else
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s:%d%s", listen, display,
-                        info->vncunused ? ",to=99" : ""));
+                        info->vnc.findunused ? ",to=99" : ""));
     }
     if (info->sdl) {
         flexarray_append(dm_args, "-sdl");
@@ -343,7 +343,7 @@ static char ** libxl__build_device_model
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl && !info->vnc)) {
+    if (info->nographic && (!info->sdl && !info->vnc.enable)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -532,10 +532,6 @@ static int libxl__vfb_and_vkb_from_devic
     vfb->backend_domid = 0;
     vfb->devid = 0;
     vfb->vnc = info->vnc;
-    vfb->vnclisten = info->vnclisten;
-    vfb->vncdisplay = info->vncdisplay;
-    vfb->vncunused = info->vncunused;
-    vfb->vncpasswd = info->vncpasswd;
     vfb->keymap = info->keymap;
     vfb->sdl = info->sdl;
     vfb->opengl = info->opengl;
@@ -861,7 +857,7 @@ int libxl__create_device_model(libxl__gc
         goto out_close;
     }
 
-    if (info->vncpasswd) {
+    if (info->vnc.passwd) {
 retry_transaction:
         /* Find uuid and the write the vnc password to xenstore for qemu. */
         t = xs_transaction_start(ctx->xsh);
@@ -870,7 +866,7 @@ retry_transaction:
             /* Now write the vncpassword into it. */
             pass_stuff = libxl__calloc(gc, 3, sizeof(char *));
             pass_stuff[0] = "vncpasswd";
-            pass_stuff[1] = info->vncpasswd;
+            pass_stuff[1] = info->vnc.passwd;
             libxl__xs_writev(gc,t,vm_path,pass_stuff);
             if (!xs_transaction_end(ctx->xsh, t, 0))
                 if (errno == EAGAIN)
@@ -985,13 +981,13 @@ static int libxl__build_xenpv_qemu_args(
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
     if (vfb != NULL) {
-        info->vnc = vfb->vnc;
-        if (vfb->vnclisten)
-            info->vnclisten = libxl__strdup(gc, vfb->vnclisten);
-        info->vncdisplay = vfb->vncdisplay;
-        info->vncunused = vfb->vncunused;
-        if (vfb->vncpasswd)
-            info->vncpasswd = vfb->vncpasswd;
+        info->vnc.enable = vfb->vnc.enable;
+        if (vfb->vnc.listen)
+            info->vnc.listen = libxl__strdup(gc, vfb->vnc.listen);
+        info->vnc.display = vfb->vnc.display;
+        info->vnc.findunused = vfb->vnc.findunused;
+        if (vfb->vnc.passwd)
+            info->vnc.passwd = vfb->vnc.passwd;
         if (vfb->keymap)
             info->keymap = libxl__strdup(gc, vfb->keymap);
         info->sdl = vfb->sdl;
diff -r d5c8efa9ef9e -r ed7106b3f874 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Tue Jan 10 16:19:52 2012 +0000
@@ -95,6 +95,16 @@ libxl_tsc_mode = Enumeration("tsc_mode",
 #
 # Complex libxl types
 #
+libxl_vnc_info = Struct("vnc_info", [
+    ("enable",        bool),
+    # "address:port" that should be listened on
+    ("listen",        string),
+    ("passwd",        string),
+    ("display",       integer),
+    # If set then try to find an unused port
+    ("findunused",    bool),
+    ])
+
 libxl_dominfo = Struct("dominfo",[
     ("uuid",        libxl_uuid),
     ("domid",       libxl_domid),
@@ -222,14 +232,7 @@ libxl_device_model_info = Struct("device
     # size of the videoram in MB
     ("videoram",         integer), 
     ("stdvga",           bool),
-    ("vnc",              bool),
-    # "address:port" that should be listened on for the VNC server
-    ("vnclisten",        string),
-    ("vncpasswd",        string),
-    # VNC display number
-    ("vncdisplay",       integer),
-    # If set then try to find an unused port for the VNC server
-    ("vncunused",        bool),
+    ("vnc",              libxl_vnc_info),
     # keyboard layout, default is en-us keyboard
     ("keymap",           string),
     ("sdl",              bool),
@@ -268,12 +271,7 @@ libxl_device_model_info = Struct("device
 libxl_device_vfb = Struct("device_vfb", [
     ("backend_domid", libxl_domid),
     ("devid",         integer),
-    ("vnc",           bool),
-    # address:port that should be listened on for the VNC server if vnc is set
-    ("vnclisten",     string),
-    ("vncpasswd",     string),
-    ("vncdisplay",    integer),
-    ("vncunused",     bool),
+    ("vnc",           libxl_vnc_info),
     # set keyboard layout, default is en-us keyboard
     ("keymap",        string),
     ("sdl",           bool),
diff -r d5c8efa9ef9e -r ed7106b3f874 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Tue Jan 10 16:19:52 2012 +0000
@@ -364,10 +364,10 @@ static void printf_info(int domid,
         printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default");
         printf("\t\t\t(videoram %d)\n", dm_info->videoram);
         printf("\t\t\t(stdvga %d)\n", dm_info->stdvga);
-        printf("\t\t\t(vnc %d)\n", dm_info->vnc);
-        printf("\t\t\t(vnclisten %s)\n", dm_info->vnclisten);
-        printf("\t\t\t(vncdisplay %d)\n", dm_info->vncdisplay);
-        printf("\t\t\t(vncunused %d)\n", dm_info->vncunused);
+        printf("\t\t\t(vnc %d)\n", dm_info->vnc.enable);
+        printf("\t\t\t(vnclisten %s)\n", dm_info->vnc.listen);
+        printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display);
+        printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused);
         printf("\t\t\t(keymap %s)\n", dm_info->keymap);
         printf("\t\t\t(sdl %d)\n", dm_info->sdl);
         printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru);
@@ -454,10 +454,10 @@ static void printf_info(int domid,
         printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid);
         printf("\t\t\t(frontend_domid %d)\n", domid);
         printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid);
-        printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc);
-        printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnclisten);
-        printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vncdisplay);
-        printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vncunused);
+        printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable);
+        printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen);
+        printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display);
+        printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused);
         printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap);
         printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl);
         printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].opengl);
@@ -961,17 +961,17 @@ skip:
                     break;
                 *p2 = '\0';
                 if (!strcmp(p, "vnc")) {
-                    vfb->vnc = atoi(p2 + 1);
+                    vfb->vnc.enable = atoi(p2 + 1);
                 } else if (!strcmp(p, "vnclisten")) {
-                    free(vfb->vnclisten);
-                    vfb->vnclisten = strdup(p2 + 1);
+                    free(vfb->vnc.listen);
+                    vfb->vnc.listen = strdup(p2 + 1);
                 } else if (!strcmp(p, "vncpasswd")) {
-                    free(vfb->vncpasswd);
-                    vfb->vncpasswd = strdup(p2 + 1);
+                    free(vfb->vnc.passwd);
+                    vfb->vnc.passwd = strdup(p2 + 1);
                 } else if (!strcmp(p, "vncdisplay")) {
-                    vfb->vncdisplay = atoi(p2 + 1);
+                    vfb->vnc.display = atoi(p2 + 1);
                 } else if (!strcmp(p, "vncunused")) {
-                    vfb->vncunused = atoi(p2 + 1);
+                    vfb->vnc.findunused = atoi(p2 + 1);
                 } else if (!strcmp(p, "keymap")) {
                     free(vfb->keymap);
                     vfb->keymap = strdup(p2 + 1);
@@ -1178,13 +1178,13 @@ skip_vfb:
         if (!xlu_cfg_get_long (config, "stdvga", &l, 0))
             dm_info->stdvga = l;
         if (!xlu_cfg_get_long (config, "vnc", &l, 0))
-            dm_info->vnc = l;
-        xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnclisten, 0);
-        xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vncpasswd, 0);
+            dm_info->vnc.enable = l;
+        xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0);
+        xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0);
         if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
-            dm_info->vncdisplay = l;
+            dm_info->vnc.display = l;
         if (!xlu_cfg_get_long (config, "vncunused", &l, 0))
-            dm_info->vncunused = l;
+            dm_info->vnc.findunused = l;
         xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0);
         if (!xlu_cfg_get_long (config, "sdl", &l, 0))
             dm_info->sdl = l;
diff -r d5c8efa9ef9e -r ed7106b3f874 tools/python/genwrap.py
--- a/tools/python/genwrap.py	Tue Jan 10 16:19:09 2012 +0000
+++ b/tools/python/genwrap.py	Tue Jan 10 16:19:52 2012 +0000
@@ -4,7 +4,7 @@ import sys,os
 
 import libxltypes
 
-(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING) = range(4)
+(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5)
 
 def py_type(ty):
     if ty == libxltypes.bool:
@@ -16,6 +16,8 @@ def py_type(ty):
             return TYPE_INT
         else:
             return TYPE_UINT
+    if isinstance(ty, libxltypes.Aggregate):
+        return TYPE_AGGREGATE
     if ty == libxltypes.string:
         return TYPE_STRING
     return None
@@ -66,6 +68,9 @@ def py_attrib_get(ty, f):
         l.append('    return genwrap__ull_get(self->obj.%s);'%f.name)
     elif t == TYPE_STRING:
         l.append('    return genwrap__string_get(&self->obj.%s);'%f.name)
+    elif t == TYPE_AGGREGATE:
+        l.append('    PyErr_SetString(PyExc_NotImplementedError, "Getting %s");'%ty.typename)
+        l.append('    return NULL;')
     else:
         tn = f.type.typename
         l.append('    return attrib__%s_get((%s *)&self->obj.%s);'%(fsanitize(tn), tn, f.name))
@@ -92,6 +97,9 @@ def py_attrib_set(ty, f):
         l.append('    return ret;')
     elif t == TYPE_STRING:
         l.append('    return genwrap__string_set(v, &self->obj.%s);'%f.name)
+    elif t == TYPE_AGGREGATE:
+        l.append('    PyErr_SetString(PyExc_NotImplementedError, "Setting %s");'%ty.typename)
+        l.append('    return -1;')
     else:
         tn = f.type.typename
         l.append('    return attrib__%s_set(v, (%s *)&self->obj.%s);'%(fsanitize(tn), tn, f.name))

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (4 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:04   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config Ian Campbell
                   ` (25 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326215019 0
# Node ID 3308d2dfd9dddb36f8a65e7a44916c6bcf02170e
# Parent  ed7106b3f874d93e8ed8d05a8464099e611edd0b
libxl: define libxl_spice_info to hold all info about the spice server

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r ed7106b3f874 -r 3308d2dfd9dd tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Tue Jan 10 16:19:52 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Tue Jan 10 17:03:39 2012 +0000
@@ -298,39 +298,39 @@ static char ** libxl__build_device_model
     if (info->sdl) {
         flexarray_append(dm_args, "-sdl");
     }
-    if (info->spice) {
+    if (info->spice.enable) {
         char *spiceoptions = NULL;
-        if (!info->spiceport && !info->spicetls_port) {
+        if (!info->spice.port && !info->spice.tls_port) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                 "at least one of the spiceport or tls_port must be provided");
             return NULL;
         }
 
-        if (!info->spicedisable_ticketing) {
-            if (!info->spicepasswd) {
+        if (!info->spice.disable_ticketing) {
+            if (!info->spice.passwd) {
                 LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                     "spice ticketing is enabled but missing password");
                 return NULL;
             }
-            else if (!info->spicepasswd[0]) {
+            else if (!info->spice.passwd[0]) {
                 LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                     "spice password can't be empty");
                 return NULL;
             }
         }
         spiceoptions = libxl__sprintf(gc, "port=%d,tls-port=%d",
-                       info->spiceport, info->spicetls_port);
-        if (info->spicehost)
+                                      info->spice.port, info->spice.tls_port);
+        if (info->spice.host)
             spiceoptions = libxl__sprintf(gc,
-                    "%s,addr=%s", spiceoptions, info->spicehost);
-        if (info->spicedisable_ticketing)
+                    "%s,addr=%s", spiceoptions, info->spice.host);
+        if (info->spice.disable_ticketing)
             spiceoptions = libxl__sprintf(gc, "%s,disable-ticketing",
                                                spiceoptions);
         else
             spiceoptions = libxl__sprintf(gc,
-                    "%s,password=%s", spiceoptions, info->spicepasswd);
+                    "%s,password=%s", spiceoptions, info->spice.passwd);
         spiceoptions = libxl__sprintf(gc, "%s,agent-mouse=%s", spiceoptions,
-                                      info->spiceagent_mouse ? "on" : "off");
+                                      info->spice.agent_mouse ? "on" : "off");
 
         flexarray_append(dm_args, "-spice");
         flexarray_append(dm_args, spiceoptions);
diff -r ed7106b3f874 -r 3308d2dfd9dd tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Tue Jan 10 16:19:52 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Tue Jan 10 17:03:39 2012 +0000
@@ -105,6 +105,26 @@ libxl_vnc_info = Struct("vnc_info", [
     ("findunused",    bool),
     ])
 
+libxl_spice_info = Struct("spice_info", [
+    ("enable",            bool),
+    # At least one of spice port or spicetls_post must be given
+    ("port",        integer),
+    ("tls_port",    integer),
+    # Interface to bind to
+    ("host",        string),
+    # enable client connection with no password
+    ("disable_ticketing", bool),
+    ("passwd",      string),
+    ("agent_mouse", bool),
+    ])
+
+libxl_sdl_info = Struct("sdl_info", [
+    ("enable",        bool),
+    ("opengl",        bool),
+    ("display",       string),
+    ("xauthority",    string),
+    ])
+
 libxl_dominfo = Struct("dominfo",[
     ("uuid",        libxl_uuid),
     ("domid",       libxl_domid),
@@ -237,16 +257,7 @@ libxl_device_model_info = Struct("device
     ("keymap",           string),
     ("sdl",              bool),
     ("opengl",           bool), # (requires sdl enabled)
-    ("spice",            bool),
-    # At least one of spice port or spicetls_post must be given
-    ("spiceport",        integer),
-    ("spicetls_port",    integer),
-    # Interface to bind to
-    ("spicehost",        string),
-    # enable client connection with no password
-    ("spicedisable_ticketing", bool),
-    ("spicepasswd",      string),
-    ("spiceagent_mouse", bool),
+    ("spice",            libxl_spice_info),
     ("nographic",        bool),
     ("gfx_passthru",     bool),
     ("serial",           string),
diff -r ed7106b3f874 -r 3308d2dfd9dd tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue Jan 10 16:19:52 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Tue Jan 10 17:03:39 2012 +0000
@@ -378,13 +378,13 @@ static void printf_info(int domid,
         printf("\t\t\t(usb %d)\n", dm_info->usb);
         printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice);
         printf("\t\t\t(acpi %d)\n", dm_info->acpi);
-        printf("\t\t\t(spice %d)\n", dm_info->spice);
-        printf("\t\t\t(spiceport %d)\n", dm_info->spiceport);
-        printf("\t\t\t(spicetls_port %d)\n", dm_info->spicetls_port);
-        printf("\t\t\t(spicehost %s)\n", dm_info->spicehost);
+        printf("\t\t\t(spice %d)\n", dm_info->spice.enable);
+        printf("\t\t\t(spiceport %d)\n", dm_info->spice.port);
+        printf("\t\t\t(spicetls_port %d)\n", dm_info->spice.tls_port);
+        printf("\t\t\t(spicehost %s)\n", dm_info->spice.host);
         printf("\t\t\t(spicedisable_ticketing %d)\n",
-                    dm_info->spicedisable_ticketing);
-        printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spiceagent_mouse);
+                    dm_info->spice.disable_ticketing);
+        printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spice.agent_mouse);
         printf("\t\t)\n");
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -1191,19 +1191,20 @@ skip_vfb:
         if (!xlu_cfg_get_long (config, "opengl", &l, 0))
             dm_info->opengl = l;
         if (!xlu_cfg_get_long (config, "spice", &l, 0))
-            dm_info->spice = l;
+            dm_info->spice.enable = l;
         if (!xlu_cfg_get_long (config, "spiceport", &l, 0))
-            dm_info->spiceport = l;
+            dm_info->spice.port = l;
         if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0))
-            dm_info->spicetls_port = l;
-        xlu_cfg_replace_string (config, "spicehost", &dm_info->spicehost, 0);
+            dm_info->spice.tls_port = l;
+        xlu_cfg_replace_string (config, "spicehost", &dm_info->spice.host, 0);
         if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0))
-            dm_info->spicedisable_ticketing = l;
-        xlu_cfg_replace_string (config, "spicepasswd", &dm_info->spicepasswd, 0);
+            dm_info->spice.disable_ticketing = l;
+        xlu_cfg_replace_string (config, "spicepasswd",
+                                &dm_info->spice.passwd, 0);
         if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0))
-            dm_info->spiceagent_mouse = l;
+            dm_info->spice.agent_mouse = l;
         else
-            dm_info->spiceagent_mouse = 1;
+            dm_info->spice.agent_mouse = 1;
         if (!xlu_cfg_get_long (config, "nographic", &l, 0))
             dm_info->nographic = l;
         if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (5 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:10   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation Ian Campbell
                   ` (24 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326296553 0
# Node ID 2cf31bf780380c42d859bb0b8f7c701cbf424180
# Parent  3308d2dfd9dddb36f8a65e7a44916c6bcf02170e
libxl: define libxl_sdl_info to hold all info about the SDL config

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 3308d2dfd9dd -r 2cf31bf78038 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Tue Jan 10 17:03:39 2012 +0000
+++ b/tools/libxl/libxl.c	Wed Jan 11 15:42:33 2012 +0000
@@ -1952,16 +1952,16 @@ out:
 int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb)
 {
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
-    vfb->display = NULL;
-    vfb->xauthority = NULL;
     vfb->vnc.enable = 1;
     vfb->vnc.passwd = NULL;
     vfb->vnc.listen = strdup("127.0.0.1");
     vfb->vnc.display = 0;
     vfb->vnc.findunused = 1;
     vfb->keymap = NULL;
-    vfb->sdl = 0;
-    vfb->opengl = 0;
+    vfb->sdl.enable = 0;
+    vfb->sdl.opengl = 0;
+    vfb->sdl.display = NULL;
+    vfb->sdl.xauthority = NULL;
     return 0;
 }
 
@@ -2012,16 +2012,19 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
                           libxl__sprintf(gc, "%d", vfb->vnc.display));
     flexarray_append_pair(back, "vncunused",
                           libxl__sprintf(gc, "%d", vfb->vnc.findunused));
-    flexarray_append_pair(back, "sdl", libxl__sprintf(gc, "%d", vfb->sdl));
-    flexarray_append_pair(back, "opengl", libxl__sprintf(gc, "%d", vfb->opengl));
-    if (vfb->xauthority) {
-        flexarray_append_pair(back, "xauthority", vfb->xauthority);
+    flexarray_append_pair(back, "sdl",
+                          libxl__sprintf(gc, "%d", vfb->sdl.enable));
+    flexarray_append_pair(back, "opengl",
+                          libxl__sprintf(gc, "%d", vfb->sdl.opengl));
+    if (vfb->sdl.xauthority) {
+        flexarray_append_pair(back, "xauthority", vfb->sdl.xauthority);
     }
-    if (vfb->display) {
-        flexarray_append_pair(back, "display", vfb->display);
+    if (vfb->sdl.display) {
+        flexarray_append_pair(back, "display", vfb->sdl.display);
     }
 
-    flexarray_append_pair(front, "backend-id", libxl__sprintf(gc, "%d", vfb->backend_domid));
+    flexarray_append_pair(front, "backend-id",
+                          libxl__sprintf(gc, "%d", vfb->backend_domid));
     flexarray_append_pair(front, "state", libxl__sprintf(gc, "%d", 1));
 
     libxl__device_generic_add(gc, &device,
diff -r 3308d2dfd9dd -r 2cf31bf78038 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Tue Jan 10 17:03:39 2012 +0000
+++ b/tools/libxl/libxl_create.c	Wed Jan 11 15:42:33 2012 +0000
@@ -137,8 +137,8 @@ int libxl_init_dm_info(libxl_ctx *ctx,
     dm_info->vnc.display = 0;
     dm_info->vnc.findunused = 1;
     dm_info->keymap = NULL;
-    dm_info->sdl = 0;
-    dm_info->opengl = 0;
+    dm_info->sdl.enable = 0;
+    dm_info->sdl.opengl = 0;
     dm_info->nographic = 0;
     dm_info->serial = NULL;
     dm_info->boot = strdup("cda");
diff -r 3308d2dfd9dd -r 2cf31bf78038 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Tue Jan 10 17:03:39 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Wed Jan 11 15:42:33 2012 +0000
@@ -128,16 +128,17 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, "-vncunused");
         }
     }
-    if (info->sdl) {
+    if (info->sdl.enable) {
         flexarray_append(dm_args, "-sdl");
-        if (!info->opengl) {
+        if (!info->sdl.opengl) {
             flexarray_append(dm_args, "-disable-opengl");
         }
+        /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl && !info->vnc.enable)) {
+    if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -295,8 +296,9 @@ static char ** libxl__build_device_model
                     libxl__sprintf(gc, "%s:%d%s", listen, display,
                         info->vnc.findunused ? ",to=99" : ""));
     }
-    if (info->sdl) {
+    if (info->sdl.enable) {
         flexarray_append(dm_args, "-sdl");
+        /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
     if (info->spice.enable) {
         char *spiceoptions = NULL;
@@ -343,7 +345,7 @@ static char ** libxl__build_device_model
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl && !info->vnc.enable)) {
+    if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -534,7 +536,6 @@ static int libxl__vfb_and_vkb_from_devic
     vfb->vnc = info->vnc;
     vfb->keymap = info->keymap;
     vfb->sdl = info->sdl;
-    vfb->opengl = info->opengl;
 
     vkb->backend_domid = 0;
     vkb->devid = 0;
@@ -991,7 +992,6 @@ static int libxl__build_xenpv_qemu_args(
         if (vfb->keymap)
             info->keymap = libxl__strdup(gc, vfb->keymap);
         info->sdl = vfb->sdl;
-        info->opengl = vfb->opengl;
     } else
         info->nographic = 1;
     info->domid = domid;
diff -r 3308d2dfd9dd -r 2cf31bf78038 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Tue Jan 10 17:03:39 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Wed Jan 11 15:42:33 2012 +0000
@@ -255,8 +255,7 @@ libxl_device_model_info = Struct("device
     ("vnc",              libxl_vnc_info),
     # keyboard layout, default is en-us keyboard
     ("keymap",           string),
-    ("sdl",              bool),
-    ("opengl",           bool), # (requires sdl enabled)
+    ("sdl",              libxl_sdl_info),
     ("spice",            libxl_spice_info),
     ("nographic",        bool),
     ("gfx_passthru",     bool),
@@ -283,12 +282,9 @@ libxl_device_vfb = Struct("device_vfb", 
     ("backend_domid", libxl_domid),
     ("devid",         integer),
     ("vnc",           libxl_vnc_info),
+    ("sdl",           libxl_sdl_info),
     # set keyboard layout, default is en-us keyboard
     ("keymap",        string),
-    ("sdl",           bool),
-    ("opengl",        bool), # (if enabled requires sdl enabled)
-    ("display",       string),
-    ("xauthority",    string),
     ])
 
 libxl_device_vkb = Struct("device_vkb", [
diff -r 3308d2dfd9dd -r 2cf31bf78038 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue Jan 10 17:03:39 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Wed Jan 11 15:42:33 2012 +0000
@@ -369,9 +369,9 @@ static void printf_info(int domid,
         printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display);
         printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused);
         printf("\t\t\t(keymap %s)\n", dm_info->keymap);
-        printf("\t\t\t(sdl %d)\n", dm_info->sdl);
+        printf("\t\t\t(sdl %d)\n", dm_info->sdl.enable);
         printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru);
-        printf("\t\t\t(opengl %d)\n", dm_info->opengl);
+        printf("\t\t\t(opengl %d)\n", dm_info->sdl.opengl);
         printf("\t\t\t(nographic %d)\n", dm_info->nographic);
         printf("\t\t\t(serial %s)\n", dm_info->serial);
         printf("\t\t\t(boot %s)\n", dm_info->boot);
@@ -459,10 +459,10 @@ static void printf_info(int domid,
         printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display);
         printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused);
         printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap);
-        printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl);
-        printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].opengl);
-        printf("\t\t\t(display %s)\n", d_config->vfbs[i].display);
-        printf("\t\t\t(xauthority %s)\n", d_config->vfbs[i].xauthority);
+        printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl.enable);
+        printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].sdl.opengl);
+        printf("\t\t\t(display %s)\n", d_config->vfbs[i].sdl.display);
+        printf("\t\t\t(xauthority %s)\n", d_config->vfbs[i].sdl.xauthority);
         printf("\t\t)\n");
         printf("\t)\n");
     }
@@ -976,15 +976,15 @@ skip:
                     free(vfb->keymap);
                     vfb->keymap = strdup(p2 + 1);
                 } else if (!strcmp(p, "sdl")) {
-                    vfb->sdl = atoi(p2 + 1);
+                    vfb->sdl.enable = atoi(p2 + 1);
                 } else if (!strcmp(p, "opengl")) {
-                    vfb->opengl = atoi(p2 + 1);
+                    vfb->sdl.opengl = atoi(p2 + 1);
                 } else if (!strcmp(p, "display")) {
-                    free(vfb->display);
-                    vfb->display = strdup(p2 + 1);
+                    free(vfb->sdl.display);
+                    vfb->sdl.display = strdup(p2 + 1);
                 } else if (!strcmp(p, "xauthority")) {
-                    free(vfb->xauthority);
-                    vfb->xauthority = strdup(p2 + 1);
+                    free(vfb->sdl.xauthority);
+                    vfb->sdl.xauthority = strdup(p2 + 1);
                 }
             } while ((p = strtok(NULL, ",")) != NULL);
 skip_vfb:
@@ -1187,9 +1187,9 @@ skip_vfb:
             dm_info->vnc.findunused = l;
         xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0);
         if (!xlu_cfg_get_long (config, "sdl", &l, 0))
-            dm_info->sdl = l;
+            dm_info->sdl.enable = l;
         if (!xlu_cfg_get_long (config, "opengl", &l, 0))
-            dm_info->opengl = l;
+            dm_info->sdl.opengl = l;
         if (!xlu_cfg_get_long (config, "spice", &l, 0))
             dm_info->spice.enable = l;
         if (!xlu_cfg_get_long (config, "spiceport", &l, 0))

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (6 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:21   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 09 of 32 RFC] libxl: now that dm creation takes domain_config stop passing down devices Ian Campbell
                   ` (23 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326296799 0
# Node ID 14605ae17bd9d8a3e2a5111ae6f06ffda0ddc441
# Parent  2cf31bf780380c42d859bb0b8f7c701cbf424180
libxl: plumb libxl_domain_config down into device model creation.

Creating the device model derives lots of bits from the guest configuration.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Wed Jan 11 15:42:33 2012 +0000
+++ b/tools/libxl/libxl_create.c	Wed Jan 11 15:46:39 2012 +0000
@@ -558,7 +558,7 @@ static int do_domain_create(libxl__gc *g
         libxl_device_vkb_dispose(&vkb);
 
         dm_info->domid = domid;
-        ret = libxl__create_device_model(gc, dm_info,
+        ret = libxl__create_device_model(gc, d_config, dm_info,
                                         d_config->disks, d_config->num_disks,
                                         d_config->vifs, d_config->num_vifs,
                                         &dm_starting);
@@ -605,7 +605,8 @@ static int do_domain_create(libxl__gc *g
             xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv;
             xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm;
 
-            libxl__create_xenpv_qemu(gc, domid, &xenpv_dm_info,
+            libxl__create_xenpv_qemu(gc, domid,
+                                     d_config, &xenpv_dm_info,
                                      d_config->vfbs, &dm_starting);
         }
         break;
diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Wed Jan 11 15:42:33 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Wed Jan 11 15:46:39 2012 +0000
@@ -82,10 +82,11 @@ static const char *libxl__domain_bios(li
 }
 
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
-                                                  const char *dm,
-                                                  libxl_device_model_info *info,
-                                                  libxl_device_disk *disks, int num_disks,
-                                                  libxl_device_nic *vifs, int num_vifs)
+                                        const char *dm,
+                                        const libxl_domain_config *guest_config,
+                                        const libxl_device_model_info *info,
+                                        const libxl_device_disk *disks, int num_disks,
+                                        const libxl_device_nic *vifs, int num_vifs)
 {
     int i;
     flexarray_t *dm_args;
@@ -236,10 +237,11 @@ static const char *qemu_disk_format_stri
 }
 
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
-                                                  const char *dm,
-                                                  libxl_device_model_info *info,
-                                                  libxl_device_disk *disks, int num_disks,
-                                                  libxl_device_nic *vifs, int num_vifs)
+                                        const char *dm,
+                                        const libxl_domain_config *guest_config,
+                                        const libxl_device_model_info *info,
+                                        const libxl_device_disk *disks, int num_disks,
+                                        const libxl_device_nic *vifs, int num_vifs)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     flexarray_t *dm_args;
@@ -500,20 +502,21 @@ static char ** libxl__build_device_model
 }
 
 static char ** libxl__build_device_model_args(libxl__gc *gc,
-                                              const char *dm,
-                                              libxl_device_model_info *info,
-                                              libxl_device_disk *disks, int num_disks,
-                                              libxl_device_nic *vifs, int num_vifs)
+                                        const char *dm,
+                                        const libxl_domain_config *guest_config,
+                                        const libxl_device_model_info *info,
+                                        const libxl_device_disk *disks, int num_disks,
+                                        const libxl_device_nic *vifs, int num_vifs)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
     switch (info->device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-        return libxl__build_device_model_args_old(gc, dm, info,
+        return libxl__build_device_model_args_old(gc, dm, guest_config, info,
                                                   disks, num_disks,
                                                   vifs, num_vifs);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        return libxl__build_device_model_args_new(gc, dm, info,
+        return libxl__build_device_model_args_new(gc, dm, guest_config, info,
                                                   disks, num_disks,
                                                   vifs, num_vifs);
     default:
@@ -524,9 +527,9 @@ static char ** libxl__build_device_model
 }
 
 static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc,
-                                                     libxl_device_model_info *info,
-                                                     libxl_device_vfb *vfb,
-                                                     libxl_device_vkb *vkb)
+                                        const libxl_device_model_info *info,
+                                        libxl_device_vfb *vfb,
+                                        libxl_device_vkb *vkb)
 {
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
     memset(vkb, 0x00, sizeof(libxl_device_vkb));
@@ -591,6 +594,7 @@ retry_transaction:
 }
 
 static int libxl__create_stubdom(libxl__gc *gc,
+                                 libxl_domain_config *guest_config,
                                  libxl_device_model_info *info,
                                  libxl_device_disk *disks, int num_disks,
                                  libxl_device_nic *vifs, int num_vifs,
@@ -601,8 +605,7 @@ static int libxl__create_stubdom(libxl__
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret;
     libxl_device_console *console;
-    libxl_domain_create_info c_info;
-    libxl_domain_build_info b_info;
+    libxl_domain_config dm_config;
     libxl__domain_build_state state;
     uint32_t domid;
     char **args;
@@ -616,7 +619,35 @@ static int libxl__create_stubdom(libxl__
         goto out;
     }
 
-    args = libxl__build_device_model_args(gc, "stubdom-dm", info,
+    memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
+    dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
+    dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid));
+
+    libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid);
+
+    memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info));
+    dm_config.b_info.max_vcpus = 1;
+    dm_config.b_info.max_memkb = 32 * 1024;
+    dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
+
+    dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV;
+    dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
+                                              libxl_xenfirmwaredir_path());
+    dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid);
+    dm_config.b_info.u.pv.ramdisk.path = "";
+    dm_config.b_info.u.pv.features = "";
+
+    /* fixme: this function can leak the stubdom if it fails */
+    domid = 0;
+    ret = libxl__domain_make(gc, &dm_config.c_info, &domid);
+    if (ret)
+        goto out;
+    ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &state);
+    if (ret)
+        goto out;
+
+    args = libxl__build_device_model_args(gc, "stubdom-dm",
+                                          guest_config, info,
                                           disks, num_disks,
                                           vifs, num_vifs);
     if (!args) {
@@ -624,33 +655,6 @@ static int libxl__create_stubdom(libxl__
         goto out;
     }
 
-    memset(&c_info, 0x00, sizeof(libxl_domain_create_info));
-    c_info.type = LIBXL_DOMAIN_TYPE_PV;
-    c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid));
-
-    libxl_uuid_copy(&c_info.uuid, &info->uuid);
-
-    memset(&b_info, 0x00, sizeof(libxl_domain_build_info));
-    b_info.max_vcpus = 1;
-    b_info.max_memkb = 32 * 1024;
-    b_info.target_memkb = b_info.max_memkb;
-
-    b_info.type = LIBXL_DOMAIN_TYPE_PV;
-    b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
-                                              libxl_xenfirmwaredir_path());
-    b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid);
-    b_info.u.pv.ramdisk.path = "";
-    b_info.u.pv.features = "";
-
-    /* fixme: this function can leak the stubdom if it fails */
-    domid = 0;
-    ret = libxl__domain_make(gc, &c_info, &domid);
-    if (ret)
-        goto out_free;
-    ret = libxl__domain_build(gc, &b_info, info, domid, &state);
-    if (ret)
-        goto out_free;
-
     libxl__write_dmargs(gc, domid, info->domid, args);
     libxl__xs_write(gc, XBT_NULL,
                    libxl__sprintf(gc, "%s/image/device-model-domid", libxl__xs_get_dompath(gc, info->domid)),
@@ -749,6 +753,7 @@ retry_transaction:
     xenpv_dm_info.extra_hvm = info->extra_hvm;
 
     if (libxl__create_xenpv_qemu(gc, domid,
+                                 &dm_config,
                                  &xenpv_dm_info,
                                  vfb, &dm_starting) < 0) {
         ret = ERROR_FAIL;
@@ -778,6 +783,7 @@ out:
 }
 
 int libxl__create_device_model(libxl__gc *gc,
+                              libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
                               libxl_device_disk *disks, int num_disks,
                               libxl_device_nic *vifs, int num_vifs,
@@ -799,7 +805,7 @@ int libxl__create_device_model(libxl__gc
         libxl_device_vkb vkb;
 
         libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb);
-        rc = libxl__create_stubdom(gc, info,
+        rc = libxl__create_stubdom(gc, guest_config, info,
                                    disks, num_disks,
                                    vifs, num_vifs,
                                    &vfb, &vkb, starting_r);
@@ -817,7 +823,8 @@ int libxl__create_device_model(libxl__gc
         rc = ERROR_FAIL;
         goto out;
     }
-    args = libxl__build_device_model_args(gc, dm, info, disks, num_disks,
+    args = libxl__build_device_model_args(gc, dm, guest_config, info,
+                                          disks, num_disks,
                                           vifs, num_vifs);
     if (!args) {
         rc = ERROR_FAIL;
@@ -1037,12 +1044,13 @@ out:
 }
 
 int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
+                             libxl_domain_config *guest_config,
                              libxl_device_model_info *info,
                              libxl_device_vfb *vfb,
                              libxl__spawner_starting **starting_r)
 {
     libxl__build_xenpv_qemu_args(gc, domid, vfb, info);
-    libxl__create_device_model(gc, info, NULL, 0, NULL, 0, starting_r);
+    libxl__create_device_model(gc, guest_config, info, NULL, 0, NULL, 0, starting_r);
     return 0;
 }
 
diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Wed Jan 11 15:42:33 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Wed Jan 11 15:46:39 2012 +0000
@@ -465,11 +465,13 @@ _hidden int libxl__domain_build(libxl__g
 _hidden const char *libxl__domain_device_model(libxl__gc *gc,
                                                libxl_device_model_info *info);
 _hidden int libxl__create_device_model(libxl__gc *gc,
+                              libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
-                              libxl_device_disk *disk, int num_disks,
+                              libxl_device_disk *disks, int num_disks,
                               libxl_device_nic *vifs, int num_vifs,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
+                              libxl_domain_config *guest_config,
                               libxl_device_model_info *dm_info,
                               libxl_device_vfb *vfb,
                               libxl__spawner_starting **starting_r);
diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_uuid.c
--- a/tools/libxl/libxl_uuid.c	Wed Jan 11 15:42:33 2012 +0000
+++ b/tools/libxl/libxl_uuid.c	Wed Jan 11 15:46:39 2012 +0000
@@ -35,7 +35,7 @@ int libxl_uuid_from_string(libxl_uuid *u
      return uuid_parse(in, uuid->uuid);
 }
 
-void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src)
+void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src)
 {
      uuid_copy(dst->uuid, src->uuid);
 }
@@ -82,7 +82,7 @@ int libxl_uuid_from_string(libxl_uuid *u
 }
 #undef LIBXL__UUID_PTRS
 
-void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src)
+void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src)
 {
      memcpy(dst->uuid, src->uuid, sizeof(dst->uuid));
 }
diff -r 2cf31bf78038 -r 14605ae17bd9 tools/libxl/libxl_uuid.h
--- a/tools/libxl/libxl_uuid.h	Wed Jan 11 15:42:33 2012 +0000
+++ b/tools/libxl/libxl_uuid.h	Wed Jan 11 15:46:39 2012 +0000
@@ -56,7 +56,7 @@ typedef struct {
 int libxl_uuid_is_nil(libxl_uuid *uuid);
 void libxl_uuid_generate(libxl_uuid *uuid);
 int libxl_uuid_from_string(libxl_uuid *uuid, const char *in);
-void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src);
+void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src);
 void libxl_uuid_clear(libxl_uuid *uuid);
 int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2);
 uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 09 of 32 RFC] libxl: now that dm creation takes domain_config stop passing down devices
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (7 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 12:15 ` [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info Ian Campbell
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326303938 0
# Node ID 9f9995e2e34967929053c8c75e7c86562b58acf9
# Parent  14605ae17bd9d8a3e2a5111ae6f06ffda0ddc441
libxl: now that dm creation takes domain_config stop passing down devices.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 14605ae17bd9 -r 9f9995e2e349 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Wed Jan 11 15:46:39 2012 +0000
+++ b/tools/libxl/libxl_create.c	Wed Jan 11 17:45:38 2012 +0000
@@ -559,8 +559,6 @@ static int do_domain_create(libxl__gc *g
 
         dm_info->domid = domid;
         ret = libxl__create_device_model(gc, d_config, dm_info,
-                                        d_config->disks, d_config->num_disks,
-                                        d_config->vifs, d_config->num_vifs,
                                         &dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
@@ -606,8 +604,7 @@ static int do_domain_create(libxl__gc *g
             xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm;
 
             libxl__create_xenpv_qemu(gc, domid,
-                                     d_config, &xenpv_dm_info,
-                                     d_config->vfbs, &dm_starting);
+                                     d_config, &xenpv_dm_info, &dm_starting);
         }
         break;
     }
diff -r 14605ae17bd9 -r 9f9995e2e349 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Wed Jan 11 15:46:39 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Wed Jan 11 17:45:38 2012 +0000
@@ -84,10 +84,10 @@ static const char *libxl__domain_bios(li
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
-                                        const libxl_device_disk *disks, int num_disks,
-                                        const libxl_device_nic *vifs, int num_vifs)
+                                        const libxl_device_model_info *info)
 {
+    const libxl_device_nic *vifs = guest_config->vifs;
+    const int num_vifs = guest_config->num_vifs;
     int i;
     flexarray_t *dm_args;
     dm_args = flexarray_make(16, 1);
@@ -239,11 +239,13 @@ static const char *qemu_disk_format_stri
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
-                                        const libxl_device_disk *disks, int num_disks,
-                                        const libxl_device_nic *vifs, int num_vifs)
+                                        const libxl_device_model_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
+    const libxl_device_disk *disks = guest_config->disks;
+    const libxl_device_nic *vifs = guest_config->vifs;
+    const int num_disks = guest_config->num_disks;
+    const int num_vifs = guest_config->num_vifs;
     flexarray_t *dm_args;
     int i;
 
@@ -504,21 +506,15 @@ static char ** libxl__build_device_model
 static char ** libxl__build_device_model_args(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
-                                        const libxl_device_disk *disks, int num_disks,
-                                        const libxl_device_nic *vifs, int num_vifs)
+                                        const libxl_device_model_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
     switch (info->device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-        return libxl__build_device_model_args_old(gc, dm, guest_config, info,
-                                                  disks, num_disks,
-                                                  vifs, num_vifs);
+        return libxl__build_device_model_args_old(gc, dm, guest_config, info);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        return libxl__build_device_model_args_new(gc, dm, guest_config, info,
-                                                  disks, num_disks,
-                                                  vifs, num_vifs);
+        return libxl__build_device_model_args_new(gc, dm, guest_config, info);
     default:
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d",
                          info->device_model_version);
@@ -596,16 +592,14 @@ retry_transaction:
 static int libxl__create_stubdom(libxl__gc *gc,
                                  libxl_domain_config *guest_config,
                                  libxl_device_model_info *info,
-                                 libxl_device_disk *disks, int num_disks,
-                                 libxl_device_nic *vifs, int num_vifs,
-                                 libxl_device_vfb *vfb,
-                                 libxl_device_vkb *vkb,
                                  libxl__spawner_starting **starting_r)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret;
     libxl_device_console *console;
     libxl_domain_config dm_config;
+    libxl_device_vfb vfb;
+    libxl_device_vkb vkb;
     libxl__domain_build_state state;
     uint32_t domid;
     char **args;
@@ -637,6 +631,19 @@ static int libxl__create_stubdom(libxl__
     dm_config.b_info.u.pv.ramdisk.path = "";
     dm_config.b_info.u.pv.features = "";
 
+    dm_config.disks = guest_config->disks;
+    dm_config.num_disks = guest_config->num_disks;
+
+    dm_config.vifs = guest_config->vifs;
+    dm_config.num_vifs = guest_config->num_vifs;
+
+    libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb);
+
+    dm_config.vfbs = &vfb;
+    dm_config.num_vfbs = 1;
+    dm_config.vkbs = &vkb;
+    dm_config.num_vkbs = 1;
+
     /* fixme: this function can leak the stubdom if it fails */
     domid = 0;
     ret = libxl__domain_make(gc, &dm_config.c_info, &domid);
@@ -647,9 +654,7 @@ static int libxl__create_stubdom(libxl__
         goto out;
 
     args = libxl__build_device_model_args(gc, "stubdom-dm",
-                                          guest_config, info,
-                                          disks, num_disks,
-                                          vifs, num_vifs);
+                                          guest_config, info);
     if (!args) {
         ret = ERROR_FAIL;
         goto out;
@@ -684,20 +689,20 @@ retry_transaction:
         if (errno == EAGAIN)
             goto retry_transaction;
 
-    for (i = 0; i < num_disks; i++) {
-        ret = libxl_device_disk_add(ctx, domid, &disks[i]);
+    for (i = 0; i < dm_config.num_disks; i++) {
+        ret = libxl_device_disk_add(ctx, domid, &dm_config.disks[i]);
         if (ret)
             goto out_free;
     }
-    for (i = 0; i < num_vifs; i++) {
-        ret = libxl_device_nic_add(ctx, domid, &vifs[i]);
+    for (i = 0; i < dm_config.num_vifs; i++) {
+        ret = libxl_device_nic_add(ctx, domid, &dm_config.vifs[i]);
         if (ret)
             goto out_free;
     }
-    ret = libxl_device_vfb_add(ctx, domid, vfb);
+    ret = libxl_device_vfb_add(ctx, domid, &dm_config.vfbs[0]);
     if (ret)
         goto out_free;
-    ret = libxl_device_vkb_add(ctx, domid, vkb);
+    ret = libxl_device_vkb_add(ctx, domid, &dm_config.vkbs[0]);
     if (ret)
         goto out_free;
 
@@ -755,7 +760,7 @@ retry_transaction:
     if (libxl__create_xenpv_qemu(gc, domid,
                                  &dm_config,
                                  &xenpv_dm_info,
-                                 vfb, &dm_starting) < 0) {
+                                 &dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;
     }
@@ -785,8 +790,6 @@ out:
 int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
-                              libxl_device_disk *disks, int num_disks,
-                              libxl_device_nic *vifs, int num_vifs,
                               libxl__spawner_starting **starting_r)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -801,14 +804,7 @@ int libxl__create_device_model(libxl__gc
     const char *dm;
 
     if (info->device_model_stubdomain) {
-        libxl_device_vfb vfb;
-        libxl_device_vkb vkb;
-
-        libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb);
-        rc = libxl__create_stubdom(gc, guest_config, info,
-                                   disks, num_disks,
-                                   vifs, num_vifs,
-                                   &vfb, &vkb, starting_r);
+        rc = libxl__create_stubdom(gc, guest_config, info, starting_r);
         goto out;
     }
 
@@ -823,9 +819,7 @@ int libxl__create_device_model(libxl__gc
         rc = ERROR_FAIL;
         goto out;
     }
-    args = libxl__build_device_model_args(gc, dm, guest_config, info,
-                                          disks, num_disks,
-                                          vifs, num_vifs);
+    args = libxl__build_device_model_args(gc, dm, guest_config, info);
     if (!args) {
         rc = ERROR_FAIL;
         goto out;
@@ -1046,11 +1040,10 @@ out:
 int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                              libxl_domain_config *guest_config,
                              libxl_device_model_info *info,
-                             libxl_device_vfb *vfb,
                              libxl__spawner_starting **starting_r)
 {
-    libxl__build_xenpv_qemu_args(gc, domid, vfb, info);
-    libxl__create_device_model(gc, guest_config, info, NULL, 0, NULL, 0, starting_r);
+    libxl__build_xenpv_qemu_args(gc, domid, &guest_config->vfbs[0], info);
+    libxl__create_device_model(gc, guest_config, info, starting_r);
     return 0;
 }
 
diff -r 14605ae17bd9 -r 9f9995e2e349 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Wed Jan 11 15:46:39 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Wed Jan 11 17:45:38 2012 +0000
@@ -467,13 +467,10 @@ _hidden const char *libxl__domain_device
 _hidden int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
-                              libxl_device_disk *disks, int num_disks,
-                              libxl_device_nic *vifs, int num_vifs,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *dm_info,
-                              libxl_device_vfb *vfb,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
         int nr_consoles, libxl_device_console *consoles,

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (8 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 09 of 32 RFC] libxl: now that dm creation takes domain_config stop passing down devices Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:22   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name Ian Campbell
                   ` (21 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326304221 0
# Node ID a27ac2ae9cefc42e3eee504cb2805824fd80d3f8
# Parent  9f9995e2e34967929053c8c75e7c86562b58acf9
libxl: remove redundant info from dm info.

Remove "target_ram", "acpi", "vcpus" and "vcpu_avail" from device model info
and use domain_build_info instead. These must all be consistently specified to
both the domain and the device model, there is no need (and a great deal of
danger) in exposing a way for a user of libxl to set them differently.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 9f9995e2e349 -r a27ac2ae9cef tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Wed Jan 11 17:45:38 2012 +0000
+++ b/tools/libxl/libxl_create.c	Wed Jan 11 17:50:21 2012 +0000
@@ -125,11 +125,7 @@ int libxl_init_dm_info(libxl_ctx *ctx,
     dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
     dm_info->device_model_stubdomain = false;
     dm_info->device_model = NULL;
-    dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb);
     dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb);
-    dm_info->acpi = b_info->u.hvm.acpi;
-    dm_info->vcpus = b_info->max_vcpus;
-    dm_info->vcpu_avail = b_info->cur_vcpus;
 
     dm_info->stdvga = 0;
     dm_info->vnc.enable = 1;
diff -r 9f9995e2e349 -r a27ac2ae9cef tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Wed Jan 11 17:45:38 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Wed Jan 11 17:50:21 2012 +0000
@@ -86,6 +86,7 @@ static char ** libxl__build_device_model
                                         const libxl_domain_config *guest_config,
                                         const libxl_device_model_info *info)
 {
+    const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_nic *vifs = guest_config->vifs;
     const int num_vifs = guest_config->num_vifs;
     int i;
@@ -167,14 +168,18 @@ static char ** libxl__build_device_model
         if (info->soundhw) {
             flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL);
         }
-        if (info->acpi) {
+        if (b_info->u.hvm.acpi) {
             flexarray_append(dm_args, "-acpi");
         }
-        if (info->vcpus > 1) {
-            flexarray_vappend(dm_args, "-vcpus", libxl__sprintf(gc, "%d", info->vcpus), NULL);
+        if (b_info->max_vcpus > 1) {
+            flexarray_vappend(dm_args, "-vcpus",
+                              libxl__sprintf(gc, "%d", b_info->max_vcpus),
+                              NULL);
         }
-        if (info->vcpu_avail) {
-            flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL);
+        if (b_info->cur_vcpus) {
+            flexarray_vappend(dm_args, "-vcpu_avail",
+                              libxl__sprintf(gc, "0x%x", b_info->cur_vcpus),
+                              NULL);
         }
         for (i = 0; i < num_vifs; i++) {
             if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
@@ -242,6 +247,7 @@ static char ** libxl__build_device_model
                                         const libxl_device_model_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
+    const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_disk *disks = guest_config->disks;
     const libxl_device_nic *vifs = guest_config->vifs;
     const int num_disks = guest_config->num_disks;
@@ -374,15 +380,18 @@ static char ** libxl__build_device_model
         if (info->soundhw) {
             flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL);
         }
-        if (!info->acpi) {
+        if (!b_info->u.hvm.acpi) {
             flexarray_append(dm_args, "-no-acpi");
         }
-        if (info->vcpus > 1) {
+        if (b_info->max_vcpus > 1) {
             flexarray_append(dm_args, "-smp");
-            if (info->vcpu_avail)
-                flexarray_append(dm_args, libxl__sprintf(gc, "%d,maxcpus=%d", info->vcpus, info->vcpu_avail));
+            if (b_info->cur_vcpus)
+                flexarray_append(dm_args, libxl__sprintf(gc, "%d,maxcpus=%d",
+                                                         b_info->max_vcpus,
+                                                         b_info->cur_vcpus));
             else
-                flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus));
+                flexarray_append(dm_args, libxl__sprintf(gc, "%d",
+                                                         b_info->max_vcpus));
         }
         for (i = 0; i < num_vifs; i++) {
             if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
@@ -440,7 +449,9 @@ static char ** libxl__build_device_model
 
     /* RAM Size */
     flexarray_append(dm_args, "-m");
-    flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram));
+    flexarray_append(dm_args,
+                     libxl__sprintf(gc, "%d",
+                                    libxl__sizekb_to_mb(b_info->target_memkb)));
 
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         for (i = 0; i < num_disks; i++) {
diff -r 9f9995e2e349 -r a27ac2ae9cef tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Wed Jan 11 17:45:38 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Wed Jan 11 17:50:21 2012 +0000
@@ -248,7 +248,6 @@ libxl_device_model_info = Struct("device
     ("device_model",     string),
     ("saved_state",      string),
     ("type",             libxl_domain_type),
-    ("target_ram",       uint32),
     # size of the videoram in MB
     ("videoram",         integer), 
     ("stdvga",           bool),
@@ -265,9 +264,6 @@ libxl_device_model_info = Struct("device
     # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse
     ("usbdevice",        string),
     ("soundhw",          string),
-    ("acpi",             bool),
-    ("vcpus",            integer), # max number of vcpus
-    ("vcpu_avail",       integer), # vcpus actually available
     ("xen_platform_pci", bool),
     # extra parameters pass directly to qemu, NULL terminated
     ("extra",            libxl_string_list),
diff -r 9f9995e2e349 -r a27ac2ae9cef tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Wed Jan 11 17:45:38 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Wed Jan 11 17:50:21 2012 +0000
@@ -377,7 +377,6 @@ static void printf_info(int domid,
         printf("\t\t\t(boot %s)\n", dm_info->boot);
         printf("\t\t\t(usb %d)\n", dm_info->usb);
         printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice);
-        printf("\t\t\t(acpi %d)\n", dm_info->acpi);
         printf("\t\t\t(spice %d)\n", dm_info->spice.enable);
         printf("\t\t\t(spiceport %d)\n", dm_info->spice.port);
         printf("\t\t\t(spicetls_port %d)\n", dm_info->spice.tls_port);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (9 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:14   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model Ian Campbell
                   ` (20 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326304712 0
# Node ID 3db40f3e8b2af814b9f79b514de82c3751c213f8
# Parent  a27ac2ae9cefc42e3eee504cb2805824fd80d3f8
libxl: drop dm_info.dom_name

This is always the same as the c_info name which we now have available.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r a27ac2ae9cef -r 3db40f3e8b2a tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Wed Jan 11 17:50:21 2012 +0000
+++ b/tools/libxl/libxl_create.c	Wed Jan 11 17:58:32 2012 +0000
@@ -121,7 +121,6 @@ int libxl_init_dm_info(libxl_ctx *ctx,
 
     libxl_uuid_generate(&dm_info->uuid);
 
-    dm_info->dom_name = strdup(c_info->name);
     dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
     dm_info->device_model_stubdomain = false;
     dm_info->device_model = NULL;
diff -r a27ac2ae9cef -r 3db40f3e8b2a tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Wed Jan 11 17:50:21 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Wed Jan 11 17:58:32 2012 +0000
@@ -86,6 +86,7 @@ static char ** libxl__build_device_model
                                         const libxl_domain_config *guest_config,
                                         const libxl_device_model_info *info)
 {
+    const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_nic *vifs = guest_config->vifs;
     const int num_vifs = guest_config->num_vifs;
@@ -99,8 +100,8 @@ static char ** libxl__build_device_model
     flexarray_vappend(dm_args, dm,
                       "-d", libxl__sprintf(gc, "%d", info->domid), NULL);
 
-    if (info->dom_name)
-        flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL);
+    if (c_info->name)
+        flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL);
 
     if (info->vnc.enable) {
         char *vncarg;
@@ -247,6 +248,7 @@ static char ** libxl__build_device_model
                                         const libxl_device_model_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
+    const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_disk *disks = guest_config->disks;
     const libxl_device_nic *vifs = guest_config->vifs;
@@ -276,8 +278,8 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-xen-attach");
     }
 
-    if (info->dom_name) {
-        flexarray_vappend(dm_args, "-name", info->dom_name, NULL);
+    if (c_info->name) {
+        flexarray_vappend(dm_args, "-name", c_info->name, NULL);
     }
     if (info->vnc.enable) {
         int display = 0;
@@ -803,6 +805,7 @@ int libxl__create_device_model(libxl__gc
                               libxl_device_model_info *info,
                               libxl__spawner_starting **starting_r)
 {
+    const libxl_domain_create_info *c_info = &guest_config->c_info;
     libxl_ctx *ctx = libxl__gc_owner(gc);
     char *path, *logfile;
     int logfile_w, null;
@@ -845,7 +848,9 @@ int libxl__create_device_model(libxl__gc
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci);
 
-    libxl_create_logfile(ctx, libxl__sprintf(gc, "qemu-dm-%s", info->dom_name), &logfile);
+    libxl_create_logfile(ctx,
+                         libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
+                         &logfile);
     logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
     free(logfile);
     null = open("/dev/null", O_RDONLY);
@@ -991,8 +996,6 @@ static int libxl__build_xenpv_qemu_args(
                                         libxl_device_vfb *vfb,
                                         libxl_device_model_info *info)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
-
     if (vfb != NULL) {
         info->vnc.enable = vfb->vnc.enable;
         if (vfb->vnc.listen)
@@ -1007,7 +1010,6 @@ static int libxl__build_xenpv_qemu_args(
     } else
         info->nographic = 1;
     info->domid = domid;
-    info->dom_name = libxl_domid_to_name(ctx, domid);
     return 0;
 }
 
diff -r a27ac2ae9cef -r 3db40f3e8b2a tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Wed Jan 11 17:50:21 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Wed Jan 11 17:58:32 2012 +0000
@@ -241,7 +241,6 @@ libxl_device_model_info = Struct("device
     # uuid is used only with stubdom, and must be different from the
     # domain uuid
     ("uuid",             libxl_uuid),
-    ("dom_name",         string),
     ("device_model_version", libxl_device_model_version),
     ("device_model_stubdomain", bool),
     # you set device_model you must set device_model_version too

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (10 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:13   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm Ian Campbell
                   ` (19 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326363959 0
# Node ID 714cb45a8327bae6ede162f12e21cc8e0397ae1f
# Parent  3db40f3e8b2af814b9f79b514de82c3751c213f8
libxl: use vfb[0] directly for xenpv device model

Rather than laundering it via dm info.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 3db40f3e8b2a -r 714cb45a8327 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Wed Jan 11 17:58:32 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 10:25:59 2012 +0000
@@ -81,6 +81,30 @@ static const char *libxl__domain_bios(li
     }
 }
 
+static const libxl_vnc_info *dm_vnc(const libxl_domain_config *guest_config,
+                                    const libxl_device_model_info *info)
+{
+    const libxl_vnc_info *vnc = NULL;
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        vnc = &info->vnc;
+    } else if (guest_config->num_vfbs > 0) {
+        vnc = &guest_config->vfbs[0].vnc;
+    }
+    return vnc && vnc->enable ? vnc : NULL;
+}
+
+static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config,
+                                    const libxl_device_model_info *info)
+{
+    const libxl_sdl_info *sdl = NULL;
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        sdl = &info->sdl;
+    } else if (guest_config->num_vfbs > 0) {
+        sdl = &guest_config->vfbs[0].sdl;
+    }
+    return sdl && sdl->enable ? sdl : NULL;
+}
+
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
@@ -89,6 +113,8 @@ static char ** libxl__build_device_model
     const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_nic *vifs = guest_config->vifs;
+    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
+    const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
     const int num_vifs = guest_config->num_vifs;
     int i;
     flexarray_t *dm_args;
@@ -103,45 +129,45 @@ static char ** libxl__build_device_model
     if (c_info->name)
         flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL);
 
-    if (info->vnc.enable) {
+    if (vnc) {
         char *vncarg;
-        if (info->vnc.display) {
-            if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) {
+        if (vnc->display) {
+            if (vnc->listen && strchr(vnc->listen, ':') == NULL) {
                 vncarg = libxl__sprintf(gc, "%s:%d",
-                                  info->vnc.listen,
-                                  info->vnc.display);
+                                  vnc->listen,
+                                  vnc->display);
             } else {
-                vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vnc.display);
+                vncarg = libxl__sprintf(gc, "127.0.0.1:%d", vnc->display);
             }
-        } else if (info->vnc.listen) {
-            if (strchr(info->vnc.listen, ':') != NULL) {
-                vncarg = info->vnc.listen;
+        } else if (vnc->listen) {
+            if (strchr(vnc->listen, ':') != NULL) {
+                vncarg = vnc->listen;
             } else {
-                vncarg = libxl__sprintf(gc, "%s:0", info->vnc.listen);
+                vncarg = libxl__sprintf(gc, "%s:0", vnc->listen);
             }
         } else {
             vncarg = "127.0.0.1:0";
         }
-        if (info->vnc.passwd && (info->vnc.passwd[0] != '\0'))
+        if (vnc->passwd && (vnc->passwd[0] != '\0'))
             vncarg = libxl__sprintf(gc, "%s,password", vncarg);
         flexarray_append(dm_args, "-vnc");
         flexarray_append(dm_args, vncarg);
 
-        if (info->vnc.findunused) {
+        if (vnc->findunused) {
             flexarray_append(dm_args, "-vncunused");
         }
     }
-    if (info->sdl.enable) {
+    if (sdl) {
         flexarray_append(dm_args, "-sdl");
-        if (!info->sdl.opengl) {
+        if (!sdl->opengl) {
             flexarray_append(dm_args, "-disable-opengl");
         }
-        /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */
+        /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) {
+    if (info->nographic && (!sdl && !vnc)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -254,6 +280,8 @@ static char ** libxl__build_device_model
     const libxl_device_nic *vifs = guest_config->vifs;
     const int num_disks = guest_config->num_disks;
     const int num_vifs = guest_config->num_vifs;
+    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
+    const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
     flexarray_t *dm_args;
     int i;
 
@@ -281,36 +309,36 @@ static char ** libxl__build_device_model
     if (c_info->name) {
         flexarray_vappend(dm_args, "-name", c_info->name, NULL);
     }
-    if (info->vnc.enable) {
+    if (vnc) {
         int display = 0;
         const char *listen = "127.0.0.1";
 
-        if (info->vnc.passwd && info->vnc.passwd[0]) {
+        if (vnc->passwd && vnc->passwd[0]) {
             assert(!"missing code for supplying vnc password to qemu");
         }
         flexarray_append(dm_args, "-vnc");
 
-        if (info->vnc.display) {
-            display = info->vnc.display;
-            if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) {
-                listen = info->vnc.listen;
+        if (vnc->display) {
+            display = vnc->display;
+            if (vnc->listen && strchr(vnc->listen, ':') == NULL) {
+                listen = vnc->listen;
             }
-        } else if (info->vnc.listen) {
-            listen = info->vnc.listen;
+        } else if (vnc->listen) {
+            listen = vnc->listen;
         }
 
         if (strchr(listen, ':') != NULL)
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s%s", listen,
-                        info->vnc.findunused ? ",to=99" : ""));
+                        vnc->findunused ? ",to=99" : ""));
         else
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s:%d%s", listen, display,
-                        info->vnc.findunused ? ",to=99" : ""));
+                        vnc->findunused ? ",to=99" : ""));
     }
-    if (info->sdl.enable) {
+    if (sdl) {
         flexarray_append(dm_args, "-sdl");
-        /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */
+        /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
     if (info->spice.enable) {
         char *spiceoptions = NULL;
@@ -357,7 +385,7 @@ static char ** libxl__build_device_model
     if (info->keymap) {
         flexarray_vappend(dm_args, "-k", info->keymap, NULL);
     }
-    if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) {
+    if (info->nographic && (!sdl && !vnc)) {
         flexarray_append(dm_args, "-nographic");
     }
     if (info->serial) {
@@ -805,8 +833,9 @@ int libxl__create_device_model(libxl__gc
                               libxl_device_model_info *info,
                               libxl__spawner_starting **starting_r)
 {
+    libxl_ctx *ctx = libxl__gc_owner(gc);
     const libxl_domain_create_info *c_info = &guest_config->c_info;
-    libxl_ctx *ctx = libxl__gc_owner(gc);
+    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
     char *path, *logfile;
     int logfile_w, null;
     int rc;
@@ -875,7 +904,7 @@ int libxl__create_device_model(libxl__gc
         goto out_close;
     }
 
-    if (info->vnc.passwd) {
+    if (vnc && vnc->passwd) {
 retry_transaction:
         /* Find uuid and the write the vnc password to xenstore for qemu. */
         t = xs_transaction_start(ctx->xsh);
@@ -884,7 +913,7 @@ retry_transaction:
             /* Now write the vncpassword into it. */
             pass_stuff = libxl__calloc(gc, 3, sizeof(char *));
             pass_stuff[0] = "vncpasswd";
-            pass_stuff[1] = info->vnc.passwd;
+            pass_stuff[1] = vnc->passwd;
             libxl__xs_writev(gc,t,vm_path,pass_stuff);
             if (!xs_transaction_end(ctx->xsh, t, 0))
                 if (errno == EAGAIN)
@@ -993,22 +1022,8 @@ out:
 
 static int libxl__build_xenpv_qemu_args(libxl__gc *gc,
                                         uint32_t domid,
-                                        libxl_device_vfb *vfb,
                                         libxl_device_model_info *info)
 {
-    if (vfb != NULL) {
-        info->vnc.enable = vfb->vnc.enable;
-        if (vfb->vnc.listen)
-            info->vnc.listen = libxl__strdup(gc, vfb->vnc.listen);
-        info->vnc.display = vfb->vnc.display;
-        info->vnc.findunused = vfb->vnc.findunused;
-        if (vfb->vnc.passwd)
-            info->vnc.passwd = vfb->vnc.passwd;
-        if (vfb->keymap)
-            info->keymap = libxl__strdup(gc, vfb->keymap);
-        info->sdl = vfb->sdl;
-    } else
-        info->nographic = 1;
     info->domid = domid;
     return 0;
 }
@@ -1055,7 +1070,7 @@ int libxl__create_xenpv_qemu(libxl__gc *
                              libxl_device_model_info *info,
                              libxl__spawner_starting **starting_r)
 {
-    libxl__build_xenpv_qemu_args(gc, domid, &guest_config->vfbs[0], info);
+    libxl__build_xenpv_qemu_args(gc, domid, info);
     libxl__create_device_model(gc, guest_config, info, starting_r);
     return 0;
 }

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (11 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:27   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm Ian Campbell
                   ` (18 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326367192 0
# Node ID 0ef52f0b6c58344ee371d668ea343628aaecb714
# Parent  714cb45a8327bae6ede162f12e21cc8e0397ae1f
libxl: move HVM emulated GFX support into b_info->u.hvm

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 10:25:59 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 11:19:52 2012 +0000
@@ -99,6 +99,16 @@ int libxl_init_build_info(libxl_ctx *ctx
         b_info->u.hvm.vpt_align = 1;
         b_info->u.hvm.timer_mode = 1;
         b_info->u.hvm.nested_hvm = 0;
+
+        b_info->u.hvm.stdvga = 0;
+        b_info->u.hvm.vnc.enable = 1;
+        b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
+        b_info->u.hvm.vnc.display = 0;
+        b_info->u.hvm.vnc.findunused = 1;
+        b_info->u.hvm.keymap = NULL;
+        b_info->u.hvm.sdl.enable = 0;
+        b_info->u.hvm.sdl.opengl = 0;
+        b_info->u.hvm.nographic = 0;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         b_info->u.pv.slack_memkb = 8 * 1024;
@@ -124,17 +134,7 @@ int libxl_init_dm_info(libxl_ctx *ctx,
     dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
     dm_info->device_model_stubdomain = false;
     dm_info->device_model = NULL;
-    dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb);
 
-    dm_info->stdvga = 0;
-    dm_info->vnc.enable = 1;
-    dm_info->vnc.listen = strdup("127.0.0.1");
-    dm_info->vnc.display = 0;
-    dm_info->vnc.findunused = 1;
-    dm_info->keymap = NULL;
-    dm_info->sdl.enable = 0;
-    dm_info->sdl.opengl = 0;
-    dm_info->nographic = 0;
     dm_info->serial = NULL;
     dm_info->boot = strdup("cda");
     dm_info->usb = 0;
diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 10:25:59 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 11:19:52 2012 +0000
@@ -86,7 +86,7 @@ static const libxl_vnc_info *dm_vnc(cons
 {
     const libxl_vnc_info *vnc = NULL;
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
-        vnc = &info->vnc;
+        vnc = &guest_config->b_info.u.hvm.vnc;
     } else if (guest_config->num_vfbs > 0) {
         vnc = &guest_config->vfbs[0].vnc;
     }
@@ -98,13 +98,24 @@ static const libxl_sdl_info *dm_sdl(cons
 {
     const libxl_sdl_info *sdl = NULL;
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
-        sdl = &info->sdl;
+        sdl = &guest_config->b_info.u.hvm.sdl;
     } else if (guest_config->num_vfbs > 0) {
         sdl = &guest_config->vfbs[0].sdl;
     }
     return sdl && sdl->enable ? sdl : NULL;
 }
 
+static const char *dm_keymap(const libxl_domain_config *guest_config,
+                             const libxl_device_model_info *info)
+{
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        return guest_config->b_info.u.hvm.keymap;
+    } else if (guest_config->num_vfbs > 0) {
+        return guest_config->vfbs[0].keymap;
+    } else
+        return NULL;
+}
+
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
@@ -116,6 +127,7 @@ static char ** libxl__build_device_model
     const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
     const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
     const int num_vifs = guest_config->num_vifs;
+    const char *keymap = dm_keymap(guest_config, info);
     int i;
     flexarray_t *dm_args;
     dm_args = flexarray_make(16, 1);
@@ -164,11 +176,8 @@ static char ** libxl__build_device_model
         }
         /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
-    if (info->keymap) {
-        flexarray_vappend(dm_args, "-k", info->keymap, NULL);
-    }
-    if (info->nographic && (!sdl && !vnc)) {
-        flexarray_append(dm_args, "-nographic");
+    if (keymap) {
+        flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
     if (info->serial) {
         flexarray_vappend(dm_args, "-serial", info->serial, NULL);
@@ -176,10 +185,17 @@ static char ** libxl__build_device_model
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
-        if (info->videoram) {
-            flexarray_vappend(dm_args, "-videoram", libxl__sprintf(gc, "%d", info->videoram), NULL);
+        if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+            flexarray_append(dm_args, "-nographic");
         }
-        if (info->stdvga) {
+
+        if (b_info->video_memkb) {
+            flexarray_vappend(dm_args, "-videoram",
+                    libxl__sprintf(gc, "%d",
+                                   libxl__sizekb_to_mb(b_info->video_memkb)),
+                    NULL);
+        }
+        if (b_info->u.hvm.stdvga) {
             flexarray_append(dm_args, "-std-vga");
         }
 
@@ -233,7 +249,11 @@ static char ** libxl__build_device_model
         if (info->gfx_passthru) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
+    } else {
+        if (!sdl && !vnc)
+            flexarray_append(dm_args, "-nographic");
     }
+
     if (info->saved_state) {
         flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL);
     }
@@ -268,6 +288,42 @@ static const char *qemu_disk_format_stri
     }
 }
 
+static char *dm_spice_options(libxl__gc *gc,
+                                    const libxl_spice_info *spice)
+{
+    char *opt;
+
+    if (!spice->port && !spice->tls_port) {
+        LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
+                   "at least one of the spiceport or tls_port must be provided");
+        return NULL;
+    }
+
+    if (!spice->disable_ticketing) {
+        if (!spice->passwd) {
+            LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
+                       "spice ticketing is enabled but missing password");
+            return NULL;
+        }
+        else if (!spice->passwd[0]) {
+            LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
+                               "spice password can't be empty");
+            return NULL;
+        }
+    }
+    opt = libxl__sprintf(gc, "port=%d,tls-port=%d",
+                         spice->port, spice->tls_port);
+    if (spice->host)
+        opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host);
+    if (spice->disable_ticketing)
+        opt = libxl__sprintf(gc, "%s,disable-ticketing", opt);
+    else
+        opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd);
+    opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt,
+                         spice->agent_mouse ? "on" : "off");
+    return opt;
+}
+
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
@@ -282,6 +338,7 @@ static char ** libxl__build_device_model
     const int num_vifs = guest_config->num_vifs;
     const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
     const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
+    const char *keymap = dm_keymap(guest_config, info);
     flexarray_t *dm_args;
     int i;
 
@@ -340,61 +397,36 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-sdl");
         /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
-    if (info->spice.enable) {
-        char *spiceoptions = NULL;
-        if (!info->spice.port && !info->spice.tls_port) {
-            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                "at least one of the spiceport or tls_port must be provided");
-            return NULL;
-        }
 
-        if (!info->spice.disable_ticketing) {
-            if (!info->spice.passwd) {
-                LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                    "spice ticketing is enabled but missing password");
-                return NULL;
-            }
-            else if (!info->spice.passwd[0]) {
-                LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                    "spice password can't be empty");
-                return NULL;
-            }
-        }
-        spiceoptions = libxl__sprintf(gc, "port=%d,tls-port=%d",
-                                      info->spice.port, info->spice.tls_port);
-        if (info->spice.host)
-            spiceoptions = libxl__sprintf(gc,
-                    "%s,addr=%s", spiceoptions, info->spice.host);
-        if (info->spice.disable_ticketing)
-            spiceoptions = libxl__sprintf(gc, "%s,disable-ticketing",
-                                               spiceoptions);
-        else
-            spiceoptions = libxl__sprintf(gc,
-                    "%s,password=%s", spiceoptions, info->spice.passwd);
-        spiceoptions = libxl__sprintf(gc, "%s,agent-mouse=%s", spiceoptions,
-                                      info->spice.agent_mouse ? "on" : "off");
+    /*if (info->type == LIBXL_DOMAIN_TYPE_PV && !b_info->nographic) {
+        flexarray_vappend(dm_args, "-vga", "xenfb", NULL);
+      } never was possible?*/
 
-        flexarray_append(dm_args, "-spice");
-        flexarray_append(dm_args, spiceoptions);
+    if (keymap) {
+        flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
 
-    if (info->type == LIBXL_DOMAIN_TYPE_PV && !info->nographic) {
-        flexarray_vappend(dm_args, "-vga", "xenfb", NULL);
-    }
-
-    if (info->keymap) {
-        flexarray_vappend(dm_args, "-k", info->keymap, NULL);
-    }
-    if (info->nographic && (!sdl && !vnc)) {
-        flexarray_append(dm_args, "-nographic");
-    }
     if (info->serial) {
         flexarray_vappend(dm_args, "-serial", info->serial, NULL);
     }
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
-        if (info->stdvga) {
+        if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+            flexarray_append(dm_args, "-nographic");
+        }
+
+        if (b_info->u.hvm.spice.enable) {
+            const libxl_spice_info *spice = &b_info->u.hvm.spice;
+            char *spiceoptions = dm_spice_options(gc, spice);
+            if (!spiceoptions)
+                return NULL;
+
+            flexarray_append(dm_args, "-spice");
+            flexarray_append(dm_args, spiceoptions);
+        }
+
+        if (b_info->u.hvm.stdvga) {
                 flexarray_vappend(dm_args, "-vga", "std", NULL);
         }
 
@@ -454,7 +486,12 @@ static char ** libxl__build_device_model
         if (info->gfx_passthru) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
+    } else {
+        if (!sdl && !vnc) {
+            flexarray_append(dm_args, "-nographic");
+        }
     }
+
     if (info->saved_state) {
         /* This file descriptor is meant to be used by QEMU */
         int migration_fd = open(info->saved_state, O_RDONLY);
@@ -563,19 +600,24 @@ static char ** libxl__build_device_model
     }
 }
 
-static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc,
-                                        const libxl_device_model_info *info,
+static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
+                                        const libxl_domain_config *guest_config,
                                         libxl_device_vfb *vfb,
                                         libxl_device_vkb *vkb)
 {
+    const libxl_domain_build_info *b_info = &guest_config->b_info;
+
+    if (b_info->type != LIBXL_DOMAIN_TYPE_HVM)
+        return ERROR_INVAL;
+
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
     memset(vkb, 0x00, sizeof(libxl_device_vkb));
 
     vfb->backend_domid = 0;
     vfb->devid = 0;
-    vfb->vnc = info->vnc;
-    vfb->keymap = info->keymap;
-    vfb->sdl = info->sdl;
+    vfb->vnc = b_info->u.hvm.vnc;
+    vfb->keymap = b_info->u.hvm.keymap;
+    vfb->sdl = b_info->u.hvm.sdl;
 
     vkb->backend_domid = 0;
     vkb->devid = 0;
@@ -678,8 +720,7 @@ static int libxl__create_stubdom(libxl__
     dm_config.vifs = guest_config->vifs;
     dm_config.num_vifs = guest_config->num_vifs;
 
-    libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb);
-
+    libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
     dm_config.vfbs = &vfb;
     dm_config.num_vfbs = 1;
     dm_config.vkbs = &vkb;
diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 10:25:59 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 11:19:52 2012 +0000
@@ -219,6 +219,13 @@ libxl_domain_build_info = Struct("domain
                                        ("vpt_align", bool),
                                        ("timer_mode", integer),
                                        ("nested_hvm", bool),
+                                       ("nographic",        bool),
+                                       ("stdvga",           bool),
+                                       ("vnc",              libxl_vnc_info),
+                                       # keyboard layout, default is en-us keyboard
+                                       ("keymap",           string),
+                                       ("sdl",              libxl_sdl_info),
+                                       ("spice",            libxl_spice_info),
                                        ])),
                  ("pv", Struct(None, [("kernel", libxl_file_reference),
                                       ("slack_memkb", uint32),
@@ -247,15 +254,6 @@ libxl_device_model_info = Struct("device
     ("device_model",     string),
     ("saved_state",      string),
     ("type",             libxl_domain_type),
-    # size of the videoram in MB
-    ("videoram",         integer), 
-    ("stdvga",           bool),
-    ("vnc",              libxl_vnc_info),
-    # keyboard layout, default is en-us keyboard
-    ("keymap",           string),
-    ("sdl",              libxl_sdl_info),
-    ("spice",            libxl_spice_info),
-    ("nographic",        bool),
     ("gfx_passthru",     bool),
     ("serial",           string),
     ("boot",             string),
diff -r 714cb45a8327 -r 0ef52f0b6c58 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 10:25:59 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:19:52 2012 +0000
@@ -361,29 +361,29 @@ static void printf_info(int domid,
         printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode);
         printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm);
 
+        printf("\t\t\t(stdvga %d)\n", b_info->u.hvm.stdvga);
+        printf("\t\t\t(vnc %d)\n", b_info->u.hvm.vnc.enable);
+        printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen);
+        printf("\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display);
+        printf("\t\t\t(vncunused %d)\n", b_info->u.hvm.vnc.findunused);
+        printf("\t\t\t(keymap %s)\n", b_info->u.hvm.keymap);
+        printf("\t\t\t(sdl %d)\n", b_info->u.hvm.sdl.enable);
+        printf("\t\t\t(opengl %d)\n", b_info->u.hvm.sdl.opengl);
+        printf("\t\t\t(nographic %d)\n", b_info->u.hvm.nographic);
+        printf("\t\t\t(spice %d)\n", b_info->u.hvm.spice.enable);
+        printf("\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port);
+        printf("\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port);
+        printf("\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host);
+        printf("\t\t\t(spicedisable_ticketing %d)\n",
+                    b_info->u.hvm.spice.disable_ticketing);
+        printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse);
+
         printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default");
-        printf("\t\t\t(videoram %d)\n", dm_info->videoram);
-        printf("\t\t\t(stdvga %d)\n", dm_info->stdvga);
-        printf("\t\t\t(vnc %d)\n", dm_info->vnc.enable);
-        printf("\t\t\t(vnclisten %s)\n", dm_info->vnc.listen);
-        printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display);
-        printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused);
-        printf("\t\t\t(keymap %s)\n", dm_info->keymap);
-        printf("\t\t\t(sdl %d)\n", dm_info->sdl.enable);
         printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru);
-        printf("\t\t\t(opengl %d)\n", dm_info->sdl.opengl);
-        printf("\t\t\t(nographic %d)\n", dm_info->nographic);
         printf("\t\t\t(serial %s)\n", dm_info->serial);
         printf("\t\t\t(boot %s)\n", dm_info->boot);
         printf("\t\t\t(usb %d)\n", dm_info->usb);
         printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice);
-        printf("\t\t\t(spice %d)\n", dm_info->spice.enable);
-        printf("\t\t\t(spiceport %d)\n", dm_info->spice.port);
-        printf("\t\t\t(spicetls_port %d)\n", dm_info->spice.tls_port);
-        printf("\t\t\t(spicehost %s)\n", dm_info->spice.host);
-        printf("\t\t\t(spicedisable_ticketing %d)\n",
-                    dm_info->spice.disable_ticketing);
-        printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spice.agent_mouse);
         printf("\t\t)\n");
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -1175,37 +1175,38 @@ skip_vfb:
 
     if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         if (!xlu_cfg_get_long (config, "stdvga", &l, 0))
-            dm_info->stdvga = l;
+            b_info->u.hvm.stdvga = l;
         if (!xlu_cfg_get_long (config, "vnc", &l, 0))
-            dm_info->vnc.enable = l;
-        xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0);
-        xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0);
+            b_info->u.hvm.vnc.enable = l;
+        xlu_cfg_replace_string (config, "vnclisten", &b_info->u.hvm.vnc.listen, 0);
+        xlu_cfg_replace_string (config, "vncpasswd", &b_info->u.hvm.vnc.passwd, 0);
         if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
-            dm_info->vnc.display = l;
+            b_info->u.hvm.vnc.display = l;
         if (!xlu_cfg_get_long (config, "vncunused", &l, 0))
-            dm_info->vnc.findunused = l;
-        xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0);
+            b_info->u.hvm.vnc.findunused = l;
+        xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0);
         if (!xlu_cfg_get_long (config, "sdl", &l, 0))
-            dm_info->sdl.enable = l;
+            b_info->u.hvm.sdl.enable = l;
         if (!xlu_cfg_get_long (config, "opengl", &l, 0))
-            dm_info->sdl.opengl = l;
+            b_info->u.hvm.sdl.opengl = l;
         if (!xlu_cfg_get_long (config, "spice", &l, 0))
-            dm_info->spice.enable = l;
+            b_info->u.hvm.spice.enable = l;
         if (!xlu_cfg_get_long (config, "spiceport", &l, 0))
-            dm_info->spice.port = l;
+            b_info->u.hvm.spice.port = l;
         if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0))
-            dm_info->spice.tls_port = l;
-        xlu_cfg_replace_string (config, "spicehost", &dm_info->spice.host, 0);
+            b_info->u.hvm.spice.tls_port = l;
+        xlu_cfg_replace_string (config, "spicehost",
+                                &b_info->u.hvm.spice.host, 0);
         if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0))
-            dm_info->spice.disable_ticketing = l;
+            b_info->u.hvm.spice.disable_ticketing = l;
         xlu_cfg_replace_string (config, "spicepasswd",
-                                &dm_info->spice.passwd, 0);
+                                &b_info->u.hvm.spice.passwd, 0);
         if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0))
-            dm_info->spice.agent_mouse = l;
+            b_info->u.hvm.spice.agent_mouse = l;
         else
-            dm_info->spice.agent_mouse = 1;
+            b_info->u.hvm.spice.agent_mouse = 1;
         if (!xlu_cfg_get_long (config, "nographic", &l, 0))
-            dm_info->nographic = l;
+            b_info->u.hvm.nographic = l;
         if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
             dm_info->gfx_passthru = l;
         xlu_cfg_replace_string (config, "serial", &dm_info->serial, 0);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (12 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:29   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm Ian Campbell
                   ` (17 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326367397 0
# Node ID 540c9fa96606437f319762663b0892af9e79a6f3
# Parent  0ef52f0b6c58344ee371d668ea343628aaecb714
libxl: HVM device configuration info build_info->u.hvm

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 0ef52f0b6c58 -r 540c9fa96606 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 11:19:52 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 11:23:17 2012 +0000
@@ -109,6 +109,11 @@ int libxl_init_build_info(libxl_ctx *ctx
         b_info->u.hvm.sdl.enable = 0;
         b_info->u.hvm.sdl.opengl = 0;
         b_info->u.hvm.nographic = 0;
+        b_info->u.hvm.serial = NULL;
+        b_info->u.hvm.boot = strdup("cda");
+        b_info->u.hvm.usb = 0;
+        b_info->u.hvm.usbdevice = NULL;
+        b_info->u.hvm.xen_platform_pci = 1;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         b_info->u.pv.slack_memkb = 8 * 1024;
@@ -135,11 +140,6 @@ int libxl_init_dm_info(libxl_ctx *ctx,
     dm_info->device_model_stubdomain = false;
     dm_info->device_model = NULL;
 
-    dm_info->serial = NULL;
-    dm_info->boot = strdup("cda");
-    dm_info->usb = 0;
-    dm_info->usbdevice = NULL;
-    dm_info->xen_platform_pci = 1;
     return 0;
 }
 
diff -r 0ef52f0b6c58 -r 540c9fa96606 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 11:19:52 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 11:23:17 2012 +0000
@@ -179,12 +179,13 @@ static char ** libxl__build_device_model
     if (keymap) {
         flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
-    if (info->serial) {
-        flexarray_vappend(dm_args, "-serial", info->serial, NULL);
-    }
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
+        if (b_info->u.hvm.serial) {
+            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+        }
+
         if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
             flexarray_append(dm_args, "-nographic");
         }
@@ -199,17 +200,18 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, "-std-vga");
         }
 
-        if (info->boot) {
-            flexarray_vappend(dm_args, "-boot", info->boot, NULL);
+        if (b_info->u.hvm.boot) {
+            flexarray_vappend(dm_args, "-boot", b_info->u.hvm.boot, NULL);
         }
-        if (info->usb || info->usbdevice) {
+        if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
             flexarray_append(dm_args, "-usb");
-            if (info->usbdevice) {
-                flexarray_vappend(dm_args, "-usbdevice", info->usbdevice, NULL);
+            if (b_info->u.hvm.usbdevice) {
+                flexarray_vappend(dm_args,
+                                  "-usbdevice", b_info->u.hvm.usbdevice, NULL);
             }
         }
-        if (info->soundhw) {
-            flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL);
+        if (b_info->u.hvm.soundhw) {
+            flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
         if (b_info->u.hvm.acpi) {
             flexarray_append(dm_args, "-acpi");
@@ -406,12 +408,13 @@ static char ** libxl__build_device_model
         flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
 
-    if (info->serial) {
-        flexarray_vappend(dm_args, "-serial", info->serial, NULL);
-    }
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
+        if (b_info->u.hvm.serial) {
+            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+        }
+
         if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
             flexarray_append(dm_args, "-nographic");
         }
@@ -430,17 +433,19 @@ static char ** libxl__build_device_model
                 flexarray_vappend(dm_args, "-vga", "std", NULL);
         }
 
-        if (info->boot) {
-            flexarray_vappend(dm_args, "-boot", libxl__sprintf(gc, "order=%s", info->boot), NULL);
+        if (b_info->u.hvm.boot) {
+            flexarray_vappend(dm_args, "-boot",
+                    libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL);
         }
-        if (info->usb || info->usbdevice) {
+        if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
             flexarray_append(dm_args, "-usb");
-            if (info->usbdevice) {
-                flexarray_vappend(dm_args, "-usbdevice", info->usbdevice, NULL);
+            if (b_info->u.hvm.usbdevice) {
+                flexarray_vappend(dm_args,
+                                  "-usbdevice", b_info->u.hvm.usbdevice, NULL);
             }
         }
-        if (info->soundhw) {
-            flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL);
+        if (b_info->u.hvm.soundhw) {
+            flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
         if (!b_info->u.hvm.acpi) {
             flexarray_append(dm_args, "-no-acpi");
@@ -788,7 +793,7 @@ retry_transaction:
     if (ret)
         goto out_free;
 
-    if (info->serial)
+    if (guest_config->b_info.u.hvm.serial)
         num_console++;
 
     console = libxl__calloc(gc, num_console, sizeof(libxl_device_console));
@@ -916,7 +921,8 @@ int libxl__create_device_model(libxl__gc
 
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
-    libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci);
+    libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
+                    "%d", !guest_config->b_info.u.hvm.xen_platform_pci);
 
     libxl_create_logfile(ctx,
                          libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
diff -r 0ef52f0b6c58 -r 540c9fa96606 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 11:19:52 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 11:23:17 2012 +0000
@@ -226,6 +226,16 @@ libxl_domain_build_info = Struct("domain
                                        ("keymap",           string),
                                        ("sdl",              libxl_sdl_info),
                                        ("spice",            libxl_spice_info),
+                                       
+                                       ("serial",           string),
+                                       ("boot",             string),
+                                       ("usb",              bool),
+                                       # usbdevice:
+                                       # - "tablet" for absolute mouse,
+                                       # - "mouse" for PS/2 protocol relative mouse
+                                       ("usbdevice",        string),
+                                       ("soundhw",          string),
+                                       ("xen_platform_pci", bool),
                                        ])),
                  ("pv", Struct(None, [("kernel", libxl_file_reference),
                                       ("slack_memkb", uint32),
@@ -255,13 +265,6 @@ libxl_device_model_info = Struct("device
     ("saved_state",      string),
     ("type",             libxl_domain_type),
     ("gfx_passthru",     bool),
-    ("serial",           string),
-    ("boot",             string),
-    ("usb",              bool),
-    # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse
-    ("usbdevice",        string),
-    ("soundhw",          string),
-    ("xen_platform_pci", bool),
     # extra parameters pass directly to qemu, NULL terminated
     ("extra",            libxl_string_list),
     # extra parameters pass directly to qemu for PV guest, NULL terminated
diff -r 0ef52f0b6c58 -r 540c9fa96606 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:19:52 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:23:17 2012 +0000
@@ -380,10 +380,10 @@ static void printf_info(int domid,
 
         printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default");
         printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru);
-        printf("\t\t\t(serial %s)\n", dm_info->serial);
-        printf("\t\t\t(boot %s)\n", dm_info->boot);
-        printf("\t\t\t(usb %d)\n", dm_info->usb);
-        printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice);
+        printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
+        printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
+        printf("\t\t\t(usb %d)\n", b_info->u.hvm.usb);
+        printf("\t\t\t(usbdevice %s)\n", b_info->u.hvm.usbdevice);
         printf("\t\t)\n");
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -1209,14 +1209,14 @@ skip_vfb:
             b_info->u.hvm.nographic = l;
         if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
             dm_info->gfx_passthru = l;
-        xlu_cfg_replace_string (config, "serial", &dm_info->serial, 0);
-        xlu_cfg_replace_string (config, "boot", &dm_info->boot, 0);
+        xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
+        xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
         if (!xlu_cfg_get_long (config, "usb", &l, 0))
-            dm_info->usb = l;
-        xlu_cfg_replace_string (config, "usbdevice", &dm_info->usbdevice, 0);
-        xlu_cfg_replace_string (config, "soundhw", &dm_info->soundhw, 0);
+            b_info->u.hvm.usb = l;
+        xlu_cfg_replace_string (config, "usbdevice", &b_info->u.hvm.usbdevice, 0);
+        xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0);
         if (!xlu_cfg_get_long (config, "xen_platform_pci", &l, 0))
-            dm_info->xen_platform_pci = l;
+            b_info->u.hvm.xen_platform_pci = l;
     }
 
     dm_info->type = c_info->type;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (13 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:11   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type Ian Campbell
                   ` (16 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326367542 0
# Node ID 28f0d13e7deafd13ae37322bb56c17541ff43a5e
# Parent  540c9fa96606437f319762663b0892af9e79a6f3
libxl: move gfx_passthru setting to b_info->u.hvm

Although xl parsed this value for both PV and HVM domains (and then a second
time for HVM domains) inside libxl it only impacts HVM guests so I think this
is the right place for it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 540c9fa96606 -r 28f0d13e7dea tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 11:23:17 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 11:25:42 2012 +0000
@@ -248,7 +248,7 @@ static char ** libxl__build_device_model
         if ( ioemu_vifs == 0 ) {
             flexarray_vappend(dm_args, "-net", "none", NULL);
         }
-        if (info->gfx_passthru) {
+        if (b_info->u.hvm.gfx_passthru) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
     } else {
@@ -488,7 +488,7 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, "-net");
             flexarray_append(dm_args, "none");
         }
-        if (info->gfx_passthru) {
+        if (b_info->u.hvm.gfx_passthru) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
     } else {
diff -r 540c9fa96606 -r 28f0d13e7dea tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 11:23:17 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 11:25:42 2012 +0000
@@ -227,6 +227,8 @@ libxl_domain_build_info = Struct("domain
                                        ("sdl",              libxl_sdl_info),
                                        ("spice",            libxl_spice_info),
                                        
+                                       ("gfx_passthru",     bool),
+                                       
                                        ("serial",           string),
                                        ("boot",             string),
                                        ("usb",              bool),
@@ -264,7 +266,6 @@ libxl_device_model_info = Struct("device
     ("device_model",     string),
     ("saved_state",      string),
     ("type",             libxl_domain_type),
-    ("gfx_passthru",     bool),
     # extra parameters pass directly to qemu, NULL terminated
     ("extra",            libxl_string_list),
     # extra parameters pass directly to qemu for PV guest, NULL terminated
diff -r 540c9fa96606 -r 28f0d13e7dea tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:23:17 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:25:42 2012 +0000
@@ -379,7 +379,7 @@ static void printf_info(int domid,
         printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse);
 
         printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default");
-        printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru);
+        printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
         printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
         printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
         printf("\t\t\t(usb %d)\n", b_info->u.hvm.usb);
@@ -732,9 +732,6 @@ static void parse_config_data(const char
     if (!xlu_cfg_get_long (config, "videoram", &l, 0))
         b_info->video_memkb = l * 1024;
 
-    if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
-        dm_info->gfx_passthru = l;
-
     switch(c_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         if (!xlu_cfg_get_string (config, "kernel", &buf, 0))
@@ -1208,7 +1205,7 @@ skip_vfb:
         if (!xlu_cfg_get_long (config, "nographic", &l, 0))
             b_info->u.hvm.nographic = l;
         if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
-            dm_info->gfx_passthru = l;
+            b_info->u.hvm.gfx_passthru = l;
         xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
         xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
         if (!xlu_cfg_get_long (config, "usb", &l, 0))

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (14 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:20   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 17 of 32 RFC] libxl: remove uuid from device model info Ian Campbell
                   ` (15 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326367981 0
# Node ID 934adb649b43db974d247c3a774ec55aa95930b6
# Parent  28f0d13e7deafd13ae37322bb56c17541ff43a5e
libxl: Remove libxl_device_model_info.type.

This is the type of the target guest which is part of the guest config.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 28f0d13e7dea -r 934adb649b43 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 11:25:42 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 11:33:01 2012 +0000
@@ -592,7 +592,6 @@ static int do_domain_create(libxl__gc *g
             memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
             xenpv_dm_info.device_model_version =
                 d_config->dm_info.device_model_version;
-            xenpv_dm_info.type = d_config->dm_info.type;
             xenpv_dm_info.device_model = d_config->dm_info.device_model;
             xenpv_dm_info.extra = d_config->dm_info.extra;
             xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv;
diff -r 28f0d13e7dea -r 934adb649b43 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 11:25:42 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 11:33:01 2012 +0000
@@ -85,7 +85,7 @@ static const libxl_vnc_info *dm_vnc(cons
                                     const libxl_device_model_info *info)
 {
     const libxl_vnc_info *vnc = NULL;
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
         vnc = &guest_config->b_info.u.hvm.vnc;
     } else if (guest_config->num_vfbs > 0) {
         vnc = &guest_config->vfbs[0].vnc;
@@ -97,7 +97,7 @@ static const libxl_sdl_info *dm_sdl(cons
                                     const libxl_device_model_info *info)
 {
     const libxl_sdl_info *sdl = NULL;
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
         sdl = &guest_config->b_info.u.hvm.sdl;
     } else if (guest_config->num_vfbs > 0) {
         sdl = &guest_config->vfbs[0].sdl;
@@ -108,7 +108,7 @@ static const libxl_sdl_info *dm_sdl(cons
 static const char *dm_keymap(const libxl_domain_config *guest_config,
                              const libxl_device_model_info *info)
 {
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
         return guest_config->b_info.u.hvm.keymap;
     } else if (guest_config->num_vfbs > 0) {
         return guest_config->vfbs[0].keymap;
@@ -179,7 +179,7 @@ static char ** libxl__build_device_model
     if (keymap) {
         flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
         if (b_info->u.hvm.serial) {
@@ -262,7 +262,7 @@ static char ** libxl__build_device_model
     for (i = 0; info->extra && info->extra[i] != NULL; i++)
         flexarray_append(dm_args, info->extra[i]);
     flexarray_append(dm_args, "-M");
-    switch (info->type) {
+    switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
         for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
@@ -361,7 +361,7 @@ static char ** libxl__build_device_model
     flexarray_append(dm_args, "-mon");
     flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
 
-    if (info->type == LIBXL_DOMAIN_TYPE_PV) {
+    if (b_info->type == LIBXL_DOMAIN_TYPE_PV) {
         flexarray_append(dm_args, "-xen-attach");
     }
 
@@ -408,7 +408,7 @@ static char ** libxl__build_device_model
         flexarray_vappend(dm_args, "-k", keymap, NULL);
     }
 
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_vifs = 0;
 
         if (b_info->u.hvm.serial) {
@@ -506,7 +506,7 @@ static char ** libxl__build_device_model
     for (i = 0; info->extra && info->extra[i] != NULL; i++)
         flexarray_append(dm_args, info->extra[i]);
     flexarray_append(dm_args, "-M");
-    switch (info->type) {
+    switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
         for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
@@ -525,7 +525,7 @@ static char ** libxl__build_device_model
                      libxl__sprintf(gc, "%d",
                                     libxl__sizekb_to_mb(b_info->target_memkb)));
 
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         for (i = 0; i < num_disks; i++) {
             int disk, part;
             int dev_number =
@@ -708,6 +708,7 @@ static int libxl__create_stubdom(libxl__
     libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid);
 
     memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info));
+    dm_config.b_info.type = dm_config.c_info.type;
     dm_config.b_info.max_vcpus = 1;
     dm_config.b_info.max_memkb = 32 * 1024;
     dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
@@ -838,7 +839,6 @@ retry_transaction:
 
     memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
     xenpv_dm_info.device_model_version = info->device_model_version;
-    xenpv_dm_info.type = LIBXL_DOMAIN_TYPE_PV;
     xenpv_dm_info.device_model = info->device_model;
     xenpv_dm_info.extra = info->extra;
     xenpv_dm_info.extra_pv = info->extra_pv;
diff -r 28f0d13e7dea -r 934adb649b43 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 11:25:42 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 11:33:01 2012 +0000
@@ -265,7 +265,6 @@ libxl_device_model_info = Struct("device
     # you set device_model you must set device_model_version too
     ("device_model",     string),
     ("saved_state",      string),
-    ("type",             libxl_domain_type),
     # extra parameters pass directly to qemu, NULL terminated
     ("extra",            libxl_string_list),
     # extra parameters pass directly to qemu for PV guest, NULL terminated
diff -r 28f0d13e7dea -r 934adb649b43 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:25:42 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 11:33:01 2012 +0000
@@ -1216,8 +1216,6 @@ skip_vfb:
             b_info->u.hvm.xen_platform_pci = l;
     }
 
-    dm_info->type = c_info->type;
-
     xlu_cfg_destroy(config);
 }

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 17 of 32 RFC] libxl: remove uuid from device model info
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (15 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:13   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 18 of 32 RFC] libxl: move device model selection variables to b_info Ian Campbell
                   ` (14 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326383425 0
# Node ID 20f5a6a37f6aac5eb314262c16e3548e6ab7a2a9
# Parent  934adb649b43db974d247c3a774ec55aa95930b6
libxl: remove uuid from device model info.

This should be managed by libxl and need not be exposed to the user.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 934adb649b43 -r 20f5a6a37f6a tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 11:33:01 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 15:50:25 2012 +0000
@@ -134,8 +134,6 @@ int libxl_init_dm_info(libxl_ctx *ctx,
 {
     memset(dm_info, '\0', sizeof(*dm_info));
 
-    libxl_uuid_generate(&dm_info->uuid);
-
     dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
     dm_info->device_model_stubdomain = false;
     dm_info->device_model = NULL;
diff -r 934adb649b43 -r 20f5a6a37f6a tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 11:33:01 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 15:50:25 2012 +0000
@@ -705,7 +705,7 @@ static int libxl__create_stubdom(libxl__
     dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
     dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid));
 
-    libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid);
+    libxl_uuid_generate(&dm_config.c_info.uuid);
 
     memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info));
     dm_config.b_info.type = dm_config.c_info.type;
diff -r 934adb649b43 -r 20f5a6a37f6a tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 11:33:01 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 15:50:25 2012 +0000
@@ -257,9 +257,6 @@ libxl_domain_build_info = Struct("domain
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
     
-    # uuid is used only with stubdom, and must be different from the
-    # domain uuid
-    ("uuid",             libxl_uuid),
     ("device_model_version", libxl_device_model_version),
     ("device_model_stubdomain", bool),
     # you set device_model you must set device_model_version too

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 18 of 32 RFC] libxl: move device model selection variables to b_info
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (16 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 17 of 32 RFC] libxl: remove uuid from device model info Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 12:15 ` [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state Ian Campbell
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326383828 0
# Node ID ff41e5fc0f12450cd836ce1466c0c51ab685e04b
# Parent  20f5a6a37f6aac5eb314262c16e3548e6ab7a2a9
libxl: move device model selection variables to b_info.

Currently we have one set of device model version (and associated) variables.
However we can actually have two device models (stub device model + non-stub PV
device model) which need not necessarily be the same version. Perhaps this
needs more thought.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl.c	Thu Jan 12 15:57:08 2012 +0000
@@ -2389,7 +2389,7 @@ int libxl_domain_need_memory(libxl_ctx *
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
-        if (dm_info->device_model_stubdomain)
+        if (b_info->device_model_stubdomain)
             *need_memkb += 32 * 1024;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 15:57:08 2012 +0000
@@ -84,6 +84,12 @@ int libxl_init_build_info(libxl_ctx *ctx
     b_info->cpuid = NULL;
     b_info->shadow_memkb = 0;
     b_info->type = c_info->type;
+
+    b_info->device_model_version =
+        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+    b_info->device_model_stubdomain = false;
+    b_info->device_model = NULL;
+
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         b_info->video_memkb = 8 * 1024;
@@ -134,9 +140,6 @@ int libxl_init_dm_info(libxl_ctx *ctx,
 {
     memset(dm_info, '\0', sizeof(*dm_info));
 
-    dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
-    dm_info->device_model_stubdomain = false;
-    dm_info->device_model = NULL;
 
     return 0;
 }
@@ -446,14 +449,14 @@ retry_transaction:
 }
 
 static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
-                             libxl_device_model_info *dm_info)
+                             libxl_domain_build_info *b_info)
 {
     char *path = NULL;
 
     path = libxl__xs_libxl_path(gc, domid);
     path = libxl__sprintf(gc, "%s/dm-version", path);
     return libxl__xs_write(gc, XBT_NULL, path, "%s",
-        libxl_device_model_version_to_string(dm_info->device_model_version));
+        libxl_device_model_version_to_string(b_info->device_model_version));
 }
 
 static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
@@ -512,7 +515,7 @@ static int do_domain_create(libxl__gc *g
         goto error_out;
     }
 
-    store_libxl_entry(gc, domid, dm_info);
+    store_libxl_entry(gc, domid, &d_config->b_info);
 
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]);
@@ -588,12 +591,6 @@ static int do_domain_create(libxl__gc *g
         if (need_qemu) {
             /* only copy those useful configs */
             memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-            xenpv_dm_info.device_model_version =
-                d_config->dm_info.device_model_version;
-            xenpv_dm_info.device_model = d_config->dm_info.device_model;
-            xenpv_dm_info.extra = d_config->dm_info.extra;
-            xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv;
-            xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm;
 
             libxl__create_xenpv_qemu(gc, domid,
                                      d_config, &xenpv_dm_info, &dm_starting);
@@ -606,7 +603,7 @@ static int do_domain_create(libxl__gc *g
     }
 
     if (dm_starting) {
-        if (dm_info->device_model_version
+        if (d_config->b_info.device_model_version
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             libxl__qmp_initializations(ctx, domid);
         }
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 15:57:08 2012 +0000
@@ -42,7 +42,7 @@ const char *libxl__device_model_savefile
 }
 
 const char *libxl__domain_device_model(libxl__gc *gc,
-                                       libxl_device_model_info *info)
+                                       const libxl_domain_build_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const char *dm;
@@ -72,7 +72,7 @@ const char *libxl__domain_device_model(l
 }
 
 static const char *libxl__domain_bios(libxl__gc *gc,
-                                libxl_device_model_info *info)
+                                const libxl_domain_build_info *info)
 {
     switch (info->device_model_version) {
     case 1: return "rombios";
@@ -259,19 +259,19 @@ static char ** libxl__build_device_model
     if (info->saved_state) {
         flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL);
     }
-    for (i = 0; info->extra && info->extra[i] != NULL; i++)
-        flexarray_append(dm_args, info->extra[i]);
+    for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
+        flexarray_append(dm_args, b_info->extra[i]);
     flexarray_append(dm_args, "-M");
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-        for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_pv[i]);
+        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_pv[i]);
         break;
     case LIBXL_DOMAIN_TYPE_HVM:
         flexarray_append(dm_args, "xenfv");
-        for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_hvm[i]);
+        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_hvm[i]);
         break;
     }
     flexarray_append(dm_args, NULL);
@@ -503,19 +503,19 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-incoming");
         flexarray_append(dm_args, libxl__sprintf(gc, "fd:%d", migration_fd));
     }
-    for (i = 0; info->extra && info->extra[i] != NULL; i++)
-        flexarray_append(dm_args, info->extra[i]);
+    for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
+        flexarray_append(dm_args, b_info->extra[i]);
     flexarray_append(dm_args, "-M");
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-        for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_pv[i]);
+        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_pv[i]);
         break;
     case LIBXL_DOMAIN_TYPE_HVM:
         flexarray_append(dm_args, "xenfv");
-        for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_hvm[i]);
+        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_hvm[i]);
         break;
     }
 
@@ -593,14 +593,14 @@ static char ** libxl__build_device_model
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
-    switch (info->device_model_version) {
+    switch (guest_config->b_info.device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
         return libxl__build_device_model_args_old(gc, dm, guest_config, info);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
         return libxl__build_device_model_args_new(gc, dm, guest_config, info);
     default:
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d",
-                         info->device_model_version);
+                         guest_config->b_info.device_model_version);
         return NULL;
     }
 }
@@ -696,7 +696,8 @@ static int libxl__create_stubdom(libxl__
     libxl__spawner_starting *dm_starting = 0;
     libxl_device_model_info xenpv_dm_info;
 
-    if (info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
+    if (guest_config->b_info.device_model_version !=
+        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
         ret = ERROR_INVAL;
         goto out;
     }
@@ -720,6 +721,14 @@ static int libxl__create_stubdom(libxl__
     dm_config.b_info.u.pv.ramdisk.path = "";
     dm_config.b_info.u.pv.features = "";
 
+    dm_config.b_info.device_model_version =
+        guest_config->b_info.device_model_version;
+    dm_config.b_info.device_model =
+        guest_config->b_info.device_model;
+    dm_config.b_info.extra = guest_config->b_info.extra;
+    dm_config.b_info.extra_pv = guest_config->b_info.extra_pv;
+    dm_config.b_info.extra_hvm = guest_config->b_info.extra_hvm;
+
     dm_config.disks = guest_config->disks;
     dm_config.num_disks = guest_config->num_disks;
 
@@ -838,11 +847,6 @@ retry_transaction:
     }
 
     memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-    xenpv_dm_info.device_model_version = info->device_model_version;
-    xenpv_dm_info.device_model = info->device_model;
-    xenpv_dm_info.extra = info->extra;
-    xenpv_dm_info.extra_pv = info->extra_pv;
-    xenpv_dm_info.extra_hvm = info->extra_hvm;
 
     if (libxl__create_xenpv_qemu(gc, domid,
                                  &dm_config,
@@ -881,6 +885,7 @@ int libxl__create_device_model(libxl__gc
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const libxl_domain_create_info *c_info = &guest_config->c_info;
+    const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
     char *path, *logfile;
     int logfile_w, null;
@@ -892,12 +897,12 @@ int libxl__create_device_model(libxl__gc
     char **pass_stuff;
     const char *dm;
 
-    if (info->device_model_stubdomain) {
+    if (b_info->device_model_stubdomain) {
         rc = libxl__create_stubdom(gc, guest_config, info, starting_r);
         goto out;
     }
 
-    dm = libxl__domain_device_model(gc, info);
+    dm = libxl__domain_device_model(gc, b_info);
     if (!dm) {
         rc = ERROR_FAIL;
         goto out;
@@ -917,12 +922,12 @@ int libxl__create_device_model(libxl__gc
     path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", info->domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path),
-                    "%s", libxl__domain_bios(gc, info));
+                    "%s", libxl__domain_bios(gc, b_info));
 
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
-                    "%d", !guest_config->b_info.u.hvm.xen_platform_pci);
+                    "%d", !b_info->u.hvm.xen_platform_pci);
 
     libxl_create_logfile(ctx,
                          libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_dom.c	Thu Jan 12 15:57:08 2012 +0000
@@ -297,7 +297,7 @@ static const char *libxl__domain_firmwar
     if (info->u.hvm.firmware)
         firmware = info->u.hvm.firmware;
     else {
-        switch (dm_info->device_model_version)
+        switch (info->device_model_version)
         {
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
             firmware = "hvmloader";
@@ -307,7 +307,7 @@ static const char *libxl__domain_firmwar
             break;
         default:
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d",
-                       dm_info->device_model_version);
+                       info->device_model_version);
             return NULL;
             break;
         }
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Thu Jan 12 15:57:08 2012 +0000
@@ -463,7 +463,7 @@ _hidden int libxl__domain_build(libxl__g
 
 /* for device model creation */
 _hidden const char *libxl__domain_device_model(libxl__gc *gc,
-                                               libxl_device_model_info *info);
+                                        const libxl_domain_build_info *info);
 _hidden int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 15:57:08 2012 +0000
@@ -205,6 +205,19 @@ libxl_domain_build_info = Struct("domain
     ("disable_migrate", bool),
     ("cpuid",           libxl_cpuid_policy_list),
     ("type",            libxl_domain_type),
+    
+    ("device_model_version", libxl_device_model_version),
+    ("device_model_stubdomain", bool),
+    # you set device_model you must set device_model_version too
+    ("device_model",     string),
+
+    # extra parameters pass directly to qemu, NULL terminated
+    ("extra",            libxl_string_list),
+    # extra parameters pass directly to qemu for PV guest, NULL terminated
+    ("extra_pv",         libxl_string_list),
+    # extra parameters pass directly to qemu for HVM guest, NULL terminated
+    ("extra_hvm",        libxl_string_list),
+
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware", string),
                                        ("pae", bool),
@@ -257,17 +270,7 @@ libxl_domain_build_info = Struct("domain
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
     
-    ("device_model_version", libxl_device_model_version),
-    ("device_model_stubdomain", bool),
-    # you set device_model you must set device_model_version too
-    ("device_model",     string),
     ("saved_state",      string),
-    # extra parameters pass directly to qemu, NULL terminated
-    ("extra",            libxl_string_list),
-    # extra parameters pass directly to qemu for PV guest, NULL terminated
-    ("extra_pv",         libxl_string_list),
-    # extra parameters pass directly to qemu for HVM guest, NULL terminated
-    ("extra_hvm",        libxl_string_list),
     ],
 )
 
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 15:57:08 2012 +0000
@@ -378,7 +378,7 @@ static void printf_info(int domid,
                     b_info->u.hvm.spice.disable_ticketing);
         printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse);
 
-        printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default");
+        printf("\t\t\t(device_model %s)\n", b_info->device_model ? : "default");
         printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
         printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
         printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
@@ -1133,27 +1133,27 @@ skip_vfb:
 
 
     xlu_cfg_replace_string (config, "device_model_override",
-                            &dm_info->device_model, 0);
+                            &b_info->device_model, 0);
     if (!xlu_cfg_get_string (config, "device_model_version", &buf, 0)) {
         if (!strcmp(buf, "qemu-xen-traditional")) {
-            dm_info->device_model_version
+            b_info->device_model_version
                 = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
         } else if (!strcmp(buf, "qemu-xen")) {
-            dm_info->device_model_version
+            b_info->device_model_version
                 = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
         } else {
             fprintf(stderr,
                     "Unknown device_model_version \"%s\" specified\n", buf);
             exit(1);
         }
-    } else if (dm_info->device_model)
+    } else if (b_info->device_model)
         fprintf(stderr, "WARNING: device model override given without specific DM version\n");
     if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0))
-        dm_info->device_model_stubdomain = l;
+        b_info->device_model_stubdomain = l;
 
 #define parse_extra_args(type)                                            \
     e = xlu_cfg_get_list_as_string_list(config, "device_model_args"#type, \
-                                    &dm_info->extra##type, 0);            \
+                                    &b_info->extra##type, 0);            \
     if (e && e != ESRCH) {                                                \
         fprintf(stderr,"xl: Unable to parse device_model_args"#type".\n");\
         exit(-ERROR_FAIL);                                                \

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (17 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 18 of 32 RFC] libxl: move device model selection variables to b_info Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:21   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info Ian Campbell
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326384100 0
# Node ID c7160a835d3c01b6317551faac90bee4f5b4601c
# Parent  ff41e5fc0f12450cd836ce1466c0c51ab685e04b
libxl: move "saved_state" to libxl__domain_build_state.

This is internal to the library and need not be exposed to the user.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r ff41e5fc0f12 -r c7160a835d3c tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 15:57:08 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 16:01:40 2012 +0000
@@ -281,9 +281,8 @@ static int domain_restore(libxl__gc *gc,
     if (ret)
         goto out;
 
-    dm_info->saved_state = NULL;
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
-        ret = asprintf(&dm_info->saved_state,
+        ret = asprintf(&state->saved_state,
                        XC_DEVICE_MODEL_RESTORE_FILE".%d", domid);
         ret = (ret < 0) ? ERROR_FAIL : 0;
     }
@@ -499,13 +498,11 @@ static int do_domain_create(libxl__gc *g
         }
     }
 
+    memset(&state, 0, sizeof(state));
+
     if ( restore_fd >= 0 ) {
         ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state, dm_info);
     } else {
-        if (dm_info->saved_state) {
-            free(dm_info->saved_state);
-            dm_info->saved_state = NULL;
-        }
         ret = libxl__domain_build(gc, &d_config->b_info, dm_info, domid, &state);
     }
 
@@ -555,7 +552,7 @@ static int do_domain_create(libxl__gc *g
 
         dm_info->domid = domid;
         ret = libxl__create_device_model(gc, d_config, dm_info,
-                                        &dm_starting);
+                                         &state, &dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "failed to create device model: %d", ret);
@@ -592,8 +589,8 @@ static int do_domain_create(libxl__gc *g
             /* only copy those useful configs */
             memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
 
-            libxl__create_xenpv_qemu(gc, domid,
-                                     d_config, &xenpv_dm_info, &dm_starting);
+            libxl__create_xenpv_qemu(gc, domid, d_config,
+                                     &xenpv_dm_info, &state, &dm_starting);
         }
         break;
     }
@@ -607,7 +604,7 @@ static int do_domain_create(libxl__gc *g
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             libxl__qmp_initializations(ctx, domid);
         }
-        ret = libxl__confirm_device_model_startup(gc, dm_info, dm_starting);
+        ret = libxl__confirm_device_model_startup(gc, &state, dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "device model did not start: %d", ret);
diff -r ff41e5fc0f12 -r c7160a835d3c tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 15:57:08 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 16:01:40 2012 +0000
@@ -119,7 +119,8 @@ static const char *dm_keymap(const libxl
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info)
+                                        const libxl_device_model_info *info,
+                                        const libxl__domain_build_state *state)
 {
     const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
@@ -256,8 +257,8 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, "-nographic");
     }
 
-    if (info->saved_state) {
-        flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL);
+    if (state->saved_state) {
+        flexarray_vappend(dm_args, "-loadvm", state->saved_state, NULL);
     }
     for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
         flexarray_append(dm_args, b_info->extra[i]);
@@ -329,7 +330,8 @@ static char *dm_spice_options(libxl__gc 
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info)
+                                        const libxl_device_model_info *info,
+                                        const libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const libxl_domain_create_info *c_info = &guest_config->c_info;
@@ -497,9 +499,9 @@ static char ** libxl__build_device_model
         }
     }
 
-    if (info->saved_state) {
+    if (state->saved_state) {
         /* This file descriptor is meant to be used by QEMU */
-        int migration_fd = open(info->saved_state, O_RDONLY);
+        int migration_fd = open(state->saved_state, O_RDONLY);
         flexarray_append(dm_args, "-incoming");
         flexarray_append(dm_args, libxl__sprintf(gc, "fd:%d", migration_fd));
     }
@@ -589,15 +591,16 @@ static char ** libxl__build_device_model
 static char ** libxl__build_device_model_args(libxl__gc *gc,
                                         const char *dm,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info)
+                                        const libxl_device_model_info *info,
+                                        const libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
     switch (guest_config->b_info.device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-        return libxl__build_device_model_args_old(gc, dm, guest_config, info);
+        return libxl__build_device_model_args_old(gc, dm, guest_config, info, state);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        return libxl__build_device_model_args_new(gc, dm, guest_config, info);
+        return libxl__build_device_model_args_new(gc, dm, guest_config, info, state);
     default:
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d",
                          guest_config->b_info.device_model_version);
@@ -680,6 +683,7 @@ retry_transaction:
 static int libxl__create_stubdom(libxl__gc *gc,
                                  libxl_domain_config *guest_config,
                                  libxl_device_model_info *info,
+                                 libxl__domain_build_state *d_state,
                                  libxl__spawner_starting **starting_r)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -688,7 +692,7 @@ static int libxl__create_stubdom(libxl__
     libxl_domain_config dm_config;
     libxl_device_vfb vfb;
     libxl_device_vkb vkb;
-    libxl__domain_build_state state;
+    libxl__domain_build_state stubdom_state;
     uint32_t domid;
     char **args;
     struct xs_permissions perm[2];
@@ -746,12 +750,12 @@ static int libxl__create_stubdom(libxl__
     ret = libxl__domain_make(gc, &dm_config.c_info, &domid);
     if (ret)
         goto out;
-    ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &state);
+    ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &stubdom_state);
     if (ret)
         goto out;
 
     args = libxl__build_device_model_args(gc, "stubdom-dm",
-                                          guest_config, info);
+                                          guest_config, info, d_state);
     if (!args) {
         ret = ERROR_FAIL;
         goto out;
@@ -823,7 +827,8 @@ retry_transaction:
             char *filename;
             char *name;
             case STUBDOM_CONSOLE_LOGGING:
-                name = libxl__sprintf(gc, "qemu-dm-%s", libxl_domid_to_name(ctx, info->domid));
+                name = libxl__sprintf(gc, "qemu-dm-%s",
+                                      libxl_domid_to_name(ctx, info->domid));
                 libxl_create_logfile(ctx, name, &filename);
                 console[i].output = libxl__sprintf(gc, "file:%s", filename);
                 free(filename);
@@ -833,15 +838,16 @@ retry_transaction:
                                 libxl__device_model_savefile(gc, info->domid));
                 break;
             case STUBDOM_CONSOLE_RESTORE:
-                if (info->saved_state)
-                    console[i].output = libxl__sprintf(gc, "pipe:%s", info->saved_state);
+                if (d_state->saved_state)
+                    console[i].output =
+                        libxl__sprintf(gc, "pipe:%s", d_state->saved_state);
                 break;
             default:
                 console[i].output = "pty";
                 break;
         }
         ret = libxl__device_console_add(gc, domid, &console[i],
-                                    i == STUBDOM_CONSOLE_LOGGING ? &state : NULL);
+                        i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL);
         if (ret)
             goto out_free;
     }
@@ -851,12 +857,12 @@ retry_transaction:
     if (libxl__create_xenpv_qemu(gc, domid,
                                  &dm_config,
                                  &xenpv_dm_info,
+                                 &stubdom_state,
                                  &dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;
     }
-    if (libxl__confirm_device_model_startup(gc, &xenpv_dm_info,
-                                            dm_starting) < 0) {
+    if (libxl__confirm_device_model_startup(gc, d_state, dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;
     }
@@ -881,6 +887,7 @@ out:
 int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
+                              libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -898,7 +905,7 @@ int libxl__create_device_model(libxl__gc
     const char *dm;
 
     if (b_info->device_model_stubdomain) {
-        rc = libxl__create_stubdom(gc, guest_config, info, starting_r);
+        rc = libxl__create_stubdom(gc, guest_config, info, state, starting_r);
         goto out;
     }
 
@@ -913,7 +920,7 @@ int libxl__create_device_model(libxl__gc
         rc = ERROR_FAIL;
         goto out;
     }
-    args = libxl__build_device_model_args(gc, dm, guest_config, info);
+    args = libxl__build_device_model_args(gc, dm, guest_config, info, state);
     if (!args) {
         rc = ERROR_FAIL;
         goto out;
@@ -994,10 +1001,9 @@ out:
 
 
 int libxl__confirm_device_model_startup(libxl__gc *gc,
-                                libxl_device_model_info *dm_info,
+                                libxl__domain_build_state *state,
                                 libxl__spawner_starting *starting)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *path;
     int domid = starting->domid;
     int ret, ret2;
@@ -1005,11 +1011,11 @@ int libxl__confirm_device_model_startup(
     ret = libxl__spawn_confirm_offspring_startup(gc,
                                      LIBXL_DEVICE_MODEL_START_TIMEOUT,
                                      "Device Model", path, "running", starting);
-    if (dm_info->saved_state) {
-        ret2 = unlink(dm_info->saved_state);
-        if (ret2) LIBXL__LOG_ERRNO(ctx, XTL_ERROR,
+    if (state->saved_state) {
+        ret2 = unlink(state->saved_state);
+        if (ret2) LIBXL__LOG_ERRNO(CTX, XTL_ERROR,
                                    "failed to remove device-model state %s\n",
-                                   dm_info->saved_state);
+                                   state->saved_state);
         /* Do not clobber spawn_confirm error code with unlink error code. */
         if (!ret) ret = ret2;
     }
@@ -1120,10 +1126,11 @@ out:
 int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                              libxl_domain_config *guest_config,
                              libxl_device_model_info *info,
+                             libxl__domain_build_state *state,
                              libxl__spawner_starting **starting_r)
 {
     libxl__build_xenpv_qemu_args(gc, domid, info);
-    libxl__create_device_model(gc, guest_config, info, starting_r);
+    libxl__create_device_model(gc, guest_config, info, state, starting_r);
     return 0;
 }
 
diff -r ff41e5fc0f12 -r c7160a835d3c tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Thu Jan 12 15:57:08 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Thu Jan 12 16:01:40 2012 +0000
@@ -220,6 +220,8 @@ typedef struct {
 
     uint32_t console_port;
     unsigned long console_mfn;
+
+    char *saved_state;
 } libxl__domain_build_state;
 
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
@@ -467,10 +469,12 @@ _hidden const char *libxl__domain_device
 _hidden int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
+                              libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *dm_info,
+                              libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
         int nr_consoles, libxl_device_console *consoles,
@@ -480,7 +484,7 @@ _hidden int libxl__need_xenpv_qemu(libxl
    * return pass *starting_r (which will be non-0) to
    * libxl__confirm_device_model_startup or libxl__detach_device_model. */
 _hidden int libxl__confirm_device_model_startup(libxl__gc *gc,
-                              libxl_device_model_info *dm_info,
+                              libxl__domain_build_state *state,
                               libxl__spawner_starting *starting);
 _hidden int libxl__detach_device_model(libxl__gc *gc, libxl__spawner_starting *starting);
 _hidden int libxl__wait_for_device_model(libxl__gc *gc,
diff -r ff41e5fc0f12 -r c7160a835d3c tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 15:57:08 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Thu Jan 12 16:01:40 2012 +0000
@@ -269,8 +269,6 @@ libxl_domain_build_info = Struct("domain
 # Device Model Information
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
-    
-    ("saved_state",      string),
     ],
 )

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (18 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:30   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago Ian Campbell
                   ` (11 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326385359 0
# Node ID 1e558d62909f4f236bb5edd7019073593564ac31
# Parent  c7160a835d3c01b6317551faac90bee4f5b4601c
libxl: remove libxl_device_model_info.

All that is left here is the target domain's domid which we can pass around as
a parameter.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl.c	Thu Jan 12 16:22:39 2012 +0000
@@ -2381,7 +2381,7 @@ out:
 }
 
 int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info,
-        libxl_device_model_info *dm_info, uint32_t *need_memkb)
+                             uint32_t *need_memkb)
 {
     GC_INIT(ctx);
     int rc = ERROR_INVAL;
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl.h	Thu Jan 12 16:22:39 2012 +0000
@@ -230,7 +230,6 @@ enum {
 typedef struct {
     libxl_domain_create_info c_info;
     libxl_domain_build_info b_info;
-    libxl_device_model_info dm_info;
 
     int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs;
 
@@ -258,10 +257,6 @@ int libxl_init_create_info(libxl_ctx *ct
 int libxl_init_build_info(libxl_ctx *ctx,
                           libxl_domain_build_info *b_info,
                           libxl_domain_create_info *c_info);
-int libxl_init_dm_info(libxl_ctx *ctx,
-                       libxl_device_model_info *dm_info,
-                       libxl_domain_create_info *c_info,
-                       libxl_domain_build_info *b_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
@@ -359,7 +354,7 @@ int libxl_set_memory_target(libxl_ctx *c
 int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t *out_target);
 /* how much free memory in the system a domain needs to be built */
 int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info,
-        libxl_device_model_info *dm_info, uint32_t *need_memkb);
+                             uint32_t *need_memkb);
 /* how much free memory is available in the system */
 int libxl_get_free_memory(libxl_ctx *ctx, uint32_t *memkb);
 /* wait for a given amount of memory to be free in the system */
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl_create.c	Thu Jan 12 16:22:39 2012 +0000
@@ -55,7 +55,6 @@ void libxl_domain_config_dispose(libxl_d
 
     libxl_domain_create_info_dispose(&d_config->c_info);
     libxl_domain_build_info_dispose(&d_config->b_info);
-    libxl_device_model_info_dispose(&d_config->dm_info);
 }
 
 int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info)
@@ -133,17 +132,6 @@ int libxl_init_build_info(libxl_ctx *ctx
     return 0;
 }
 
-int libxl_init_dm_info(libxl_ctx *ctx,
-                       libxl_device_model_info *dm_info,
-                       libxl_domain_create_info *c_info,
-                       libxl_domain_build_info *b_info)
-{
-    memset(dm_info, '\0', sizeof(*dm_info));
-
-
-    return 0;
-}
-
 static int init_console_info(libxl_device_console *console, int dev_num)
 {
     memset(console, 0x00, sizeof(libxl_device_console));
@@ -157,7 +145,6 @@ static int init_console_info(libxl_devic
 
 int libxl__domain_build(libxl__gc *gc,
                         libxl_domain_build_info *info,
-                        libxl_device_model_info *dm_info,
                         uint32_t domid,
                         libxl__domain_build_state *state)
 {
@@ -173,7 +160,7 @@ int libxl__domain_build(libxl__gc *gc,
 
     switch (info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
-        ret = libxl__build_hvm(gc, domid, info, dm_info, state);
+        ret = libxl__build_hvm(gc, domid, info, state);
         if (ret)
             goto out;
 
@@ -227,8 +214,7 @@ out:
 
 static int domain_restore(libxl__gc *gc, libxl_domain_build_info *info,
                           uint32_t domid, int fd,
-                          libxl__domain_build_state *state,
-                          libxl_device_model_info *dm_info)
+                          libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     char **vments = NULL, **localents = NULL;
@@ -464,7 +450,6 @@ static int do_domain_create(libxl__gc *g
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     libxl__spawner_starting *dm_starting = 0;
-    libxl_device_model_info *dm_info = &d_config->dm_info;
     libxl__domain_build_state state;
     uint32_t domid;
     int i, ret;
@@ -501,9 +486,9 @@ static int do_domain_create(libxl__gc *g
     memset(&state, 0, sizeof(state));
 
     if ( restore_fd >= 0 ) {
-        ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state, dm_info);
+        ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state);
     } else {
-        ret = libxl__domain_build(gc, &d_config->b_info, dm_info, domid, &state);
+        ret = libxl__domain_build(gc, &d_config->b_info, domid, &state);
     }
 
     if (ret) {
@@ -550,8 +535,7 @@ static int do_domain_create(libxl__gc *g
         libxl_device_vkb_add(ctx, domid, &vkb);
         libxl_device_vkb_dispose(&vkb);
 
-        dm_info->domid = domid;
-        ret = libxl__create_device_model(gc, d_config, dm_info,
+        ret = libxl__create_device_model(gc, domid, d_config,
                                          &state, &dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
@@ -564,7 +548,6 @@ static int do_domain_create(libxl__gc *g
     {
         int need_qemu = 0;
         libxl_device_console console;
-        libxl_device_model_info xenpv_dm_info;
 
         for (i = 0; i < d_config->num_vfbs; i++) {
             libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
@@ -586,11 +569,7 @@ static int do_domain_create(libxl__gc *g
         libxl_device_console_dispose(&console);
 
         if (need_qemu) {
-            /* only copy those useful configs */
-            memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-
-            libxl__create_xenpv_qemu(gc, domid, d_config,
-                                     &xenpv_dm_info, &state, &dm_starting);
+            libxl__create_xenpv_qemu(gc, domid, d_config, &state, &dm_starting);
         }
         break;
     }
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 16:22:39 2012 +0000
@@ -81,8 +81,7 @@ static const char *libxl__domain_bios(li
     }
 }
 
-static const libxl_vnc_info *dm_vnc(const libxl_domain_config *guest_config,
-                                    const libxl_device_model_info *info)
+static const libxl_vnc_info *dm_vnc(const libxl_domain_config *guest_config)
 {
     const libxl_vnc_info *vnc = NULL;
     if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
@@ -93,8 +92,7 @@ static const libxl_vnc_info *dm_vnc(cons
     return vnc && vnc->enable ? vnc : NULL;
 }
 
-static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config,
-                                    const libxl_device_model_info *info)
+static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config)
 {
     const libxl_sdl_info *sdl = NULL;
     if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
@@ -105,8 +103,7 @@ static const libxl_sdl_info *dm_sdl(cons
     return sdl && sdl->enable ? sdl : NULL;
 }
 
-static const char *dm_keymap(const libxl_domain_config *guest_config,
-                             const libxl_device_model_info *info)
+static const char *dm_keymap(const libxl_domain_config *guest_config)
 {
     if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
         return guest_config->b_info.u.hvm.keymap;
@@ -117,18 +114,17 @@ static const char *dm_keymap(const libxl
 }
 
 static char ** libxl__build_device_model_args_old(libxl__gc *gc,
-                                        const char *dm,
+                                        const char *dm, int domid,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
                                         const libxl__domain_build_state *state)
 {
     const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_device_nic *vifs = guest_config->vifs;
-    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
-    const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
+    const libxl_vnc_info *vnc = dm_vnc(guest_config);
+    const libxl_sdl_info *sdl = dm_sdl(guest_config);
     const int num_vifs = guest_config->num_vifs;
-    const char *keymap = dm_keymap(guest_config, info);
+    const char *keymap = dm_keymap(guest_config);
     int i;
     flexarray_t *dm_args;
     dm_args = flexarray_make(16, 1);
@@ -137,7 +133,7 @@ static char ** libxl__build_device_model
         return NULL;
 
     flexarray_vappend(dm_args, dm,
-                      "-d", libxl__sprintf(gc, "%d", info->domid), NULL);
+                      "-d", libxl__sprintf(gc, "%d", domid), NULL);
 
     if (c_info->name)
         flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL);
@@ -233,7 +229,8 @@ static char ** libxl__build_device_model
                                    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);
+                    ifname = libxl__sprintf(gc,
+                                            "tap%d.%d", domid, vifs[i].devid);
                 else
                     ifname = vifs[i].ifname;
                 flexarray_vappend(dm_args,
@@ -328,9 +325,8 @@ static char *dm_spice_options(libxl__gc 
 }
 
 static char ** libxl__build_device_model_args_new(libxl__gc *gc,
-                                        const char *dm,
+                                        const char *dm, int guest_domid,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
                                         const libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -340,9 +336,9 @@ static char ** libxl__build_device_model
     const libxl_device_nic *vifs = guest_config->vifs;
     const int num_disks = guest_config->num_disks;
     const int num_vifs = guest_config->num_vifs;
-    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
-    const libxl_sdl_info *sdl = dm_sdl(guest_config, info);
-    const char *keymap = dm_keymap(guest_config, info);
+    const libxl_vnc_info *vnc = dm_vnc(guest_config);
+    const libxl_sdl_info *sdl = dm_sdl(guest_config);
+    const char *keymap = dm_keymap(guest_config);
     flexarray_t *dm_args;
     int i;
 
@@ -351,14 +347,14 @@ static char ** libxl__build_device_model
         return NULL;
 
     flexarray_vappend(dm_args, dm,
-                      "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL);
+                      "-xen-domid",
+                      libxl__sprintf(gc, "%d", guest_domid), NULL);
 
     flexarray_append(dm_args, "-chardev");
     flexarray_append(dm_args,
                      libxl__sprintf(gc, "socket,id=libxl-cmd,"
                                     "path=%s/qmp-libxl-%d,server,nowait",
-                                    libxl_run_dir_path(),
-                                    info->domid));
+                                    libxl_run_dir_path(), guest_domid));
 
     flexarray_append(dm_args, "-mon");
     flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
@@ -468,7 +464,8 @@ static char ** libxl__build_device_model
                                 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);
+                    ifname = libxl__sprintf(gc, "tap%d.%d",
+                                            guest_domid, vifs[i].devid);
                 } else {
                     ifname = vifs[i].ifname;
                 }
@@ -589,18 +586,21 @@ static char ** libxl__build_device_model
 }
 
 static char ** libxl__build_device_model_args(libxl__gc *gc,
-                                        const char *dm,
+                                        const char *dm, int guest_domid,
                                         const libxl_domain_config *guest_config,
-                                        const libxl_device_model_info *info,
                                         const libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
     switch (guest_config->b_info.device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-        return libxl__build_device_model_args_old(gc, dm, guest_config, info, state);
+        return libxl__build_device_model_args_old(gc, dm,
+                                                  guest_domid, guest_config,
+                                                  state);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        return libxl__build_device_model_args_new(gc, dm, guest_config, info, state);
+        return libxl__build_device_model_args_new(gc, dm,
+                                                  guest_domid, guest_config,
+                                                  state);
     default:
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d",
                          guest_config->b_info.device_model_version);
@@ -632,7 +632,9 @@ static int libxl__vfb_and_vkb_from_hvm_g
     return 0;
 }
 
-static int libxl__write_dmargs(libxl__gc *gc, int domid, int guest_domid, char **args)
+static int libxl__write_stub_dmargs(libxl__gc *gc,
+                                    int dm_domid, int guest_domid,
+                                    char **args)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int i;
@@ -644,7 +646,7 @@ static int libxl__write_dmargs(libxl__gc
 
     roperm[0].id = 0;
     roperm[0].perms = XS_PERM_NONE;
-    roperm[1].id = domid;
+    roperm[1].id = dm_domid;
     roperm[1].perms = XS_PERM_READ;
 
     vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/vm", guest_domid));
@@ -681,8 +683,8 @@ retry_transaction:
 }
 
 static int libxl__create_stubdom(libxl__gc *gc,
+                                 int guest_domid,
                                  libxl_domain_config *guest_config,
-                                 libxl_device_model_info *info,
                                  libxl__domain_build_state *d_state,
                                  libxl__spawner_starting **starting_r)
 {
@@ -693,12 +695,11 @@ static int libxl__create_stubdom(libxl__
     libxl_device_vfb vfb;
     libxl_device_vkb vkb;
     libxl__domain_build_state stubdom_state;
-    uint32_t domid;
+    uint32_t dm_domid;
     char **args;
     struct xs_permissions perm[2];
     xs_transaction_t t;
     libxl__spawner_starting *dm_starting = 0;
-    libxl_device_model_info xenpv_dm_info;
 
     if (guest_config->b_info.device_model_version !=
         LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
@@ -708,7 +709,8 @@ static int libxl__create_stubdom(libxl__
 
     memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
     dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
-    dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid));
+    dm_config.c_info.name = libxl__sprintf(gc, "%s-dm",
+                                    libxl__domid_to_name(gc, guest_domid));
 
     libxl_uuid_generate(&dm_config.c_info.uuid);
 
@@ -721,7 +723,7 @@ static int libxl__create_stubdom(libxl__
     dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV;
     dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
                                               libxl_xenfirmwaredir_path());
-    dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid);
+    dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
     dm_config.b_info.u.pv.ramdisk.path = "";
     dm_config.b_info.u.pv.features = "";
 
@@ -746,64 +748,74 @@ static int libxl__create_stubdom(libxl__
     dm_config.num_vkbs = 1;
 
     /* fixme: this function can leak the stubdom if it fails */
-    domid = 0;
-    ret = libxl__domain_make(gc, &dm_config.c_info, &domid);
+    dm_domid = 0;
+    ret = libxl__domain_make(gc, &dm_config.c_info, &dm_domid);
     if (ret)
         goto out;
-    ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &stubdom_state);
+    ret = libxl__domain_build(gc, &dm_config.b_info, dm_domid, &stubdom_state);
     if (ret)
         goto out;
 
-    args = libxl__build_device_model_args(gc, "stubdom-dm",
-                                          guest_config, info, d_state);
+    args = libxl__build_device_model_args(gc, "stubdom-dm", guest_domid,
+                                          guest_config, d_state);
     if (!args) {
         ret = ERROR_FAIL;
         goto out;
     }
 
-    libxl__write_dmargs(gc, domid, info->domid, args);
+    libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args);
     libxl__xs_write(gc, XBT_NULL,
-                   libxl__sprintf(gc, "%s/image/device-model-domid", libxl__xs_get_dompath(gc, info->domid)),
-                   "%d", domid);
+                   libxl__sprintf(gc, "%s/image/device-model-domid",
+                                  libxl__xs_get_dompath(gc, guest_domid)),
+                   "%d", dm_domid);
     libxl__xs_write(gc, XBT_NULL,
-                   libxl__sprintf(gc, "%s/target", libxl__xs_get_dompath(gc, domid)),
-                   "%d", info->domid);
-    ret = xc_domain_set_target(ctx->xch, domid, info->domid);
+                   libxl__sprintf(gc, "%s/target",
+                                  libxl__xs_get_dompath(gc, dm_domid)),
+                   "%d", guest_domid);
+    ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting target domain %d -> %d", domid, info->domid);
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+                         "setting target domain %d -> %d",
+                         dm_domid, guest_domid);
         ret = ERROR_FAIL;
         goto out_free;
     }
-    xs_set_target(ctx->xsh, domid, info->domid);
+    xs_set_target(ctx->xsh, dm_domid, guest_domid);
 
-    perm[0].id = domid;
+    perm[0].id = dm_domid;
     perm[0].perms = XS_PERM_NONE;
-    perm[1].id = info->domid;
+    perm[1].id = guest_domid;
     perm[1].perms = XS_PERM_READ;
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
-    xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid));
-    xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid), perm, ARRAY_SIZE(perm));
-    xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/%d/device/vfs", domid));
-    xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/%d/device/vfs",domid), perm, ARRAY_SIZE(perm));
+    xs_mkdir(ctx->xsh, t,
+        libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid));
+    xs_set_permissions(ctx->xsh, t,
+        libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid),
+                       perm, ARRAY_SIZE(perm));
+    xs_mkdir(ctx->xsh, t,
+        libxl__sprintf(gc, "/local/domain/%d/device/vfs", dm_domid));
+    xs_set_permissions(ctx->xsh, t,
+        libxl__sprintf(gc, "/local/domain/%d/device/vfs", dm_domid),
+                       perm, ARRAY_SIZE(perm));
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;
 
     for (i = 0; i < dm_config.num_disks; i++) {
-        ret = libxl_device_disk_add(ctx, domid, &dm_config.disks[i]);
+        ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i]);
         if (ret)
             goto out_free;
     }
     for (i = 0; i < dm_config.num_vifs; i++) {
-        ret = libxl_device_nic_add(ctx, domid, &dm_config.vifs[i]);
+        ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i]);
         if (ret)
             goto out_free;
     }
-    ret = libxl_device_vfb_add(ctx, domid, &dm_config.vfbs[0]);
+    ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config.vfbs[0]);
     if (ret)
         goto out_free;
-    ret = libxl_device_vkb_add(ctx, domid, &dm_config.vkbs[0]);
+    ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config.vkbs[0]);
     if (ret)
         goto out_free;
 
@@ -828,14 +840,14 @@ retry_transaction:
             char *name;
             case STUBDOM_CONSOLE_LOGGING:
                 name = libxl__sprintf(gc, "qemu-dm-%s",
-                                      libxl_domid_to_name(ctx, info->domid));
+                                      libxl_domid_to_name(ctx, guest_domid));
                 libxl_create_logfile(ctx, name, &filename);
                 console[i].output = libxl__sprintf(gc, "file:%s", filename);
                 free(filename);
                 break;
             case STUBDOM_CONSOLE_SAVE:
                 console[i].output = libxl__sprintf(gc, "file:%s",
-                                libxl__device_model_savefile(gc, info->domid));
+                                libxl__device_model_savefile(gc, guest_domid));
                 break;
             case STUBDOM_CONSOLE_RESTORE:
                 if (d_state->saved_state)
@@ -846,17 +858,14 @@ retry_transaction:
                 console[i].output = "pty";
                 break;
         }
-        ret = libxl__device_console_add(gc, domid, &console[i],
+        ret = libxl__device_console_add(gc, dm_domid, &console[i],
                         i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL);
         if (ret)
             goto out_free;
     }
 
-    memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-
-    if (libxl__create_xenpv_qemu(gc, domid,
+    if (libxl__create_xenpv_qemu(gc, dm_domid,
                                  &dm_config,
-                                 &xenpv_dm_info,
                                  &stubdom_state,
                                  &dm_starting) < 0) {
         ret = ERROR_FAIL;
@@ -867,12 +876,12 @@ retry_transaction:
         goto out_free;
     }
 
-    libxl_domain_unpause(ctx, domid);
+    libxl_domain_unpause(ctx, dm_domid);
 
     if (starting_r) {
         *starting_r = calloc(1, sizeof(libxl__spawner_starting));
-        (*starting_r)->domid = info->domid;
-        (*starting_r)->dom_path = libxl__xs_get_dompath(gc, info->domid);
+        (*starting_r)->domid = guest_domid;
+        (*starting_r)->dom_path = libxl__xs_get_dompath(gc, guest_domid);
         (*starting_r)->for_spawn = NULL;
     }
 
@@ -885,15 +894,15 @@ out:
 }
 
 int libxl__create_device_model(libxl__gc *gc,
+                              int domid,
                               libxl_domain_config *guest_config,
-                              libxl_device_model_info *info,
                               libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const libxl_domain_create_info *c_info = &guest_config->c_info;
     const libxl_domain_build_info *b_info = &guest_config->b_info;
-    const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
+    const libxl_vnc_info *vnc = dm_vnc(guest_config);
     char *path, *logfile;
     int logfile_w, null;
     int rc;
@@ -905,7 +914,7 @@ int libxl__create_device_model(libxl__gc
     const char *dm;
 
     if (b_info->device_model_stubdomain) {
-        rc = libxl__create_stubdom(gc, guest_config, info, state, starting_r);
+        rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r);
         goto out;
     }
 
@@ -920,18 +929,18 @@ int libxl__create_device_model(libxl__gc
         rc = ERROR_FAIL;
         goto out;
     }
-    args = libxl__build_device_model_args(gc, dm, guest_config, info, state);
+    args = libxl__build_device_model_args(gc, dm, domid, guest_config, state);
     if (!args) {
         rc = ERROR_FAIL;
         goto out;
     }
 
-    path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", info->domid);
+    path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path),
                     "%s", libxl__domain_bios(gc, b_info));
 
-    path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid);
+    path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
                     "%d", !b_info->u.hvm.xen_platform_pci);
@@ -955,8 +964,8 @@ int libxl__create_device_model(libxl__gc
         p->for_spawn = NULL;
     }
 
-    p->domid = info->domid;
-    p->dom_path = libxl__xs_get_dompath(gc, info->domid);
+    p->domid = domid;
+    p->dom_path = libxl__xs_get_dompath(gc, domid);
     p->pid_path = "image/device-model-pid";
     if (!p->dom_path) {
         rc = ERROR_FAIL;
@@ -1078,14 +1087,6 @@ out:
     return ret;
 }
 
-static int libxl__build_xenpv_qemu_args(libxl__gc *gc,
-                                        uint32_t domid,
-                                        libxl_device_model_info *info)
-{
-    info->domid = domid;
-    return 0;
-}
-
 int libxl__need_xenpv_qemu(libxl__gc *gc,
         int nr_consoles, libxl_device_console *consoles,
         int nr_vfbs, libxl_device_vfb *vfbs,
@@ -1125,12 +1126,10 @@ out:
 
 int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                              libxl_domain_config *guest_config,
-                             libxl_device_model_info *info,
                              libxl__domain_build_state *state,
                              libxl__spawner_starting **starting_r)
 {
-    libxl__build_xenpv_qemu_args(gc, domid, info);
-    libxl__create_device_model(gc, guest_config, info, state, starting_r);
+    libxl__create_device_model(gc, domid, guest_config, state, starting_r);
     return 0;
 }
 
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl_dom.c	Thu Jan 12 16:22:39 2012 +0000
@@ -288,8 +288,7 @@ static int hvm_build_set_params(xc_inter
 }
 
 static const char *libxl__domain_firmware(libxl__gc *gc,
-                                          libxl_domain_build_info *info,
-                                          libxl_device_model_info *dm_info)
+                                          libxl_domain_build_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const char *firmware;
@@ -317,12 +316,11 @@ static const char *libxl__domain_firmwar
 
 int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
               libxl_domain_build_info *info,
-              libxl_device_model_info *dm_info,
               libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int ret, rc = ERROR_FAIL;
-    const char *firmware = libxl__domain_firmware(gc, info, dm_info);
+    const char *firmware = libxl__domain_firmware(gc, info);
 
     if (!firmware)
         goto out;
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Thu Jan 12 16:22:39 2012 +0000
@@ -234,7 +234,6 @@ _hidden int libxl__build_pv(libxl__gc *g
              libxl_domain_build_info *info, libxl__domain_build_state *state);
 _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
               libxl_domain_build_info *info,
-              libxl_device_model_info *dm_info,
               libxl__domain_build_state *state);
 
 _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
@@ -456,10 +455,11 @@ _hidden void libxl__exec(int stdinfd, in
                const char *arg0, char **args); // logs errors, never returns
 
 /* from xl_create */
-_hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid);
+_hidden int libxl__domain_make(libxl__gc *gc,
+                               libxl_domain_create_info *info,
+                               uint32_t *domid);
 _hidden int libxl__domain_build(libxl__gc *gc,
                                 libxl_domain_build_info *info,
-                                libxl_device_model_info *dm_info,
                                 uint32_t domid,
                                 libxl__domain_build_state *state);
 
@@ -467,13 +467,12 @@ _hidden int libxl__domain_build(libxl__g
 _hidden const char *libxl__domain_device_model(libxl__gc *gc,
                                         const libxl_domain_build_info *info);
 _hidden int libxl__create_device_model(libxl__gc *gc,
+                              int domid,
                               libxl_domain_config *guest_config,
-                              libxl_device_model_info *info,
                               libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                               libxl_domain_config *guest_config,
-                              libxl_device_model_info *dm_info,
                               libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
diff -r c7160a835d3c -r 1e558d62909f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jan 12 16:01:40 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Thu Jan 12 16:22:39 2012 +0000
@@ -289,8 +289,7 @@ static void dolog(const char *file, int 
 }
 
 static void printf_info(int domid,
-                        libxl_domain_config *d_config,
-                        libxl_device_model_info *dm_info)
+                        libxl_domain_config *d_config)
 {
     int i;
     libxl_dominfo info;
@@ -569,8 +568,7 @@ static void split_string_into_string_lis
 static void parse_config_data(const char *configfile_filename_report,
                               const char *configfile_data,
                               int configfile_len,
-                              libxl_domain_config *d_config,
-                              libxl_device_model_info *dm_info)
+                              libxl_domain_config *d_config)
 {
     const char *buf;
     long l;
@@ -1110,9 +1108,6 @@ skip_vfb:
         break;
     }
 
-    /* init dm from c and b */
-    if (libxl_init_dm_info(ctx, dm_info, c_info, b_info))
-        exit(1);
     /* parse device model arguments, this works for pv, hvm and stubdom */
     if (!xlu_cfg_get_string (config, "device_model", &buf, 0)) {
         fprintf(stderr,
@@ -1362,7 +1357,7 @@ struct domain_create {
     char **migration_domname_r; /* from malloc */
 };
 
-static int freemem(libxl_domain_build_info *b_info, libxl_device_model_info *dm_info)
+static int freemem(libxl_domain_build_info *b_info)
 {
     int rc, retries = 3;
     uint32_t need_memkb, free_memkb;
@@ -1370,7 +1365,7 @@ static int freemem(libxl_domain_build_in
     if (!autoballoon)
         return 0;
 
-    rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb);
+    rc = libxl_domain_need_memory(ctx, b_info, &need_memkb);
     if (rc < 0)
         return rc;
 
@@ -1553,7 +1548,7 @@ static int create_domain(struct domain_c
     if (!dom_info->quiet)
         printf("Parsing config file %s\n", config_file);
 
-    parse_config_data(config_file, config_data, config_len, &d_config, &d_config.dm_info);
+    parse_config_data(config_file, config_data, config_len, &d_config);
 
     if (migrate_fd >= 0) {
         if (d_config.c_info.name) {
@@ -1574,7 +1569,7 @@ static int create_domain(struct domain_c
     }
 
     if (debug || dom_info->dryrun)
-        printf_info(-1, &d_config, &d_config.dm_info);
+        printf_info(-1, &d_config);
 
     ret = 0;
     if (dom_info->dryrun)
@@ -1587,7 +1582,7 @@ start:
     if (rc < 0)
         goto error_out;
 
-    ret = freemem(&d_config.b_info, &d_config.dm_info);
+    ret = freemem(&d_config.b_info);
     if (ret < 0) {
         fprintf(stderr, "failed to free memory for the domain\n");
         ret = ERROR_FAIL;
@@ -2331,7 +2326,6 @@ static void list_domains_details(const l
     char *config_file;
     uint8_t *data;
     int i, len, rc;
-    libxl_device_model_info dm_info;
 
     for (i = 0; i < nb_domain; i++) {
         /* no detailed info available on dom0 */
@@ -2342,8 +2336,8 @@ static void list_domains_details(const l
             continue;
         CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid));
         memset(&d_config, 0x00, sizeof(d_config));
-        parse_config_data(config_file, (char *)data, len, &d_config, &dm_info);
-        printf_info(info[i].domid, &d_config, &dm_info);
+        parse_config_data(config_file, (char *)data, len, &d_config);
+        printf_info(info[i].domid, &d_config);
         libxl_domain_config_dispose(&d_config);
         free(data);
         free(config_file);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (19 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:29   ` Olaf Hering
  2012-01-16 16:50   ` [PATCH 21 of 32] libxl: drop vfs patch Ian Jackson
  2012-01-16 12:15 ` [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense Ian Campbell
                   ` (10 subsequent siblings)
  31 siblings, 2 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326386958 0
# Node ID 9771c7a1959e680ab8ef7de9008232770f04aecd
# Parent  1e558d62909f4f236bb5edd7019073593564ac31
libxl: drop vfs patch -- fsback/front were deleted some time ago

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 1e558d62909f -r 9771c7a1959e tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 16:22:39 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 16:49:18 2012 +0000
@@ -793,11 +793,6 @@ retry_transaction:
     xs_set_permissions(ctx->xsh, t,
         libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid),
                        perm, ARRAY_SIZE(perm));
-    xs_mkdir(ctx->xsh, t,
-        libxl__sprintf(gc, "/local/domain/%d/device/vfs", dm_domid));
-    xs_set_permissions(ctx->xsh, t,
-        libxl__sprintf(gc, "/local/domain/%d/device/vfs", dm_domid),
-                       perm, ARRAY_SIZE(perm));
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (20 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:04   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too Ian Campbell
                   ` (9 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326387397 0
# Node ID fa999f4bcd85526a9ad1a6649f4069497801c5cd
# Parent  9771c7a1959e680ab8ef7de9008232770f04aecd
libxl: only write "disable_pf" key to xenstore when it makes sense

This key is only used by the traditional qemu-dm when servicing an HVM domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 9771c7a1959e -r fa999f4bcd85 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 16:49:18 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 16:56:37 2012 +0000
@@ -937,8 +937,12 @@ int libxl__create_device_model(libxl__gc
 
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
-    libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
-                    "%d", !b_info->u.hvm.xen_platform_pci);
+
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
+        b_info->device_model_version
+        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL)
+        libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
+                        "%d", !b_info->u.hvm.xen_platform_pci);
 
     libxl_create_logfile(ctx,
                          libxl__sprintf(gc, "qemu-dm-%s", c_info->name),

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (21 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:09   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type Ian Campbell
                   ` (8 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326388309 0
# Node ID 0d3abdb6c01894e4e07400317a0b49433dbaf1a5
# Parent  fa999f4bcd85526a9ad1a6649f4069497801c5cd
libxl: use libxl_*_init internally too

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r fa999f4bcd85 -r 0d3abdb6c018 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Jan 12 16:56:37 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Thu Jan 12 17:11:49 2012 +0000
@@ -614,12 +614,16 @@ static int libxl__vfb_and_vkb_from_hvm_g
                                         libxl_device_vkb *vkb)
 {
     const libxl_domain_build_info *b_info = &guest_config->b_info;
+    int ret;
 
     if (b_info->type != LIBXL_DOMAIN_TYPE_HVM)
         return ERROR_INVAL;
 
-    memset(vfb, 0x00, sizeof(libxl_device_vfb));
-    memset(vkb, 0x00, sizeof(libxl_device_vkb));
+    ret = libxl_device_vfb_init(CTX, vfb);
+    if (ret) return ret;
+
+    ret = libxl_device_vkb_init(CTX, vkb);
+    if (ret) return ret;
 
     vfb->backend_domid = 0;
     vfb->devid = 0;
@@ -707,14 +711,18 @@ static int libxl__create_stubdom(libxl__
         goto out;
     }
 
-    memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
+    ret = libxl_init_create_info(CTX, &dm_config.c_info);
+    if (ret) goto out;
+
     dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
     dm_config.c_info.name = libxl__sprintf(gc, "%s-dm",
                                     libxl__domid_to_name(gc, guest_domid));
 
     libxl_uuid_generate(&dm_config.c_info.uuid);
 
-    memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info));
+    ret = libxl_init_build_info(CTX, &dm_config.b_info, &dm_config.c_info);
+    if (ret) goto out;
+
     dm_config.b_info.type = dm_config.c_info.type;
     dm_config.b_info.max_vcpus = 1;
     dm_config.b_info.max_memkb = 32 * 1024;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (22 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:06   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool Ian Campbell
                   ` (7 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326470399 0
# Node ID 7e9f3ce2cd1f05ae30727bed05f295c7fdfbb2ea
# Parent  0d3abdb6c01894e4e07400317a0b49433dbaf1a5
libxl: add new "defbool" built in type.

This type is a but like a "boolean" but with a third state "default" (so really
I suppose its a tristate).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/gentest.py
--- a/tools/libxl/gentest.py	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/gentest.py	Fri Jan 13 15:59:59 2012 +0000
@@ -19,7 +19,8 @@ def randomize_case(s):
 def randomize_enum(e):
     return random.choice([v.name for v in e.values])
 
-handcoded = ["libxl_cpumap", "libxl_key_value_list",
+handcoded = ["libxl_defbool", # Temp until a user appears in the next patch
+             "libxl_cpumap", "libxl_key_value_list",
              "libxl_cpuid_policy_list", "libxl_file_reference",
              "libxl_string_list", "libxl_cpuarray"]
 
@@ -54,6 +55,8 @@ def gen_rand_init(ty, v, indent = "    "
               ty.pass_arg(v, parent is None))
     elif ty.typename in ["bool"]:
         s += "%s = rand() %% 2;\n" % v
+    elif ty.typename in ["libxl_defbool"]:
+        s += "libxl_defbool_set(%s, !!rand() %% 1);\n" % v
     elif ty.typename in ["char *"]:
         s += "%s = rand_str();\n" % v
     elif ty.private:
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxl.c	Fri Jan 13 15:59:59 2012 +0000
@@ -126,6 +126,47 @@ void libxl_key_value_list_dispose(libxl_
     free(kvl);
 }
 
+#define LIBXL__DEFBOOL_DEFAULT (0)
+#define LIBXL__DEFBOOL_FALSE (-1)
+#define LIBXL__DEFBOOL_TRUE (1)
+
+void libxl_defbool_set(libxl_defbool *db, bool b)
+{
+    db->val = b ? LIBXL__DEFBOOL_TRUE : LIBXL__DEFBOOL_FALSE;
+}
+
+void libxl_defbool_unset(libxl_defbool *db)
+{
+    db->val = LIBXL__DEFBOOL_DEFAULT;
+}
+
+bool libxl_defbool_is_default(libxl_defbool db)
+{
+    return !db.val;
+}
+
+void libxl_defbool_setdefault(libxl_defbool *db, bool b)
+{
+    if (libxl_defbool_is_default(*db))
+        libxl_defbool_set(db, b);
+}
+
+bool libxl_defbool_val(libxl_defbool db)
+{
+    assert(!libxl_defbool_is_default(db));
+    return db.val > 0;
+}
+
+const char *libxl_defbool_to_string(libxl_defbool b)
+{
+    if (b.val < 0)
+        return "False";
+    else if (b.val > 0)
+        return "True";
+    else
+        return "<default>";
+}
+
 /******************************************************************************/
 
 
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxl.h	Fri Jan 13 15:59:59 2012 +0000
@@ -199,6 +199,30 @@ typedef struct {
     int v;
 } libxl_enum_string_table;
 
+/*
+ * A boolean variable with an explicit default state.
+ *
+ * Users should treat this struct as opaque and use the following
+ * defined macros and accessor functions.
+ *
+ * To allow users of the library to naively select all defaults this
+ * state is represented as 0. False is < 0 and True is > 0.
+ */
+typedef struct {
+    int val;
+} libxl_defbool;
+
+void libxl_defbool_set(libxl_defbool *db, bool b);
+/* Resets to default */
+void libxl_defbool_unset(libxl_defbool *db);
+/* Sets db only if it is currently == default */
+void libxl_defbool_setdefault(libxl_defbool *db, bool b);
+bool libxl_defbool_is_default(libxl_defbool db);
+/* db must not be == default */
+bool libxl_defbool_val(libxl_defbool db);
+
+const char *libxl_defbool_to_string(libxl_defbool b);
+
 typedef struct libxl__ctx libxl_ctx;
 
 #include "_libxl_types.h"
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxl_json.c
--- a/tools/libxl/libxl_json.c	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxl_json.c	Fri Jan 13 15:59:59 2012 +0000
@@ -87,6 +87,12 @@ yajl_gen_status libxl__yajl_gen_enum(yaj
 /*
  * YAJL generators for builtin libxl types.
  */
+yajl_gen_status libxl_defbool_gen_json(yajl_gen hand,
+                                       libxl_defbool *db)
+{
+    return libxl__yajl_gen_asciiz(hand, libxl_defbool_to_string(*db));
+}
+
 yajl_gen_status libxl_uuid_gen_json(yajl_gen hand,
                                     libxl_uuid *uuid)
 {
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Fri Jan 13 15:59:59 2012 +0000
@@ -5,6 +5,8 @@
 
 namespace("libxl_")
 
+libxl_defbool = Builtin("defbool", passby=PASS_BY_REFERENCE)
+
 libxl_domid = Builtin("domid", json_fn = "yajl_gen_integer", autogenerate_json = False)
 libxl_uuid = Builtin("uuid", passby=PASS_BY_REFERENCE)
 libxl_mac = Builtin("mac", passby=PASS_BY_REFERENCE)
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxlu_cfg.c
--- a/tools/libxl/libxlu_cfg.c	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxlu_cfg.c	Fri Jan 13 15:59:59 2012 +0000
@@ -235,6 +235,17 @@ int xlu_cfg_get_long(const XLU_Config *c
     return 0;
 }
 
+int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, libxl_defbool *b,
+                     int dont_warn)
+{
+    int ret;
+    long l;
+
+    ret = xlu_cfg_get_long(cfg, n, &l, dont_warn);
+    if (ret) return ret;
+    libxl_defbool_set(b, !!l);
+    return 0;
+}
 
 int xlu_cfg_get_list(const XLU_Config *cfg, const char *n,
                      XLU_ConfigList **list_r, int *entries_r, int dont_warn) {
diff -r 0d3abdb6c018 -r 7e9f3ce2cd1f tools/libxl/libxlutil.h
--- a/tools/libxl/libxlutil.h	Thu Jan 12 17:11:49 2012 +0000
+++ b/tools/libxl/libxlutil.h	Fri Jan 13 15:59:59 2012 +0000
@@ -52,6 +52,8 @@ int xlu_cfg_replace_string(const XLU_Con
                            char **value_r, int dont_warn);
 int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r,
                      int dont_warn);
+int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b,
+                     int dont_warn);
 
 int xlu_cfg_get_list(const XLU_Config*, const char *n,
                      XLU_ConfigList **list_r /* may be 0 */,

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (23 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:31   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 26 " Ian Campbell
                   ` (6 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326470400 0
# Node ID 87c469583499236e6a524f9c9271323ae91394fe
# Parent  7e9f3ce2cd1f05ae30727bed05f295c7fdfbb2ea
libxl: make boolean members of libxl_domain_create_info into libxl_defbool

All members of libxl_domain_create_info are now "0 == default".

It doesn't seem reasonble for the library to pick a default for the domain type
so reject as invalid.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/gentest.py
--- a/tools/libxl/gentest.py	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/gentest.py	Fri Jan 13 16:00:00 2012 +0000
@@ -19,8 +19,7 @@ def randomize_case(s):
 def randomize_enum(e):
     return random.choice([v.name for v in e.values])
 
-handcoded = ["libxl_defbool", # Temp until a user appears in the next patch
-             "libxl_cpumap", "libxl_key_value_list",
+handcoded = ["libxl_cpumap", "libxl_key_value_list",
              "libxl_cpuid_policy_list", "libxl_file_reference",
              "libxl_string_list", "libxl_cpuarray"]
 
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/libxl_create.c	Fri Jan 13 16:00:00 2012 +0000
@@ -60,13 +60,20 @@ void libxl_domain_config_dispose(libxl_d
 int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info)
 {
     memset(c_info, '\0', sizeof(*c_info));
-    c_info->xsdata = NULL;
-    c_info->platformdata = NULL;
-    c_info->hap = 1;
-    c_info->type = LIBXL_DOMAIN_TYPE_HVM;
-    c_info->oos = 1;
-    c_info->ssidref = 0;
-    c_info->poolid = 0;
+    return 0;
+}
+
+int libxl__domain_create_info_setdefaults(libxl__gc *gc,
+                                          libxl_domain_create_info *c_info)
+{
+    if (!c_info->type)
+        return ERROR_INVAL;
+
+    if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        libxl_defbool_setdefault(&c_info->hap, true);
+        libxl_defbool_setdefault(&c_info->oos, true);
+    }
+
     return 0;
 }
 
@@ -325,8 +332,8 @@ int libxl__domain_make(libxl__gc *gc, li
     flags = 0;
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
         flags |= XEN_DOMCTL_CDF_hvm_guest;
-        flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
-        flags |= info->oos ? 0 : XEN_DOMCTL_CDF_oos_off;
+        flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
+        flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
     }
     *domid = -1;
 
@@ -456,6 +463,9 @@ static int do_domain_create(libxl__gc *g
 
     domid = 0;
 
+    ret = libxl__domain_create_info_setdefaults(gc, &d_config->c_info);
+    if (ret) goto error_out;
+
     ret = libxl__domain_make(gc, &d_config->c_info, &domid);
     if (ret) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Fri Jan 13 16:00:00 2012 +0000
@@ -749,6 +749,9 @@ static int libxl__create_stubdom(libxl__
     dm_config.vifs = guest_config->vifs;
     dm_config.num_vifs = guest_config->num_vifs;
 
+    ret = libxl__domain_create_info_setdefaults(gc, &dm_config.c_info);
+    if (ret) goto out;
+
     libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
     dm_config.vfbs = &vfb;
     dm_config.num_vfbs = 1;
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Fri Jan 13 16:00:00 2012 +0000
@@ -224,6 +224,15 @@ typedef struct {
     char *saved_state;
 } libxl__domain_build_state;
 
+/*
+ * Idempotently set the defaults for various user provided data structures.
+ *
+ * All libxl API functions are expected to have arranged for this to
+ * be called before using any values within these structures.
+ */
+int libxl__domain_create_info_setdefaults(libxl__gc *gc,
+                                          libxl_domain_create_info *c_info);
+
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
               libxl_domain_build_info *info, libxl__domain_build_state *state);
 _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid,
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Fri Jan 13 16:00:00 2012 +0000
@@ -180,8 +180,8 @@ libxl_version_info = Struct("version_inf
 
 libxl_domain_create_info = Struct("domain_create_info",[
     ("type",         libxl_domain_type),
-    ("hap",          bool),
-    ("oos",          bool),
+    ("hap",          libxl_defbool),
+    ("oos",          libxl_defbool),
     ("ssidref",      uint32),
     ("name",         string),
     ("uuid",         libxl_uuid),
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Fri Jan 13 16:00:00 2012 +0000
@@ -300,8 +300,8 @@ static void printf_info(int domid,
     printf("(domain\n\t(domid %d)\n", domid);
     printf("\t(create_info)\n");
     printf("\t(hvm %d)\n", c_info->type == LIBXL_DOMAIN_TYPE_HVM);
-    printf("\t(hap %d)\n", c_info->hap);
-    printf("\t(oos %d)\n", c_info->oos);
+    printf("\t(hap %s)\n", libxl_defbool_to_string(c_info->hap));
+    printf("\t(oos %s)\n", libxl_defbool_to_string(c_info->oos));
     printf("\t(ssidref %d)\n", c_info->ssidref);
     printf("\t(name %s)\n", c_info->name);
 
@@ -614,8 +614,7 @@ static void parse_config_data(const char
         !strncmp(buf, "hvm", strlen(buf)))
         c_info->type = LIBXL_DOMAIN_TYPE_HVM;
 
-    if (!xlu_cfg_get_long (config, "hap", &l, 0))
-        c_info->hap = l;
+    xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);
 
     if (xlu_cfg_replace_string (config, "name", &c_info->name, 0)) {
         fprintf(stderr, "Domain name must be specified.");
@@ -631,8 +630,7 @@ static void parse_config_data(const char
         libxl_uuid_generate(&c_info->uuid);
     }
 
-    if (!xlu_cfg_get_long(config, "oos", &l, 0))
-        c_info->oos = l;
+    xlu_cfg_get_defbool(config, "oos", &c_info->oos, 0);
 
     if (!xlu_cfg_get_string (config, "pool", &buf, 0)) {
         c_info->poolid = -1;
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/python/genwrap.py
--- a/tools/python/genwrap.py	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/python/genwrap.py	Fri Jan 13 16:00:00 2012 +0000
@@ -4,11 +4,13 @@ import sys,os
 
 import libxltypes
 
-(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5)
+(TYPE_DEFBOOL, TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(6)
 
 def py_type(ty):
     if ty == libxltypes.bool:
         return TYPE_BOOL
+    if ty.typename == "libxl_defbool":
+        return TYPE_DEFBOOL
     if isinstance(ty, libxltypes.Enumeration):
         return TYPE_UINT
     if isinstance(ty, libxltypes.Number):
@@ -44,6 +46,8 @@ def py_decls(ty):
         for f in ty.fields:
             if py_type(f.type) is not None:
                 continue
+            if py_type(f.type) == TYPE_DEFBOOL:
+                continue
             if ty.marshal_out():
                 l.append('_hidden PyObject *attrib__%s_get(%s *%s);'%(\
                     fsanitize(f.type.typename), f.type.typename, f.name))
@@ -62,6 +66,8 @@ def py_attrib_get(ty, f):
         l.append('    ret = (self->obj.%s) ? Py_True : Py_False;'%f.name)
         l.append('    Py_INCREF(ret);')
         l.append('    return ret;')
+    elif t == TYPE_DEFBOOL:
+        l.append('    return genwrap__defbool_get(&self->obj.%s);'%f.name)
     elif t == TYPE_INT:
         l.append('    return genwrap__ll_get(self->obj.%s);'%f.name)
     elif t == TYPE_UINT:
@@ -85,6 +91,8 @@ def py_attrib_set(ty, f):
     if t == TYPE_BOOL:
         l.append('    self->obj.%s = (NULL == v || Py_None == v || Py_False == v) ? 0 : 1;'%f.name)
         l.append('    return 0;')
+    elif t == TYPE_DEFBOOL:
+        l.append('    return genwrap__defbool_set(v, &self->obj.%s);'%f.name)
     elif t == TYPE_UINT or t == TYPE_INT:
         l.append('    %slong long tmp;'%(t == TYPE_UINT and 'unsigned ' or ''))
         l.append('    int ret;')
@@ -276,6 +284,8 @@ _hidden PyObject *genwrap__ull_get(unsig
 _hidden int genwrap__ull_set(PyObject *v, unsigned long long *val, unsigned long long mask);
 _hidden PyObject *genwrap__ll_get(long long val);
 _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask);
+_hidden PyObject *genwrap__defbool_get(libxl_defbool *db);
+_hidden int genwrap__defbool_set(PyObject *v, libxl_defbool *db);
 
 """ % " ".join(sys.argv))
     for ty in [ty for ty in types if isinstance(ty, libxltypes.Aggregate)]:
diff -r 7e9f3ce2cd1f -r 87c469583499 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c	Fri Jan 13 15:59:59 2012 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c	Fri Jan 13 16:00:00 2012 +0000
@@ -156,6 +156,21 @@ int genwrap__ll_set(PyObject *v, long lo
     return 0;
 }
 
+PyObject *genwrap__defbool_get(libxl_defbool *db)
+{
+    PyObject *ret;
+    ret = libxl_defbool_val(*db) ? Py_True : Py_False;
+    Py_INCREF(ret);
+    return ret;
+}
+
+int genwrap__defbool_set(PyObject *v, libxl_defbool *db)
+{
+    bool val = !(NULL == v || Py_None == v || Py_False == v);
+    libxl_defbool_set(db, val);
+    return 0;
+}
+
 static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len)
 {
     char *tmp;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 26 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (24 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:28   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options Ian Campbell
                   ` (5 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326471469 0
# Node ID 81def18dfda0899a8c7309f284d7ee4d6009da62
# Parent  87c469583499236e6a524f9c9271323ae91394fe
libxl: make boolean members of libxl_domain_create_info into libxl_defbool

This just covers the obvious ones.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl.c	Fri Jan 13 16:17:49 2012 +0000
@@ -2425,7 +2425,11 @@ int libxl_domain_need_memory(libxl_ctx *
                              uint32_t *need_memkb)
 {
     GC_INIT(ctx);
-    int rc = ERROR_INVAL;
+    int rc;
+
+    rc = libxl__domain_build_info_setdefaults(gc, b_info);
+    if (rc) goto out;
+
     *need_memkb = b_info->target_memkb;
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
@@ -2437,6 +2441,7 @@ int libxl_domain_need_memory(libxl_ctx *
         *need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY;
         break;
     default:
+        rc = ERROR_INVAL;
         goto out;
     }
     if (*need_memkb % (2 * 1024))
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl.h	Fri Jan 13 16:17:49 2012 +0000
@@ -280,7 +280,7 @@ int libxl_ctx_postfork(libxl_ctx *ctx);
 int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info);
 int libxl_init_build_info(libxl_ctx *ctx,
                           libxl_domain_build_info *b_info,
-                          libxl_domain_create_info *c_info);
+                          const libxl_domain_create_info *c_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_bootloader.c
--- a/tools/libxl/libxl_bootloader.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_bootloader.c	Fri Jan 13 16:17:49 2012 +0000
@@ -352,6 +352,9 @@ int libxl_run_bootloader(libxl_ctx *ctx,
     if (info->type != LIBXL_DOMAIN_TYPE_PV || !info->u.pv.bootloader)
         goto out;
 
+    rc = libxl__domain_build_info_setdefaults(gc, info);
+    if (rc) goto out;
+
     rc = ERROR_INVAL;
     if (!disk)
         goto out;
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_create.c	Fri Jan 13 16:17:49 2012 +0000
@@ -79,14 +79,13 @@ int libxl__domain_create_info_setdefault
 
 int libxl_init_build_info(libxl_ctx *ctx,
                           libxl_domain_build_info *b_info,
-                          libxl_domain_create_info *c_info)
+                          const libxl_domain_create_info *c_info)
 {
     memset(b_info, '\0', sizeof(*b_info));
     b_info->max_vcpus = 1;
     b_info->cur_vcpus = 1;
     b_info->max_memkb = 32 * 1024;
     b_info->target_memkb = b_info->max_memkb;
-    b_info->disable_migrate = 0;
     b_info->cpuid = NULL;
     b_info->shadow_memkb = 0;
     b_info->type = c_info->type;
@@ -100,17 +99,7 @@ int libxl_init_build_info(libxl_ctx *ctx
     case LIBXL_DOMAIN_TYPE_HVM:
         b_info->video_memkb = 8 * 1024;
         b_info->u.hvm.firmware = NULL;
-        b_info->u.hvm.pae = 1;
-        b_info->u.hvm.apic = 1;
-        b_info->u.hvm.acpi = 1;
-        b_info->u.hvm.acpi_s3 = 1;
-        b_info->u.hvm.acpi_s4 = 1;
-        b_info->u.hvm.nx = 1;
-        b_info->u.hvm.viridian = 0;
-        b_info->u.hvm.hpet = 1;
-        b_info->u.hvm.vpt_align = 1;
         b_info->u.hvm.timer_mode = 1;
-        b_info->u.hvm.nested_hvm = 0;
 
         b_info->u.hvm.stdvga = 0;
         b_info->u.hvm.vnc.enable = 1;
@@ -123,9 +112,7 @@ int libxl_init_build_info(libxl_ctx *ctx
         b_info->u.hvm.nographic = 0;
         b_info->u.hvm.serial = NULL;
         b_info->u.hvm.boot = strdup("cda");
-        b_info->u.hvm.usb = 0;
         b_info->u.hvm.usbdevice = NULL;
-        b_info->u.hvm.xen_platform_pci = 1;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         b_info->u.pv.slack_memkb = 8 * 1024;
@@ -139,6 +126,39 @@ int libxl_init_build_info(libxl_ctx *ctx
     return 0;
 }
 
+int libxl__domain_build_info_setdefaults(libxl__gc *gc,
+                                         libxl_domain_build_info *b_info)
+{
+    libxl_defbool_setdefault(&b_info->disable_migrate, false);
+    switch (b_info->type) {
+    case LIBXL_DOMAIN_TYPE_HVM:
+        libxl_defbool_setdefault(&b_info->u.hvm.pae, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.apic, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.acpi, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.acpi_s3, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.acpi_s4, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.nx, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.viridian, false);
+        libxl_defbool_setdefault(&b_info->u.hvm.hpet, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.vpt_align, true);
+        libxl_defbool_setdefault(&b_info->u.hvm.nested_hvm, false);
+        libxl_defbool_setdefault(&b_info->u.hvm.usb, false);
+        libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true);
+        break;
+    case LIBXL_DOMAIN_TYPE_PV:
+        libxl_defbool_setdefault(&b_info->u.pv.e820_host, false);
+        break;
+    default:
+        LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
+                   "invalid domain type %s in create info",
+                   libxl_domain_type_to_string(b_info->type));
+        return ERROR_INVAL;
+    }
+
+    return 0;
+}
+
+
 static int init_console_info(libxl_device_console *console, int dev_num)
 {
     memset(console, 0x00, sizeof(libxl_device_console));
@@ -181,11 +201,11 @@ int libxl__domain_build(libxl__gc *gc,
 
         localents = libxl__calloc(gc, 7, sizeof(char *));
         localents[0] = "platform/acpi";
-        localents[1] = (info->u.hvm.acpi) ? "1" : "0";
+        localents[1] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
         localents[2] = "platform/acpi_s3";
-        localents[3] = (info->u.hvm.acpi_s3) ? "1" : "0";
+        localents[3] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
         localents[4] = "platform/acpi_s4";
-        localents[5] = (info->u.hvm.acpi_s4) ? "1" : "0";
+        localents[5] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0";
 
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -478,6 +498,8 @@ static int do_domain_create(libxl__gc *g
             goto error_out;
     }
 
+    ret = libxl__domain_build_info_setdefaults(gc, &d_config->b_info);
+    if (ret) goto error_out;
 
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl__device_disk_set_backend(gc, &d_config->disks[i]);
@@ -615,7 +637,7 @@ static int do_domain_create(libxl__gc *g
     }
 
     if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
-        d_config->b_info.u.pv.e820_host) {
+        libxl_defbool_val(d_config->b_info.u.pv.e820_host)) {
         int rc;
         rc = libxl__e820_alloc(gc, domid, d_config);
         if (rc)
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Fri Jan 13 16:17:49 2012 +0000
@@ -200,7 +200,7 @@ static char ** libxl__build_device_model
         if (b_info->u.hvm.boot) {
             flexarray_vappend(dm_args, "-boot", b_info->u.hvm.boot, NULL);
         }
-        if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
+        if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) {
             flexarray_append(dm_args, "-usb");
             if (b_info->u.hvm.usbdevice) {
                 flexarray_vappend(dm_args,
@@ -210,7 +210,7 @@ static char ** libxl__build_device_model
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (b_info->u.hvm.acpi) {
+        if (libxl_defbool_val(b_info->u.hvm.acpi)) {
             flexarray_append(dm_args, "-acpi");
         }
         if (b_info->max_vcpus > 1) {
@@ -435,7 +435,7 @@ static char ** libxl__build_device_model
             flexarray_vappend(dm_args, "-boot",
                     libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL);
         }
-        if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
+        if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) {
             flexarray_append(dm_args, "-usb");
             if (b_info->u.hvm.usbdevice) {
                 flexarray_vappend(dm_args,
@@ -445,7 +445,7 @@ static char ** libxl__build_device_model
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (!b_info->u.hvm.acpi) {
+        if (!libxl_defbool_val(b_info->u.hvm.acpi)) {
             flexarray_append(dm_args, "-no-acpi");
         }
         if (b_info->max_vcpus > 1) {
@@ -751,6 +751,8 @@ static int libxl__create_stubdom(libxl__
 
     ret = libxl__domain_create_info_setdefaults(gc, &dm_config.c_info);
     if (ret) goto out;
+    ret = libxl__domain_build_info_setdefaults(gc, &dm_config.b_info);
+    if (ret) goto out;
 
     libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
     dm_config.vfbs = &vfb;
@@ -953,7 +955,7 @@ int libxl__create_device_model(libxl__gc
         b_info->device_model_version
         == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL)
         libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
-                        "%d", !b_info->u.hvm.xen_platform_pci);
+                    "%d", !libxl_defbool_val(b_info->u.hvm.xen_platform_pci));
 
     libxl_create_logfile(ctx,
                          libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_dom.c	Fri Jan 13 16:17:49 2012 +0000
@@ -95,7 +95,7 @@ int libxl__build_pre(libxl__gc *gc, uint
         abort();
     }
     xc_domain_set_tsc_info(ctx->xch, domid, tsc_mode, 0, 0, 0);
-    if ( info->disable_migrate )
+    if (libxl_defbool_val(info->disable_migrate))
         xc_domain_disable_migrate(ctx->xch, domid);
 
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
@@ -264,7 +264,7 @@ static int hvm_build_set_params(xc_inter
         return -1;
 
     va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
-    va_hvm->apic_mode = info->u.hvm.apic;
+    va_hvm->apic_mode = libxl_defbool_val(info->u.hvm.apic);
     va_hvm->nr_vcpus = info->max_vcpus;
     memcpy(va_hvm->vcpu_online, &info->cur_vcpus, sizeof(info->cur_vcpus));
     for (i = 0, sum = 0; i < va_hvm->length; i++)
@@ -274,14 +274,19 @@ static int hvm_build_set_params(xc_inter
 
     xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
     xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED,
+                     libxl_defbool_val(info->u.hvm.pae));
 #if defined(__i386__) || defined(__x86_64__)
-    xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) info->u.hvm.hpet);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN,
+                     libxl_defbool_val(info->u.hvm.viridian));
+    xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED,
+                     libxl_defbool_val(info->u.hvm.hpet));
 #endif
     xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->u.hvm.timer_mode);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->u.hvm.vpt_align);
-    xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM, info->u.hvm.nested_hvm);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN,
+                     libxl_defbool_val(info->u.hvm.vpt_align));
+    xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM,
+                     libxl_defbool_val(info->u.hvm.nested_hvm));
     xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
     xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
     return 0;
@@ -358,7 +363,7 @@ int libxl__domain_restore_common(libxl__
     case LIBXL_DOMAIN_TYPE_HVM:
         hvm = 1;
         superpages = 1;
-        pae = info->u.hvm.pae;
+        pae = libxl_defbool_val(info->u.hvm.pae);
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         hvm = 0;
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Fri Jan 13 16:17:49 2012 +0000
@@ -232,6 +232,8 @@ typedef struct {
  */
 int libxl__domain_create_info_setdefaults(libxl__gc *gc,
                                           libxl_domain_create_info *c_info);
+int libxl__domain_build_info_setdefaults(libxl__gc *gc,
+                                         libxl_domain_build_info *b_info);
 
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
               libxl_domain_build_info *info, libxl__domain_build_state *state);
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_pci.c	Fri Jan 13 16:17:49 2012 +0000
@@ -1381,7 +1381,7 @@ int libxl__e820_alloc(libxl__gc *gc, uin
         return ERROR_INVAL;
 
     b_info = &d_config->b_info;
-    if (!b_info->u.pv.e820_host)
+    if (!libxl_defbool_val(b_info->u.pv.e820_host))
         return ERROR_INVAL;
 
     rc = xc_get_machine_memory_map(ctx->xch, map, E820MAX);
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Fri Jan 13 16:17:49 2012 +0000
@@ -204,7 +204,7 @@ libxl_domain_build_info = Struct("domain
     ("target_memkb",    uint32),
     ("video_memkb",     uint32),
     ("shadow_memkb",    uint32),
-    ("disable_migrate", bool),
+    ("disable_migrate", libxl_defbool),
     ("cpuid",           libxl_cpuid_policy_list),
     ("type",            libxl_domain_type),
     
@@ -221,19 +221,19 @@ libxl_domain_build_info = Struct("domain
     ("extra_hvm",        libxl_string_list),
 
     ("u", KeyedUnion(None, libxl_domain_type, "type",
-                [("hvm", Struct(None, [("firmware", string),
-                                       ("pae", bool),
-                                       ("apic", bool),
-                                       ("acpi", bool),
-                                       ("acpi_s3", bool),
-                                       ("acpi_s4", bool),
-                                       ("nx", bool),
-                                       ("viridian", bool),
-                                       ("timeoffset", string),
-                                       ("hpet", bool),
-                                       ("vpt_align", bool),
-                                       ("timer_mode", integer),
-                                       ("nested_hvm", bool),
+                [("hvm", Struct(None, [("firmware",         string),
+                                       ("pae",              libxl_defbool),
+                                       ("apic",             libxl_defbool),
+                                       ("acpi",             libxl_defbool),
+                                       ("acpi_s3",          libxl_defbool),
+                                       ("acpi_s4",          libxl_defbool),
+                                       ("nx",               libxl_defbool),
+                                       ("viridian",         libxl_defbool),
+                                       ("timeoffset",       string),
+                                       ("hpet",             libxl_defbool),
+                                       ("vpt_align",        libxl_defbool),
+                                       ("timer_mode",       integer),
+                                       ("nested_hvm",       libxl_defbool),
                                        ("nographic",        bool),
                                        ("stdvga",           bool),
                                        ("vnc",              libxl_vnc_info),
@@ -246,13 +246,13 @@ libxl_domain_build_info = Struct("domain
                                        
                                        ("serial",           string),
                                        ("boot",             string),
-                                       ("usb",              bool),
+                                       ("usb",              libxl_defbool),
                                        # usbdevice:
                                        # - "tablet" for absolute mouse,
                                        # - "mouse" for PS/2 protocol relative mouse
                                        ("usbdevice",        string),
                                        ("soundhw",          string),
-                                       ("xen_platform_pci", bool),
+                                       ("xen_platform_pci", libxl_defbool),
                                        ])),
                  ("pv", Struct(None, [("kernel", libxl_file_reference),
                                       ("slack_memkb", uint32),
@@ -262,7 +262,7 @@ libxl_domain_build_info = Struct("domain
                                       ("ramdisk", libxl_file_reference),
                                       ("features", string, {'const': True}),
                                       # Use host's E820 for PCI passthrough.
-                                      ("e820_host", bool),
+                                      ("e820_host", libxl_defbool),
                                       ])),
                  ])),
     ],
diff -r 87c469583499 -r 81def18dfda0 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Jan 13 16:00:00 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Fri Jan 13 16:17:49 2012 +0000
@@ -330,7 +330,8 @@ static void printf_info(int domid,
     printf("\t(tsc_mode %s)\n", libxl_tsc_mode_to_string(b_info->tsc_mode));
     printf("\t(max_memkb %d)\n", b_info->max_memkb);
     printf("\t(target_memkb %d)\n", b_info->target_memkb);
-    printf("\t(nomigrate %d)\n", b_info->disable_migrate);
+    printf("\t(nomigrate %s)\n",
+           libxl_defbool_to_string(b_info->disable_migrate));
 
     if (c_info->type == LIBXL_DOMAIN_TYPE_PV && b_info->u.pv.bootloader) {
         int i;
@@ -350,16 +351,21 @@ static void printf_info(int domid,
         printf("\t\t\t(firmware %s)\n", b_info->u.hvm.firmware);
         printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb);
         printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb);
-        printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae);
-        printf("\t\t\t(apic %d)\n", b_info->u.hvm.apic);
-        printf("\t\t\t(acpi %d)\n", b_info->u.hvm.acpi);
-        printf("\t\t\t(nx %d)\n", b_info->u.hvm.nx);
-        printf("\t\t\t(viridian %d)\n", b_info->u.hvm.viridian);
-        printf("\t\t\t(hpet %d)\n", b_info->u.hvm.hpet);
-        printf("\t\t\t(vpt_align %d)\n", b_info->u.hvm.vpt_align);
+        printf("\t\t\t(pae %s)\n", libxl_defbool_to_string(b_info->u.hvm.pae));
+        printf("\t\t\t(apic %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.apic));
+        printf("\t\t\t(acpi %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.acpi));
+        printf("\t\t\t(nx %s)\n", libxl_defbool_to_string(b_info->u.hvm.nx));
+        printf("\t\t\t(viridian %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.viridian));
+        printf("\t\t\t(hpet %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.hpet));
+        printf("\t\t\t(vpt_align %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.vpt_align));
         printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode);
-        printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm);
-
+        printf("\t\t\t(nestedhvm %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.nested_hvm));
         printf("\t\t\t(stdvga %d)\n", b_info->u.hvm.stdvga);
         printf("\t\t\t(vnc %d)\n", b_info->u.hvm.vnc.enable);
         printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen);
@@ -381,7 +387,7 @@ static void printf_info(int domid,
         printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
         printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
         printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
-        printf("\t\t\t(usb %d)\n", b_info->u.hvm.usb);
+        printf("\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb));
         printf("\t\t\t(usbdevice %s)\n", b_info->u.hvm.usbdevice);
         printf("\t\t)\n");
         break;
@@ -390,7 +396,8 @@ static void printf_info(int domid,
         printf("\t\t\t(kernel %s)\n", b_info->u.pv.kernel.path);
         printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline);
         printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path);
-        printf("\t\t\t(e820_host %d)\n", b_info->u.pv.e820_host);
+        printf("\t\t\t(e820_host %s)\n",
+               libxl_defbool_to_string(b_info->u.pv.e820_host));
         printf("\t\t)\n");
         break;
     default:
@@ -699,8 +706,7 @@ static void parse_config_data(const char
         : libxl_get_required_shadow_memory(b_info->max_memkb,
                                            b_info->max_vcpus);
 
-    if (!xlu_cfg_get_long (config, "nomigrate", &l, 0))
-        b_info->disable_migrate = l;
+    xlu_cfg_get_defbool(config, "nomigrate", &b_info->disable_migrate, 0);
 
     if (!xlu_cfg_get_long(config, "tsc_mode", &l, 1)) {
         const char *s = libxl_tsc_mode_to_string(l);
@@ -736,28 +742,19 @@ static void parse_config_data(const char
 
         xlu_cfg_replace_string (config, "firmware_override",
                                 &b_info->u.hvm.firmware, 0);
-        if (!xlu_cfg_get_long (config, "pae", &l, 0))
-            b_info->u.hvm.pae = l;
-        if (!xlu_cfg_get_long (config, "apic", &l, 0))
-            b_info->u.hvm.apic = l;
-        if (!xlu_cfg_get_long (config, "acpi", &l, 0))
-            b_info->u.hvm.acpi = l;
-        if (!xlu_cfg_get_long (config, "acpi_s3", &l, 0))
-            b_info->u.hvm.acpi_s3 = l;
-        if (!xlu_cfg_get_long (config, "acpi_s4", &l, 0))
-            b_info->u.hvm.acpi_s4 = l;
-        if (!xlu_cfg_get_long (config, "nx", &l, 0))
-            b_info->u.hvm.nx = l;
-        if (!xlu_cfg_get_long (config, "viridian", &l, 0))
-            b_info->u.hvm.viridian = l;
-        if (!xlu_cfg_get_long (config, "hpet", &l, 0))
-            b_info->u.hvm.hpet = l;
-        if (!xlu_cfg_get_long (config, "vpt_align", &l, 0))
-            b_info->u.hvm.vpt_align = l;
+
+        xlu_cfg_get_defbool(config, "pae", &b_info->u.hvm.pae, 0);
+        xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
+        xlu_cfg_get_defbool(config, "acpi", &b_info->u.hvm.acpi, 0);
+        xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0);
+        xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
+        xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
+        xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
+        xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
+        xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
         if (!xlu_cfg_get_long (config, "timer_mode", &l, 0))
             b_info->u.hvm.timer_mode = l;
-        if (!xlu_cfg_get_long (config, "nestedhvm", &l, 0))
-            b_info->u.hvm.nested_hvm = l;
+        xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0);
         break;
     case LIBXL_DOMAIN_TYPE_PV:
     {
@@ -994,19 +991,10 @@ skip_vfb:
 
     /* To be reworked (automatically enabled) once the auto ballooning
      * after guest starts is done (with PCI devices passed in). */
-    if (!xlu_cfg_get_long (config, "e820_host", &l, 0)) {
-        switch (c_info->type) {
-        case LIBXL_DOMAIN_TYPE_HVM:
-            fprintf(stderr, "Can't do e820_host in HVM mode!");
-            break;
-        case LIBXL_DOMAIN_TYPE_PV:
-            if (l)
-                b_info->u.pv.e820_host = true;
-            break;
-        default:
-            abort();
-        }
-    }
+    if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+        xlu_cfg_get_defbool(config, "e820_host", &b_info->u.pv.e820_host, 0);
+    }
+
     if (!xlu_cfg_get_list (config, "pci", &pcis, 0, 0)) {
         int i;
         d_config->num_pcidevs = 0;
@@ -1024,7 +1012,7 @@ skip_vfb:
                 d_config->num_pcidevs++;
         }
         if (d_config->num_pcidevs && c_info->type == LIBXL_DOMAIN_TYPE_PV)
-            b_info->u.pv.e820_host = true;
+            libxl_defbool_set(&b_info->u.pv.e820_host, true);
     }
 
     switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) {
@@ -1201,12 +1189,12 @@ skip_vfb:
             b_info->u.hvm.gfx_passthru = l;
         xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
         xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
-        if (!xlu_cfg_get_long (config, "usb", &l, 0))
-            b_info->u.hvm.usb = l;
-        xlu_cfg_replace_string (config, "usbdevice", &b_info->u.hvm.usbdevice, 0);
+        xlu_cfg_get_defbool(config, "usb", &b_info->u.hvm.usb, 0);
+        xlu_cfg_replace_string (config, "usbdevice",
+                                &b_info->u.hvm.usbdevice, 0);
         xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0);
-        if (!xlu_cfg_get_long (config, "xen_platform_pci", &l, 0))
-            b_info->u.hvm.xen_platform_pci = l;
+        xlu_cfg_get_defbool(config, "xen_platform_pci",
+                            &b_info->u.hvm.xen_platform_pci, 0);
     }
 
     xlu_cfg_destroy(config);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (25 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 26 " Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:26   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 28 of 32 RFC] libxl: initialise NULL==default members of build info later Ian Campbell
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326474297 0
# Node ID b8426902efa002b6941aee6dff109aa33a4372c8
# Parent  81def18dfda0899a8c7309f284d7ee4d6009da62
libxl: use defbool for graphics related options

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 81def18dfda0 -r b8426902efa0 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/libxl/libxl.c	Fri Jan 13 17:04:57 2012 +0000
@@ -1993,16 +1993,24 @@ out:
 int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb)
 {
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
-    vfb->vnc.enable = 1;
-    vfb->vnc.passwd = NULL;
-    vfb->vnc.listen = strdup("127.0.0.1");
-    vfb->vnc.display = 0;
-    vfb->vnc.findunused = 1;
-    vfb->keymap = NULL;
-    vfb->sdl.enable = 0;
-    vfb->sdl.opengl = 0;
-    vfb->sdl.display = NULL;
-    vfb->sdl.xauthority = NULL;
+    return 0;
+}
+
+static int libxl__device_vfb_setdefaults(libxl__gc *gc,
+                                         libxl_device_vfb *vfb)
+{
+    libxl_defbool_setdefault(&vfb->vnc.enable, true);
+    if (libxl_defbool_val(vfb->vnc.enable)) {
+        if (!vfb->vnc.listen)
+            vfb->vnc.listen = strdup("127.0.0.1");
+        libxl_defbool_setdefault(&vfb->vnc.findunused, true);
+    }
+
+    libxl_defbool_setdefault(&vfb->sdl.enable, false);
+    if (libxl_defbool_val(vfb->sdl.enable)) {
+        libxl_defbool_setdefault(&vfb->sdl.opengl, false);
+    }
+
     return 0;
 }
 
@@ -2027,6 +2035,9 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
     libxl__device device;
     int rc;
 
+    rc = libxl__device_vfb_setdefaults(gc, vfb);
+    if (rc) goto out;
+
     front = flexarray_make(16, 1);
     if (!front) {
         rc = ERROR_NOMEM;
@@ -2046,17 +2057,17 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
     flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1));
     flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid));
     flexarray_append_pair(back, "vnc",
-                          libxl__sprintf(gc, "%d", vfb->vnc.enable));
+                          libxl_defbool_val(vfb->vnc.enable) ? "1" : "0");
     flexarray_append_pair(back, "vnclisten", vfb->vnc.listen);
     flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd);
     flexarray_append_pair(back, "vncdisplay",
                           libxl__sprintf(gc, "%d", vfb->vnc.display));
     flexarray_append_pair(back, "vncunused",
-                          libxl__sprintf(gc, "%d", vfb->vnc.findunused));
+                          libxl_defbool_val(vfb->vnc.findunused) ? "1" : "0");
     flexarray_append_pair(back, "sdl",
-                          libxl__sprintf(gc, "%d", vfb->sdl.enable));
+                          libxl_defbool_val(vfb->sdl.enable) ? "1" : "0");
     flexarray_append_pair(back, "opengl",
-                          libxl__sprintf(gc, "%d", vfb->sdl.opengl));
+                          libxl_defbool_val(vfb->sdl.opengl) ? "1" : "0");
     if (vfb->sdl.xauthority) {
         flexarray_append_pair(back, "xauthority", vfb->sdl.xauthority);
     }
diff -r 81def18dfda0 -r b8426902efa0 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/libxl/libxl_create.c	Fri Jan 13 17:04:57 2012 +0000
@@ -101,15 +101,9 @@ int libxl_init_build_info(libxl_ctx *ctx
         b_info->u.hvm.firmware = NULL;
         b_info->u.hvm.timer_mode = 1;
 
-        b_info->u.hvm.stdvga = 0;
-        b_info->u.hvm.vnc.enable = 1;
         b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
         b_info->u.hvm.vnc.display = 0;
-        b_info->u.hvm.vnc.findunused = 1;
         b_info->u.hvm.keymap = NULL;
-        b_info->u.hvm.sdl.enable = 0;
-        b_info->u.hvm.sdl.opengl = 0;
-        b_info->u.hvm.nographic = 0;
         b_info->u.hvm.serial = NULL;
         b_info->u.hvm.boot = strdup("cda");
         b_info->u.hvm.usbdevice = NULL;
@@ -144,6 +138,28 @@ int libxl__domain_build_info_setdefaults
         libxl_defbool_setdefault(&b_info->u.hvm.nested_hvm, false);
         libxl_defbool_setdefault(&b_info->u.hvm.usb, false);
         libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true);
+
+        libxl_defbool_setdefault(&b_info->u.hvm.stdvga, false);
+        libxl_defbool_setdefault(&b_info->u.hvm.vnc.enable, true);
+        if (libxl_defbool_val(b_info->u.hvm.vnc.enable)) {
+            libxl_defbool_setdefault(&b_info->u.hvm.vnc.findunused, true);
+        }
+
+        libxl_defbool_setdefault(&b_info->u.hvm.sdl.enable, false);
+        if (libxl_defbool_val(b_info->u.hvm.sdl.enable)) {
+            libxl_defbool_setdefault(&b_info->u.hvm.sdl.opengl, false);
+        }
+
+        libxl_defbool_setdefault(&b_info->u.hvm.spice.enable, false);
+        if (libxl_defbool_val(b_info->u.hvm.spice.enable)) {
+            libxl_defbool_setdefault(&b_info->u.hvm.spice.disable_ticketing,
+                                     false);
+            libxl_defbool_setdefault(&b_info->u.hvm.spice.agent_mouse, true);
+        }
+
+        libxl_defbool_setdefault(&b_info->u.hvm.nographic, false);
+
+        libxl_defbool_setdefault(&b_info->u.hvm.gfx_passthru, false);
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         libxl_defbool_setdefault(&b_info->u.pv.e820_host, false);
diff -r 81def18dfda0 -r b8426902efa0 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Fri Jan 13 17:04:57 2012 +0000
@@ -89,7 +89,7 @@ static const libxl_vnc_info *dm_vnc(cons
     } else if (guest_config->num_vfbs > 0) {
         vnc = &guest_config->vfbs[0].vnc;
     }
-    return vnc && vnc->enable ? vnc : NULL;
+    return vnc && libxl_defbool_val(vnc->enable) ? vnc : NULL;
 }
 
 static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config)
@@ -100,7 +100,7 @@ static const libxl_sdl_info *dm_sdl(cons
     } else if (guest_config->num_vfbs > 0) {
         sdl = &guest_config->vfbs[0].sdl;
     }
-    return sdl && sdl->enable ? sdl : NULL;
+    return sdl && libxl_defbool_val(sdl->enable) ? sdl : NULL;
 }
 
 static const char *dm_keymap(const libxl_domain_config *guest_config)
@@ -162,13 +162,13 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-vnc");
         flexarray_append(dm_args, vncarg);
 
-        if (vnc->findunused) {
+        if (libxl_defbool_val(vnc->findunused)) {
             flexarray_append(dm_args, "-vncunused");
         }
     }
     if (sdl) {
         flexarray_append(dm_args, "-sdl");
-        if (!sdl->opengl) {
+        if (!libxl_defbool_val(sdl->opengl)) {
             flexarray_append(dm_args, "-disable-opengl");
         }
         /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
@@ -183,7 +183,7 @@ static char ** libxl__build_device_model
             flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
         }
 
-        if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+        if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
             flexarray_append(dm_args, "-nographic");
         }
 
@@ -193,7 +193,7 @@ static char ** libxl__build_device_model
                                    libxl__sizekb_to_mb(b_info->video_memkb)),
                     NULL);
         }
-        if (b_info->u.hvm.stdvga) {
+        if (libxl_defbool_val(b_info->u.hvm.stdvga)) {
             flexarray_append(dm_args, "-std-vga");
         }
 
@@ -246,7 +246,7 @@ static char ** libxl__build_device_model
         if ( ioemu_vifs == 0 ) {
             flexarray_vappend(dm_args, "-net", "none", NULL);
         }
-        if (b_info->u.hvm.gfx_passthru) {
+        if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
     } else {
@@ -299,7 +299,7 @@ static char *dm_spice_options(libxl__gc 
         return NULL;
     }
 
-    if (!spice->disable_ticketing) {
+    if (!libxl_defbool_val(spice->disable_ticketing)) {
         if (!spice->passwd) {
             LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
                        "spice ticketing is enabled but missing password");
@@ -315,12 +315,12 @@ static char *dm_spice_options(libxl__gc 
                          spice->port, spice->tls_port);
     if (spice->host)
         opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host);
-    if (spice->disable_ticketing)
+    if (libxl_defbool_val(spice->disable_ticketing))
         opt = libxl__sprintf(gc, "%s,disable-ticketing", opt);
     else
         opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd);
     opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt,
-                         spice->agent_mouse ? "on" : "off");
+                         libxl_defbool_val(spice->agent_mouse) ? "on" : "off");
     return opt;
 }
 
@@ -387,11 +387,11 @@ static char ** libxl__build_device_model
         if (strchr(listen, ':') != NULL)
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s%s", listen,
-                        vnc->findunused ? ",to=99" : ""));
+                        libxl_defbool_val(vnc->findunused) ? ",to=99" : ""));
         else
             flexarray_append(dm_args,
                     libxl__sprintf(gc, "%s:%d%s", listen, display,
-                        vnc->findunused ? ",to=99" : ""));
+                        libxl_defbool_val(vnc->findunused) ? ",to=99" : ""));
     }
     if (sdl) {
         flexarray_append(dm_args, "-sdl");
@@ -413,11 +413,11 @@ static char ** libxl__build_device_model
             flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
         }
 
-        if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+        if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
             flexarray_append(dm_args, "-nographic");
         }
 
-        if (b_info->u.hvm.spice.enable) {
+        if (libxl_defbool_val(b_info->u.hvm.spice.enable)) {
             const libxl_spice_info *spice = &b_info->u.hvm.spice;
             char *spiceoptions = dm_spice_options(gc, spice);
             if (!spiceoptions)
@@ -427,7 +427,7 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, spiceoptions);
         }
 
-        if (b_info->u.hvm.stdvga) {
+        if (libxl_defbool_val(b_info->u.hvm.stdvga)) {
                 flexarray_vappend(dm_args, "-vga", "std", NULL);
         }
 
@@ -487,7 +487,7 @@ static char ** libxl__build_device_model
             flexarray_append(dm_args, "-net");
             flexarray_append(dm_args, "none");
         }
-        if (b_info->u.hvm.gfx_passthru) {
+        if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) {
             flexarray_append(dm_args, "-gfx_passthru");
         }
     } else {
diff -r 81def18dfda0 -r b8426902efa0 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Fri Jan 13 17:04:57 2012 +0000
@@ -98,31 +98,31 @@ libxl_tsc_mode = Enumeration("tsc_mode",
 # Complex libxl types
 #
 libxl_vnc_info = Struct("vnc_info", [
-    ("enable",        bool),
+    ("enable",        libxl_defbool),
     # "address:port" that should be listened on
     ("listen",        string),
     ("passwd",        string),
     ("display",       integer),
     # If set then try to find an unused port
-    ("findunused",    bool),
+    ("findunused",    libxl_defbool),
     ])
 
 libxl_spice_info = Struct("spice_info", [
-    ("enable",            bool),
+    ("enable",      libxl_defbool),
     # At least one of spice port or spicetls_post must be given
     ("port",        integer),
     ("tls_port",    integer),
     # Interface to bind to
     ("host",        string),
     # enable client connection with no password
-    ("disable_ticketing", bool),
+    ("disable_ticketing", libxl_defbool),
     ("passwd",      string),
-    ("agent_mouse", bool),
+    ("agent_mouse", libxl_defbool),
     ])
 
 libxl_sdl_info = Struct("sdl_info", [
-    ("enable",        bool),
-    ("opengl",        bool),
+    ("enable",        libxl_defbool),
+    ("opengl",        libxl_defbool),
     ("display",       string),
     ("xauthority",    string),
     ])
@@ -234,15 +234,15 @@ libxl_domain_build_info = Struct("domain
                                        ("vpt_align",        libxl_defbool),
                                        ("timer_mode",       integer),
                                        ("nested_hvm",       libxl_defbool),
-                                       ("nographic",        bool),
-                                       ("stdvga",           bool),
+                                       ("nographic",        libxl_defbool),
+                                       ("stdvga",           libxl_defbool),
                                        ("vnc",              libxl_vnc_info),
                                        # keyboard layout, default is en-us keyboard
                                        ("keymap",           string),
                                        ("sdl",              libxl_sdl_info),
                                        ("spice",            libxl_spice_info),
                                        
-                                       ("gfx_passthru",     bool),
+                                       ("gfx_passthru",     libxl_defbool),
                                        
                                        ("serial",           string),
                                        ("boot",             string),
diff -r 81def18dfda0 -r b8426902efa0 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Fri Jan 13 17:04:57 2012 +0000
@@ -366,25 +366,34 @@ static void printf_info(int domid,
         printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode);
         printf("\t\t\t(nestedhvm %s)\n",
                libxl_defbool_to_string(b_info->u.hvm.nested_hvm));
-        printf("\t\t\t(stdvga %d)\n", b_info->u.hvm.stdvga);
-        printf("\t\t\t(vnc %d)\n", b_info->u.hvm.vnc.enable);
+        printf("\t\t\t(stdvga %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.stdvga));
+        printf("\t\t\t(vnc %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.vnc.enable));
         printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen);
         printf("\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display);
-        printf("\t\t\t(vncunused %d)\n", b_info->u.hvm.vnc.findunused);
+        printf("\t\t\t(vncunused %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.vnc.findunused));
         printf("\t\t\t(keymap %s)\n", b_info->u.hvm.keymap);
-        printf("\t\t\t(sdl %d)\n", b_info->u.hvm.sdl.enable);
-        printf("\t\t\t(opengl %d)\n", b_info->u.hvm.sdl.opengl);
-        printf("\t\t\t(nographic %d)\n", b_info->u.hvm.nographic);
-        printf("\t\t\t(spice %d)\n", b_info->u.hvm.spice.enable);
+        printf("\t\t\t(sdl %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.sdl.enable));
+        printf("\t\t\t(opengl %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.sdl.opengl));
+        printf("\t\t\t(nographic %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.nographic));
+        printf("\t\t\t(spice %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.spice.enable));
         printf("\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port);
         printf("\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port);
         printf("\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host);
-        printf("\t\t\t(spicedisable_ticketing %d)\n",
-                    b_info->u.hvm.spice.disable_ticketing);
-        printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse);
+        printf("\t\t\t(spicedisable_ticketing %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.spice.disable_ticketing));
+        printf("\t\t\t(spiceagent_mouse %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.spice.agent_mouse));
 
         printf("\t\t\t(device_model %s)\n", b_info->device_model ? : "default");
-        printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
+        printf("\t\t\t(gfx_passthru %s)\n",
+               libxl_defbool_to_string(b_info->u.hvm.gfx_passthru));
         printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
         printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
         printf("\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb));
@@ -459,13 +468,17 @@ static void printf_info(int domid,
         printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid);
         printf("\t\t\t(frontend_domid %d)\n", domid);
         printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid);
-        printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable);
+        printf("\t\t\t(vnc %s)\n",
+               libxl_defbool_to_string(d_config->vfbs[i].vnc.enable));
         printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen);
         printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display);
-        printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused);
+        printf("\t\t\t(vncunused %s)\n",
+               libxl_defbool_to_string(d_config->vfbs[i].vnc.findunused));
         printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap);
-        printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl.enable);
-        printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].sdl.opengl);
+        printf("\t\t\t(sdl %s)\n",
+               libxl_defbool_to_string(d_config->vfbs[i].sdl.enable));
+        printf("\t\t\t(opengl %s)\n",
+               libxl_defbool_to_string(d_config->vfbs[i].sdl.opengl));
         printf("\t\t\t(display %s)\n", d_config->vfbs[i].sdl.display);
         printf("\t\t\t(xauthority %s)\n", d_config->vfbs[i].sdl.xauthority);
         printf("\t\t)\n");
@@ -950,7 +963,7 @@ skip:
                     break;
                 *p2 = '\0';
                 if (!strcmp(p, "vnc")) {
-                    vfb->vnc.enable = atoi(p2 + 1);
+                    libxl_defbool_set(&vfb->vnc.enable, atoi(p2 + 1));
                 } else if (!strcmp(p, "vnclisten")) {
                     free(vfb->vnc.listen);
                     vfb->vnc.listen = strdup(p2 + 1);
@@ -960,14 +973,14 @@ skip:
                 } else if (!strcmp(p, "vncdisplay")) {
                     vfb->vnc.display = atoi(p2 + 1);
                 } else if (!strcmp(p, "vncunused")) {
-                    vfb->vnc.findunused = atoi(p2 + 1);
+                    libxl_defbool_set(&vfb->vnc.findunused, atoi(p2 + 1));
                 } else if (!strcmp(p, "keymap")) {
                     free(vfb->keymap);
                     vfb->keymap = strdup(p2 + 1);
                 } else if (!strcmp(p, "sdl")) {
-                    vfb->sdl.enable = atoi(p2 + 1);
+                    libxl_defbool_set(&vfb->sdl.enable, atoi(p2 + 1));
                 } else if (!strcmp(p, "opengl")) {
-                    vfb->sdl.opengl = atoi(p2 + 1);
+                    libxl_defbool_set(&vfb->sdl.opengl, atoi(p2 + 1));
                 } else if (!strcmp(p, "display")) {
                     free(vfb->sdl.display);
                     vfb->sdl.display = strdup(p2 + 1);
@@ -1152,41 +1165,35 @@ skip_vfb:
 #undef parse_extra_args
 
     if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
-        if (!xlu_cfg_get_long (config, "stdvga", &l, 0))
-            b_info->u.hvm.stdvga = l;
-        if (!xlu_cfg_get_long (config, "vnc", &l, 0))
-            b_info->u.hvm.vnc.enable = l;
-        xlu_cfg_replace_string (config, "vnclisten", &b_info->u.hvm.vnc.listen, 0);
-        xlu_cfg_replace_string (config, "vncpasswd", &b_info->u.hvm.vnc.passwd, 0);
+        xlu_cfg_get_defbool(config, "stdvga", &b_info->u.hvm.stdvga, 0);
+        xlu_cfg_get_defbool(config, "vnc", &b_info->u.hvm.vnc.enable, 0);
+        xlu_cfg_replace_string (config, "vnclisten",
+                                &b_info->u.hvm.vnc.listen, 0);
+        xlu_cfg_replace_string (config, "vncpasswd",
+                                &b_info->u.hvm.vnc.passwd, 0);
         if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
             b_info->u.hvm.vnc.display = l;
-        if (!xlu_cfg_get_long (config, "vncunused", &l, 0))
-            b_info->u.hvm.vnc.findunused = l;
+        xlu_cfg_get_defbool(config, "vncunused",
+                            &b_info->u.hvm.vnc.findunused, 0);
         xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0);
-        if (!xlu_cfg_get_long (config, "sdl", &l, 0))
-            b_info->u.hvm.sdl.enable = l;
-        if (!xlu_cfg_get_long (config, "opengl", &l, 0))
-            b_info->u.hvm.sdl.opengl = l;
-        if (!xlu_cfg_get_long (config, "spice", &l, 0))
-            b_info->u.hvm.spice.enable = l;
+        xlu_cfg_get_defbool(config, "sdl", &b_info->u.hvm.sdl.enable, 0);
+        xlu_cfg_get_defbool(config, "opengl", &b_info->u.hvm.sdl.opengl, 0);
+        xlu_cfg_get_defbool (config, "spice", &b_info->u.hvm.spice.enable, 0);
         if (!xlu_cfg_get_long (config, "spiceport", &l, 0))
             b_info->u.hvm.spice.port = l;
         if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0))
             b_info->u.hvm.spice.tls_port = l;
         xlu_cfg_replace_string (config, "spicehost",
                                 &b_info->u.hvm.spice.host, 0);
-        if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0))
-            b_info->u.hvm.spice.disable_ticketing = l;
+        xlu_cfg_get_defbool(config, "spicedisable_ticketing",
+                            &b_info->u.hvm.spice.disable_ticketing, 0);
         xlu_cfg_replace_string (config, "spicepasswd",
                                 &b_info->u.hvm.spice.passwd, 0);
-        if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0))
-            b_info->u.hvm.spice.agent_mouse = l;
-        else
-            b_info->u.hvm.spice.agent_mouse = 1;
-        if (!xlu_cfg_get_long (config, "nographic", &l, 0))
-            b_info->u.hvm.nographic = l;
-        if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
-            b_info->u.hvm.gfx_passthru = l;
+        xlu_cfg_get_defbool(config, "spiceagent_mouse",
+                            &b_info->u.hvm.spice.agent_mouse, 0);
+        xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
+        xlu_cfg_get_defbool(config, "gfx_passthru", 
+                            &b_info->u.hvm.gfx_passthru, 0);
         xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
         xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
         xlu_cfg_get_defbool(config, "usb", &b_info->u.hvm.usb, 0);
diff -r 81def18dfda0 -r b8426902efa0 tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py	Fri Jan 13 17:04:57 2012 +0000
@@ -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_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),
     "libxl_mac":            ("int array",              "Mac_val(gc, lg, &%(c)s, %(o)s)",    "Val_mac(&%(c)s)"),
diff -r 81def18dfda0 -r b8426902efa0 tools/ocaml/libs/xl/xenlight_stubs.c
--- a/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 16:17:49 2012 +0000
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 17:04:57 2012 +0000
@@ -130,6 +130,19 @@ static int string_string_tuple_array_val
 
 #endif
 
+/* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */
+#define Val_none Val_int(0)
+#define Some_val(v) Field(v,0)
+
+static value Val_some(value v)
+{
+	CAMLparam1(v);
+	CAMLlocal1(some);
+	some = caml_alloc(1, 0);
+	Store_field(some, 0, v);
+	CAMLreturn(some);
+}
+
 static value Val_mac (libxl_mac *c_val)
 {
 	CAMLparam0();
@@ -182,6 +195,33 @@ static int Uuid_val(caml_gc *gc, struct 
 	CAMLreturn(0);
 }
 
+static value Val_defbool(libxl_defbool c_val)
+{
+	CAMLparam0();
+	CAMLlocal1(v);
+
+	if (libxl_defbool_is_default(c_val))
+		v = Val_none;
+	else {
+		bool b = libxl_defbool_val(c_val);
+		v = Val_some(b ? Val_bool(true) : Val_bool(false));
+	}
+	CAMLreturn(v);
+}
+
+static libxl_defbool Defbool_val(value v)
+{
+	CAMLparam1(v);
+	libxl_defbool db;
+	if (v == Val_none)
+		libxl_defbool_unset(&db);
+	else {
+		bool b = Bool_val(Some_val(v));
+		libxl_defbool_set(&db, b);
+	}
+	return db;
+}
+
 static value Val_hwcap(libxl_hwcap *c_val)
 {
 	CAMLparam0();

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 28 of 32 RFC] libxl: initialise NULL==default members of build info later
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (26 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 12:15 ` [PATCH 29 of 32 RFC] libxl: add named enum for timer mode Ian Campbell
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326712734 0
# Node ID 90fe4b95bdc935b2d5328603aa77d4de37253c36
# Parent  b8426902efa002b6941aee6dff109aa33a4372c8
libxl: initialise NULL==default members of build info later.

Specifically do it at setdefaults time instead of init time.

I'm not entirely sure if video_memkb can legitimately be 0. Hopefully this
corresponds to 'nographics' instead.

I think the rest are reasonable although it's not clear that shadow_memkb
doesn't belong in u.hvm I didn't change that here.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r b8426902efa0 -r 90fe4b95bdc9 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Fri Jan 13 17:04:57 2012 +0000
+++ b/tools/libxl/libxl_create.c	Mon Jan 16 11:18:54 2012 +0000
@@ -82,12 +82,6 @@ int libxl_init_build_info(libxl_ctx *ctx
                           const libxl_domain_create_info *c_info)
 {
     memset(b_info, '\0', sizeof(*b_info));
-    b_info->max_vcpus = 1;
-    b_info->cur_vcpus = 1;
-    b_info->max_memkb = 32 * 1024;
-    b_info->target_memkb = b_info->max_memkb;
-    b_info->cpuid = NULL;
-    b_info->shadow_memkb = 0;
     b_info->type = c_info->type;
 
     b_info->device_model_version =
@@ -97,16 +91,7 @@ int libxl_init_build_info(libxl_ctx *ctx
 
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
-        b_info->video_memkb = 8 * 1024;
-        b_info->u.hvm.firmware = NULL;
         b_info->u.hvm.timer_mode = 1;
-
-        b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
-        b_info->u.hvm.vnc.display = 0;
-        b_info->u.hvm.keymap = NULL;
-        b_info->u.hvm.serial = NULL;
-        b_info->u.hvm.boot = strdup("cda");
-        b_info->u.hvm.usbdevice = NULL;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         b_info->u.pv.slack_memkb = 8 * 1024;
@@ -123,9 +108,21 @@ int libxl_init_build_info(libxl_ctx *ctx
 int libxl__domain_build_info_setdefaults(libxl__gc *gc,
                                          libxl_domain_build_info *b_info)
 {
+    if (!b_info->max_vcpus)
+        b_info->max_vcpus = 1;
+    if (!b_info->cur_vcpus)
+        b_info->cur_vcpus = 1;
+    if (!b_info->max_memkb)
+        b_info->max_memkb = 32 * 1024;
+    if (!b_info->target_memkb)
+        b_info->target_memkb = b_info->max_memkb;
+
     libxl_defbool_setdefault(&b_info->disable_migrate, false);
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
+        if (!b_info->video_memkb)
+            b_info->video_memkb = 8 * 1024;
+
         libxl_defbool_setdefault(&b_info->u.hvm.pae, true);
         libxl_defbool_setdefault(&b_info->u.hvm.apic, true);
         libxl_defbool_setdefault(&b_info->u.hvm.acpi, true);
@@ -139,10 +136,15 @@ int libxl__domain_build_info_setdefaults
         libxl_defbool_setdefault(&b_info->u.hvm.usb, false);
         libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true);
 
+        if (!b_info->u.hvm.boot)
+            b_info->u.hvm.boot = strdup("cda");
+
         libxl_defbool_setdefault(&b_info->u.hvm.stdvga, false);
         libxl_defbool_setdefault(&b_info->u.hvm.vnc.enable, true);
         if (libxl_defbool_val(b_info->u.hvm.vnc.enable)) {
             libxl_defbool_setdefault(&b_info->u.hvm.vnc.findunused, true);
+            if (!b_info->u.hvm.vnc.listen)
+                b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
         }
 
         libxl_defbool_setdefault(&b_info->u.hvm.sdl.enable, false);

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (27 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 28 of 32 RFC] libxl: initialise NULL==default members of build info later Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:17   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 30 of 32 RFC] libxl: drop 8M slack for PV guests Ian Campbell
                   ` (2 subsequent siblings)
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326713149 0
# Node ID feeea78c60ef4a0ec5d4d827bb15cc004ece9774
# Parent  90fe4b95bdc935b2d5328603aa77d4de37253c36
libxl: add named enum for timer mode.

In order to have 0 == default the specific values are off-by-one from the
underlying domctl. I'm not sure I like this.

I looked at updating xl.cfg(5) for these while I was here but frankly, even
after reading the comment in xen/include/public/hvm/params.h, I don't have a
clue what they mean, no_missed_ticks_pending in particular might as well be
written in klingon...

For the same reason I didn't try and give the enum more user-friendly names.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_create.c	Mon Jan 16 11:25:49 2012 +0000
@@ -91,7 +91,6 @@ int libxl_init_build_info(libxl_ctx *ctx
 
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
-        b_info->u.hvm.timer_mode = 1;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         b_info->u.pv.slack_memkb = 8 * 1024;
@@ -122,6 +121,9 @@ int libxl__domain_build_info_setdefaults
     case LIBXL_DOMAIN_TYPE_HVM:
         if (!b_info->video_memkb)
             b_info->video_memkb = 8 * 1024;
+        if (b_info->u.hvm.timer_mode == LIBXL_TIMER_MODE_DEFAULT)
+            b_info->u.hvm.timer_mode =
+                LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS;
 
         libxl_defbool_setdefault(&b_info->u.hvm.pae, true);
         libxl_defbool_setdefault(&b_info->u.hvm.apic, true);
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_dom.c	Mon Jan 16 11:25:49 2012 +0000
@@ -248,6 +248,13 @@ out:
     return ret == 0 ? 0 : ERROR_FAIL;
 }
 
+static unsigned long timer_mode(const libxl_domain_build_info *info)
+{
+    const libxl_timer_mode mode = info->u.hvm.timer_mode;
+    assert(mode != LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS &&
+           mode <= LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING);
+    return ((unsigned long)mode) - 1;
+}
 static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
                                 libxl_domain_build_info *info,
                                 int store_evtchn, unsigned long *store_mfn,
@@ -282,7 +289,7 @@ static int hvm_build_set_params(xc_inter
     xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED,
                      libxl_defbool_val(info->u.hvm.hpet));
 #endif
-    xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->u.hvm.timer_mode);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, timer_mode(info));
     xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN,
                      libxl_defbool_val(info->u.hvm.vpt_align));
     xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM,
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Mon Jan 16 11:25:49 2012 +0000
@@ -94,6 +94,15 @@ libxl_tsc_mode = Enumeration("tsc_mode",
     (3, "native_paravirt"),
     ])
 
+# NB: specific values are + 1 from underlying hypercall value
+libxl_timer_mode = Enumeration("timer_mode", [
+    (0, "default"),
+    (1, "delay_for_missed_ticks"),
+    (2, "no_delay_for_missed_ticks"),
+    (3, "no_missed_ticks_pending"),
+    (4, "one_missed_tick_pending"),
+    ])
+
 #
 # Complex libxl types
 #
@@ -232,7 +241,7 @@ libxl_domain_build_info = Struct("domain
                                        ("timeoffset",       string),
                                        ("hpet",             libxl_defbool),
                                        ("vpt_align",        libxl_defbool),
-                                       ("timer_mode",       integer),
+                                       ("timer_mode",       libxl_timer_mode),
                                        ("nested_hvm",       libxl_defbool),
                                        ("nographic",        libxl_defbool),
                                        ("stdvga",           libxl_defbool),
diff -r 90fe4b95bdc9 -r feeea78c60ef tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Mon Jan 16 11:18:54 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Mon Jan 16 11:25:49 2012 +0000
@@ -363,7 +363,8 @@ static void printf_info(int domid,
                libxl_defbool_to_string(b_info->u.hvm.hpet));
         printf("\t\t\t(vpt_align %s)\n",
                libxl_defbool_to_string(b_info->u.hvm.vpt_align));
-        printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode);
+        printf("\t\t\t(timer_mode %s)\n",
+               libxl_timer_mode_to_string(b_info->u.hvm.timer_mode));
         printf("\t\t\t(nestedhvm %s)\n",
                libxl_defbool_to_string(b_info->u.hvm.nested_hvm));
         printf("\t\t\t(stdvga %s)\n",
@@ -765,8 +766,31 @@ static void parse_config_data(const char
         xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
-        if (!xlu_cfg_get_long (config, "timer_mode", &l, 0))
+
+        if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) {
+            /* enum is off by one from raw number */
+            const char *s = libxl_timer_mode_to_string(l++);
+            fprintf(stderr, "WARNING: specifying \"timer_mode\" as an integer is deprecated. "
+                    "Please use the named parameter variant. %s%s%s\n",
+                    s ? "e.g. timer_mode=\"" : "",
+                    s ? s : "",
+                    s ? "\"" : "");
+
+            if (l < LIBXL_TIMER_MODE_DEFAULT ||
+                l > LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING) {
+                fprintf(stderr, "ERROR: invalid value %ld for \"timer_mode\"\n", l);
+                exit (1);
+            }
             b_info->u.hvm.timer_mode = l;
+        } else if (!xlu_cfg_get_string(config, "timer_mode", &buf, 0)) {
+            fprintf(stderr, "got a timer mode string: \"%s\"\n", buf);
+            if (libxl_timer_mode_from_string(buf, &b_info->u.hvm.timer_mode)) {
+                fprintf(stderr, "ERROR: invalid value \"%s\" for \"timer_mode\"\n",
+                        buf);
+                exit (1);
+            }
+        }
+
         xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0);
         break;
     case LIBXL_DOMAIN_TYPE_PV:

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 30 of 32 RFC] libxl: drop 8M slack for PV guests
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (28 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 29 of 32 RFC] libxl: add named enum for timer mode Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 12:15 ` [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool Ian Campbell
  2012-01-16 12:15 ` [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible Ian Campbell
  31 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326713350 0
# Node ID 7ffc8e870fbb5a9edcd6f8d46f2b0296d38cb5ed
# Parent  feeea78c60ef4a0ec5d4d827bb15cc004ece9774
libxl: drop 8M slack for PV guests.

As far as I can tell this serves no purpose. I think it relates to the old
8M to "account for backend allocations" which we used to add. This leaves a bit
of unpopulated space in the Pseudo-physical address space which can be used by
backends when mapping foreign memory. However 8M is not representative of that
any more and modern kernels do not operate in this way anyway.

I suspect an argument could be made for removing this from the libxl API
altogether but instead lets jsut set the overhead to 0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r feeea78c60ef -r 7ffc8e870fbb tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Mon Jan 16 11:25:49 2012 +0000
+++ b/tools/libxl/libxl_create.c	Mon Jan 16 11:29:10 2012 +0000
@@ -89,18 +89,6 @@ int libxl_init_build_info(libxl_ctx *ctx
     b_info->device_model_stubdomain = false;
     b_info->device_model = NULL;
 
-    switch (b_info->type) {
-    case LIBXL_DOMAIN_TYPE_HVM:
-        break;
-    case LIBXL_DOMAIN_TYPE_PV:
-        b_info->u.pv.slack_memkb = 8 * 1024;
-        break;
-    default:
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                   "invalid domain type %s in create info",
-                   libxl_domain_type_to_string(b_info->type));
-        return ERROR_INVAL;
-    }
     return 0;
 }

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (29 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 30 of 32 RFC] libxl: drop 8M slack for PV guests Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 16:12   ` Ian Jackson
  2012-01-16 12:15 ` [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible Ian Campbell
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326713598 0
# Node ID a2dc899d0f229d82baca92a06b3b7a5b4d918324
# Parent  7ffc8e870fbb5a9edcd6f8d46f2b0296d38cb5ed
libxl: switch device model selection over to libxl_defbool

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 7ffc8e870fbb -r a2dc899d0f22 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Mon Jan 16 11:29:10 2012 +0000
+++ b/tools/libxl/libxl.c	Mon Jan 16 11:33:18 2012 +0000
@@ -2445,7 +2445,7 @@ int libxl_domain_need_memory(libxl_ctx *
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
-        if (b_info->device_model_stubdomain)
+        if (libxl_defbool_val(b_info->device_model_stubdomain))
             *need_memkb += 32 * 1024;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
diff -r 7ffc8e870fbb -r a2dc899d0f22 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Mon Jan 16 11:29:10 2012 +0000
+++ b/tools/libxl/libxl_create.c	Mon Jan 16 11:33:18 2012 +0000
@@ -84,17 +84,18 @@ int libxl_init_build_info(libxl_ctx *ctx
     memset(b_info, '\0', sizeof(*b_info));
     b_info->type = c_info->type;
 
-    b_info->device_model_version =
-        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
-    b_info->device_model_stubdomain = false;
-    b_info->device_model = NULL;
-
     return 0;
 }
 
 int libxl__domain_build_info_setdefaults(libxl__gc *gc,
                                          libxl_domain_build_info *b_info)
 {
+    if (!b_info->device_model_version)
+        b_info->device_model_version =
+            LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+
+    libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
     if (!b_info->cur_vcpus)
diff -r 7ffc8e870fbb -r a2dc899d0f22 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Mon Jan 16 11:29:10 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Mon Jan 16 11:33:18 2012 +0000
@@ -47,7 +47,7 @@ const char *libxl__domain_device_model(l
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const char *dm;
 
-    if (info->device_model_stubdomain)
+    if (libxl_defbool_val(info->device_model_stubdomain))
         return NULL;
 
     if (info->device_model) {
@@ -921,7 +921,7 @@ int libxl__create_device_model(libxl__gc
     char **pass_stuff;
     const char *dm;
 
-    if (b_info->device_model_stubdomain) {
+    if (libxl_defbool_val(b_info->device_model_stubdomain)) {
         rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r);
         goto out;
     }
diff -r 7ffc8e870fbb -r a2dc899d0f22 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl	Mon Jan 16 11:29:10 2012 +0000
+++ b/tools/libxl/libxl_types.idl	Mon Jan 16 11:33:18 2012 +0000
@@ -218,8 +218,8 @@ libxl_domain_build_info = Struct("domain
     ("type",            libxl_domain_type),
     
     ("device_model_version", libxl_device_model_version),
-    ("device_model_stubdomain", bool),
-    # you set device_model you must set device_model_version too
+    ("device_model_stubdomain", libxl_defbool),
+    # if you set device_model you must set device_model_version too
     ("device_model",     string),
 
     # extra parameters pass directly to qemu, NULL terminated
diff -r 7ffc8e870fbb -r a2dc899d0f22 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Mon Jan 16 11:29:10 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Mon Jan 16 11:33:18 2012 +0000
@@ -1166,8 +1166,8 @@ skip_vfb:
         }
     } else if (b_info->device_model)
         fprintf(stderr, "WARNING: device model override given without specific DM version\n");
-    if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0))
-        b_info->device_model_stubdomain = l;
+    xlu_cfg_get_defbool (config, "device_model_stubdomain_override",
+                         &b_info->device_model_stubdomain, 0);
 
 #define parse_extra_args(type)                                            \
     e = xlu_cfg_get_list_as_string_list(config, "device_model_args"#type, \

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
                   ` (30 preceding siblings ...)
  2012-01-16 12:15 ` [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool Ian Campbell
@ 2012-01-16 12:15 ` Ian Campbell
  2012-01-16 15:53   ` Stefano Stabellini
  31 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 12:15 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326715929 0
# Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8
# Parent  a2dc899d0f229d82baca92a06b3b7a5b4d918324
libxl: Default to stub device model whenever possible.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c	Mon Jan 16 11:33:18 2012 +0000
+++ b/tools/libxl/libxl_create.c	Mon Jan 16 12:12:09 2012 +0000
@@ -94,7 +94,20 @@ int libxl__domain_build_info_setdefaults
         b_info->device_model_version =
             LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
 
-    libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+    /* Default to stub domain device model if possible */
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM
+        && b_info->device_model_version
+        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL
+        && access(libxl__stubdom_kernel(gc), R_OK) == 0) {
+        libxl_defbool_setdefault(&b_info->device_model_stubdomain, true);
+    } else {
+        libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+    }
+
+    if (b_info->device_model_version !=
+        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+        libxl_defbool_val(b_info->device_model_stubdomain))
+        return ERROR_INVAL;
 
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Mon Jan 16 11:33:18 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Mon Jan 16 12:12:09 2012 +0000
@@ -686,6 +686,11 @@ retry_transaction:
     return 0;
 }
 
+char *libxl__stubdom_kernel(libxl__gc *gc)
+{
+    return libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path());
+}
+
 static int libxl__create_stubdom(libxl__gc *gc,
                                  int guest_domid,
                                  libxl_domain_config *guest_config,
@@ -729,8 +734,7 @@ static int libxl__create_stubdom(libxl__
     dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
 
     dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV;
-    dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
-                                              libxl_xenfirmwaredir_path());
+    dm_config.b_info.u.pv.kernel.path = libxl__stubdom_kernel(gc);
     dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
     dm_config.b_info.u.pv.ramdisk.path = "";
     dm_config.b_info.u.pv.features = "";
diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Mon Jan 16 11:33:18 2012 +0000
+++ b/tools/libxl/libxl_internal.h	Mon Jan 16 12:12:09 2012 +0000
@@ -482,6 +482,8 @@ _hidden int libxl__create_device_model(l
                               libxl_domain_config *guest_config,
                               libxl__domain_build_state *state,
                               libxl__spawner_starting **starting_r);
+_hidden char *libxl__stubdom_kernel(libxl__gc *gc);
+
 _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
                               libxl_domain_config *guest_config,
                               libxl__domain_build_state *state,

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 12:15 ` [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible Ian Campbell
@ 2012-01-16 15:53   ` Stefano Stabellini
  2012-01-16 16:02     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Stefano Stabellini @ 2012-01-16 15:53 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Ian Jackson

On Mon, 16 Jan 2012, Ian Campbell wrote:
> # HG changeset patch
> # User Ian Campbell <ian.campbell@citrix.com>
> # Date 1326715929 0
> # Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8
> # Parent  a2dc899d0f229d82baca92a06b3b7a5b4d918324
> libxl: Default to stub device model whenever possible.

Considering that stubdoms are not yet at feature parity I don't think we
should make this change for 4.2.
At the very least we should expand the set of conditions on which we base
the decision on: certainly the presence of an audio device, maybe pci
passthrough and the type of block backend (considering that some of them
go through qemu now) in case they aren't working properly.


> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> 
> diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_create.c
> --- a/tools/libxl/libxl_create.c	Mon Jan 16 11:33:18 2012 +0000
> +++ b/tools/libxl/libxl_create.c	Mon Jan 16 12:12:09 2012 +0000
> @@ -94,7 +94,20 @@ int libxl__domain_build_info_setdefaults
>          b_info->device_model_version =
>              LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
>  
> -    libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
> +    /* Default to stub domain device model if possible */
> +    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM
> +        && b_info->device_model_version
> +        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL
> +        && access(libxl__stubdom_kernel(gc), R_OK) == 0) {
> +        libxl_defbool_setdefault(&b_info->device_model_stubdomain, true);
> +    } else {
> +        libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
> +    }
> +
> +    if (b_info->device_model_version !=
> +        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
> +        libxl_defbool_val(b_info->device_model_stubdomain))
> +        return ERROR_INVAL;
>  
>      if (!b_info->max_vcpus)
>          b_info->max_vcpus = 1;
> diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_dm.c
> --- a/tools/libxl/libxl_dm.c	Mon Jan 16 11:33:18 2012 +0000
> +++ b/tools/libxl/libxl_dm.c	Mon Jan 16 12:12:09 2012 +0000
> @@ -686,6 +686,11 @@ retry_transaction:
>      return 0;
>  }
>  
> +char *libxl__stubdom_kernel(libxl__gc *gc)
> +{
> +    return libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path());
> +}
> +
>  static int libxl__create_stubdom(libxl__gc *gc,
>                                   int guest_domid,
>                                   libxl_domain_config *guest_config,
> @@ -729,8 +734,7 @@ static int libxl__create_stubdom(libxl__
>      dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
>  
>      dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV;
> -    dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
> -                                              libxl_xenfirmwaredir_path());
> +    dm_config.b_info.u.pv.kernel.path = libxl__stubdom_kernel(gc);
>      dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
>      dm_config.b_info.u.pv.ramdisk.path = "";
>      dm_config.b_info.u.pv.features = "";
> diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_internal.h
> --- a/tools/libxl/libxl_internal.h	Mon Jan 16 11:33:18 2012 +0000
> +++ b/tools/libxl/libxl_internal.h	Mon Jan 16 12:12:09 2012 +0000
> @@ -482,6 +482,8 @@ _hidden int libxl__create_device_model(l
>                                libxl_domain_config *guest_config,
>                                libxl__domain_build_state *state,
>                                libxl__spawner_starting **starting_r);
> +_hidden char *libxl__stubdom_kernel(libxl__gc *gc);
> +
>  _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
>                                libxl_domain_config *guest_config,
>                                libxl__domain_build_state *state,
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 15:53   ` Stefano Stabellini
@ 2012-01-16 16:02     ` Ian Campbell
  2012-01-16 17:01       ` Stefano Stabellini
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:02 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, Ian Jackson

On Mon, 2012-01-16 at 15:53 +0000, Stefano Stabellini wrote:
> On Mon, 16 Jan 2012, Ian Campbell wrote:
> > # HG changeset patch
> > # User Ian Campbell <ian.campbell@citrix.com>
> > # Date 1326715929 0
> > # Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8
> > # Parent  a2dc899d0f229d82baca92a06b3b7a5b4d918324
> > libxl: Default to stub device model whenever possible.
> 
> Considering that stubdoms are not yet at feature parity I don't think we
> should make this change for 4.2.
> At the very least we should expand the set of conditions on which we base
> the decision on: certainly the presence of an audio device, maybe pci
> passthrough and the type of block backend (considering that some of them
> go through qemu now) in case they aren't working properly.

Tweaking the precise conditions is reasonable and indeed the main thrust
of the series is to allow to make this sort of determination and to
change our minds about it.

Disabling stub-dm in the face of an audio is a no brainer. PCI
passthrough less obviously so since itm in theory, works but given the
number of problems we've had with it I'm inclined to also gate on that.

Which leaves block devices which is an interesting one because currently
I don't have enough info in hand during
libxl__domain_build_info_setdefaults to make that determination. I shall
look at how I can resolve that.

Ian.

> 
> 
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > 
> > diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_create.c
> > --- a/tools/libxl/libxl_create.c	Mon Jan 16 11:33:18 2012 +0000
> > +++ b/tools/libxl/libxl_create.c	Mon Jan 16 12:12:09 2012 +0000
> > @@ -94,7 +94,20 @@ int libxl__domain_build_info_setdefaults
> >          b_info->device_model_version =
> >              LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
> >  
> > -    libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
> > +    /* Default to stub domain device model if possible */
> > +    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM
> > +        && b_info->device_model_version
> > +        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL
> > +        && access(libxl__stubdom_kernel(gc), R_OK) == 0) {
> > +        libxl_defbool_setdefault(&b_info->device_model_stubdomain, true);
> > +    } else {
> > +        libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
> > +    }
> > +
> > +    if (b_info->device_model_version !=
> > +        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
> > +        libxl_defbool_val(b_info->device_model_stubdomain))
> > +        return ERROR_INVAL;
> >  
> >      if (!b_info->max_vcpus)
> >          b_info->max_vcpus = 1;
> > diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_dm.c
> > --- a/tools/libxl/libxl_dm.c	Mon Jan 16 11:33:18 2012 +0000
> > +++ b/tools/libxl/libxl_dm.c	Mon Jan 16 12:12:09 2012 +0000
> > @@ -686,6 +686,11 @@ retry_transaction:
> >      return 0;
> >  }
> >  
> > +char *libxl__stubdom_kernel(libxl__gc *gc)
> > +{
> > +    return libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path());
> > +}
> > +
> >  static int libxl__create_stubdom(libxl__gc *gc,
> >                                   int guest_domid,
> >                                   libxl_domain_config *guest_config,
> > @@ -729,8 +734,7 @@ static int libxl__create_stubdom(libxl__
> >      dm_config.b_info.target_memkb = dm_config.b_info.max_memkb;
> >  
> >      dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV;
> > -    dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
> > -                                              libxl_xenfirmwaredir_path());
> > +    dm_config.b_info.u.pv.kernel.path = libxl__stubdom_kernel(gc);
> >      dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
> >      dm_config.b_info.u.pv.ramdisk.path = "";
> >      dm_config.b_info.u.pv.features = "";
> > diff -r a2dc899d0f22 -r 953a1ce64385 tools/libxl/libxl_internal.h
> > --- a/tools/libxl/libxl_internal.h	Mon Jan 16 11:33:18 2012 +0000
> > +++ b/tools/libxl/libxl_internal.h	Mon Jan 16 12:12:09 2012 +0000
> > @@ -482,6 +482,8 @@ _hidden int libxl__create_device_model(l
> >                                libxl_domain_config *guest_config,
> >                                libxl__domain_build_state *state,
> >                                libxl__spawner_starting **starting_r);
> > +_hidden char *libxl__stubdom_kernel(libxl__gc *gc);
> > +
> >  _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
> >                                libxl_domain_config *guest_config,
> >                                libxl__domain_build_state *state,
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
> > 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types
  2012-01-16 12:15 ` [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types Ian Campbell
@ 2012-01-16 16:03   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:03 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types"):
> libxl: use keyword arguments for field definitions in aggregate types.
> 
> The original code is not so bad now that the comments are gone but this is
> still a bit cleaner.
> 
> No change in the generated code.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense
  2012-01-16 12:15 ` [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense Ian Campbell
@ 2012-01-16 16:04   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense"):
> libxl: only write "disable_pf" key to xenstore when it makes sense
> 
> This key is only used by the traditional qemu-dm when servicing an HVM domain.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server
  2012-01-16 12:15 ` [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server Ian Campbell
@ 2012-01-16 16:04   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 06 of 32 RFC] libxl: define libxl_spice> libxl: define libxl_spice_info to hold all info about the spice server

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type
  2012-01-16 12:15 ` [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type Ian Campbell
@ 2012-01-16 16:06   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:06 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type"):
> libxl: add new "defbool" built in type.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 12:15 ` [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too Ian Campbell
@ 2012-01-16 16:09   ` Ian Jackson
  2012-01-16 16:15     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:09 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
> libxl: use libxl_*_init internally too
...
> +    ret = libxl_device_vfb_init(CTX, vfb);
> +    if (ret) return ret;

Can we make these init functions infallible ?  (I haven't read
their code yet...)

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config
  2012-01-16 12:15 ` [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config Ian Campbell
@ 2012-01-16 16:10   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:10 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config"):
> libxl: define libxl_sdl_info to hold all info about the SDL config

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm
  2012-01-16 12:15 ` [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm Ian Campbell
@ 2012-01-16 16:11   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:11 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 15 of 32 RFC] libxl: move gfx_passthru > libxl: move gfx_passthru setting to b_info->u.hvm

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool
  2012-01-16 12:15 ` [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool Ian Campbell
@ 2012-01-16 16:12   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:12 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool"):
> libxl: switch device model selection over to libxl_defbool

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model
  2012-01-16 12:15 ` [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model Ian Campbell
@ 2012-01-16 16:13   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:13 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model"):
> libxl: use vfb[0] directly for xenpv device model

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 17 of 32 RFC] libxl: remove uuid from device model info
  2012-01-16 12:15 ` [PATCH 17 of 32 RFC] libxl: remove uuid from device model info Ian Campbell
@ 2012-01-16 16:13   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:13 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 17 of 32 RFC] libxl: remove uuid from device model info"):
> libxl: remove uuid from device model info.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name
  2012-01-16 12:15 ` [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name Ian Campbell
@ 2012-01-16 16:14   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:14 UTC (permalink / raw)
  To: Ian Campbell; +Cc: ian.jackson, xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name"):
> libxl: drop dm_info.dom_name

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 16:09   ` Ian Jackson
@ 2012-01-16 16:15     ` Ian Campbell
  2012-01-16 16:16       ` Ian Jackson
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:15 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:09 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
> > libxl: use libxl_*_init internally too
> ...
> > +    ret = libxl_device_vfb_init(CTX, vfb);
> > +    if (ret) return ret;
> 
> Can we make these init functions infallible ?  (I haven't read
> their code yet...)

I think the reason is that sometimes they might allocate memory. Many of
them don't (I don't know about vfb in particular) and I don't know
whether we prefer consistency in similar functions or avoiding pointless
return values (I prefer the former so as to avoid needing to change the
public API in the future when we find that we have introduced a way for
a function to fail).

Possibly in the new world order (where init ~= memset and setdefaults
does thework) this will no longer be the case, but then the same will
become true of the setdefaults function.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 16:15     ` Ian Campbell
@ 2012-01-16 16:16       ` Ian Jackson
  2012-01-16 16:23         ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:16 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally	too"):
> I think the reason is that sometimes they might allocate memory. Many of
> them don't (I don't know about vfb in particular) and I don't know
> whether we prefer consistency in similar functions or avoiding pointless
> return values (I prefer the former so as to avoid needing to change the
> public API in the future when we find that we have introduced a way for
> a function to fail).

Why might they need to allocate memory ?

> Possibly in the new world order (where init ~= memset and setdefaults
> does thework) this will no longer be the case, but then the same will
> become true of the setdefaults function.

Yes.  I think it's OK for setdefaults to be able to fail.

Having infallible init functions is a real boon because it makes the
caller's memory management much easier, because they can always safely
dispose.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info
  2012-01-16 12:15 ` [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info Ian Campbell
@ 2012-01-16 16:16   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:16 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info"):
> libxl: define libxl_vnc_info to hold all info about the vnc info

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
  2012-01-16 12:15 ` [PATCH 29 of 32 RFC] libxl: add named enum for timer mode Ian Campbell
@ 2012-01-16 16:17   ` Ian Jackson
  2012-01-16 16:25     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:17 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
> libxl: add named enum for timer mode.
> 
> In order to have 0 == default the specific values are off-by-one from the
> underlying domctl. I'm not sure I like this.

If we're abolishing the idea of memsetting infos to 0, and instead
requiring everyone to call _init, we could decree that all-bits-set
means "use default value".

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type
  2012-01-16 12:15 ` [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type Ian Campbell
@ 2012-01-16 16:20   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:20 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type"):
> libxl: Remove libxl_device_model_info.type.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation
  2012-01-16 12:15 ` [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation Ian Campbell
@ 2012-01-16 16:21   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:21 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation"):
> libxl: plumb libxl_domain_config down into device model creation.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Although there are some lines which are still wrapping on my screen.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state
  2012-01-16 12:15 ` [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state Ian Campbell
@ 2012-01-16 16:21   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:21 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state"):
> libxl: move "saved_state" to libxl__domain_build_state.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info
  2012-01-16 12:15 ` [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info Ian Campbell
@ 2012-01-16 16:22   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:22 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info"):
> libxl: remove redundant info from dm info.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 16:16       ` Ian Jackson
@ 2012-01-16 16:23         ` Ian Campbell
  2012-01-16 16:25           ` Ian Jackson
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:23 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:16 +0000, Ian Jackson wrote:
> Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally	too"):
> > I think the reason is that sometimes they might allocate memory. Many of
> > them don't (I don't know about vfb in particular) and I don't know
> > whether we prefer consistency in similar functions or avoiding pointless
> > return values (I prefer the former so as to avoid needing to change the
> > public API in the future when we find that we have introduced a way for
> > a function to fail).
> 
> Why might they need to allocate memory ?

e.g. vif->model = strdup("rtl8139").

> > Possibly in the new world order (where init ~= memset and setdefaults
> > does thework) this will no longer be the case, but then the same will
> > become true of the setdefaults function.
> 
> Yes.  I think it's OK for setdefaults to be able to fail.
> 
> Having infallible init functions is a real boon because it makes the
> caller's memory management much easier, because they can always safely
> dispose.

I think my series has made more *_init functions have no possibility of
failure but I don't think it is all of them.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
  2012-01-16 12:14 ` [PATCH 01 of 32 RFC] libxl: remove comment support from IDL Ian Campbell
@ 2012-01-16 16:23   ` Ian Jackson
  2012-01-16 16:29     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:23 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from IDL"):
> libxl: remove comment support from IDL

I'm not entirely convinced by this, or at least not yet.

Are we going to eventually have an automatic docs generator and find
that this "literate" style (if I may grossly stretch the term) is what
we wanted ?

I guess the current syntax is not really suitable for going for a
literate style in the idl.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
  2012-01-16 16:17   ` Ian Jackson
@ 2012-01-16 16:25     ` Ian Campbell
  2012-01-16 16:27       ` Ian Jackson
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:25 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:17 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
> > libxl: add named enum for timer mode.
> > 
> > In order to have 0 == default the specific values are off-by-one from the
> > underlying domctl. I'm not sure I like this.
> 
> If we're abolishing the idea of memsetting infos to 0, and instead
> requiring everyone to call _init, 

I'm happy to take either approach to be honest. I imagine most _init
functions will turn into just a memset anyway at which point maybe we
should just ditch them.

I'd rather either all data types had an init or none is my only real
feeling on the matter.

> we could decree that all-bits-set means "use default value".

Do you mean in genral or just this specific field?

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
  2012-01-16 16:23         ` Ian Campbell
@ 2012-01-16 16:25           ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:25 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally	too"):
> On Mon, 2012-01-16 at 16:16 +0000, Ian Jackson wrote:
> > Why might they need to allocate memory ?
> 
> e.g. vif->model = strdup("rtl8139").

That should be done in setdefault, not in init.  If for no other
reason than doing it in init means the application has to free again
this string which we pointless allocated.

> > Having infallible init functions is a real boon because it makes the
> > caller's memory management much easier, because they can always safely
> > dispose.
> 
> I think my series has made more *_init functions have no possibility of
> failure but I don't think it is all of them.

Are there any that are left that are fallible ?

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options
  2012-01-16 12:15 ` [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options Ian Campbell
@ 2012-01-16 16:26   ` Ian Jackson
  2012-01-16 16:40     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:26 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options"):
> libxl: use defbool for graphics related options
...
> diff -r 81def18dfda0 -r b8426902efa0 tools/ocaml/libs/xl/xenlight_stubs.c
> --- a/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 16:17:49 2012 +0000
> +++ b/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 17:04:57 2012 +0000
> @@ -130,6 +130,19 @@ static int string_string_tuple_array_val
>  
>  #endif
>  
> +/* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */
> +#define Val_none Val_int(0)
> +#define Some_val(v) Field(v,0)
...
> +static value Val_some(value v)
> +{
...

I wasn't expecting to find this at the end of this patch.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
  2012-01-16 16:25     ` Ian Campbell
@ 2012-01-16 16:27       ` Ian Jackson
  2012-01-17 11:26         ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:27 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer	mode"):
> I'm happy to take either approach to be honest. I imagine most _init
> functions will turn into just a memset anyway at which point maybe we
> should just ditch them.
> 
> I'd rather either all data types had an init or none is my only real
> feeling on the matter.

I absolutely agree.  (The init function could be autogenerated.)

> > we could decree that all-bits-set means "use default value".
> 
> Do you mean in genral or just this specific field?

In general.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm
  2012-01-16 12:15 ` [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm Ian Campbell
@ 2012-01-16 16:27   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:27 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm"):
> libxl: move HVM emulated GFX support into b_info->u.hvm

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 26 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
  2012-01-16 12:15 ` [PATCH 26 " Ian Campbell
@ 2012-01-16 16:28   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:28 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 26 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool"):
> libxl: make boolean members of libxl_domain_create_info into libxl_defbool

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago
  2012-01-16 12:15 ` [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago Ian Campbell
@ 2012-01-16 16:29   ` Olaf Hering
  2012-01-16 16:41     ` Ian Campbell
  2012-01-16 16:50   ` [PATCH 21 of 32] libxl: drop vfs patch Ian Jackson
  1 sibling, 1 reply; 83+ messages in thread
From: Olaf Hering @ 2012-01-16 16:29 UTC (permalink / raw)
  To: Ian Campbell; +Cc: ian.jackson, xen-devel

On Mon, Jan 16, Ian Campbell wrote:


> libxl: drop vfs patch -- fsback/front were deleted some time ago

Do you mean path instead of patch?

Olaf

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
  2012-01-16 16:23   ` Ian Jackson
@ 2012-01-16 16:29     ` Ian Campbell
  2012-01-16 16:30       ` Ian Jackson
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:29 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:23 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from IDL"):
> > libxl: remove comment support from IDL
> 
> I'm not entirely convinced by this, or at least not yet.
> 
> Are we going to eventually have an automatic docs generator and find
> that this "literate" style (if I may grossly stretch the term) is what
> we wanted ?

I honestly don't know.

I guess in some sense this new scheme is no different in this respect to
any other source file which we might want to extract docs from?

> I guess the current syntax is not really suitable for going for a
> literate style in the idl.

It is pretty limited/limiting.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 12:15 ` [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm Ian Campbell
@ 2012-01-16 16:29   ` Ian Jackson
  2012-01-16 16:46     ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:29 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configu> libxl: HVM device configuration info build_info->u.hvm

I'm not sure I agree with this change.  In general our model is that
devices might be provided via HVM or PV interfaces but the config
doesn't distinguish.

Eg, if we implement some kind of pvusb, aren't we just going to have
to move it back ?

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
  2012-01-16 16:29     ` Ian Campbell
@ 2012-01-16 16:30       ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:30 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from	IDL"):
> On Mon, 2012-01-16 at 16:23 +0000, Ian Jackson wrote:
> > Are we going to eventually have an automatic docs generator and find
> > that this "literate" style (if I may grossly stretch the term) is what
> > we wanted ?
> 
> I honestly don't know.
> 
> I guess in some sense this new scheme is no different in this respect to
> any other source file which we might want to extract docs from?
> 
> > I guess the current syntax is not really suitable for going for a
> > literate style in the idl.
> 
> It is pretty limited/limiting.

OK, I think this will do for now.  Certainly the comments you're
removing aren't valuable, so

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info
  2012-01-16 12:15 ` [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info Ian Campbell
@ 2012-01-16 16:30   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:30 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info"):
> libxl: remove libxl_device_model_info.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
  2012-01-16 12:15 ` [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool Ian Campbell
@ 2012-01-16 16:31   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:31 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool"):
> libxl: make boolean members of libxl_domain_create_info into libxl_defbool

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Modulo a decision about the representation of "default".

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options
  2012-01-16 16:26   ` Ian Jackson
@ 2012-01-16 16:40     ` Ian Campbell
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:40 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:26 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options"):
> > libxl: use defbool for graphics related options
> ...
> > diff -r 81def18dfda0 -r b8426902efa0 tools/ocaml/libs/xl/xenlight_stubs.c
> > --- a/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 16:17:49 2012 +0000
> > +++ b/tools/ocaml/libs/xl/xenlight_stubs.c	Fri Jan 13 17:04:57 2012 +0000
> > @@ -130,6 +130,19 @@ static int string_string_tuple_array_val
> >  
> >  #endif
> >  
> > +/* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */
> > +#define Val_none Val_int(0)
> > +#define Some_val(v) Field(v,0)
> ...
> > +static value Val_some(value v)
> > +{
> ...
> 
> I wasn't expecting to find this at the end of this patch.

I think this is the first time a struct which is covered by the ocaml
stubs used a defbool.

It's tricky to do this in a staged manner because you get all sorts of
"unused static function" warnings.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago
  2012-01-16 16:29   ` Olaf Hering
@ 2012-01-16 16:41     ` Ian Campbell
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:41 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Ian Jackson

On Mon, 2012-01-16 at 16:29 +0000, Olaf Hering wrote:
> On Mon, Jan 16, Ian Campbell wrote:
> 
> 
> > libxl: drop vfs patch -- fsback/front were deleted some time ago
> 
> Do you mean path instead of patch?

Yes I did, finger macros got in the way.

Thanks
Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 16:29   ` Ian Jackson
@ 2012-01-16 16:46     ` Ian Campbell
  2012-01-16 16:53       ` Ian Jackson
  2012-01-31 14:48       ` Ian Jackson
  0 siblings, 2 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 16:46 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:29 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configu> libxl: HVM device configuration info build_info->u.hvm
> 
> I'm not sure I agree with this change.

There were several things that I wasn't sure about the placement of. I
just knew that device_model_info was wrong ;-)

>   In general our model is that
> devices might be provided via HVM or PV interfaces but the config
> doesn't distinguish.
> 
> Eg, if we implement some kind of pvusb, aren't we just going to have
> to move it back ?

On the one hand I agree.

On the other hand these particular two USB options are very thin shims
over the equivalent qemu options and do not contain anything like the
necessary richness to allow them to describe a device in the detail
needed to be a first class thing in the IDL. I suspect that if/when we
have PVUSB we will gain libxl_device_usb as a thing which is completely
orthogonal to these two.

I think a similar argument applies to the audio option?

Boot, Serial and the platform PCI options are pretty HVM specific I
think.

While we are at it -- do you have any thoughts on how per-arch options
should be handled? I was thinking of adding the possibility in the IDL
to tag a field with a list of architectures?

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 04 of 32] ocaml: Correct ocaml type name for Aggregate types
  2012-01-16 12:15 ` [PATCH 04 of 32 RFC] ocaml: Correct ocaml type name for Aggregate types Ian Campbell
@ 2012-01-16 16:49   ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:49 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 04 of 32] ocaml: Correct ocaml type name for Aggregate types"):
> ocaml: Correct ocaml type name for Aggregate types.
> 
> No change to the generated code because this path isn't used yet.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32] libxl: drop vfs patch
  2012-01-16 12:15 ` [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago Ian Campbell
  2012-01-16 16:29   ` Olaf Hering
@ 2012-01-16 16:50   ` Ian Jackson
  2012-01-16 17:09     ` Ian Campbell
  1 sibling, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:50 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
> libxl: drop vfs path -- fsback/front were deleted some time ago
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

I was going to apply this, but it doesn't fit in the current tree.  I
guess the context is updated by earlier patches in your series.  So
for now:

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 16:46     ` Ian Campbell
@ 2012-01-16 16:53       ` Ian Jackson
  2012-01-16 17:45         ` Ian Campbell
  2012-01-31 14:48       ` Ian Jackson
  1 sibling, 1 reply; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 16:53 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm"):
> While we are at it -- do you have any thoughts on how per-arch options
> should be handled? I was thinking of adding the possibility in the IDL
> to tag a field with a list of architectures?

If we eventually tunnel these structures over some kind of IPC
mechanism it might be necessary to deal with values from other than
the native architecture.

So perhaps per-arch fields should exist in every version and just have
the arch in their name somehow, although that wouldn't spot people
setting them inappropriately.

Alternative a variadic substructure where _init sets the enum to the
default native arch ?

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 16:02     ` Ian Campbell
@ 2012-01-16 17:01       ` Stefano Stabellini
  2012-01-16 17:14         ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Stefano Stabellini @ 2012-01-16 17:01 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Ian Jackson, Stefano Stabellini

On Mon, 16 Jan 2012, Ian Campbell wrote:
> On Mon, 2012-01-16 at 15:53 +0000, Stefano Stabellini wrote:
> > On Mon, 16 Jan 2012, Ian Campbell wrote:
> > > # HG changeset patch
> > > # User Ian Campbell <ian.campbell@citrix.com>
> > > # Date 1326715929 0
> > > # Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8
> > > # Parent  a2dc899d0f229d82baca92a06b3b7a5b4d918324
> > > libxl: Default to stub device model whenever possible.
> > 
> > Considering that stubdoms are not yet at feature parity I don't think we
> > should make this change for 4.2.
> > At the very least we should expand the set of conditions on which we base
> > the decision on: certainly the presence of an audio device, maybe pci
> > passthrough and the type of block backend (considering that some of them
> > go through qemu now) in case they aren't working properly.
> 
> Tweaking the precise conditions is reasonable and indeed the main thrust
> of the series is to allow to make this sort of determination and to
> change our minds about it.

The danger of this approach is that stubdoms are not really transparent
from the admin point of view.
>From the basic difference when you "xl list", to memory usage, a stubdom
based setup is quite different from a non-stubdom based setup.
If I were an admin I would really want to know when I am running one or
the other.
Making the change under their feet is bad enough but making a difference
choice depending on a various set of variables is certainly not going to
be popular.


> Disabling stub-dm in the face of an audio is a no brainer. PCI
> passthrough less obviously so since itm in theory, works but given the
> number of problems we've had with it I'm inclined to also gate on that.
> 
> Which leaves block devices which is an interesting one because currently
> I don't have enough info in hand during
> libxl__domain_build_info_setdefaults to make that determination. I shall
> look at how I can resolve that.

Theoretically this case could also work with stubdoms because the block
backend would be provided by the other qemu, the one running in dom0.
However it is not probably going to work right now.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32] libxl: drop vfs patch
  2012-01-16 16:50   ` [PATCH 21 of 32] libxl: drop vfs patch Ian Jackson
@ 2012-01-16 17:09     ` Ian Campbell
  2012-01-16 17:30       ` Ian Campbell
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 17:09 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:50 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
> > libxl: drop vfs path -- fsback/front were deleted some time ago
> > 
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> 
> I was going to apply this, but it doesn't fit in the current tree.  I
> guess the context is updated by earlier patches in your series.  So
> for now:
> 
> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks, I'll pull it to the front for the next posting.

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 17:01       ` Stefano Stabellini
@ 2012-01-16 17:14         ` Ian Campbell
  2012-01-17 14:11           ` Stefano Stabellini
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 17:14 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, Ian Jackson

On Mon, 2012-01-16 at 17:01 +0000, Stefano Stabellini wrote:
> On Mon, 16 Jan 2012, Ian Campbell wrote:
> > On Mon, 2012-01-16 at 15:53 +0000, Stefano Stabellini wrote:
> > > On Mon, 16 Jan 2012, Ian Campbell wrote:
> > > > # HG changeset patch
> > > > # User Ian Campbell <ian.campbell@citrix.com>
> > > > # Date 1326715929 0
> > > > # Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8
> > > > # Parent  a2dc899d0f229d82baca92a06b3b7a5b4d918324
> > > > libxl: Default to stub device model whenever possible.
> > > 
> > > Considering that stubdoms are not yet at feature parity I don't think we
> > > should make this change for 4.2.
> > > At the very least we should expand the set of conditions on which we base
> > > the decision on: certainly the presence of an audio device, maybe pci
> > > passthrough and the type of block backend (considering that some of them
> > > go through qemu now) in case they aren't working properly.
> > 
> > Tweaking the precise conditions is reasonable and indeed the main thrust
> > of the series is to allow to make this sort of determination and to
> > change our minds about it.
> 
> The danger of this approach is that stubdoms are not really transparent
> from the admin point of view.
> From the basic difference when you "xl list", to memory usage, a stubdom
> based setup is quite different from a non-stubdom based setup.
> If I were an admin I would really want to know when I am running one or
> the other.

> Making the change under their feet is bad enough but making a difference
> choice depending on a various set of variables is certainly not going to
> be popular.

Our recommendation as upstream is that stub domains are the most
scalable and secure configuration. I think our defaults should reflect
that.

Users who care specifically about stubdom or not can continue to force
the choice (using device_model_stubdomain_override=1|0 in their config).

Ian.
> 
> 
> > Disabling stub-dm in the face of an audio is a no brainer. PCI
> > passthrough less obviously so since itm in theory, works but given the
> > number of problems we've had with it I'm inclined to also gate on that.
> > 
> > Which leaves block devices which is an interesting one because currently
> > I don't have enough info in hand during
> > libxl__domain_build_info_setdefaults to make that determination. I shall
> > look at how I can resolve that.
> 
> Theoretically this case could also work with stubdoms because the block
> backend would be provided by the other qemu, the one running in dom0.
> However it is not probably going to work right now.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32] libxl: drop vfs patch
  2012-01-16 17:09     ` Ian Campbell
@ 2012-01-16 17:30       ` Ian Campbell
  2012-01-16 17:56         ` Ian Jackson
  0 siblings, 1 reply; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 17:30 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 17:09 +0000, Ian Campbell wrote:
> On Mon, 2012-01-16 at 16:50 +0000, Ian Jackson wrote:
> > Ian Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
> > > libxl: drop vfs path -- fsback/front were deleted some time ago
> > > 
> > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > 
> > I was going to apply this, but it doesn't fit in the current tree.  I
> > guess the context is updated by earlier patches in your series.  So
> > for now:
> > 
> > Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> Thanks, I'll pull it to the front for the next posting.

In fact, why I don't I just post the rebased version of that one patch
now, it doesn't really have much to do with this series.

This applies to current unstable.

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

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1326734948 0
# Node ID fed4bb058ea7200ef79b32f54254db92761fd258
# Parent  71571eced36ed674df3d38b4222c2a4bbebe0749
libxl: drop vfs path -- fsback/front were deleted some time ago

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

diff -r 71571eced36e -r fed4bb058ea7 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Mon Jan 16 17:26:03 2012 +0000
+++ b/tools/libxl/libxl_dm.c	Mon Jan 16 17:29:08 2012 +0000
@@ -669,8 +669,6 @@ retry_transaction:
     t = xs_transaction_start(ctx->xsh);
     xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid));
     xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid), perm, ARRAY_SIZE(perm));
-    xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/%d/device/vfs", domid));
-    xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/%d/device/vfs",domid), perm, ARRAY_SIZE(perm));
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 16:53       ` Ian Jackson
@ 2012-01-16 17:45         ` Ian Campbell
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-16 17:45 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:53 +0000, Ian Jackson wrote:
> Ian Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm"):
> > While we are at it -- do you have any thoughts on how per-arch options
> > should be handled? I was thinking of adding the possibility in the IDL
> > to tag a field with a list of architectures?
> 
> If we eventually tunnel these structures over some kind of IPC
> mechanism it might be necessary to deal with values from other than
> the native architecture.

Hrm, yes.

> So perhaps per-arch fields should exist in every version and just have
> the arch in their name somehow, although that wouldn't spot people
> setting them inappropriately.
> 
> Alternative a variadic substructure where _init sets the enum to the
> default native arch ?

I wonder if these all fit into the existing build_info.u.{hvm,pv}. e.g.
if we shouldn't have hvm_x86,pv_x86,arm etc instead?

Another alternative is to do like we do for for foreign structures in
the hypervisor and generate compat versions of each struct as well as
native ones (e.g. libxl_x86_...).

Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 21 of 32] libxl: drop vfs patch
  2012-01-16 17:30       ` Ian Campbell
@ 2012-01-16 17:56         ` Ian Jackson
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-16 17:56 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
> In fact, why I don't I just post the rebased version of that one patch
> now, it doesn't really have much to do with this series.
> 
> This applies to current unstable.

Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks,
Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
  2012-01-16 16:27       ` Ian Jackson
@ 2012-01-17 11:26         ` Ian Campbell
  0 siblings, 0 replies; 83+ messages in thread
From: Ian Campbell @ 2012-01-17 11:26 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Mon, 2012-01-16 at 16:27 +0000, Ian Jackson wrote:
> Ian Campbell writes ("Re: [Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer	mode"):
> > I'm happy to take either approach to be honest. I imagine most _init
> > functions will turn into just a memset anyway at which point maybe we
> > should just ditch them.
> > 
> > I'd rather either all data types had an init or none is my only real
> > feeling on the matter.
> 
> I absolutely agree.  (The init function could be autogenerated.)

OK, I shall arrange that each type libxl_FOO has a libxl_FOO_init which
cannot fail and which is (normally) generated from the IDL. Likewise I
will arrange for a libxl_FOO_setdefaults which can fail.

This gives us the freedom to have non-zero representation for the
default on a per-type or per-field exceptional basis.

This will however make this series even larger...

> > > we could decree that all-bits-set means "use default value".
> > 
> > Do you mean in genral or just this specific field?
> 
> In general.
> 
> Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
  2012-01-16 17:14         ` Ian Campbell
@ 2012-01-17 14:11           ` Stefano Stabellini
  0 siblings, 0 replies; 83+ messages in thread
From: Stefano Stabellini @ 2012-01-17 14:11 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Ian Jackson, Stefano Stabellini

On Mon, 16 Jan 2012, Ian Campbell wrote:
> > > > Considering that stubdoms are not yet at feature parity I don't think we
> > > > should make this change for 4.2.
> > > > At the very least we should expand the set of conditions on which we base
> > > > the decision on: certainly the presence of an audio device, maybe pci
> > > > passthrough and the type of block backend (considering that some of them
> > > > go through qemu now) in case they aren't working properly.
> > > 
> > > Tweaking the precise conditions is reasonable and indeed the main thrust
> > > of the series is to allow to make this sort of determination and to
> > > change our minds about it.
> > 
> > The danger of this approach is that stubdoms are not really transparent
> > from the admin point of view.
> > From the basic difference when you "xl list", to memory usage, a stubdom
> > based setup is quite different from a non-stubdom based setup.
> > If I were an admin I would really want to know when I am running one or
> > the other.
> 
> > Making the change under their feet is bad enough but making a difference
> > choice depending on a various set of variables is certainly not going to
> > be popular.
> 
> Our recommendation as upstream is that stub domains are the most
> scalable and secure configuration. I think our defaults should reflect
> that.
> 
> Users who care specifically about stubdom or not can continue to force
> the choice (using device_model_stubdomain_override=1|0 in their config).

While the benefits of stubdoms in terms of security are a no brainer,
the benefits in terms of scalability are certainly less clear: are we
actually sure that using stubdoms is more scalable than a 64 bit dom0
with multiple vcpus?
I am asking because qemu instances running on Linux would share text and
use only the ram they actually need (nowadays most VMs have PV drivers
anyway) while stubdoms would unconditionally take 32MB of ram.
I don't think anybody actually run any real world benchmarks to
demonstrate any scalability benefits. Before saying that they are our
recommended solution and before switching them to default maybe we ought
to run at least one?
Otherwise if these tests have been run, I would like a link to some
nice figures :)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
  2012-01-16 16:46     ` Ian Campbell
  2012-01-16 16:53       ` Ian Jackson
@ 2012-01-31 14:48       ` Ian Jackson
  1 sibling, 0 replies; 83+ messages in thread
From: Ian Jackson @ 2012-01-31 14:48 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm"):
> On Mon, 2012-01-16 at 16:29 +0000, Ian Jackson wrote:
> > Eg, if we implement some kind of pvusb, aren't we just going to have
> > to move it back ?
> 
> On the one hand I agree.
> 
> On the other hand these particular two USB options are very thin shims
> over the equivalent qemu options and do not contain anything like the
> necessary richness to allow them to describe a device in the detail
> needed to be a first class thing in the IDL. I suspect that if/when we
> have PVUSB we will gain libxl_device_usb as a thing which is completely
> orthogonal to these two.
> 
> I think a similar argument applies to the audio option?

Fair enough.

...
> While we are at it -- do you have any thoughts on how per-arch options
> should be handled? I was thinking of adding the possibility in the IDL
> to tag a field with a list of architectures?

This is a red herring for this patch, I think, so:

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks,
Ian.

^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2012-01-31 14:48 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16 12:14 [PATCH 00 of 32 RFC] libxl: drop device_model_info, better defaults support, stubdoms by default Ian Campbell
2012-01-16 12:14 ` [PATCH 01 of 32 RFC] libxl: remove comment support from IDL Ian Campbell
2012-01-16 16:23   ` Ian Jackson
2012-01-16 16:29     ` Ian Campbell
2012-01-16 16:30       ` Ian Jackson
2012-01-16 12:15 ` [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types Ian Campbell
2012-01-16 16:03   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 03 of 32 RFC] ocaml: use libxl IDL type helpers for C argument passing Ian Campbell
2012-01-16 12:15 ` [PATCH 04 of 32 RFC] ocaml: Correct ocaml type name for Aggregate types Ian Campbell
2012-01-16 16:49   ` [PATCH 04 of 32] " Ian Jackson
2012-01-16 12:15 ` [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info Ian Campbell
2012-01-16 16:16   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server Ian Campbell
2012-01-16 16:04   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config Ian Campbell
2012-01-16 16:10   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation Ian Campbell
2012-01-16 16:21   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 09 of 32 RFC] libxl: now that dm creation takes domain_config stop passing down devices Ian Campbell
2012-01-16 12:15 ` [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info Ian Campbell
2012-01-16 16:22   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name Ian Campbell
2012-01-16 16:14   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model Ian Campbell
2012-01-16 16:13   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm Ian Campbell
2012-01-16 16:27   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm Ian Campbell
2012-01-16 16:29   ` Ian Jackson
2012-01-16 16:46     ` Ian Campbell
2012-01-16 16:53       ` Ian Jackson
2012-01-16 17:45         ` Ian Campbell
2012-01-31 14:48       ` Ian Jackson
2012-01-16 12:15 ` [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm Ian Campbell
2012-01-16 16:11   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type Ian Campbell
2012-01-16 16:20   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 17 of 32 RFC] libxl: remove uuid from device model info Ian Campbell
2012-01-16 16:13   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 18 of 32 RFC] libxl: move device model selection variables to b_info Ian Campbell
2012-01-16 12:15 ` [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state Ian Campbell
2012-01-16 16:21   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info Ian Campbell
2012-01-16 16:30   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago Ian Campbell
2012-01-16 16:29   ` Olaf Hering
2012-01-16 16:41     ` Ian Campbell
2012-01-16 16:50   ` [PATCH 21 of 32] libxl: drop vfs patch Ian Jackson
2012-01-16 17:09     ` Ian Campbell
2012-01-16 17:30       ` Ian Campbell
2012-01-16 17:56         ` Ian Jackson
2012-01-16 12:15 ` [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense Ian Campbell
2012-01-16 16:04   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too Ian Campbell
2012-01-16 16:09   ` Ian Jackson
2012-01-16 16:15     ` Ian Campbell
2012-01-16 16:16       ` Ian Jackson
2012-01-16 16:23         ` Ian Campbell
2012-01-16 16:25           ` Ian Jackson
2012-01-16 12:15 ` [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type Ian Campbell
2012-01-16 16:06   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool Ian Campbell
2012-01-16 16:31   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 26 " Ian Campbell
2012-01-16 16:28   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options Ian Campbell
2012-01-16 16:26   ` Ian Jackson
2012-01-16 16:40     ` Ian Campbell
2012-01-16 12:15 ` [PATCH 28 of 32 RFC] libxl: initialise NULL==default members of build info later Ian Campbell
2012-01-16 12:15 ` [PATCH 29 of 32 RFC] libxl: add named enum for timer mode Ian Campbell
2012-01-16 16:17   ` Ian Jackson
2012-01-16 16:25     ` Ian Campbell
2012-01-16 16:27       ` Ian Jackson
2012-01-17 11:26         ` Ian Campbell
2012-01-16 12:15 ` [PATCH 30 of 32 RFC] libxl: drop 8M slack for PV guests Ian Campbell
2012-01-16 12:15 ` [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool Ian Campbell
2012-01-16 16:12   ` Ian Jackson
2012-01-16 12:15 ` [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible Ian Campbell
2012-01-16 15:53   ` Stefano Stabellini
2012-01-16 16:02     ` Ian Campbell
2012-01-16 17:01       ` Stefano Stabellini
2012-01-16 17:14         ` Ian Campbell
2012-01-17 14:11           ` Stefano Stabellini

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.