libxl: drop device_model_info, better defaults support, stubdoms by default
RFC PATCH 1/1 libxl: drop device_model_info, better defaults support, stubdoms by default
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).
RFC PATCH 1/1 libxl: remove comment support from IDL
# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/gentypes.py +0 -23
@@ -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
tools/libxl/libxl_types.idl +87 -79
225 lines not on this page · raw message
tools/libxl/libxltypes.py +5 -17
@@ -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) #
Re: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
Ian Campbell writes ("[Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from IDL"):
Quoted 1 line
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.
Re: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from IDL"):
Quoted 1 line
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?
Quoted 2 lines
I guess the current syntax is not really suitable for going for a literate style in the idl.
It is pretty limited/limiting.
Ian.
Ian Jackson
Acked-byRe: [PATCH 01 of 32 RFC] libxl: remove comment support from IDL
Ian Campbell writes ("Re: [Xen-devel] [PATCH 01 of 32 RFC] libxl: remove comment support from IDL"):
Quoted 7 lines · Ian Jackson
Quoted 3 lines
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.
Quoted 7 lines
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?
Quoted 2 lines
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
RFC PATCH 1/1 libxl: use keyword arguments for field definitions in aggregate types
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl_types.idl +1 -1
@@ -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), ])),
tools/libxl/libxltypes.py +4 -4
@@ -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) #
Re: [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types
Ian Campbell writes ("[Xen-devel] [PATCH 02 of 32 RFC] libxl: use keyword arguments for field definitions in aggregate types"):
Quoted 8 lines
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 <[email protected]>
RFC PATCH 1/1 ocaml: use libxl IDL type helpers for C argument passing
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/ocaml/libs/xl/genwrap.py +10 -17
@@ -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
RFC PATCH 1/1 ocaml: Correct ocaml type name for Aggregate types
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/ocaml/libs/xl/genwrap.py +2 -0
@@ -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
Re: [PATCH 04 of 32] ocaml: Correct ocaml type name for Aggregate types
Ian Campbell writes ("[Xen-devel] [PATCH 04 of 32] ocaml: Correct ocaml type name for Aggregate types"):
Quoted 5 lines
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 <[email protected]>
RFC PATCH 1/1 libxl: define libxl_vnc_info to hold all info about the vnc info
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.c +13 -10
@@ -1954,11 +1954,11 @@ int libxl_device_vfb_init(libxl_ctx *ctxmemset (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) {
tools/libxl/libxl_create.c +4 -4
@@ -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 ;
tools/libxl/libxl_dm.c +33 -37
147 lines not on this page · raw message
tools/libxl/libxl_types.idl +12 -14
@@ -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),
tools/libxl/xl_cmdimpl.c +20 -20
@@ -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;
tools/python/genwrap.py +9 -1
@@ -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))
Re: [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info
Ian Campbell writes ("[Xen-devel] [PATCH 05 of 32 RFC] libxl: define libxl_vnc_info to hold all info about the vnc info"):
Quoted 1 line
libxl: define
libxl_vnc_infoto hold all info about the vnc info
RFC PATCH 1/1 libxl: define libxl_spice_info to hold all info about the spice server
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1326215019 0
# Node ID 3308d2dfd9dddb36f8a65e7a44916c6bcf02170e
# Parent ed7106b3f874d93e8ed8d05a8464099e611edd0b
libxl: define libxl_spice_info to hold all info about the spice server
tools/libxl/libxl_dm.c +11 -11
@@ -298,39 +298,39 @@ static char ** libxl__build_device_modelif (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);
tools/libxl/libxl_types.idl +21 -10
@@ -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),
tools/libxl/xl_cmdimpl.c +15 -14
@@ -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 ))
Re: [PATCH 06 of 32 RFC] libxl: define libxl_spice_info to hold all info about the spice server
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
RFC PATCH 1/1 libxl: define libxl_sdl_info to hold all info about the SDL config
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1326296553 0
# Node ID 2cf31bf780380c42d859bb0b8f7c701cbf424180
# Parent 3308d2dfd9dddb36f8a65e7a44916c6bcf02170e
libxl: define libxl_sdl_info to hold all info about the SDL config
tools/libxl/libxl.c +14 -11
@@ -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,
tools/libxl/libxl_create.c +2 -2
@@ -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" );
tools/libxl/libxl_dm.c +7 -7
@@ -128,16 +128,17 @@ static char ** libxl__build_device_modelflexarray_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_modellibxl__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_modelif (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;
tools/libxl/libxl_types.idl +2 -6
@@ -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", [
tools/libxl/xl_cmdimpl.c +14 -14
@@ -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 ))
Re: [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config
Ian Campbell writes ("[Xen-devel] [PATCH 07 of 32 RFC] libxl: define libxl_sdl_info to hold all info about the SDL config"):
Quoted 1 line
libxl: define
libxl_sdl_infoto hold all info about the SDL config
RFC PATCH 1/1 libxl: plumb libxl_domain_config down into device model creation
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl_create.c +3 -2
@@ -558,7 +558,7 @@ static int do_domain_create(libxl__gc *glibxl_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 ;
tools/libxl/libxl_dm.c +58 -50
199 lines not on this page · raw message
tools/libxl/libxl_internal.h +3 -1
@@ -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);
tools/libxl/libxl_uuid.c +2 -2
@@ -35,7 +35,7 @@ int libxl_uuid_from_string(libxl_uuid *ureturn 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)); }
tools/libxl/libxl_uuid.h +1 -1
@@ -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);
Re: [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation
Ian Campbell writes ("[Xen-devel] [PATCH 08 of 32 RFC] libxl: plumb libxl_domain_config down into device model creation"):
Quoted 1 line
libxl: plumb
libxl_domain_configdown into device model creation.
Although there are some lines which are still wrapping on my screen.
Ian.
RFC PATCH 1/1 libxl: now that dm creation takes domain_config stop passing down devices
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1326303938 0
# Node ID 9f9995e2e34967929053c8c75e7c86562b58acf9
# Parent 14605ae17bd9d8a3e2a5111ae6f06ffda0ddc441
libxl: now that dm creation takes domain_config stop passing down devices.
tools/libxl/libxl_create.c +1 -4
@@ -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 ; }
tools/libxl/libxl_dm.c +38 -45
180 lines not on this page · raw message
tools/libxl/libxl_internal.h +0 -3
@@ -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,
RFC PATCH 1/1 libxl: remove redundant info from dm info
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +0 -4
@@ -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 ;
tools/libxl/libxl_dm.c +22 -11
@@ -86,6 +86,7 @@ static char ** libxl__build_device_modelconst 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_modelif (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_modelif (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++) {
tools/libxl/libxl_types.idl +0 -4
@@ -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),
tools/libxl/xl_cmdimpl.c +0 -1
@@ -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);
Re: [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info
Ian Campbell writes ("[Xen-devel] [PATCH 10 of 32 RFC] libxl: remove redundant info from dm info"):
Quoted 1 line
libxl: remove redundant info from dm info.
RFC PATCH 1/1 libxl: drop dm_info.dom_name
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +0 -1
@@ -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 ;
tools/libxl/libxl_dm.c +10 -8
@@ -86,6 +86,7 @@ static char ** libxl__build_device_modelconst 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_modelflexarray_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_modelflexarray_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__gcxs_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 ; }
tools/libxl/libxl_types.idl +0 -1
@@ -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
Re: [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name
Ian Campbell writes ("[Xen-devel] [PATCH 11 of 32 RFC] libxl: drop dm_info.dom_name"):
Quoted 1 line
libxl: drop dm_info.dom_name
RFC PATCH 1/1 libxl: use vfb[0] directly for xenpv device model
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326363959 0
# Node ID 714cb45a8327bae6ede162f12e21cc8e0397ae1f # Parent 3db40f3e8b2af814b9f79b514de82c3751c213f8
libxl: use vfb[0] directly for xenpv device model
Rather than laundering it via dm info.
tools/libxl/libxl_dm.c +62 -47
@@ -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_modelconst 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_modelif (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_modelconst 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_modelif (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_modelif (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 ; }
Re: [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model
Ian Campbell writes ("[Xen-devel] [PATCH 12 of 32 RFC] libxl: use vfb[0] directly for xenpv device model"):
Quoted 1 line
libxl: use vfb[0] directly for xenpv device model
RFC PATCH 1/1 libxl: move HVM emulated GFX support into b_info->u.hvm
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326367192 0
# Node ID 0ef52f0b6c58344ee371d668ea343628aaecb714 # Parent 714cb45a8327bae6ede162f12e21cc8e0397ae1f
libxl: move HVM emulated GFX support into b_info->u.hvm
tools/libxl/libxl_create.c +10 -10
@@ -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 ;
tools/libxl/libxl_dm.c +103 -62
264 lines not on this page · raw message
tools/libxl/libxl_types.idl +7 -9
@@ -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),
tools/libxl/xl_cmdimpl.c +36 -35
102 lines not on this page · raw message
Re: [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm
Ian Campbell writes ("[Xen-devel] [PATCH 13 of 32 RFC] libxl: move HVM emulated GFX support into b_info->u.hvm"):
Quoted 1 line
libxl: move HVM emulated GFX support into
b_info->u.hvm
RFC PATCH 1/1 libxl: HVM device configuration info build_info->u.hvm
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326367397 0
# Node ID 540c9fa96606437f319762663b0892af9e79a6f3 # Parent 0ef52f0b6c58344ee371d668ea343628aaecb714
libxl: HVM device configuration info build_info->u.hvm
tools/libxl/libxl_create.c +5 -5
@@ -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 ; }
tools/libxl/libxl_dm.c +28 -22
100 lines not on this page · raw message
tools/libxl/libxl_types.idl +10 -7
@@ -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
tools/libxl/xl_cmdimpl.c +10 -10
@@ -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;
Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
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.
Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
Quoted 3 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configu> libxl: HVM device configuration info
build_info->u.hvmI'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 ;-)
Quoted 6 lines
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.
Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
Ian Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm"):
Quoted 3 lines
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.
Re: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info
build_info->u.hvm"):Quoted 3 lines
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.
Quoted 6 lines
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
_initsets 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.
Ian Jackson
Acked-byRe: [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm
In reply to Ian CampbellIan Campbell writes ("Re: [Xen-devel] [PATCH 14 of 32 RFC] libxl: HVM device configuration info build_info->u.hvm"):
Quoted 6 lines · Ian Jackson
Quoted 2 lines
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.
Quoted 8 lines
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_usbas a thing which is completely orthogonal to these two.I think a similar argument applies to the audio option?
Fair enough.
...
Quoted 3 lines
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:
Thanks,
Ian.
RFC PATCH 1/1 libxl: move gfx_passthru setting to b_info->u.hvm
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_dm.c +2 -2
@@ -248,7 +248,7 @@ static char ** libxl__build_device_modelif ( 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_modelflexarray_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 {
tools/libxl/libxl_types.idl +2 -1
@@ -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
tools/libxl/xl_cmdimpl.c +2 -5
@@ -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 charif (!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 ))
Re: [PATCH 15 of 32 RFC] libxl: move gfx_passthru setting to b_info->u.hvm
Ian Campbell writes ("[Xen-devel] [PATCH 15 of 32 RFC] libxl: move gfx_passthru > libxl: move gfx_passthru setting to b_info->u.hvm
RFC PATCH 1/1 libxl: Remove libxl_device_model_info.type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +0 -1
@@ -592,7 +592,6 @@ static int do_domain_create(libxl__gc *gmemset ((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;
tools/libxl/libxl_dm.c +10 -10
@@ -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(consstatic 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_modelif (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_modelfor (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_modelflexarray_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_modelflexarray_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_modelfor (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_modellibxl__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;
tools/libxl/libxl_types.idl +0 -1
@@ -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
tools/libxl/xl_cmdimpl.c +0 -2
@@ -1216,8 +1216,6 @@ skip_vfb: b_info->u.hvm.xen_platform_pci = l; } - dm_info->type = c_info->type; -xlu_cfg_destroy (config); }
Re: [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type
Ian Campbell writes ("[Xen-devel] [PATCH 16 of 32 RFC] libxl: Remove libxl_device_model_info.type"):
Quoted 1 line
libxl: Remove libxl_device_model_info.type.
RFC PATCH 1/1 libxl: remove uuid from device model info
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +0 -2
@@ -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 ;
tools/libxl/libxl_dm.c +1 -1
@@ -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;
tools/libxl/libxl_types.idl +0 -3
@@ -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
Re: [PATCH 17 of 32 RFC] libxl: remove uuid from device model info
Ian Campbell writes ("[Xen-devel] [PATCH 17 of 32 RFC] libxl: remove uuid from device model info"):
Quoted 1 line
libxl: remove uuid from device model info.
RFC PATCH 1/1 libxl: move device model selection variables to b_info
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl.c +1 -1
@@ -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 :
tools/libxl/libxl_create.c +10 -13
@@ -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 *gif (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); }
tools/libxl/libxl_dm.c +31 -26
151 lines not on this page · raw message
tools/libxl/libxl_dom.c +2 -2
@@ -297,7 +297,7 @@ static const char *libxl__domain_firmwarif (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_firmwarbreak ;default :LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"invalid device model version %d" , - dm_info->device_model_version); + info->device_model_version);return NULL ;break ; }
tools/libxl/libxl_internal.h +1 -1
@@ -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,
tools/libxl/libxl_types.idl +13 -10
@@ -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), ], )
tools/libxl/xl_cmdimpl.c +7 -7
@@ -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); \
RFC PATCH 1/1 libxl: move "saved_state" to libxl__domain_build_state
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +7 -10
@@ -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);
tools/libxl/libxl_dm.c +34 -27
190 lines not on this page · raw message
tools/libxl/libxl_internal.h +5 -1
@@ -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,
tools/libxl/libxl_types.idl +0 -2
@@ -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), ], )
Re: [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state
Ian Campbell writes ("[Xen-devel] [PATCH 19 of 32 RFC] libxl: move "saved_state" to libxl__domain_build_state"):
Quoted 1 line
libxl: move "
saved_state" tolibxl__domain_build_state.
RFC PATCH 1/1 libxl: remove libxl_device_model_info
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl.c +1 -1
@@ -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 ;
tools/libxl/libxl.h +1 -6
@@ -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 *ctint 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 *cint 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 */
tools/libxl/libxl_create.c +6 -27
@@ -55,7 +55,6 @@ void libxl_domain_config_dispose(libxl_dlibxl_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 *ctxreturn 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_devicint 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 *gmemset (&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 *glibxl_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 *glibxl_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 ; }
tools/libxl/libxl_dm.c +84 -85
426 lines not on this page · raw message
tools/libxl/libxl_dom.c +2 -4
@@ -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_firmwarint 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;
tools/libxl/libxl_internal.h +4 -5
@@ -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,
tools/libxl/xl_cmdimpl.c +9 -15
@@ -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_lisstatic 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_inif (!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_cif (!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 lchar *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 lcontinue ;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);
Re: [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info
Ian Campbell writes ("[Xen-devel] [PATCH 20 of 32 RFC] libxl: remove libxl_device_model_info"):
Quoted 1 line
libxl: remove
libxl_device_model_info.
RFC PATCH 1/1 libxl: drop vfs patch -- fsback/front were deleted some time ago
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1326386958 0
# Node ID 9771c7a1959e680ab8ef7de9008232770f04aecd
# Parent 1e558d62909f4f236bb5edd7019073593564ac31
libxl: drop vfs patch -- fsback/front were deleted some time ago
tools/libxl/libxl_dm.c +0 -5
@@ -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;
Re: [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago
Quoted 1 line · Ian Campbell
libxl: drop vfs patch -- fsback/front were deleted some time ago
Do you mean path instead of patch?
Olaf
Re: [PATCH 21 of 32 RFC] libxl: drop vfs patch -- fsback/front were deleted some time ago
Quoted 6 lines · Olaf Hering
Quoted 1 line · Ian Campbell
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.
Re: [PATCH 21 of 32] libxl: drop vfs patch
In reply to Ian CampbellIan Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
Quoted 3 lines
libxl: drop vfs path -- fsback/front were deleted some time ago
Signed-off-by Ian Campbell <[email protected]>
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:
Ian.
Re: [PATCH 21 of 32] libxl: drop vfs patch
Quoted 10 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
Quoted 3 lines
libxl: drop vfs path -- fsback/front were deleted some time ago
Signed-off-by Ian Campbell <[email protected]>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 <[email protected]>
Thanks, I'll pull it to the front for the next posting.
Ian.
Ian Campbell
Acked-by Ian JacksonRe: [PATCH 21 of 32] libxl: drop vfs patch
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
Quoted 3 lines
libxl: drop vfs path -- fsback/front were deleted some time ago
Signed-off-by Ian Campbell <[email protected]>
Quoted 7 lines
Quoted 5 lines
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 <[email protected]>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 <[email protected]>
# Date 1326734948 0
# Node ID fed4bb058ea7200ef79b32f54254db92761fd258
# Parent 71571eced36ed674df3d38b4222c2a4bbebe0749
libxl: drop vfs path -- fsback/front were deleted some time ago
tools/libxl/libxl_dm.c +0 -2
@@ -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;
Re: [PATCH 21 of 32] libxl: drop vfs patch
Ian Campbell writes ("Re: [Xen-devel] [PATCH 21 of 32] libxl: drop vfs patch"):
Quoted 4 lines
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.
Thanks,
Ian.
RFC PATCH 1/1 libxl: only write "disable_pf" key to xenstore when it makes sense
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl_dm.c +6 -2
@@ -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),
Re: [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense
Ian Campbell writes ("[Xen-devel] [PATCH 22 of 32 RFC] libxl: only write "disable_pf" key to xenstore when it makes sense"):
Quoted 5 lines
libxl: only write "
disable_pf" key to xenstore when it makes senseThis key is only used by the traditional qemu-dm when servicing an HVM domain.
Signed-off-by Ian Campbell <[email protected]>
RFC PATCH 1/1 libxl: use libxl_*_init internally too
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326388309 0
# Node ID 0d3abdb6c01894e4e07400317a0b49433dbaf1a5 # Parent fa999f4bcd85526a9ad1a6649f4069497801c5cd
libxl: use libxl_*_init internally too
tools/libxl/libxl_dm.c +12 -4
@@ -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 ;
Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
Ian Campbell writes ("[Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
Quoted 1 line
libxl: use libxl_*_init internally too
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ 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.
Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
Quoted 1 line
libxl: use libxl_*_init internally too
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ 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.
Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
Quoted 6 lines
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 ?
Quoted 3 lines
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.
Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
Quoted 6 lines
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").
Quoted 9 lines
Quoted 3 lines
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.
Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too
Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"):
Quoted 4 lines · Ian Jackson
Quoted 1 line
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.
Quoted 6 lines
Quoted 3 lines
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
*_initfunctions 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.
RFC PATCH 1/1 libxl: add new "defbool" built in type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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).
tools/libxl/gentest.py +4 -1
@@ -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:
tools/libxl/libxl.c +41 -0
47 lines not on this page · raw message
tools/libxl/libxl.h +24 -0
@@ -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"
tools/libxl/libxl_json.c +6 -0
@@ -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) {
tools/libxl/libxl_types.idl +2 -0
@@ -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)
tools/libxl/libxlu_cfg.c +11 -0
@@ -235,6 +235,17 @@ int xlu_cfg_get_long(const XLU_Config *creturn 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) {
tools/libxl/libxlutil.h +2 -0
@@ -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 */,
Re: [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type
Ian Campbell writes ("[Xen-devel] [PATCH 24 of 32 RFC] libxl: add new "defbool" built in type"):
Quoted 1 line
libxl: add new "defbool" built in type.
RFC PATCH 1/1 libxl: make boolean members of libxl_domain_create_info into libxl_defbool
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/gentest.py +1 -2
@@ -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"]
tools/libxl/libxl_create.c +19 -9
@@ -60,13 +60,20 @@ void libxl_domain_config_dispose(libxl_dint 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);
tools/libxl/libxl_dm.c +3 -0
@@ -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 ;
tools/libxl/libxl_internal.h +9 -0
@@ -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,
tools/libxl/libxl_types.idl +2 -2
@@ -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),
tools/libxl/xl_cmdimpl.c +4 -6
@@ -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 charlibxl_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 ;
tools/python/genwrap.py +11 -1
@@ -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)]:
tools/python/xen/lowlevel/xl/xl.c +15 -0
@@ -156,6 +156,21 @@ int genwrap__ll_set(PyObject *v, long loreturn 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;
Re: [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
Ian Campbell writes ("[Xen-devel] [PATCH 25 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool"):
Quoted 1 line
libxl: make boolean members of
libxl_domain_create_infointolibxl_defbool
Modulo a decision about the representation of "default".
Ian.
RFC PATCH 1/1 libxl: make boolean members of libxl_domain_create_info into libxl_defbool
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl.c +6 -1
@@ -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 ))
tools/libxl/libxl.h +1 -1
@@ -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);
tools/libxl/libxl_bootloader.c +3 -0
@@ -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;
tools/libxl/libxl_create.c +40 -18
110 lines not on this page · raw message
tools/libxl/libxl_dm.c +7 -5
@@ -200,7 +200,7 @@ static char ** libxl__build_device_modelif (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_modelif (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_modelflexarray_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_modelif (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),
tools/libxl/libxl_dom.c +13 -8
@@ -95,7 +95,7 @@ int libxl__build_pre(libxl__gc *gc, uintabort (); }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_interreturn -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_interxc_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 ;
tools/libxl/libxl_internal.h +2 -0
@@ -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);
tools/libxl/libxl_pci.c +1 -1
@@ -1381,7 +1381,7 @@ int libxl__e820_alloc(libxl__gc *gc, uinreturn 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 );
tools/libxl/libxl_types.idl +17 -17
@@ -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), ])), ])), ],
tools/libxl/xl_cmdimpl.c +41 -53
152 lines not on this page · raw message
Re: [PATCH 26 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool
Ian Campbell writes ("[Xen-devel] [PATCH 26 of 32 RFC] libxl: make boolean members of libxl_domain_create_info into libxl_defbool"):
Quoted 1 line
libxl: make boolean members of
libxl_domain_create_infointolibxl_defbool
RFC PATCH 1/1 libxl: use defbool for graphics related options
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326474297 0
# Node ID b8426902efa002b6941aee6dff109aa33a4372c8 # Parent 81def18dfda0899a8c7309f284d7ee4d6009da62
libxl: use defbool for graphics related options
tools/libxl/libxl.c +25 -14
@@ -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); }
tools/libxl/libxl_create.c +22 -6
@@ -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_setdefaultslibxl_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);
tools/libxl/libxl_dm.c +16 -16
@@ -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_modelflexarray_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_modelflexarray_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_modelif ( 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__gcreturn 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_modelif (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_modelflexarray_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_modelflexarray_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_modelflexarray_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 {
tools/libxl/libxl_types.idl +10 -10
@@ -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),
tools/libxl/xl_cmdimpl.c +50 -43
150 lines not on this page · raw message
tools/ocaml/libs/xl/genwrap.py +1 -0
@@ -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)"),
tools/ocaml/libs/xl/xenlight_stubs.c +40 -0
@@ -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, structCAMLreturn (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 ();
Re: [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options
Ian Campbell writes ("[Xen-devel] [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options"):
Quoted 1 line
libxl: use defbool for graphics related options
...
Quoted 10 lines
diff -r
81def18dfda0-rb8426902efa0tools/ocaml/libs/xl/xenlight_stubs.ctools/ocaml/libs/xl/xenlight_stubs.c +3
-0@@ -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)
...
tools/ocaml/libs/xl/xenlight_stubs.c static int string_string_tuple_array_val · line 138
Quoted 2 lines
tools/ocaml/libs/xl/xenlight_stubs.c +2
-0+static value Val_some (value v) +{
...
I wasn't expecting to find this at the end of this patch.
Ian.
Re: [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options
Quoted 14 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 27 of 32 RFC] libxl: use defbool for graphics related options"):
Quoted 1 line
libxl: use defbool for graphics related options
...
Quoted 10 lines
diff -r
81def18dfda0-rb8426902efa0tools/ocaml/libs/xl/xenlight_stubs.ctools/ocaml/libs/xl/xenlight_stubs.c +3
-0@@ -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)...
Quoted 5 lines
tools/ocaml/libs/xl/xenlight_stubs.c static int string_string_tuple_array_val · line 138
Quoted 2 lines
tools/ocaml/libs/xl/xenlight_stubs.c +2
-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.
RFC PATCH 1/1 libxl: initialise NULL==default members of build info later
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.
tools/libxl/libxl_create.c +17 -15
@@ -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 *ctxswitch (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 *ctxint 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_setdefaultslibxl_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);
RFC PATCH 1/1 libxl: add named enum for timer mode
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +3 -1
@@ -91,7 +91,6 @@ int libxl_init_build_info(libxl_ctx *ctxswitch (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_setdefaultscase 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);
tools/libxl/libxl_dom.c +8 -1
@@ -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_interxc_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,
tools/libxl/libxl_types.idl +10 -1
@@ -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),
tools/libxl/xl_cmdimpl.c +26 -2
@@ -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 charxlu_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 :
Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
Ian Campbell writes ("[Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
Quoted 4 lines
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.
Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
Quoted 4 lines
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.
Quoted 1 line
we could decree that all-bits-set means "use default value".
Do you mean in genral or just this specific field?
Ian.
Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
Ian Campbell writes ("Re: [Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
Quoted 6 lines
I'm happy to take either approach to be honest. I imagine most
_initfunctions 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.)
Quoted 3 lines
Quoted 1 line
we could decree that all-bits-set means "use default value".
Do you mean in genral or just this specific field?
In general.
Ian.
Re: [PATCH 29 of 32 RFC] libxl: add named enum for timer mode
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH 29 of 32 RFC] libxl: add named enum for timer mode"):
Quoted 6 lines
I'm happy to take either approach to be honest. I imagine most
_initfunctions 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...
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
we could decree that all-bits-set means "use default value".
Do you mean in genral or just this specific field?
In general.
Ian.
RFC PATCH 1/1 libxl: drop 8M slack for PV guests
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # 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.
tools/libxl/libxl_create.c +0 -12
@@ -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 ; }
RFC PATCH 1/1 libxl: switch device model selection over to libxl_defbool
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1326713598 0
# Node ID a2dc899d0f229d82baca92a06b3b7a5b4d918324 # Parent 7ffc8e870fbb5a9edcd6f8d46f2b0296d38cb5ed
libxl: switch device model selection over to libxl_defbool
tools/libxl/libxl.c +1 -1
@@ -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 :
tools/libxl/libxl_create.c +6 -5
@@ -84,17 +84,18 @@ int libxl_init_build_info(libxl_ctx *ctxmemset (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)
tools/libxl/libxl_dm.c +2 -2
@@ -47,7 +47,7 @@ const char *libxl__domain_device_model(llibxl_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__gcchar **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; }
tools/libxl/libxl_types.idl +2 -2
@@ -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
tools/libxl/xl_cmdimpl.c +2 -2
@@ -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, \
Re: [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool
Ian Campbell writes ("[Xen-devel] [PATCH 31 of 32 RFC] libxl: switch device model selection over to libxl_defbool"):
Quoted 1 line
libxl: switch device model selection over to
libxl_defbool
RFC PATCH 1/1 libxl: Default to stub device model whenever possible
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326715929 0
# Node ID 953a1ce643856edcf9fbbbc2680690b3a26dede8 # Parent a2dc899d0f229d82baca92a06b3b7a5b4d918324
libxl: Default to stub device model whenever possible.
tools/libxl/libxl_create.c +14 -1
@@ -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 ;
tools/libxl/libxl_dm.c +6 -2
@@ -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 ="" ;
tools/libxl/libxl_internal.h +2 -0
@@ -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,
Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
Quoted 6 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326715929 0
# Node ID953a1ce643856edcf9fbbbc2680690b3a26dede8# Parenta2dc899d0f229d82baca92a06b3b7a5b4d918324
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.
Quoted 70 lines
Signed-off-by Ian Campbell <[email protected]>diff -r
a2dc899d0f22-r953a1ce64385tools/libxl/libxl_create.ctools/libxl/libxl_create.c +14
-1@@ -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-r953a1ce64385tools/libxl/libxl_dm.ctools/libxl/libxl_dm.c +6
-2@@ -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-r953a1ce64385tools/libxl/libxl_internal.htools/libxl/libxl_internal.h +2
-0@@ -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
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
Quoted 8 lines · Stefano Stabellini
Quoted 6 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326715929 0
# Node ID953a1ce643856edcf9fbbbc2680690b3a26dede8# Parenta2dc899d0f229d82baca92a06b3b7a5b4d918324
libxl: Default to stub device model whenever possible.
Quoted 6 lines
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.
Quoted 72 lines
Quoted 72 lines
Signed-off-by Ian Campbell <[email protected]>diff -r
a2dc899d0f22-r953a1ce64385tools/libxl/libxl_create.ctools/libxl/libxl_create.c +14
-1@@ -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-r953a1ce64385tools/libxl/libxl_dm.ctools/libxl/libxl_dm.c +6
-2@@ -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-r953a1ce64385tools/libxl/libxl_internal.htools/libxl/libxl_internal.h +2
-0@@ -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
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
Quoted 16 lines · Ian Campbell
Quoted 8 lines · Stefano Stabellini
Quoted 6 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326715929 0
# Node ID953a1ce643856edcf9fbbbc2680690b3a26dede8# Parenta2dc899d0f229d82baca92a06b3b7a5b4d918324
libxl: Default to stub device model whenever possible.Quoted 6 lines
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.
Quoted 3 lines
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.
Quoted 1 line
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.
Quoted 8 lines
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_setdefaultsto 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.
Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
Quoted 28 lines · Stefano Stabellini
Quoted 16 lines · Ian Campbell
Quoted 8 lines · Stefano Stabellini
Quoted 6 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1326715929 0
# Node ID953a1ce643856edcf9fbbbc2680690b3a26dede8# Parenta2dc899d0f229d82baca92a06b3b7a5b4d918324
libxl: Default to stub device model whenever possible.Quoted 6 lines
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.Quoted 3 lines
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.
Quoted 3 lines
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.
Quoted 14 lines
Quoted 10 lines
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_setdefaultsto 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.
Re: [PATCH 32 of 32 RFC] libxl: Default to stub device model whenever possible
Quoted 22 lines · Ian Campbell
Quoted 18 lines
Quoted 10 lines
Quoted 6 lines
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.Quoted 3 lines
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.
Quoted 6 lines
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 :)