This is the first portion of my previous "libxl: drop device_model_info, better defaults support, stubdoms by default" series. Specifically it is the "drop device_model_info" bit (plus some incidental bits & bobs). I''ve split it to make it all a bit more manageable and to allow it to be reviewed while I address some other concerns with the latter bits of the other series. This comes after "libxl: tweak the cpupool interface slightly" which I sent this morning in my queue but I think the only relation is a tiny bit of overlap of the context in patch #2. It also comes after "libxl: remove _libxl_json_internal.h from libxl_json.h" but I beleive there is no overlap there. Ian.
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 01 of 20] libxl: remove comment support from IDL
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID 63146f3cd17e526c53496adeeddf5da90f13d2bc # Parent 80c94293e87d80c7f375ac330d46333c65d0005d libxl: remove comment support from IDL People typically don''t look for comments in generated source and the syntax for specifying them in the IDL makes things harder to follow. Instead just use source code comments in the IDL itself. I dropped a bunch of "foo bool # enable or disable foo" type comments. A lot of the remainder still aren''t terribly useful though. No change to the generate code other than the comments being removed. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 80c94293e87d -r 63146f3cd17e tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/gentypes.py Mon Jan 23 16:38:17 2012 +0000 @@ -5,19 +5,6 @@ import re import libxltypes -def format_comment(level, comment): - indent = reduce(lambda x,y: x + " ", range(level), "") - s = "%s/*\n" % indent - s += "%s * " % indent - comment = comment.replace("\n", "\n%s * " % indent) - x = re.compile(r''^%s \* $'' % indent, re.MULTILINE) - comment = x.sub("%s *" % indent, comment) - s += comment - s += "\n" - s += "%s */" % indent - s += "\n" - return s - def libxl_C_instance_of(ty, instancename): if isinstance(ty, libxltypes.Aggregate) and ty.typename is None: if instancename is None: @@ -30,17 +17,12 @@ def libxl_C_instance_of(ty, instancename def libxl_C_type_define(ty, indent = ""): s = "" if isinstance(ty, libxltypes.Enumeration): - if ty.comment is not None: - s += format_comment(0, ty.comment) - if ty.typename is None: s += "enum {\n" else: s += "typedef enum %s {\n" % ty.typename for v in ty.values: - if v.comment is not None: - s += format_comment(4, v.comment) x = "%s = %d" % (v.name, v.value) x = x.replace("\n", "\n ") s += " " + x + ",\n" @@ -50,17 +32,12 @@ def libxl_C_type_define(ty, indent = "") s += "} %s" % ty.typename elif isinstance(ty, libxltypes.Aggregate): - if ty.comment is not None: - s += format_comment(0, ty.comment) - if ty.typename is None: s += "%s {\n" % ty.kind else: s += "typedef %s %s {\n" % (ty.kind, ty.typename) for f in ty.fields: - if f.comment is not None: - s += format_comment(4, f.comment) x = libxl_C_instance_of(f.type, f.name) if f.const: x = "const " + x diff -r 80c94293e87d -r 63146f3cd17e tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -28,8 +28,8 @@ libxl_domain_type = Enumeration("domain_ ]) libxl_device_model_version = Enumeration("device_model_version", [ - (1, "QEMU_XEN_TRADITIONAL", "Historical qemu-xen device model (qemu-dm)"), - (2, "QEMU_XEN", "Upstream based qemu-xen device model"), + (1, "QEMU_XEN_TRADITIONAL"), # Historical qemu-xen device model (qemu-dm) + (2, "QEMU_XEN"), # Upstream based qemu-xen device model ]) libxl_console_type = Enumeration("console_type", [ @@ -98,18 +98,18 @@ libxl_tsc_mode = Enumeration("tsc_mode", libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), ("domid", libxl_domid), - ("ssidref", uint32), + ("ssidref", uint32), ("running", bool), ("blocked", bool), ("paused", bool), ("shutdown", bool), ("dying", bool), - ("shutdown_reason", uint8, False, -"""Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying). - -Otherwise set to a value guaranteed not to clash with any valid -SHUTDOWN_* constant."""), + # Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying). + # + # Otherwise set to a value guaranteed not to clash with any valid + # SHUTDOWN_* constant. + ("shutdown_reason", uint8), ("current_memkb", uint64), ("shared_memkb", uint64), ("max_memkb", uint64), @@ -158,6 +158,11 @@ libxl_domain_create_info = Struct("domai ("poolid", uint32), ]) +# Instances of libxl_file_reference contained in this struct which +# have been mapped (with libxl_file_reference_map) will be unmapped +# by libxl_domain_build/restore. If either of these are never called +# then the user is responsible for calling +# libxl_file_reference_unmap. libxl_domain_build_info = Struct("domain_build_info",[ ("max_vcpus", integer), ("cur_vcpus", integer), @@ -192,84 +197,87 @@ libxl_domain_build_info = Struct("domain ("cmdline", string), ("ramdisk", libxl_file_reference), ("features", string, True), - ("e820_host", bool, False, "Use host''s E820 for PCI passthrough."), + # Use host''s E820 for PCI passthrough. + ("e820_host", bool), ])), ])), ], - comment -"""Instances of libxl_file_reference contained in this struct which -have been mapped (with libxl_file_reference_map) will be unmapped -by libxl_domain_build/restore. If either of these are never called -then the user is responsible for calling -libxl_file_reference_unmap.""") +) +# Device Model Information libxl_device_model_info = Struct("device_model_info",[ ("domid", libxl_domid), - ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"), + + # uuid is used only with stubdom, and must be different from the + # domain uuid + ("uuid", libxl_uuid), ("dom_name", string), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", bool), - ("device_model", string, False, "if you set this you must set device_model_version too"), + # you set device_model you must set device_model_version too + ("device_model", string), ("saved_state", string), ("type", libxl_domain_type), ("target_ram", uint32), - ("videoram", integer, False, "size of the videoram in MB"), - ("stdvga", bool, False, "stdvga enabled or disabled"), - ("vnc", bool, False, "vnc enabled or disabled"), - ("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"), - ("vncpasswd", string, False, "the VNC password"), - ("vncdisplay", integer, False, "set VNC display number"), - ("vncunused", bool, False, "try to find an unused port for the VNC server"), - ("keymap", string, False, "set keyboard layout, default is en-us keyboard"), - ("sdl", bool, False, "sdl enabled or disabled"), - ("opengl", bool, False, "opengl enabled or disabled (if enabled requires sdl enabled)"), - ("spice", bool, False, - "spice enabled or disabled"), - ("spiceport", integer, False, - "the port that should be listened on for the spice server"), - ("spicetls_port", integer, False, """the tls port -that should be listened on for the spice server, -at least one of the port or tls port must be given"""), - ("spicehost", string, False, """the interface -that should be listened on if given otherwise any interface"""), - ("spicedisable_ticketing", bool, False, - "enable client connection with no password"), - ("spicepasswd", string, False, """set ticket password -witch must be used by a client for connection. -The password never expires"""), - ("spiceagent_mouse", bool, False, - "Whether spice agent is used for client mouse mode(default is on)"), - ("nographic", bool, False, "no graphics, use serial port"), - ("gfx_passthru", bool, False, "graphics passthrough enabled or disabled"), - ("serial", string, False, "serial port re-direct to pty deivce"), - ("boot", string, False, "boot order, for example dca"), - ("usb", bool, False, "usb support enabled or disabled"), - ("usbdevice", string, False, "enable usb mouse: tablet for absolute mouse, mouse for PS/2 protocol relative mouse"), - ("soundhw", string, False, "enable sound hardware"), - ("acpi", bool, False, "acpi enabled or disabled"), - ("vcpus", integer, False, "max number of vcpus"), - ("vcpu_avail", integer, False, "vcpus actually available"), - ("xen_platform_pci", bool, False, "enable/disable the xen platform pci device"), - ("extra", libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"), - ("extra_pv", libxl_string_list, False, "extra parameters pass directly to qemu for PV guest, NULL terminated"), - ("extra_hvm", libxl_string_list, False, "extra parameters pass directly to qemu for HVM guest, NULL terminated"), + # size of the videoram in MB + ("videoram", integer), + ("stdvga", bool), + ("vnc", bool), + # "address:port" that should be listened on for the VNC server + ("vnclisten", string), + ("vncpasswd", string), + # VNC display number + ("vncdisplay", integer), + # If set then try to find an unused port for the VNC server + ("vncunused", bool), + # keyboard layout, default is en-us keyboard + ("keymap", string), + ("sdl", bool), + ("opengl", bool), # (requires sdl enabled) + ("spice", bool), + # At least one of spice port or spicetls_post must be given + ("spiceport", integer), + ("spicetls_port", integer), + # Interface to bind to + ("spicehost", string), + # enable client connection with no password + ("spicedisable_ticketing", bool), + ("spicepasswd", string), + ("spiceagent_mouse", bool), + ("nographic", bool), + ("gfx_passthru", bool), + ("serial", string), + ("boot", string), + ("usb", bool), + # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse + ("usbdevice", string), + ("soundhw", string), + ("acpi", bool), + ("vcpus", integer), # max number of vcpus + ("vcpu_avail", integer), # vcpus actually available + ("xen_platform_pci", bool), + # extra parameters pass directly to qemu, NULL terminated + ("extra", libxl_string_list), + # extra parameters pass directly to qemu for PV guest, NULL terminated + ("extra_pv", libxl_string_list), + # extra parameters pass directly to qemu for HVM guest, NULL terminated + ("extra_hvm", libxl_string_list), ], - comment-"""Device Model information. - -Network is missing""") +) libxl_device_vfb = Struct("device_vfb", [ ("backend_domid", libxl_domid), ("devid", integer), - ("vnc", bool, False, "vnc enabled or disabled"), - ("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"), - ("vncpasswd", string, False, "the VNC password"), - ("vncdisplay", integer, False, "set VNC display number"), - ("vncunused", bool, False, "try to find an unused port for the VNC server"), - ("keymap", string, False, "set keyboard layout, default is en-us keyboard"), - ("sdl", bool, False, "sdl enabled or disabled"), - ("opengl", bool, False, "opengl enabled or disabled (if enabled requires sdl enabled)"), + ("vnc", bool), + # address:port that should be listened on for the VNC server if vnc is set + ("vnclisten", string), + ("vncpasswd", string), + ("vncdisplay", integer), + ("vncunused", bool), + # set keyboard layout, default is en-us keyboard + ("keymap", string), + ("sdl", bool), + ("opengl", bool), # (if enabled requires sdl enabled) ("display", string), ("xauthority", string), ]) @@ -346,13 +354,13 @@ libxl_nicinfo = Struct("nicinfo", [ ]) libxl_vcpuinfo = Struct("vcpuinfo", [ - ("vcpuid", uint32, False, "vcpu''s id"), - ("cpu", uint32, False, "current mapping"), - ("online", bool, False, "currently online (not hotplugged)?"), - ("blocked", bool, False, "blocked waiting for an event?"), - ("running", bool, False, "currently scheduled on its CPU?"), - ("vcpu_time", uint64, False, "total vcpu time ran (ns)"), - ("cpumap", libxl_cpumap, False, "current cpu''s affinities"), + ("vcpuid", uint32), + ("cpu", uint32), + ("online", bool), + ("blocked", bool), + ("running", bool), + ("vcpu_time", uint64), # total vcpu time ran (ns) + ("cpumap", libxl_cpumap), # current cpu''s affinities ]) libxl_physinfo = Struct("physinfo", [ @@ -373,9 +381,9 @@ libxl_physinfo = Struct("physinfo", [ ], dispose_fn=None, dir=DIR_OUT) libxl_topologyinfo = Struct("topologyinfo", [ - ("coremap", libxl_cpuarray, False, "cpu to core map"), - ("socketmap", libxl_cpuarray, False, "cpu to socket map"), - ("nodemap", libxl_cpuarray, False, "cpu to node map"), + ("coremap", libxl_cpuarray), # cpu to core map + ("socketmap", libxl_cpuarray), # cpu to socket map + ("nodemap", libxl_cpuarray), # cpu to node map ]) libxl_sched_credit = Struct("sched_credit", [ diff -r 80c94293e87d -r 63146f3cd17e tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxltypes.py Mon Jan 23 16:38:17 2012 +0000 @@ -22,7 +22,6 @@ def _get_default_namespace(): class Type(object): def __init__(self, typename, **kwargs): - self.comment = kwargs.setdefault(''comment'', None) self.namespace = kwargs.setdefault(''namespace'', _get_default_namespace()) self.dir = kwargs.setdefault(''dir'', DIR_BOTH) @@ -120,7 +119,6 @@ class EnumerationValue(object): self.rawname = str.upper(enum.rawname) + "_" + self.valuename self.name = str.upper(enum.namespace) + self.rawname self.value = value - self.comment = kwargs.setdefault("comment", None) class Enumeration(Type): def __init__(self, typename, values, **kwargs): @@ -129,16 +127,9 @@ class Enumeration(Type): self.values = [] for v in values: - # (value, name[, comment=None]) - if len(v) == 2: - (num,name) = v - comment = None - elif len(v) == 3: - num,name,comment = v - else: - raise "" + # (value, name) + (num,name) = v self.values.append(EnumerationValue(self, num, name, - comment=comment, typename=self.rawname)) def lookup(self, name): for v in self.values: @@ -152,7 +143,6 @@ class Field(object): self.type = type self.name = name self.const = kwargs.setdefault(''const'', False) - self.comment = kwargs.setdefault(''comment'', None) self.enumname = kwargs.setdefault(''enumname'', None) class Aggregate(Type): @@ -164,19 +154,17 @@ class Aggregate(Type): self.fields = [] for f in fields: - # (name, type[, const=False[, comment=None]]) + # (name, type[, const=False]) if len(f) == 2: n,t = f const = False - comment = None elif len(f) == 3: n,t,const = f - comment = None else: - n,t,const,comment = f + raise ValueError if n is None: raise ValueError - self.fields.append(Field(t,n,const=const,comment=comment)) + self.fields.append(Field(t,n,const=const)) # Returns a tuple (stem, field-expr) #
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 02 of 20] libxl: use keyword arguments for field definitions in aggregate types
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID 7a22673b930e5cc9dce8a1b43df4c4ca8daf49aa # Parent 63146f3cd17e526c53496adeeddf5da90f13d2bc libxl: use keyword arguments for field definitions in aggregate types. The original code is not so bad now that the comments are gone but this is still a bit cleaner. No change in the generated code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 63146f3cd17e -r 7a22673b930e tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -196,7 +196,7 @@ libxl_domain_build_info = Struct("domain ("bootloader_args", libxl_string_list), ("cmdline", string), ("ramdisk", libxl_file_reference), - ("features", string, True), + ("features", string, {''const'': True}), # Use host''s E820 for PCI passthrough. ("e820_host", bool), ])), diff -r 63146f3cd17e -r 7a22673b930e tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxltypes.py Mon Jan 23 16:38:17 2012 +0000 @@ -154,17 +154,17 @@ class Aggregate(Type): self.fields = [] for f in fields: - # (name, type[, const=False]) + # (name, type[, {kw args}]) if len(f) == 2: n,t = f - const = False + kw = {} elif len(f) == 3: - n,t,const = f + n,t,kw = f else: raise ValueError if n is None: raise ValueError - self.fields.append(Field(t,n,const=const)) + self.fields.append(Field(t,n,**kw)) # Returns a tuple (stem, field-expr) #
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 03 of 20] ocaml: use libxl IDL type helpers for C argument passing
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID a44bd706400238c6f5e309c3925fa90718b80576 # Parent 7a22673b930e5cc9dce8a1b43df4c4ca8daf49aa ocaml: use libxl IDL type helpers for C argument passing Makes handling of nested structs more correct. Only change to the generated code right now is that the FOO_Val (C->ocamlC) function for Enumeration types now takes the C argument by value instead of reference. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 7a22673b930e -r a44bd7064002 tools/ocaml/libs/xl/genwrap.py --- a/tools/ocaml/libs/xl/genwrap.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/ocaml/libs/xl/genwrap.py Mon Jan 23 16:38:17 2012 +0000 @@ -112,11 +112,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]: @@ -148,17 +143,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" @@ -171,11 +167,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]: @@ -198,7 +189,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 @@ -212,20 +203,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
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 04 of 20] libxl: define libxl_vnc_info to hold all info about the vnc info
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID 83418dbcfc0ab05da8dc1774e66deeb421eae003 # Parent a44bd706400238c6f5e309c3925fa90718b80576 libxl: define libxl_vnc_info to hold all info about the vnc info Reduces duplication in libxl_vfb and libxl_device_model. Updated bindings but the python ones in particular are unlikely to be useful until a user presents itself and fixes them up. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 @@ -1943,11 +1943,11 @@ int libxl_device_vfb_init(libxl_ctx *ctx memset(vfb, 0x00, sizeof(libxl_device_vfb)); vfb->display = NULL; vfb->xauthority = NULL; - vfb->vnc = 1; - vfb->vncpasswd = NULL; - vfb->vnclisten = strdup("127.0.0.1"); - vfb->vncdisplay = 0; - vfb->vncunused = 1; + vfb->vnc.enable = 1; + vfb->vnc.passwd = NULL; + vfb->vnc.listen = strdup("127.0.0.1"); + vfb->vnc.display = 0; + vfb->vnc.findunused = 1; vfb->keymap = NULL; vfb->sdl = 0; vfb->opengl = 0; @@ -1993,11 +1993,14 @@ int libxl_device_vfb_add(libxl_ctx *ctx, flexarray_append_pair(back, "online", "1"); flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1)); flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid)); - flexarray_append_pair(back, "vnc", libxl__sprintf(gc, "%d", vfb->vnc)); - flexarray_append_pair(back, "vnclisten", vfb->vnclisten); - flexarray_append_pair(back, "vncpasswd", vfb->vncpasswd); - flexarray_append_pair(back, "vncdisplay", libxl__sprintf(gc, "%d", vfb->vncdisplay)); - flexarray_append_pair(back, "vncunused", libxl__sprintf(gc, "%d", vfb->vncunused)); + flexarray_append_pair(back, "vnc", + libxl__sprintf(gc, "%d", vfb->vnc.enable)); + flexarray_append_pair(back, "vnclisten", vfb->vnc.listen); + flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd); + flexarray_append_pair(back, "vncdisplay", + libxl__sprintf(gc, "%d", vfb->vnc.display)); + flexarray_append_pair(back, "vncunused", + libxl__sprintf(gc, "%d", vfb->vnc.findunused)); flexarray_append_pair(back, "sdl", libxl__sprintf(gc, "%d", vfb->sdl)); flexarray_append_pair(back, "opengl", libxl__sprintf(gc, "%d", vfb->opengl)); if (vfb->xauthority) { diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 @@ -126,10 +126,10 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->vcpu_avail = b_info->cur_vcpus; dm_info->stdvga = 0; - dm_info->vnc = 1; - dm_info->vnclisten = strdup("127.0.0.1"); - dm_info->vncdisplay = 0; - dm_info->vncunused = 1; + dm_info->vnc.enable = 1; + dm_info->vnc.listen = strdup("127.0.0.1"); + dm_info->vnc.display = 0; + dm_info->vnc.findunused = 1; dm_info->keymap = NULL; dm_info->sdl = 0; dm_info->opengl = 0; diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -92,31 +92,31 @@ static char ** libxl__build_device_model if (info->dom_name) flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL); - if (info->vnc) { + if (info->vnc.enable) { char *vncarg; - if (info->vncdisplay) { - if (info->vnclisten && strchr(info->vnclisten, '':'') == NULL) { + if (info->vnc.display) { + if (info->vnc.listen && strchr(info->vnc.listen, '':'') == NULL) { vncarg = libxl__sprintf(gc, "%s:%d", - info->vnclisten, - info->vncdisplay); + info->vnc.listen, + info->vnc.display); } else { - vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vncdisplay); + vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vnc.display); } - } else if (info->vnclisten) { - if (strchr(info->vnclisten, '':'') != NULL) { - vncarg = info->vnclisten; + } else if (info->vnc.listen) { + if (strchr(info->vnc.listen, '':'') != NULL) { + vncarg = info->vnc.listen; } else { - vncarg = libxl__sprintf(gc, "%s:0", info->vnclisten); + vncarg = libxl__sprintf(gc, "%s:0", info->vnc.listen); } } else { vncarg = "127.0.0.1:0"; } - if (info->vncpasswd && (info->vncpasswd[0] != ''\0'')) + if (info->vnc.passwd && (info->vnc.passwd[0] != ''\0'')) vncarg = libxl__sprintf(gc, "%s,password", vncarg); flexarray_append(dm_args, "-vnc"); flexarray_append(dm_args, vncarg); - if (info->vncunused) { + if (info->vnc.findunused) { flexarray_append(dm_args, "-vncunused"); } } @@ -129,7 +129,7 @@ static char ** libxl__build_device_model if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc)) { + if (info->nographic && (!info->sdl && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -260,32 +260,32 @@ static char ** libxl__build_device_model if (info->dom_name) { flexarray_vappend(dm_args, "-name", info->dom_name, NULL); } - if (info->vnc) { + if (info->vnc.enable) { int display = 0; const char *listen = "127.0.0.1"; - if (info->vncpasswd && info->vncpasswd[0]) { + if (info->vnc.passwd && info->vnc.passwd[0]) { assert(!"missing code for supplying vnc password to qemu"); } flexarray_append(dm_args, "-vnc"); - if (info->vncdisplay) { - display = info->vncdisplay; - if (info->vnclisten && strchr(info->vnclisten, '':'') == NULL) { - listen = info->vnclisten; + if (info->vnc.display) { + display = info->vnc.display; + if (info->vnc.listen && strchr(info->vnc.listen, '':'') == NULL) { + listen = info->vnc.listen; } - } else if (info->vnclisten) { - listen = info->vnclisten; + } else if (info->vnc.listen) { + listen = info->vnc.listen; } if (strchr(listen, '':'') != NULL) flexarray_append(dm_args, libxl__sprintf(gc, "%s%s", listen, - info->vncunused ? ",to=99" : "")); + info->vnc.findunused ? ",to=99" : "")); else flexarray_append(dm_args, libxl__sprintf(gc, "%s:%d%s", listen, display, - info->vncunused ? ",to=99" : "")); + info->vnc.findunused ? ",to=99" : "")); } if (info->sdl) { flexarray_append(dm_args, "-sdl"); @@ -335,7 +335,7 @@ static char ** libxl__build_device_model if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc)) { + if (info->nographic && (!info->sdl && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -524,10 +524,6 @@ static int libxl__vfb_and_vkb_from_devic vfb->backend_domid = 0; vfb->devid = 0; vfb->vnc = info->vnc; - vfb->vnclisten = info->vnclisten; - vfb->vncdisplay = info->vncdisplay; - vfb->vncunused = info->vncunused; - vfb->vncpasswd = info->vncpasswd; vfb->keymap = info->keymap; vfb->sdl = info->sdl; vfb->opengl = info->opengl; @@ -851,7 +847,7 @@ int libxl__create_device_model(libxl__gc goto out_close; } - if (info->vncpasswd) { + if (info->vnc.passwd) { retry_transaction: /* Find uuid and the write the vnc password to xenstore for qemu. */ t = xs_transaction_start(ctx->xsh); @@ -860,7 +856,7 @@ retry_transaction: /* Now write the vncpassword into it. */ pass_stuff = libxl__calloc(gc, 3, sizeof(char *)); pass_stuff[0] = "vncpasswd"; - pass_stuff[1] = info->vncpasswd; + pass_stuff[1] = info->vnc.passwd; libxl__xs_writev(gc,t,vm_path,pass_stuff); if (!xs_transaction_end(ctx->xsh, t, 0)) if (errno == EAGAIN) @@ -975,13 +971,13 @@ static int libxl__build_xenpv_qemu_args( libxl_ctx *ctx = libxl__gc_owner(gc); if (vfb != NULL) { - info->vnc = vfb->vnc; - if (vfb->vnclisten) - info->vnclisten = libxl__strdup(gc, vfb->vnclisten); - info->vncdisplay = vfb->vncdisplay; - info->vncunused = vfb->vncunused; - if (vfb->vncpasswd) - info->vncpasswd = vfb->vncpasswd; + info->vnc.enable = vfb->vnc.enable; + if (vfb->vnc.listen) + info->vnc.listen = libxl__strdup(gc, vfb->vnc.listen); + info->vnc.display = vfb->vnc.display; + info->vnc.findunused = vfb->vnc.findunused; + if (vfb->vnc.passwd) + info->vnc.passwd = vfb->vnc.passwd; if (vfb->keymap) info->keymap = libxl__strdup(gc, vfb->keymap); info->sdl = vfb->sdl; diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -95,6 +95,16 @@ libxl_tsc_mode = Enumeration("tsc_mode", # # Complex libxl types # +libxl_vnc_info = Struct("vnc_info", [ + ("enable", bool), + # "address:port" that should be listened on + ("listen", string), + ("passwd", string), + ("display", integer), + # If set then try to find an unused port + ("findunused", bool), + ]) + libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), ("domid", libxl_domid), @@ -222,14 +232,7 @@ libxl_device_model_info = Struct("device # size of the videoram in MB ("videoram", integer), ("stdvga", bool), - ("vnc", bool), - # "address:port" that should be listened on for the VNC server - ("vnclisten", string), - ("vncpasswd", string), - # VNC display number - ("vncdisplay", integer), - # If set then try to find an unused port for the VNC server - ("vncunused", bool), + ("vnc", libxl_vnc_info), # keyboard layout, default is en-us keyboard ("keymap", string), ("sdl", bool), @@ -268,12 +271,7 @@ libxl_device_model_info = Struct("device libxl_device_vfb = Struct("device_vfb", [ ("backend_domid", libxl_domid), ("devid", integer), - ("vnc", bool), - # address:port that should be listened on for the VNC server if vnc is set - ("vnclisten", string), - ("vncpasswd", string), - ("vncdisplay", integer), - ("vncunused", bool), + ("vnc", libxl_vnc_info), # set keyboard layout, default is en-us keyboard ("keymap", string), ("sdl", bool), diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 @@ -366,10 +366,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); @@ -456,10 +456,10 @@ static void printf_info(int domid, printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid); printf("\t\t\t(frontend_domid %d)\n", domid); printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid); - printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc); - printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnclisten); - printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vncdisplay); - printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vncunused); + printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable); + printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen); + printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display); + printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused); printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap); printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl); printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].opengl); @@ -961,17 +961,17 @@ skip: break; *p2 = ''\0''; if (!strcmp(p, "vnc")) { - vfb->vnc = atoi(p2 + 1); + vfb->vnc.enable = atoi(p2 + 1); } else if (!strcmp(p, "vnclisten")) { - free(vfb->vnclisten); - vfb->vnclisten = strdup(p2 + 1); + free(vfb->vnc.listen); + vfb->vnc.listen = strdup(p2 + 1); } else if (!strcmp(p, "vncpasswd")) { - free(vfb->vncpasswd); - vfb->vncpasswd = strdup(p2 + 1); + free(vfb->vnc.passwd); + vfb->vnc.passwd = strdup(p2 + 1); } else if (!strcmp(p, "vncdisplay")) { - vfb->vncdisplay = atoi(p2 + 1); + vfb->vnc.display = atoi(p2 + 1); } else if (!strcmp(p, "vncunused")) { - vfb->vncunused = atoi(p2 + 1); + vfb->vnc.findunused = atoi(p2 + 1); } else if (!strcmp(p, "keymap")) { free(vfb->keymap); vfb->keymap = strdup(p2 + 1); @@ -1178,13 +1178,13 @@ skip_vfb: if (!xlu_cfg_get_long (config, "stdvga", &l, 0)) dm_info->stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l, 0)) - dm_info->vnc = l; - xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnclisten, 0); - xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vncpasswd, 0); + dm_info->vnc.enable = l; + xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0); + xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0); if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0)) - dm_info->vncdisplay = l; + dm_info->vnc.display = l; if (!xlu_cfg_get_long (config, "vncunused", &l, 0)) - dm_info->vncunused = l; + dm_info->vnc.findunused = l; xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0); if (!xlu_cfg_get_long (config, "sdl", &l, 0)) dm_info->sdl = l; diff -r a44bd7064002 -r 83418dbcfc0a tools/python/genwrap.py --- a/tools/python/genwrap.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/python/genwrap.py Mon Jan 23 16:38:17 2012 +0000 @@ -4,7 +4,7 @@ import sys,os import libxltypes -(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING) = range(4) +(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5) def py_type(ty): if ty == libxltypes.bool: @@ -16,6 +16,8 @@ def py_type(ty): return TYPE_INT else: return TYPE_UINT + if isinstance(ty, libxltypes.Aggregate): + return TYPE_AGGREGATE if ty == libxltypes.string: return TYPE_STRING return None @@ -66,6 +68,9 @@ def py_attrib_get(ty, f): l.append('' return genwrap__ull_get(self->obj.%s);''%f.name) elif t == TYPE_STRING: l.append('' return genwrap__string_get(&self->obj.%s);''%f.name) + elif t == TYPE_AGGREGATE: + l.append('' PyErr_SetString(PyExc_NotImplementedError, "Getting %s");''%ty.typename) + l.append('' return NULL;'') else: tn = f.type.typename l.append('' return attrib__%s_get((%s *)&self->obj.%s);''%(fsanitize(tn), tn, f.name)) @@ -92,6 +97,9 @@ def py_attrib_set(ty, f): l.append('' return ret;'') elif t == TYPE_STRING: l.append('' return genwrap__string_set(v, &self->obj.%s);''%f.name) + elif t == TYPE_AGGREGATE: + l.append('' PyErr_SetString(PyExc_NotImplementedError, "Setting %s");''%ty.typename) + l.append('' return -1;'') else: tn = f.type.typename l.append('' return attrib__%s_set(v, (%s *)&self->obj.%s);''%(fsanitize(tn), tn, f.name))
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 05 of 20] libxl: define libxl_spice_info to hold all info about the spice server
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID e241db296cbfa86557cd5cfaf7bb870e455dedad # Parent 83418dbcfc0ab05da8dc1774e66deeb421eae003 libxl: define libxl_spice_info to hold all info about the spice server Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 83418dbcfc0a -r e241db296cbf tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -290,39 +290,39 @@ static char ** libxl__build_device_model if (info->sdl) { flexarray_append(dm_args, "-sdl"); } - if (info->spice) { + if (info->spice.enable) { char *spiceoptions = NULL; - if (!info->spiceport && !info->spicetls_port) { + if (!info->spice.port && !info->spice.tls_port) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "at least one of the spiceport or tls_port must be provided"); return NULL; } - if (!info->spicedisable_ticketing) { - if (!info->spicepasswd) { + if (!info->spice.disable_ticketing) { + if (!info->spice.passwd) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "spice ticketing is enabled but missing password"); return NULL; } - else if (!info->spicepasswd[0]) { + else if (!info->spice.passwd[0]) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "spice password can''t be empty"); return NULL; } } spiceoptions = libxl__sprintf(gc, "port=%d,tls-port=%d", - info->spiceport, info->spicetls_port); - if (info->spicehost) + info->spice.port, info->spice.tls_port); + if (info->spice.host) spiceoptions = libxl__sprintf(gc, - "%s,addr=%s", spiceoptions, info->spicehost); - if (info->spicedisable_ticketing) + "%s,addr=%s", spiceoptions, info->spice.host); + if (info->spice.disable_ticketing) spiceoptions = libxl__sprintf(gc, "%s,disable-ticketing", spiceoptions); else spiceoptions = libxl__sprintf(gc, - "%s,password=%s", spiceoptions, info->spicepasswd); + "%s,password=%s", spiceoptions, info->spice.passwd); spiceoptions = libxl__sprintf(gc, "%s,agent-mouse=%s", spiceoptions, - info->spiceagent_mouse ? "on" : "off"); + info->spice.agent_mouse ? "on" : "off"); flexarray_append(dm_args, "-spice"); flexarray_append(dm_args, spiceoptions); diff -r 83418dbcfc0a -r e241db296cbf tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -105,6 +105,26 @@ libxl_vnc_info = Struct("vnc_info", [ ("findunused", bool), ]) +libxl_spice_info = Struct("spice_info", [ + ("enable", bool), + # At least one of spice port or spicetls_post must be given + ("port", integer), + ("tls_port", integer), + # Interface to bind to + ("host", string), + # enable client connection with no password + ("disable_ticketing", bool), + ("passwd", string), + ("agent_mouse", bool), + ]) + +libxl_sdl_info = Struct("sdl_info", [ + ("enable", bool), + ("opengl", bool), + ("display", string), + ("xauthority", string), + ]) + libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), ("domid", libxl_domid), @@ -237,16 +257,7 @@ libxl_device_model_info = Struct("device ("keymap", string), ("sdl", bool), ("opengl", bool), # (requires sdl enabled) - ("spice", bool), - # At least one of spice port or spicetls_post must be given - ("spiceport", integer), - ("spicetls_port", integer), - # Interface to bind to - ("spicehost", string), - # enable client connection with no password - ("spicedisable_ticketing", bool), - ("spicepasswd", string), - ("spiceagent_mouse", bool), + ("spice", libxl_spice_info), ("nographic", bool), ("gfx_passthru", bool), ("serial", string), diff -r 83418dbcfc0a -r e241db296cbf tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 @@ -380,13 +380,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))
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 06 of 20] libxl: define libxl_sdl_info to hold all info about the SDL config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID 16d23a64e9c79955405c44c07f2e39cfb0ad238a # Parent e241db296cbfa86557cd5cfaf7bb870e455dedad libxl: define libxl_sdl_info to hold all info about the SDL config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e241db296cbf -r 16d23a64e9c7 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 @@ -1941,16 +1941,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; } @@ -2001,16 +2001,19 @@ int libxl_device_vfb_add(libxl_ctx *ctx, libxl__sprintf(gc, "%d", vfb->vnc.display)); flexarray_append_pair(back, "vncunused", libxl__sprintf(gc, "%d", vfb->vnc.findunused)); - flexarray_append_pair(back, "sdl", libxl__sprintf(gc, "%d", vfb->sdl)); - flexarray_append_pair(back, "opengl", libxl__sprintf(gc, "%d", vfb->opengl)); - if (vfb->xauthority) { - flexarray_append_pair(back, "xauthority", vfb->xauthority); + flexarray_append_pair(back, "sdl", + libxl__sprintf(gc, "%d", vfb->sdl.enable)); + flexarray_append_pair(back, "opengl", + libxl__sprintf(gc, "%d", vfb->sdl.opengl)); + if (vfb->sdl.xauthority) { + flexarray_append_pair(back, "xauthority", vfb->sdl.xauthority); } - if (vfb->display) { - flexarray_append_pair(back, "display", vfb->display); + if (vfb->sdl.display) { + flexarray_append_pair(back, "display", vfb->sdl.display); } - flexarray_append_pair(front, "backend-id", libxl__sprintf(gc, "%d", vfb->backend_domid)); + flexarray_append_pair(front, "backend-id", + libxl__sprintf(gc, "%d", vfb->backend_domid)); flexarray_append_pair(front, "state", libxl__sprintf(gc, "%d", 1)); libxl__device_generic_add(gc, &device, diff -r e241db296cbf -r 16d23a64e9c7 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 @@ -131,8 +131,8 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->vnc.display = 0; dm_info->vnc.findunused = 1; dm_info->keymap = NULL; - dm_info->sdl = 0; - dm_info->opengl = 0; + dm_info->sdl.enable = 0; + dm_info->sdl.opengl = 0; dm_info->nographic = 0; dm_info->serial = NULL; dm_info->boot = strdup("cda"); diff -r e241db296cbf -r 16d23a64e9c7 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -120,16 +120,17 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-vncunused"); } } - if (info->sdl) { + if (info->sdl.enable) { flexarray_append(dm_args, "-sdl"); - if (!info->opengl) { + if (!info->sdl.opengl) { flexarray_append(dm_args, "-disable-opengl"); } + /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */ } if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc.enable)) { + if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -287,8 +288,9 @@ static char ** libxl__build_device_model libxl__sprintf(gc, "%s:%d%s", listen, display, info->vnc.findunused ? ",to=99" : "")); } - if (info->sdl) { + if (info->sdl.enable) { flexarray_append(dm_args, "-sdl"); + /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */ } if (info->spice.enable) { char *spiceoptions = NULL; @@ -335,7 +337,7 @@ static char ** libxl__build_device_model if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc.enable)) { + if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -526,7 +528,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; @@ -981,7 +982,6 @@ static int libxl__build_xenpv_qemu_args( if (vfb->keymap) info->keymap = libxl__strdup(gc, vfb->keymap); info->sdl = vfb->sdl; - info->opengl = vfb->opengl; } else info->nographic = 1; info->domid = domid; diff -r e241db296cbf -r 16d23a64e9c7 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -255,8 +255,7 @@ libxl_device_model_info = Struct("device ("vnc", libxl_vnc_info), # keyboard layout, default is en-us keyboard ("keymap", string), - ("sdl", bool), - ("opengl", bool), # (requires sdl enabled) + ("sdl", libxl_sdl_info), ("spice", libxl_spice_info), ("nographic", bool), ("gfx_passthru", bool), @@ -283,12 +282,9 @@ libxl_device_vfb = Struct("device_vfb", ("backend_domid", libxl_domid), ("devid", integer), ("vnc", libxl_vnc_info), + ("sdl", libxl_sdl_info), # set keyboard layout, default is en-us keyboard ("keymap", string), - ("sdl", bool), - ("opengl", bool), # (if enabled requires sdl enabled) - ("display", string), - ("xauthority", string), ]) libxl_device_vkb = Struct("device_vkb", [ diff -r e241db296cbf -r 16d23a64e9c7 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 @@ -371,9 +371,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); @@ -461,10 +461,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))
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 07 of 20] libxl: plumb libxl_domain_config down into device model creation
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID c03b3c71a923216fe50882770a72b3cc9f433a85 # Parent 16d23a64e9c79955405c44c07f2e39cfb0ad238a libxl: plumb libxl_domain_config down into device model creation. Creating the device model derives lots of bits from the guest configuration. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 16d23a64e9c7 -r c03b3c71a923 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 @@ -568,7 +568,7 @@ static int do_domain_create(libxl__gc *g libxl_device_vkb_dispose(&vkb); dm_info->domid = domid; - ret = libxl__create_device_model(gc, dm_info, + ret = libxl__create_device_model(gc, d_config, dm_info, d_config->disks, d_config->num_disks, d_config->vifs, d_config->num_vifs, &dm_starting); @@ -615,7 +615,8 @@ static int do_domain_create(libxl__gc *g xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv; xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm; - libxl__create_xenpv_qemu(gc, domid, &xenpv_dm_info, + libxl__create_xenpv_qemu(gc, domid, + d_config, &xenpv_dm_info, d_config->vfbs, &dm_starting); } break; diff -r 16d23a64e9c7 -r c03b3c71a923 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -74,10 +74,11 @@ static const char *libxl__domain_bios(li } static char ** libxl__build_device_model_args_old(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { int i; flexarray_t *dm_args; @@ -228,10 +229,11 @@ static const char *qemu_disk_format_stri } static char ** libxl__build_device_model_args_new(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { libxl_ctx *ctx = libxl__gc_owner(gc); flexarray_t *dm_args; @@ -492,20 +494,21 @@ static char ** libxl__build_device_model } static char ** libxl__build_device_model_args(libxl__gc *gc, - const char *dm, - libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs) + const char *dm, + const libxl_domain_config *guest_config, + const libxl_device_model_info *info, + const libxl_device_disk *disks, int num_disks, + const libxl_device_nic *vifs, int num_vifs) { libxl_ctx *ctx = libxl__gc_owner(gc); switch (info->device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - return libxl__build_device_model_args_old(gc, dm, info, + return libxl__build_device_model_args_old(gc, dm, guest_config, info, disks, num_disks, vifs, num_vifs); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - return libxl__build_device_model_args_new(gc, dm, info, + return libxl__build_device_model_args_new(gc, dm, guest_config, info, disks, num_disks, vifs, num_vifs); default: @@ -516,9 +519,9 @@ static char ** libxl__build_device_model } static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc, - libxl_device_model_info *info, - libxl_device_vfb *vfb, - libxl_device_vkb *vkb) + const libxl_device_model_info *info, + libxl_device_vfb *vfb, + libxl_device_vkb *vkb) { memset(vfb, 0x00, sizeof(libxl_device_vfb)); memset(vkb, 0x00, sizeof(libxl_device_vkb)); @@ -583,6 +586,7 @@ retry_transaction: } static int libxl__create_stubdom(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, @@ -593,8 +597,7 @@ static int libxl__create_stubdom(libxl__ libxl_ctx *ctx = libxl__gc_owner(gc); int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret; libxl_device_console *console; - libxl_domain_create_info c_info; - libxl_domain_build_info b_info; + libxl_domain_config dm_config; libxl__domain_build_state state; uint32_t domid; char **args; @@ -608,7 +611,35 @@ static int libxl__create_stubdom(libxl__ goto out; } - args = libxl__build_device_model_args(gc, "stubdom-dm", info, + memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info)); + dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV; + dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid)); + + libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid); + + memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info)); + dm_config.b_info.max_vcpus = 1; + dm_config.b_info.max_memkb = 32 * 1024; + dm_config.b_info.target_memkb = dm_config.b_info.max_memkb; + + dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV; + dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", + libxl_xenfirmwaredir_path()); + dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); + dm_config.b_info.u.pv.ramdisk.path = ""; + dm_config.b_info.u.pv.features = ""; + + /* fixme: this function can leak the stubdom if it fails */ + domid = 0; + ret = libxl__domain_make(gc, &dm_config.c_info, &domid); + if (ret) + goto out; + ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &state); + if (ret) + goto out; + + args = libxl__build_device_model_args(gc, "stubdom-dm", + guest_config, info, disks, num_disks, vifs, num_vifs); if (!args) { @@ -616,33 +647,6 @@ static int libxl__create_stubdom(libxl__ goto out; } - memset(&c_info, 0x00, sizeof(libxl_domain_create_info)); - c_info.type = LIBXL_DOMAIN_TYPE_PV; - c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid)); - - libxl_uuid_copy(&c_info.uuid, &info->uuid); - - memset(&b_info, 0x00, sizeof(libxl_domain_build_info)); - b_info.max_vcpus = 1; - b_info.max_memkb = 32 * 1024; - b_info.target_memkb = b_info.max_memkb; - - b_info.type = LIBXL_DOMAIN_TYPE_PV; - b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", - libxl_xenfirmwaredir_path()); - b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); - b_info.u.pv.ramdisk.path = ""; - b_info.u.pv.features = ""; - - /* fixme: this function can leak the stubdom if it fails */ - domid = 0; - ret = libxl__domain_make(gc, &c_info, &domid); - if (ret) - goto out_free; - ret = libxl__domain_build(gc, &b_info, info, domid, &state); - if (ret) - goto out_free; - libxl__write_dmargs(gc, domid, info->domid, args); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/image/device-model-domid", libxl__xs_get_dompath(gc, info->domid)), @@ -739,6 +743,7 @@ retry_transaction: xenpv_dm_info.extra_hvm = info->extra_hvm; if (libxl__create_xenpv_qemu(gc, domid, + &dm_config, &xenpv_dm_info, vfb, &dm_starting) < 0) { ret = ERROR_FAIL; @@ -768,6 +773,7 @@ out: } int libxl__create_device_model(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, @@ -789,7 +795,7 @@ int libxl__create_device_model(libxl__gc libxl_device_vkb vkb; libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - rc = libxl__create_stubdom(gc, info, + rc = libxl__create_stubdom(gc, guest_config, info, disks, num_disks, vifs, num_vifs, &vfb, &vkb, starting_r); @@ -807,7 +813,8 @@ int libxl__create_device_model(libxl__gc rc = ERROR_FAIL; goto out; } - args = libxl__build_device_model_args(gc, dm, info, disks, num_disks, + args = libxl__build_device_model_args(gc, dm, guest_config, info, + disks, num_disks, vifs, num_vifs); if (!args) { rc = ERROR_FAIL; @@ -1027,12 +1034,13 @@ out: } int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, + libxl_domain_config *guest_config, libxl_device_model_info *info, libxl_device_vfb *vfb, libxl__spawner_starting **starting_r) { libxl__build_xenpv_qemu_args(gc, domid, vfb, info); - libxl__create_device_model(gc, info, NULL, 0, NULL, 0, starting_r); + libxl__create_device_model(gc, guest_config, info, NULL, 0, NULL, 0, starting_r); return 0; } diff -r 16d23a64e9c7 -r c03b3c71a923 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Jan 23 16:38:17 2012 +0000 @@ -493,11 +493,13 @@ _hidden int libxl__domain_build(libxl__g _hidden const char *libxl__domain_device_model(libxl__gc *gc, libxl_device_model_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, + libxl_domain_config *guest_config, libxl_device_model_info *info, - libxl_device_disk *disk, int num_disks, + libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, libxl__spawner_starting **starting_r); _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, + libxl_domain_config *guest_config, libxl_device_model_info *dm_info, libxl_device_vfb *vfb, libxl__spawner_starting **starting_r); diff -r 16d23a64e9c7 -r c03b3c71a923 tools/libxl/libxl_uuid.c --- a/tools/libxl/libxl_uuid.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_uuid.c Mon Jan 23 16:38:17 2012 +0000 @@ -35,7 +35,7 @@ int libxl_uuid_from_string(libxl_uuid *u return uuid_parse(in, uuid->uuid); } -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src) +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src) { uuid_copy(dst->uuid, src->uuid); } @@ -82,7 +82,7 @@ int libxl_uuid_from_string(libxl_uuid *u } #undef LIBXL__UUID_PTRS -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src) +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src) { memcpy(dst->uuid, src->uuid, sizeof(dst->uuid)); } diff -r 16d23a64e9c7 -r c03b3c71a923 tools/libxl/libxl_uuid.h --- a/tools/libxl/libxl_uuid.h Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_uuid.h Mon Jan 23 16:38:17 2012 +0000 @@ -56,7 +56,7 @@ typedef struct { int libxl_uuid_is_nil(libxl_uuid *uuid); void libxl_uuid_generate(libxl_uuid *uuid); int libxl_uuid_from_string(libxl_uuid *uuid, const char *in); -void libxl_uuid_copy(libxl_uuid *dst, libxl_uuid *src); +void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src); void libxl_uuid_clear(libxl_uuid *uuid); int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2); uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid);
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 08 of 20] libxl: now that dm creation takes domain_config stop passing down devices
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336697 0 # Node ID e6287c6308bd2ef1fb6440ee2be4f0d5492566f9 # Parent c03b3c71a923216fe50882770a72b3cc9f433a85 libxl: now that dm creation takes domain_config stop passing down devices. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r c03b3c71a923 -r e6287c6308bd tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 @@ -569,8 +569,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, @@ -616,8 +614,7 @@ static int do_domain_create(libxl__gc *g xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm; libxl__create_xenpv_qemu(gc, domid, - d_config, &xenpv_dm_info, - d_config->vfbs, &dm_starting); + d_config, &xenpv_dm_info, &dm_starting); } break; } diff -r c03b3c71a923 -r e6287c6308bd tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -76,10 +76,10 @@ static const char *libxl__domain_bios(li static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, - const libxl_device_disk *disks, int num_disks, - const libxl_device_nic *vifs, int num_vifs) + const libxl_device_model_info *info) { + const libxl_device_nic *vifs = guest_config->vifs; + const int num_vifs = guest_config->num_vifs; int i; flexarray_t *dm_args; dm_args = flexarray_make(16, 1); @@ -231,11 +231,13 @@ static const char *qemu_disk_format_stri static char ** libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, - const libxl_device_disk *disks, int num_disks, - const libxl_device_nic *vifs, int num_vifs) + const libxl_device_model_info *info) { libxl_ctx *ctx = libxl__gc_owner(gc); + const libxl_device_disk *disks = guest_config->disks; + const libxl_device_nic *vifs = guest_config->vifs; + const int num_disks = guest_config->num_disks; + const int num_vifs = guest_config->num_vifs; flexarray_t *dm_args; int i; @@ -496,21 +498,15 @@ static char ** libxl__build_device_model static char ** libxl__build_device_model_args(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, - const libxl_device_disk *disks, int num_disks, - const libxl_device_nic *vifs, int num_vifs) + const libxl_device_model_info *info) { libxl_ctx *ctx = libxl__gc_owner(gc); switch (info->device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - return libxl__build_device_model_args_old(gc, dm, guest_config, info, - disks, num_disks, - vifs, num_vifs); + return libxl__build_device_model_args_old(gc, dm, guest_config, info); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - return libxl__build_device_model_args_new(gc, dm, guest_config, info, - disks, num_disks, - vifs, num_vifs); + return libxl__build_device_model_args_new(gc, dm, guest_config, info); default: LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", info->device_model_version); @@ -588,16 +584,14 @@ retry_transaction: static int libxl__create_stubdom(libxl__gc *gc, libxl_domain_config *guest_config, libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs, - libxl_device_vfb *vfb, - libxl_device_vkb *vkb, libxl__spawner_starting **starting_r) { libxl_ctx *ctx = libxl__gc_owner(gc); int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret; libxl_device_console *console; libxl_domain_config dm_config; + libxl_device_vfb vfb; + libxl_device_vkb vkb; libxl__domain_build_state state; uint32_t domid; char **args; @@ -629,6 +623,19 @@ static int libxl__create_stubdom(libxl__ dm_config.b_info.u.pv.ramdisk.path = ""; dm_config.b_info.u.pv.features = ""; + dm_config.disks = guest_config->disks; + dm_config.num_disks = guest_config->num_disks; + + dm_config.vifs = guest_config->vifs; + dm_config.num_vifs = guest_config->num_vifs; + + libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); + + dm_config.vfbs = &vfb; + dm_config.num_vfbs = 1; + dm_config.vkbs = &vkb; + dm_config.num_vkbs = 1; + /* fixme: this function can leak the stubdom if it fails */ domid = 0; ret = libxl__domain_make(gc, &dm_config.c_info, &domid); @@ -639,9 +646,7 @@ static int libxl__create_stubdom(libxl__ goto out; args = libxl__build_device_model_args(gc, "stubdom-dm", - guest_config, info, - disks, num_disks, - vifs, num_vifs); + guest_config, info); if (!args) { ret = ERROR_FAIL; goto out; @@ -674,20 +679,20 @@ retry_transaction: if (errno == EAGAIN) goto retry_transaction; - for (i = 0; i < num_disks; i++) { - ret = libxl_device_disk_add(ctx, domid, &disks[i]); + for (i = 0; i < dm_config.num_disks; i++) { + ret = libxl_device_disk_add(ctx, domid, &dm_config.disks[i]); if (ret) goto out_free; } - for (i = 0; i < num_vifs; i++) { - ret = libxl_device_nic_add(ctx, domid, &vifs[i]); + for (i = 0; i < dm_config.num_vifs; i++) { + ret = libxl_device_nic_add(ctx, domid, &dm_config.vifs[i]); if (ret) goto out_free; } - ret = libxl_device_vfb_add(ctx, domid, vfb); + ret = libxl_device_vfb_add(ctx, domid, &dm_config.vfbs[0]); if (ret) goto out_free; - ret = libxl_device_vkb_add(ctx, domid, vkb); + ret = libxl_device_vkb_add(ctx, domid, &dm_config.vkbs[0]); if (ret) goto out_free; @@ -745,7 +750,7 @@ retry_transaction: if (libxl__create_xenpv_qemu(gc, domid, &dm_config, &xenpv_dm_info, - vfb, &dm_starting) < 0) { + &dm_starting) < 0) { ret = ERROR_FAIL; goto out_free; } @@ -775,8 +780,6 @@ out: int libxl__create_device_model(libxl__gc *gc, libxl_domain_config *guest_config, libxl_device_model_info *info, - libxl_device_disk *disks, int num_disks, - libxl_device_nic *vifs, int num_vifs, libxl__spawner_starting **starting_r) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -791,14 +794,7 @@ int libxl__create_device_model(libxl__gc const char *dm; if (info->device_model_stubdomain) { - libxl_device_vfb vfb; - libxl_device_vkb vkb; - - libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - rc = libxl__create_stubdom(gc, guest_config, info, - disks, num_disks, - vifs, num_vifs, - &vfb, &vkb, starting_r); + rc = libxl__create_stubdom(gc, guest_config, info, starting_r); goto out; } @@ -813,9 +809,7 @@ int libxl__create_device_model(libxl__gc rc = ERROR_FAIL; goto out; } - args = libxl__build_device_model_args(gc, dm, guest_config, info, - disks, num_disks, - vifs, num_vifs); + args = libxl__build_device_model_args(gc, dm, guest_config, info); if (!args) { rc = ERROR_FAIL; goto out; @@ -1036,11 +1030,10 @@ out: int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, libxl_domain_config *guest_config, libxl_device_model_info *info, - libxl_device_vfb *vfb, libxl__spawner_starting **starting_r) { - libxl__build_xenpv_qemu_args(gc, domid, vfb, info); - libxl__create_device_model(gc, guest_config, info, NULL, 0, NULL, 0, starting_r); + libxl__build_xenpv_qemu_args(gc, domid, &guest_config->vfbs[0], info); + libxl__create_device_model(gc, guest_config, info, starting_r); return 0; } diff -r c03b3c71a923 -r e6287c6308bd tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Jan 23 16:38:17 2012 +0000 @@ -495,13 +495,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,
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 09 of 20] libxl: remove redundant info from dm info
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID ceec8103098f611789c4fe6405b7f681d8b21f0e # Parent e6287c6308bd2ef1fb6440ee2be4f0d5492566f9 libxl: remove redundant info from dm info. Remove "target_ram", "acpi", "vcpus" and "vcpu_avail" from device model info and use domain_build_info instead. These must all be consistently specified to both the domain and the device model, there is no need (and a great deal of danger) in exposing a way for a user of libxl to set them differently. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e6287c6308bd -r ceec8103098f tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -119,11 +119,7 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; - dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb); dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); - dm_info->acpi = b_info->u.hvm.acpi; - dm_info->vcpus = b_info->max_vcpus; - dm_info->vcpu_avail = b_info->cur_vcpus; dm_info->stdvga = 0; dm_info->vnc.enable = 1; diff -r e6287c6308bd -r ceec8103098f tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -78,6 +78,7 @@ static char ** libxl__build_device_model const libxl_domain_config *guest_config, const libxl_device_model_info *info) { + const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_device_nic *vifs = guest_config->vifs; const int num_vifs = guest_config->num_vifs; int i; @@ -159,14 +160,18 @@ static char ** libxl__build_device_model if (info->soundhw) { flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL); } - if (info->acpi) { + if (b_info->u.hvm.acpi) { flexarray_append(dm_args, "-acpi"); } - if (info->vcpus > 1) { - flexarray_vappend(dm_args, "-vcpus", libxl__sprintf(gc, "%d", info->vcpus), NULL); + if (b_info->max_vcpus > 1) { + flexarray_vappend(dm_args, "-vcpus", + libxl__sprintf(gc, "%d", b_info->max_vcpus), + NULL); } - if (info->vcpu_avail) { - flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL); + if (b_info->cur_vcpus) { + flexarray_vappend(dm_args, "-vcpu_avail", + libxl__sprintf(gc, "0x%x", b_info->cur_vcpus), + NULL); } for (i = 0; i < num_vifs; i++) { if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { @@ -234,6 +239,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; @@ -366,15 +372,18 @@ static char ** libxl__build_device_model if (info->soundhw) { flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL); } - if (!info->acpi) { + if (!b_info->u.hvm.acpi) { flexarray_append(dm_args, "-no-acpi"); } - if (info->vcpus > 1) { + if (b_info->max_vcpus > 1) { flexarray_append(dm_args, "-smp"); - if (info->vcpu_avail) - flexarray_append(dm_args, libxl__sprintf(gc, "%d,maxcpus=%d", info->vcpus, info->vcpu_avail)); + if (b_info->cur_vcpus) + flexarray_append(dm_args, libxl__sprintf(gc, "%d,maxcpus=%d", + b_info->max_vcpus, + b_info->cur_vcpus)); else - flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus)); + flexarray_append(dm_args, libxl__sprintf(gc, "%d", + b_info->max_vcpus)); } for (i = 0; i < num_vifs; i++) { if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { @@ -432,7 +441,9 @@ static char ** libxl__build_device_model /* RAM Size */ flexarray_append(dm_args, "-m"); - flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram)); + flexarray_append(dm_args, + libxl__sprintf(gc, "%d", + libxl__sizekb_to_mb(b_info->target_memkb))); if (info->type == LIBXL_DOMAIN_TYPE_HVM) { for (i = 0; i < num_disks; i++) { diff -r e6287c6308bd -r ceec8103098f tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -248,7 +248,6 @@ libxl_device_model_info = Struct("device ("device_model", string), ("saved_state", string), ("type", libxl_domain_type), - ("target_ram", uint32), # size of the videoram in MB ("videoram", integer), ("stdvga", bool), @@ -265,9 +264,6 @@ libxl_device_model_info = Struct("device # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse ("usbdevice", string), ("soundhw", string), - ("acpi", bool), - ("vcpus", integer), # max number of vcpus - ("vcpu_avail", integer), # vcpus actually available ("xen_platform_pci", bool), # extra parameters pass directly to qemu, NULL terminated ("extra", libxl_string_list), diff -r e6287c6308bd -r ceec8103098f tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -379,7 +379,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);
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID e5bc9888a14f19b625489b6b2cd7206c9f3be262 # Parent ceec8103098f611789c4fe6405b7f681d8b21f0e libxl: drop dm_info.dom_name This is always the same as the c_info name which we now have available. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r ceec8103098f -r e5bc9888a14f tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -115,7 +115,6 @@ int libxl_init_dm_info(libxl_ctx *ctx, libxl_uuid_generate(&dm_info->uuid); - dm_info->dom_name = strdup(c_info->name); dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; diff -r ceec8103098f -r e5bc9888a14f tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -78,6 +78,7 @@ static char ** libxl__build_device_model const libxl_domain_config *guest_config, const libxl_device_model_info *info) { + const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_device_nic *vifs = guest_config->vifs; const int num_vifs = guest_config->num_vifs; @@ -91,8 +92,8 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, dm, "-d", libxl__sprintf(gc, "%d", info->domid), NULL); - if (info->dom_name) - flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL); + if (c_info->name) + flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL); if (info->vnc.enable) { char *vncarg; @@ -239,6 +240,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; @@ -268,8 +270,8 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-xen-attach"); } - if (info->dom_name) { - flexarray_vappend(dm_args, "-name", info->dom_name, NULL); + if (c_info->name) { + flexarray_vappend(dm_args, "-name", c_info->name, NULL); } if (info->vnc.enable) { int display = 0; @@ -793,6 +795,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; @@ -835,7 +838,9 @@ int libxl__create_device_model(libxl__gc xs_mkdir(ctx->xsh, XBT_NULL, path); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci); - libxl_create_logfile(ctx, libxl__sprintf(gc, "qemu-dm-%s", info->dom_name), &logfile); + libxl_create_logfile(ctx, + libxl__sprintf(gc, "qemu-dm-%s", c_info->name), + &logfile); logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644); free(logfile); null = open("/dev/null", O_RDONLY); @@ -981,8 +986,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) @@ -997,7 +1000,6 @@ static int libxl__build_xenpv_qemu_args( } else info->nographic = 1; info->domid = domid; - info->dom_name = libxl_domid_to_name(ctx, domid); return 0; } diff -r ceec8103098f -r e5bc9888a14f tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -241,7 +241,6 @@ libxl_device_model_info = Struct("device # uuid is used only with stubdom, and must be different from the # domain uuid ("uuid", libxl_uuid), - ("dom_name", string), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", bool), # you set device_model you must set device_model_version too
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 11 of 20] libxl: use vfb[0] directly for xenpv device model
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID d3882dfe0aa93b5be6ce1ae85cf9e07f4146b620 # Parent e5bc9888a14f19b625489b6b2cd7206c9f3be262 libxl: use vfb[0] directly for xenpv device model Rather than laundering it via dm info. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e5bc9888a14f -r d3882dfe0aa9 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -73,6 +73,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, @@ -81,6 +105,8 @@ static char ** libxl__build_device_model const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_device_nic *vifs = guest_config->vifs; + const libxl_vnc_info *vnc = dm_vnc(guest_config, info); + const libxl_sdl_info *sdl = dm_sdl(guest_config, info); const int num_vifs = guest_config->num_vifs; int i; flexarray_t *dm_args; @@ -95,45 +121,45 @@ static char ** libxl__build_device_model if (c_info->name) flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL); - if (info->vnc.enable) { + if (vnc) { char *vncarg; - if (info->vnc.display) { - if (info->vnc.listen && strchr(info->vnc.listen, '':'') == NULL) { + if (vnc->display) { + if (vnc->listen && strchr(vnc->listen, '':'') == NULL) { vncarg = libxl__sprintf(gc, "%s:%d", - info->vnc.listen, - info->vnc.display); + vnc->listen, + vnc->display); } else { - vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vnc.display); + vncarg = libxl__sprintf(gc, "127.0.0.1:%d", vnc->display); } - } else if (info->vnc.listen) { - if (strchr(info->vnc.listen, '':'') != NULL) { - vncarg = info->vnc.listen; + } else if (vnc->listen) { + if (strchr(vnc->listen, '':'') != NULL) { + vncarg = vnc->listen; } else { - vncarg = libxl__sprintf(gc, "%s:0", info->vnc.listen); + vncarg = libxl__sprintf(gc, "%s:0", vnc->listen); } } else { vncarg = "127.0.0.1:0"; } - if (info->vnc.passwd && (info->vnc.passwd[0] != ''\0'')) + if (vnc->passwd && (vnc->passwd[0] != ''\0'')) vncarg = libxl__sprintf(gc, "%s,password", vncarg); flexarray_append(dm_args, "-vnc"); flexarray_append(dm_args, vncarg); - if (info->vnc.findunused) { + if (vnc->findunused) { flexarray_append(dm_args, "-vncunused"); } } - if (info->sdl.enable) { + if (sdl) { flexarray_append(dm_args, "-sdl"); - if (!info->sdl.opengl) { + if (!sdl->opengl) { flexarray_append(dm_args, "-disable-opengl"); } - /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */ + /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) { + if (info->nographic && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -246,6 +272,8 @@ static char ** libxl__build_device_model const libxl_device_nic *vifs = guest_config->vifs; const int num_disks = guest_config->num_disks; const int num_vifs = guest_config->num_vifs; + const libxl_vnc_info *vnc = dm_vnc(guest_config, info); + const libxl_sdl_info *sdl = dm_sdl(guest_config, info); flexarray_t *dm_args; int i; @@ -273,36 +301,36 @@ static char ** libxl__build_device_model if (c_info->name) { flexarray_vappend(dm_args, "-name", c_info->name, NULL); } - if (info->vnc.enable) { + if (vnc) { int display = 0; const char *listen = "127.0.0.1"; - if (info->vnc.passwd && info->vnc.passwd[0]) { + if (vnc->passwd && vnc->passwd[0]) { assert(!"missing code for supplying vnc password to qemu"); } flexarray_append(dm_args, "-vnc"); - if (info->vnc.display) { - display = info->vnc.display; - if (info->vnc.listen && strchr(info->vnc.listen, '':'') == NULL) { - listen = info->vnc.listen; + if (vnc->display) { + display = vnc->display; + if (vnc->listen && strchr(vnc->listen, '':'') == NULL) { + listen = vnc->listen; } - } else if (info->vnc.listen) { - listen = info->vnc.listen; + } else if (vnc->listen) { + listen = vnc->listen; } if (strchr(listen, '':'') != NULL) flexarray_append(dm_args, libxl__sprintf(gc, "%s%s", listen, - info->vnc.findunused ? ",to=99" : "")); + vnc->findunused ? ",to=99" : "")); else flexarray_append(dm_args, libxl__sprintf(gc, "%s:%d%s", listen, display, - info->vnc.findunused ? ",to=99" : "")); + vnc->findunused ? ",to=99" : "")); } - if (info->sdl.enable) { + if (sdl) { flexarray_append(dm_args, "-sdl"); - /* XXX info->sdl.{display,xauthority} into $DISPLAY/$XAUTHORITY */ + /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } if (info->spice.enable) { char *spiceoptions = NULL; @@ -349,7 +377,7 @@ static char ** libxl__build_device_model if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl.enable && !info->vnc.enable)) { + if (info->nographic && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -795,8 +823,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; @@ -865,7 +894,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); @@ -874,7 +903,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) @@ -983,22 +1012,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; } @@ -1045,7 +1060,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; }
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 12 of 20] libxl: move HVM emulated GFX support into b_info->u.hvm
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 188443bf7392231d675ee195e2e72314c8568f8a # Parent d3882dfe0aa93b5be6ce1ae85cf9e07f4146b620 libxl: move HVM emulated GFX support into b_info->u.hvm Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r d3882dfe0aa9 -r 188443bf7392 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -93,6 +93,16 @@ int libxl_init_build_info(libxl_ctx *ctx b_info->u.hvm.timer_mode = 1; b_info->u.hvm.nested_hvm = 0; b_info->u.hvm.no_incr_generationid = 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; @@ -118,17 +128,7 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; - dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); - dm_info->stdvga = 0; - dm_info->vnc.enable = 1; - dm_info->vnc.listen = strdup("127.0.0.1"); - dm_info->vnc.display = 0; - dm_info->vnc.findunused = 1; - dm_info->keymap = NULL; - dm_info->sdl.enable = 0; - dm_info->sdl.opengl = 0; - dm_info->nographic = 0; dm_info->serial = NULL; dm_info->boot = strdup("cda"); dm_info->usb = 0; diff -r d3882dfe0aa9 -r 188443bf7392 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -78,7 +78,7 @@ static const libxl_vnc_info *dm_vnc(cons { const libxl_vnc_info *vnc = NULL; if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - vnc = &info->vnc; + vnc = &guest_config->b_info.u.hvm.vnc; } else if (guest_config->num_vfbs > 0) { vnc = &guest_config->vfbs[0].vnc; } @@ -90,13 +90,24 @@ static const libxl_sdl_info *dm_sdl(cons { const libxl_sdl_info *sdl = NULL; if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - sdl = &info->sdl; + sdl = &guest_config->b_info.u.hvm.sdl; } else if (guest_config->num_vfbs > 0) { sdl = &guest_config->vfbs[0].sdl; } return sdl && sdl->enable ? sdl : NULL; } +static const char *dm_keymap(const libxl_domain_config *guest_config, + const libxl_device_model_info *info) +{ + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + return guest_config->b_info.u.hvm.keymap; + } else if (guest_config->num_vfbs > 0) { + return guest_config->vfbs[0].keymap; + } else + return NULL; +} + static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, @@ -108,6 +119,7 @@ static char ** libxl__build_device_model const libxl_vnc_info *vnc = dm_vnc(guest_config, info); const libxl_sdl_info *sdl = dm_sdl(guest_config, info); const int num_vifs = guest_config->num_vifs; + const char *keymap = dm_keymap(guest_config, info); int i; flexarray_t *dm_args; dm_args = flexarray_make(16, 1); @@ -156,11 +168,8 @@ static char ** libxl__build_device_model } /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } - if (info->keymap) { - flexarray_vappend(dm_args, "-k", info->keymap, NULL); - } - if (info->nographic && (!sdl && !vnc)) { - flexarray_append(dm_args, "-nographic"); + if (keymap) { + flexarray_vappend(dm_args, "-k", keymap, NULL); } if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); @@ -168,10 +177,17 @@ static char ** libxl__build_device_model if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; - if (info->videoram) { - flexarray_vappend(dm_args, "-videoram", libxl__sprintf(gc, "%d", info->videoram), NULL); + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + flexarray_append(dm_args, "-nographic"); } - if (info->stdvga) { + + if (b_info->video_memkb) { + flexarray_vappend(dm_args, "-videoram", + libxl__sprintf(gc, "%d", + libxl__sizekb_to_mb(b_info->video_memkb)), + NULL); + } + if (b_info->u.hvm.stdvga) { flexarray_append(dm_args, "-std-vga"); } @@ -225,7 +241,11 @@ static char ** libxl__build_device_model if (info->gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } + } else { + if (!sdl && !vnc) + flexarray_append(dm_args, "-nographic"); } + if (info->saved_state) { flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL); } @@ -260,6 +280,42 @@ static const char *qemu_disk_format_stri } } +static char *dm_spice_options(libxl__gc *gc, + const libxl_spice_info *spice) +{ + char *opt; + + if (!spice->port && !spice->tls_port) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "at least one of the spiceport or tls_port must be provided"); + return NULL; + } + + if (!spice->disable_ticketing) { + if (!spice->passwd) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "spice ticketing is enabled but missing password"); + return NULL; + } + else if (!spice->passwd[0]) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "spice password can''t be empty"); + return NULL; + } + } + opt = libxl__sprintf(gc, "port=%d,tls-port=%d", + spice->port, spice->tls_port); + if (spice->host) + opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host); + if (spice->disable_ticketing) + opt = libxl__sprintf(gc, "%s,disable-ticketing", opt); + else + opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd); + opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt, + spice->agent_mouse ? "on" : "off"); + return opt; +} + static char ** libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, @@ -274,6 +330,7 @@ static char ** libxl__build_device_model const int num_vifs = guest_config->num_vifs; const libxl_vnc_info *vnc = dm_vnc(guest_config, info); const libxl_sdl_info *sdl = dm_sdl(guest_config, info); + const char *keymap = dm_keymap(guest_config, info); flexarray_t *dm_args; int i; @@ -332,61 +389,36 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-sdl"); /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */ } - if (info->spice.enable) { - char *spiceoptions = NULL; - if (!info->spice.port && !info->spice.tls_port) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "at least one of the spiceport or tls_port must be provided"); - return NULL; - } - if (!info->spice.disable_ticketing) { - if (!info->spice.passwd) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "spice ticketing is enabled but missing password"); - return NULL; - } - else if (!info->spice.passwd[0]) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "spice password can''t be empty"); - return NULL; - } - } - spiceoptions = libxl__sprintf(gc, "port=%d,tls-port=%d", - info->spice.port, info->spice.tls_port); - if (info->spice.host) - spiceoptions = libxl__sprintf(gc, - "%s,addr=%s", spiceoptions, info->spice.host); - if (info->spice.disable_ticketing) - spiceoptions = libxl__sprintf(gc, "%s,disable-ticketing", - spiceoptions); - else - spiceoptions = libxl__sprintf(gc, - "%s,password=%s", spiceoptions, info->spice.passwd); - spiceoptions = libxl__sprintf(gc, "%s,agent-mouse=%s", spiceoptions, - info->spice.agent_mouse ? "on" : "off"); + /*if (info->type == LIBXL_DOMAIN_TYPE_PV && !b_info->nographic) { + flexarray_vappend(dm_args, "-vga", "xenfb", NULL); + } never was possible?*/ - flexarray_append(dm_args, "-spice"); - flexarray_append(dm_args, spiceoptions); + if (keymap) { + flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->type == LIBXL_DOMAIN_TYPE_PV && !info->nographic) { - flexarray_vappend(dm_args, "-vga", "xenfb", NULL); - } - - if (info->keymap) { - flexarray_vappend(dm_args, "-k", info->keymap, NULL); - } - if (info->nographic && (!sdl && !vnc)) { - flexarray_append(dm_args, "-nographic"); - } if (info->serial) { flexarray_vappend(dm_args, "-serial", info->serial, NULL); } if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; - if (info->stdvga) { + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { + flexarray_append(dm_args, "-nographic"); + } + + if (b_info->u.hvm.spice.enable) { + const libxl_spice_info *spice = &b_info->u.hvm.spice; + char *spiceoptions = dm_spice_options(gc, spice); + if (!spiceoptions) + return NULL; + + flexarray_append(dm_args, "-spice"); + flexarray_append(dm_args, spiceoptions); + } + + if (b_info->u.hvm.stdvga) { flexarray_vappend(dm_args, "-vga", "std", NULL); } @@ -446,7 +478,12 @@ static char ** libxl__build_device_model if (info->gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } + } else { + if (!sdl && !vnc) { + flexarray_append(dm_args, "-nographic"); + } } + if (info->saved_state) { /* This file descriptor is meant to be used by QEMU */ int migration_fd = open(info->saved_state, O_RDONLY); @@ -555,19 +592,24 @@ static char ** libxl__build_device_model } } -static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc, - const libxl_device_model_info *info, +static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc, + const libxl_domain_config *guest_config, libxl_device_vfb *vfb, libxl_device_vkb *vkb) { + const libxl_domain_build_info *b_info = &guest_config->b_info; + + if (b_info->type != LIBXL_DOMAIN_TYPE_HVM) + return ERROR_INVAL; + memset(vfb, 0x00, sizeof(libxl_device_vfb)); memset(vkb, 0x00, sizeof(libxl_device_vkb)); vfb->backend_domid = 0; vfb->devid = 0; - vfb->vnc = info->vnc; - vfb->keymap = info->keymap; - vfb->sdl = info->sdl; + vfb->vnc = b_info->u.hvm.vnc; + vfb->keymap = b_info->u.hvm.keymap; + vfb->sdl = b_info->u.hvm.sdl; vkb->backend_domid = 0; vkb->devid = 0; @@ -670,8 +712,7 @@ static int libxl__create_stubdom(libxl__ dm_config.vifs = guest_config->vifs; dm_config.num_vifs = guest_config->num_vifs; - libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - + libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb); dm_config.vfbs = &vfb; dm_config.num_vfbs = 1; dm_config.vkbs = &vkb; diff -r d3882dfe0aa9 -r 188443bf7392 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -219,6 +219,13 @@ libxl_domain_build_info = Struct("domain ("timer_mode", integer), ("nested_hvm", bool), ("no_incr_generationid", bool), + ("nographic", bool), + ("stdvga", bool), + ("vnc", libxl_vnc_info), + # keyboard layout, default is en-us keyboard + ("keymap", string), + ("sdl", libxl_sdl_info), + ("spice", libxl_spice_info), ])), ("pv", Struct(None, [("kernel", libxl_file_reference), ("slack_memkb", uint32), @@ -247,15 +254,6 @@ libxl_device_model_info = Struct("device ("device_model", string), ("saved_state", string), ("type", libxl_domain_type), - # size of the videoram in MB - ("videoram", integer), - ("stdvga", bool), - ("vnc", libxl_vnc_info), - # keyboard layout, default is en-us keyboard - ("keymap", string), - ("sdl", libxl_sdl_info), - ("spice", libxl_spice_info), - ("nographic", bool), ("gfx_passthru", bool), ("serial", string), ("boot", string), diff -r d3882dfe0aa9 -r 188443bf7392 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -363,29 +363,29 @@ static void printf_info(int domid, printf("\t\t\t(no_incr_generationid %d)\n", b_info->u.hvm.no_incr_generationid); + printf("\t\t\t(stdvga %d)\n", b_info->u.hvm.stdvga); + printf("\t\t\t(vnc %d)\n", b_info->u.hvm.vnc.enable); + printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen); + printf("\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display); + printf("\t\t\t(vncunused %d)\n", b_info->u.hvm.vnc.findunused); + printf("\t\t\t(keymap %s)\n", b_info->u.hvm.keymap); + printf("\t\t\t(sdl %d)\n", b_info->u.hvm.sdl.enable); + printf("\t\t\t(opengl %d)\n", b_info->u.hvm.sdl.opengl); + printf("\t\t\t(nographic %d)\n", b_info->u.hvm.nographic); + printf("\t\t\t(spice %d)\n", b_info->u.hvm.spice.enable); + printf("\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port); + printf("\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port); + printf("\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host); + printf("\t\t\t(spicedisable_ticketing %d)\n", + b_info->u.hvm.spice.disable_ticketing); + printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse); + printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); - printf("\t\t\t(videoram %d)\n", dm_info->videoram); - printf("\t\t\t(stdvga %d)\n", dm_info->stdvga); - printf("\t\t\t(vnc %d)\n", dm_info->vnc.enable); - printf("\t\t\t(vnclisten %s)\n", dm_info->vnc.listen); - printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display); - printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused); - printf("\t\t\t(keymap %s)\n", dm_info->keymap); - printf("\t\t\t(sdl %d)\n", dm_info->sdl.enable); printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru); - printf("\t\t\t(opengl %d)\n", dm_info->sdl.opengl); - printf("\t\t\t(nographic %d)\n", dm_info->nographic); printf("\t\t\t(serial %s)\n", dm_info->serial); printf("\t\t\t(boot %s)\n", dm_info->boot); printf("\t\t\t(usb %d)\n", dm_info->usb); printf("\t\t\t(usbdevice %s)\n", dm_info->usbdevice); - printf("\t\t\t(spice %d)\n", dm_info->spice.enable); - printf("\t\t\t(spiceport %d)\n", dm_info->spice.port); - printf("\t\t\t(spicetls_port %d)\n", dm_info->spice.tls_port); - printf("\t\t\t(spicehost %s)\n", dm_info->spice.host); - printf("\t\t\t(spicedisable_ticketing %d)\n", - dm_info->spice.disable_ticketing); - printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spice.agent_mouse); printf("\t\t)\n"); break; case LIBXL_DOMAIN_TYPE_PV: @@ -1175,37 +1175,38 @@ skip_vfb: if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) { if (!xlu_cfg_get_long (config, "stdvga", &l, 0)) - dm_info->stdvga = l; + b_info->u.hvm.stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l, 0)) - dm_info->vnc.enable = l; - xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0); - xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0); + b_info->u.hvm.vnc.enable = l; + xlu_cfg_replace_string (config, "vnclisten", &b_info->u.hvm.vnc.listen, 0); + xlu_cfg_replace_string (config, "vncpasswd", &b_info->u.hvm.vnc.passwd, 0); if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0)) - dm_info->vnc.display = l; + b_info->u.hvm.vnc.display = l; if (!xlu_cfg_get_long (config, "vncunused", &l, 0)) - dm_info->vnc.findunused = l; - xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0); + b_info->u.hvm.vnc.findunused = l; + xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0); if (!xlu_cfg_get_long (config, "sdl", &l, 0)) - dm_info->sdl.enable = l; + b_info->u.hvm.sdl.enable = l; if (!xlu_cfg_get_long (config, "opengl", &l, 0)) - dm_info->sdl.opengl = l; + b_info->u.hvm.sdl.opengl = l; if (!xlu_cfg_get_long (config, "spice", &l, 0)) - dm_info->spice.enable = l; + b_info->u.hvm.spice.enable = l; if (!xlu_cfg_get_long (config, "spiceport", &l, 0)) - dm_info->spice.port = l; + b_info->u.hvm.spice.port = l; if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0)) - dm_info->spice.tls_port = l; - xlu_cfg_replace_string (config, "spicehost", &dm_info->spice.host, 0); + b_info->u.hvm.spice.tls_port = l; + xlu_cfg_replace_string (config, "spicehost", + &b_info->u.hvm.spice.host, 0); if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0)) - dm_info->spice.disable_ticketing = l; + b_info->u.hvm.spice.disable_ticketing = l; xlu_cfg_replace_string (config, "spicepasswd", - &dm_info->spice.passwd, 0); + &b_info->u.hvm.spice.passwd, 0); if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0)) - dm_info->spice.agent_mouse = l; + b_info->u.hvm.spice.agent_mouse = l; else - dm_info->spice.agent_mouse = 1; + b_info->u.hvm.spice.agent_mouse = 1; if (!xlu_cfg_get_long (config, "nographic", &l, 0)) - dm_info->nographic = l; + b_info->u.hvm.nographic = l; if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0)) dm_info->gfx_passthru = l; xlu_cfg_replace_string (config, "serial", &dm_info->serial, 0);
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 13 of 20] libxl: HVM device configuration info build_info->u.hvm
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 6caa4c9b20e176884050310999c5a5eb4c555a41 # Parent 188443bf7392231d675ee195e2e72314c8568f8a libxl: HVM device configuration info build_info->u.hvm Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 188443bf7392 -r 6caa4c9b20e1 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -103,6 +103,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; @@ -129,11 +134,6 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; - dm_info->serial = NULL; - dm_info->boot = strdup("cda"); - dm_info->usb = 0; - dm_info->usbdevice = NULL; - dm_info->xen_platform_pci = 1; return 0; } diff -r 188443bf7392 -r 6caa4c9b20e1 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -171,12 +171,13 @@ static char ** libxl__build_device_model if (keymap) { flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->serial) { - flexarray_vappend(dm_args, "-serial", info->serial, NULL); - } if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; + if (b_info->u.hvm.serial) { + flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); + } + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } @@ -191,17 +192,18 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-std-vga"); } - if (info->boot) { - flexarray_vappend(dm_args, "-boot", info->boot, NULL); + if (b_info->u.hvm.boot) { + flexarray_vappend(dm_args, "-boot", b_info->u.hvm.boot, NULL); } - if (info->usb || info->usbdevice) { + if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) { flexarray_append(dm_args, "-usb"); - if (info->usbdevice) { - flexarray_vappend(dm_args, "-usbdevice", info->usbdevice, NULL); + if (b_info->u.hvm.usbdevice) { + flexarray_vappend(dm_args, + "-usbdevice", b_info->u.hvm.usbdevice, NULL); } } - if (info->soundhw) { - flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL); + if (b_info->u.hvm.soundhw) { + flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); } if (b_info->u.hvm.acpi) { flexarray_append(dm_args, "-acpi"); @@ -398,12 +400,13 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->serial) { - flexarray_vappend(dm_args, "-serial", info->serial, NULL); - } if (info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; + if (b_info->u.hvm.serial) { + flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); + } + if (b_info->u.hvm.nographic && (!sdl && !vnc)) { flexarray_append(dm_args, "-nographic"); } @@ -422,17 +425,19 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-vga", "std", NULL); } - if (info->boot) { - flexarray_vappend(dm_args, "-boot", libxl__sprintf(gc, "order=%s", info->boot), NULL); + if (b_info->u.hvm.boot) { + flexarray_vappend(dm_args, "-boot", + libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL); } - if (info->usb || info->usbdevice) { + if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) { flexarray_append(dm_args, "-usb"); - if (info->usbdevice) { - flexarray_vappend(dm_args, "-usbdevice", info->usbdevice, NULL); + if (b_info->u.hvm.usbdevice) { + flexarray_vappend(dm_args, + "-usbdevice", b_info->u.hvm.usbdevice, NULL); } } - if (info->soundhw) { - flexarray_vappend(dm_args, "-soundhw", info->soundhw, NULL); + if (b_info->u.hvm.soundhw) { + flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); } if (!b_info->u.hvm.acpi) { flexarray_append(dm_args, "-no-acpi"); @@ -778,7 +783,7 @@ retry_transaction: if (ret) goto out_free; - if (info->serial) + if (guest_config->b_info.u.hvm.serial) num_console++; console = libxl__calloc(gc, num_console, sizeof(libxl_device_console)); @@ -906,7 +911,8 @@ int libxl__create_device_model(libxl__gc path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid); xs_mkdir(ctx->xsh, XBT_NULL, path); - libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci); + libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), + "%d", !guest_config->b_info.u.hvm.xen_platform_pci); libxl_create_logfile(ctx, libxl__sprintf(gc, "qemu-dm-%s", c_info->name), diff -r 188443bf7392 -r 6caa4c9b20e1 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -226,6 +226,16 @@ libxl_domain_build_info = Struct("domain ("keymap", string), ("sdl", libxl_sdl_info), ("spice", libxl_spice_info), + + ("serial", string), + ("boot", string), + ("usb", bool), + # usbdevice: + # - "tablet" for absolute mouse, + # - "mouse" for PS/2 protocol relative mouse + ("usbdevice", string), + ("soundhw", string), + ("xen_platform_pci", bool), ])), ("pv", Struct(None, [("kernel", libxl_file_reference), ("slack_memkb", uint32), @@ -255,13 +265,6 @@ libxl_device_model_info = Struct("device ("saved_state", string), ("type", libxl_domain_type), ("gfx_passthru", bool), - ("serial", string), - ("boot", string), - ("usb", bool), - # usbdevice: "tablet" for absolute mouse, "mouse" for PS/2 protocol relative mouse - ("usbdevice", string), - ("soundhw", string), - ("xen_platform_pci", bool), # extra parameters pass directly to qemu, NULL terminated ("extra", libxl_string_list), # extra parameters pass directly to qemu for PV guest, NULL terminated diff -r 188443bf7392 -r 6caa4c9b20e1 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -382,10 +382,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;
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 14 of 20] libxl: move gfx_passthru setting to b_info->u.hvm
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID b8a133e35c9100d301a19c217ee275b0a01ae55c # Parent 6caa4c9b20e176884050310999c5a5eb4c555a41 libxl: move gfx_passthru setting to b_info->u.hvm Although xl parsed this value for both PV and HVM domains (and then a second time for HVM domains) inside libxl it only impacts HVM guests so I think this is the right place for it. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 6caa4c9b20e1 -r b8a133e35c91 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -240,7 +240,7 @@ static char ** libxl__build_device_model if ( ioemu_vifs == 0 ) { flexarray_vappend(dm_args, "-net", "none", NULL); } - if (info->gfx_passthru) { + if (b_info->u.hvm.gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } } else { @@ -480,7 +480,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-net"); flexarray_append(dm_args, "none"); } - if (info->gfx_passthru) { + if (b_info->u.hvm.gfx_passthru) { flexarray_append(dm_args, "-gfx_passthru"); } } else { diff -r 6caa4c9b20e1 -r b8a133e35c91 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -227,6 +227,8 @@ libxl_domain_build_info = Struct("domain ("sdl", libxl_sdl_info), ("spice", libxl_spice_info), + ("gfx_passthru", bool), + ("serial", string), ("boot", string), ("usb", bool), @@ -264,7 +266,6 @@ libxl_device_model_info = Struct("device ("device_model", string), ("saved_state", string), ("type", libxl_domain_type), - ("gfx_passthru", bool), # extra parameters pass directly to qemu, NULL terminated ("extra", libxl_string_list), # extra parameters pass directly to qemu for PV guest, NULL terminated diff -r 6caa4c9b20e1 -r b8a133e35c91 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -381,7 +381,7 @@ static void printf_info(int domid, printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse); printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); - printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru); + printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru); printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial); printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot); printf("\t\t\t(usb %d)\n", b_info->u.hvm.usb); @@ -732,9 +732,6 @@ static void parse_config_data(const char if (!xlu_cfg_get_long (config, "videoram", &l, 0)) b_info->video_memkb = l * 1024; - if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0)) - dm_info->gfx_passthru = l; - switch(c_info->type) { case LIBXL_DOMAIN_TYPE_HVM: if (!xlu_cfg_get_string (config, "kernel", &buf, 0)) @@ -1208,7 +1205,7 @@ skip_vfb: if (!xlu_cfg_get_long (config, "nographic", &l, 0)) b_info->u.hvm.nographic = l; if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0)) - dm_info->gfx_passthru = l; + b_info->u.hvm.gfx_passthru = l; xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0); xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0); if (!xlu_cfg_get_long (config, "usb", &l, 0))
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 15 of 20] libxl: Remove libxl_device_model_info.type
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID e5f62c6ec77ce933d4f5f92758e7d4aa5a7a6369 # Parent b8a133e35c9100d301a19c217ee275b0a01ae55c libxl: Remove libxl_device_model_info.type. This is the type of the target guest which is part of the guest config. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r b8a133e35c91 -r e5f62c6ec77c tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -602,7 +602,6 @@ static int do_domain_create(libxl__gc *g memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); xenpv_dm_info.device_model_version d_config->dm_info.device_model_version; - xenpv_dm_info.type = d_config->dm_info.type; xenpv_dm_info.device_model = d_config->dm_info.device_model; xenpv_dm_info.extra = d_config->dm_info.extra; xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv; diff -r b8a133e35c91 -r e5f62c6ec77c tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -77,7 +77,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; @@ -89,7 +89,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; @@ -100,7 +100,7 @@ static const libxl_sdl_info *dm_sdl(cons static const char *dm_keymap(const libxl_domain_config *guest_config, const libxl_device_model_info *info) { - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) { return guest_config->b_info.u.hvm.keymap; } else if (guest_config->num_vfbs > 0) { return guest_config->vfbs[0].keymap; @@ -171,7 +171,7 @@ static char ** libxl__build_device_model if (keymap) { flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; if (b_info->u.hvm.serial) { @@ -254,7 +254,7 @@ static char ** libxl__build_device_model for (i = 0; info->extra && info->extra[i] != NULL; i++) flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); - switch (info->type) { + switch (b_info->type) { case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++) @@ -353,7 +353,7 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-mon"); flexarray_append(dm_args, "chardev=libxl-cmd,mode=control"); - if (info->type == LIBXL_DOMAIN_TYPE_PV) { + if (b_info->type == LIBXL_DOMAIN_TYPE_PV) { flexarray_append(dm_args, "-xen-attach"); } @@ -400,7 +400,7 @@ static char ** libxl__build_device_model flexarray_vappend(dm_args, "-k", keymap, NULL); } - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_vifs = 0; if (b_info->u.hvm.serial) { @@ -498,7 +498,7 @@ static char ** libxl__build_device_model for (i = 0; info->extra && info->extra[i] != NULL; i++) flexarray_append(dm_args, info->extra[i]); flexarray_append(dm_args, "-M"); - switch (info->type) { + switch (b_info->type) { case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++) @@ -517,7 +517,7 @@ static char ** libxl__build_device_model libxl__sprintf(gc, "%d", libxl__sizekb_to_mb(b_info->target_memkb))); - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { for (i = 0; i < num_disks; i++) { int disk, part; int dev_number @@ -700,6 +700,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; @@ -828,7 +829,6 @@ retry_transaction: memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); xenpv_dm_info.device_model_version = info->device_model_version; - xenpv_dm_info.type = LIBXL_DOMAIN_TYPE_PV; xenpv_dm_info.device_model = info->device_model; xenpv_dm_info.extra = info->extra; xenpv_dm_info.extra_pv = info->extra_pv; diff -r b8a133e35c91 -r e5f62c6ec77c tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -265,7 +265,6 @@ libxl_device_model_info = Struct("device # you set device_model you must set device_model_version too ("device_model", string), ("saved_state", string), - ("type", libxl_domain_type), # extra parameters pass directly to qemu, NULL terminated ("extra", libxl_string_list), # extra parameters pass directly to qemu for PV guest, NULL terminated diff -r b8a133e35c91 -r e5f62c6ec77c tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -1216,8 +1216,6 @@ skip_vfb: b_info->u.hvm.xen_platform_pci = l; } - dm_info->type = c_info->type; - xlu_cfg_destroy(config); }
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 16 of 20] libxl: remove uuid from device model info
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 1f5af57bd77645f1e2e235b4cf786025aae4c73f # Parent e5f62c6ec77ce933d4f5f92758e7d4aa5a7a6369 libxl: remove uuid from device model info. This should be managed by libxl and need not be exposed to the user. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e5f62c6ec77c -r 1f5af57bd776 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -128,8 +128,6 @@ int libxl_init_dm_info(libxl_ctx *ctx, { memset(dm_info, ''\0'', sizeof(*dm_info)); - libxl_uuid_generate(&dm_info->uuid); - dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; dm_info->device_model = NULL; diff -r e5f62c6ec77c -r 1f5af57bd776 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -697,7 +697,7 @@ static int libxl__create_stubdom(libxl__ dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV; dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid)); - libxl_uuid_copy(&dm_config.c_info.uuid, &info->uuid); + libxl_uuid_generate(&dm_config.c_info.uuid); memset(&dm_config.b_info, 0x00, sizeof(libxl_domain_build_info)); dm_config.b_info.type = dm_config.c_info.type; diff -r e5f62c6ec77c -r 1f5af57bd776 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -257,9 +257,6 @@ libxl_domain_build_info = Struct("domain libxl_device_model_info = Struct("device_model_info",[ ("domid", libxl_domid), - # uuid is used only with stubdom, and must be different from the - # domain uuid - ("uuid", libxl_uuid), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", bool), # you set device_model you must set device_model_version too
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 17 of 20] libxl: move device model selection variables to b_info
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 3101b9483229b61afe4945949832c04abe323a59 # Parent 1f5af57bd77645f1e2e235b4cf786025aae4c73f libxl: move device model selection variables to b_info. Currently we have one set of device model version (and associated) variables. However we can actually have two device models (stub device model + non-stub PV device model) which need not necessarily be the same version. Perhaps this needs more thought. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl.c Mon Jan 23 16:38:18 2012 +0000 @@ -2378,7 +2378,7 @@ int libxl_domain_need_memory(libxl_ctx * switch (b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY; - if (dm_info->device_model_stubdomain) + if (b_info->device_model_stubdomain) *need_memkb += 32 * 1024; break; case LIBXL_DOMAIN_TYPE_PV: diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -77,6 +77,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; @@ -128,9 +134,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; } @@ -456,14 +459,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, @@ -522,7 +525,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]); @@ -598,12 +601,6 @@ static int do_domain_create(libxl__gc *g if (need_qemu) { /* only copy those useful configs */ memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); - xenpv_dm_info.device_model_version - d_config->dm_info.device_model_version; - xenpv_dm_info.device_model = d_config->dm_info.device_model; - xenpv_dm_info.extra = d_config->dm_info.extra; - xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv; - xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm; libxl__create_xenpv_qemu(gc, domid, d_config, &xenpv_dm_info, &dm_starting); @@ -616,7 +613,7 @@ static int do_domain_create(libxl__gc *g } if (dm_starting) { - if (dm_info->device_model_version + if (d_config->b_info.device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { libxl__qmp_initializations(ctx, domid); } diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -34,7 +34,7 @@ const char *libxl__device_model_savefile } const char *libxl__domain_device_model(libxl__gc *gc, - libxl_device_model_info *info) + const libxl_domain_build_info *info) { libxl_ctx *ctx = libxl__gc_owner(gc); const char *dm; @@ -64,7 +64,7 @@ const char *libxl__domain_device_model(l } static const char *libxl__domain_bios(libxl__gc *gc, - libxl_device_model_info *info) + const libxl_domain_build_info *info) { switch (info->device_model_version) { case 1: return "rombios"; @@ -251,19 +251,19 @@ static char ** libxl__build_device_model if (info->saved_state) { flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL); } - for (i = 0; info->extra && info->extra[i] != NULL; i++) - flexarray_append(dm_args, info->extra[i]); + for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra[i]); flexarray_append(dm_args, "-M"); switch (b_info->type) { case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); - for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++) - flexarray_append(dm_args, info->extra_pv[i]); + for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra_pv[i]); break; case LIBXL_DOMAIN_TYPE_HVM: flexarray_append(dm_args, "xenfv"); - for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++) - flexarray_append(dm_args, info->extra_hvm[i]); + for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra_hvm[i]); break; } flexarray_append(dm_args, NULL); @@ -495,19 +495,19 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-incoming"); flexarray_append(dm_args, libxl__sprintf(gc, "fd:%d", migration_fd)); } - for (i = 0; info->extra && info->extra[i] != NULL; i++) - flexarray_append(dm_args, info->extra[i]); + for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra[i]); flexarray_append(dm_args, "-M"); switch (b_info->type) { case LIBXL_DOMAIN_TYPE_PV: flexarray_append(dm_args, "xenpv"); - for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++) - flexarray_append(dm_args, info->extra_pv[i]); + for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra_pv[i]); break; case LIBXL_DOMAIN_TYPE_HVM: flexarray_append(dm_args, "xenfv"); - for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++) - flexarray_append(dm_args, info->extra_hvm[i]); + for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) + flexarray_append(dm_args, b_info->extra_hvm[i]); break; } @@ -585,14 +585,14 @@ static char ** libxl__build_device_model { libxl_ctx *ctx = libxl__gc_owner(gc); - switch (info->device_model_version) { + switch (guest_config->b_info.device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: return libxl__build_device_model_args_old(gc, dm, guest_config, info); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: return libxl__build_device_model_args_new(gc, dm, guest_config, info); default: LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", - info->device_model_version); + guest_config->b_info.device_model_version); return NULL; } } @@ -688,7 +688,8 @@ static int libxl__create_stubdom(libxl__ libxl__spawner_starting *dm_starting = 0; libxl_device_model_info xenpv_dm_info; - if (info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { + if (guest_config->b_info.device_model_version !+ LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { ret = ERROR_INVAL; goto out; } @@ -712,6 +713,14 @@ static int libxl__create_stubdom(libxl__ dm_config.b_info.u.pv.ramdisk.path = ""; dm_config.b_info.u.pv.features = ""; + dm_config.b_info.device_model_version + guest_config->b_info.device_model_version; + dm_config.b_info.device_model + guest_config->b_info.device_model; + dm_config.b_info.extra = guest_config->b_info.extra; + dm_config.b_info.extra_pv = guest_config->b_info.extra_pv; + dm_config.b_info.extra_hvm = guest_config->b_info.extra_hvm; + dm_config.disks = guest_config->disks; dm_config.num_disks = guest_config->num_disks; @@ -828,11 +837,6 @@ retry_transaction: } memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); - xenpv_dm_info.device_model_version = info->device_model_version; - xenpv_dm_info.device_model = info->device_model; - xenpv_dm_info.extra = info->extra; - xenpv_dm_info.extra_pv = info->extra_pv; - xenpv_dm_info.extra_hvm = info->extra_hvm; if (libxl__create_xenpv_qemu(gc, domid, &dm_config, @@ -871,6 +875,7 @@ int libxl__create_device_model(libxl__gc { libxl_ctx *ctx = libxl__gc_owner(gc); const libxl_domain_create_info *c_info = &guest_config->c_info; + const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_vnc_info *vnc = dm_vnc(guest_config, info); char *path, *logfile; int logfile_w, null; @@ -882,12 +887,12 @@ int libxl__create_device_model(libxl__gc char **pass_stuff; const char *dm; - if (info->device_model_stubdomain) { + if (b_info->device_model_stubdomain) { rc = libxl__create_stubdom(gc, guest_config, info, starting_r); goto out; } - dm = libxl__domain_device_model(gc, info); + dm = libxl__domain_device_model(gc, b_info); if (!dm) { rc = ERROR_FAIL; goto out; @@ -906,13 +911,13 @@ int libxl__create_device_model(libxl__gc path = xs_get_domain_path(ctx->xsh, info->domid); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/hvmloader/bios", path), - "%s", libxl__domain_bios(gc, info)); + "%s", libxl__domain_bios(gc, b_info)); free(path); path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid); xs_mkdir(ctx->xsh, XBT_NULL, path); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), - "%d", !guest_config->b_info.u.hvm.xen_platform_pci); + "%d", !b_info->u.hvm.xen_platform_pci); libxl_create_logfile(ctx, libxl__sprintf(gc, "qemu-dm-%s", c_info->name), diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dom.c Mon Jan 23 16:38:18 2012 +0000 @@ -299,7 +299,7 @@ static const char *libxl__domain_firmwar if (info->u.hvm.firmware) firmware = info->u.hvm.firmware; else { - switch (dm_info->device_model_version) + switch (info->device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: firmware = "hvmloader"; @@ -309,7 +309,7 @@ static const char *libxl__domain_firmwar break; default: LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d", - dm_info->device_model_version); + info->device_model_version); return NULL; break; } diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 @@ -491,7 +491,7 @@ _hidden int libxl__domain_build(libxl__g /* for device model creation */ _hidden const char *libxl__domain_device_model(libxl__gc *gc, - libxl_device_model_info *info); + const libxl_domain_build_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, libxl_domain_config *guest_config, libxl_device_model_info *info, diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -204,6 +204,19 @@ libxl_domain_build_info = Struct("domain ("disable_migrate", bool), ("cpuid", libxl_cpuid_policy_list), ("type", libxl_domain_type), + + ("device_model_version", libxl_device_model_version), + ("device_model_stubdomain", bool), + # you set device_model you must set device_model_version too + ("device_model", string), + + # extra parameters pass directly to qemu, NULL terminated + ("extra", libxl_string_list), + # extra parameters pass directly to qemu for PV guest, NULL terminated + ("extra_pv", libxl_string_list), + # extra parameters pass directly to qemu for HVM guest, NULL terminated + ("extra_hvm", libxl_string_list), + ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), ("pae", bool), @@ -257,17 +270,7 @@ libxl_domain_build_info = Struct("domain libxl_device_model_info = Struct("device_model_info",[ ("domid", libxl_domid), - ("device_model_version", libxl_device_model_version), - ("device_model_stubdomain", bool), - # you set device_model you must set device_model_version too - ("device_model", string), ("saved_state", string), - # extra parameters pass directly to qemu, NULL terminated - ("extra", libxl_string_list), - # extra parameters pass directly to qemu for PV guest, NULL terminated - ("extra_pv", libxl_string_list), - # extra parameters pass directly to qemu for HVM guest, NULL terminated - ("extra_hvm", libxl_string_list), ], ) diff -r 1f5af57bd776 -r 3101b9483229 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -380,7 +380,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); \
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 18 of 20] libxl: move "saved_state" to libxl__domain_build_state
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 4ef7e58d38791a1bbcb982e6f948ab1f0c805d5f # Parent 3101b9483229b61afe4945949832c04abe323a59 libxl: move "saved_state" to libxl__domain_build_state. This is internal to the library and need not be exposed to the user. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 3101b9483229 -r 4ef7e58d3879 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -275,9 +275,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; } @@ -509,13 +508,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); } @@ -565,7 +562,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); @@ -602,8 +599,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; } @@ -617,7 +614,7 @@ static int do_domain_create(libxl__gc *g == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { libxl__qmp_initializations(ctx, domid); } - ret = libxl__confirm_device_model_startup(gc, dm_info, dm_starting); + ret = libxl__confirm_device_model_startup(gc, &state, dm_starting); if (ret < 0) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "device model did not start: %d", ret); diff -r 3101b9483229 -r 4ef7e58d3879 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -111,7 +111,8 @@ static const char *dm_keymap(const libxl static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info) + const libxl_device_model_info *info, + const libxl__domain_build_state *state) { const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; @@ -248,8 +249,8 @@ static char ** libxl__build_device_model flexarray_append(dm_args, "-nographic"); } - if (info->saved_state) { - flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL); + if (state->saved_state) { + flexarray_vappend(dm_args, "-loadvm", state->saved_state, NULL); } for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++) flexarray_append(dm_args, b_info->extra[i]); @@ -321,7 +322,8 @@ static char *dm_spice_options(libxl__gc static char ** libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info) + const libxl_device_model_info *info, + const libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); const libxl_domain_create_info *c_info = &guest_config->c_info; @@ -489,9 +491,9 @@ static char ** libxl__build_device_model } } - if (info->saved_state) { + if (state->saved_state) { /* This file descriptor is meant to be used by QEMU */ - int migration_fd = open(info->saved_state, O_RDONLY); + int migration_fd = open(state->saved_state, O_RDONLY); flexarray_append(dm_args, "-incoming"); flexarray_append(dm_args, libxl__sprintf(gc, "fd:%d", migration_fd)); } @@ -581,15 +583,16 @@ static char ** libxl__build_device_model static char ** libxl__build_device_model_args(libxl__gc *gc, const char *dm, const libxl_domain_config *guest_config, - const libxl_device_model_info *info) + const libxl_device_model_info *info, + const libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); switch (guest_config->b_info.device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - return libxl__build_device_model_args_old(gc, dm, guest_config, info); + return libxl__build_device_model_args_old(gc, dm, guest_config, info, state); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - return libxl__build_device_model_args_new(gc, dm, guest_config, info); + return libxl__build_device_model_args_new(gc, dm, guest_config, info, state); default: LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", guest_config->b_info.device_model_version); @@ -672,6 +675,7 @@ retry_transaction: static int libxl__create_stubdom(libxl__gc *gc, libxl_domain_config *guest_config, libxl_device_model_info *info, + libxl__domain_build_state *d_state, libxl__spawner_starting **starting_r) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -680,7 +684,7 @@ static int libxl__create_stubdom(libxl__ libxl_domain_config dm_config; libxl_device_vfb vfb; libxl_device_vkb vkb; - libxl__domain_build_state state; + libxl__domain_build_state stubdom_state; uint32_t domid; char **args; struct xs_permissions perm[2]; @@ -738,12 +742,12 @@ static int libxl__create_stubdom(libxl__ ret = libxl__domain_make(gc, &dm_config.c_info, &domid); if (ret) goto out; - ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &state); + ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &stubdom_state); if (ret) goto out; args = libxl__build_device_model_args(gc, "stubdom-dm", - guest_config, info); + guest_config, info, d_state); if (!args) { ret = ERROR_FAIL; goto out; @@ -813,7 +817,8 @@ retry_transaction: char *filename; char *name; case STUBDOM_CONSOLE_LOGGING: - name = libxl__sprintf(gc, "qemu-dm-%s", libxl_domid_to_name(ctx, info->domid)); + name = libxl__sprintf(gc, "qemu-dm-%s", + libxl_domid_to_name(ctx, info->domid)); libxl_create_logfile(ctx, name, &filename); console[i].output = libxl__sprintf(gc, "file:%s", filename); free(filename); @@ -823,15 +828,16 @@ retry_transaction: libxl__device_model_savefile(gc, info->domid)); break; case STUBDOM_CONSOLE_RESTORE: - if (info->saved_state) - console[i].output = libxl__sprintf(gc, "pipe:%s", info->saved_state); + if (d_state->saved_state) + console[i].output + libxl__sprintf(gc, "pipe:%s", d_state->saved_state); break; default: console[i].output = "pty"; break; } ret = libxl__device_console_add(gc, domid, &console[i], - i == STUBDOM_CONSOLE_LOGGING ? &state : NULL); + i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL); if (ret) goto out_free; } @@ -841,12 +847,12 @@ retry_transaction: if (libxl__create_xenpv_qemu(gc, domid, &dm_config, &xenpv_dm_info, + &stubdom_state, &dm_starting) < 0) { ret = ERROR_FAIL; goto out_free; } - if (libxl__confirm_device_model_startup(gc, &xenpv_dm_info, - dm_starting) < 0) { + if (libxl__confirm_device_model_startup(gc, d_state, dm_starting) < 0) { ret = ERROR_FAIL; goto out_free; } @@ -871,6 +877,7 @@ out: int libxl__create_device_model(libxl__gc *gc, libxl_domain_config *guest_config, libxl_device_model_info *info, + libxl__domain_build_state *state, libxl__spawner_starting **starting_r) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -888,7 +895,7 @@ int libxl__create_device_model(libxl__gc const char *dm; if (b_info->device_model_stubdomain) { - rc = libxl__create_stubdom(gc, guest_config, info, starting_r); + rc = libxl__create_stubdom(gc, guest_config, info, state, starting_r); goto out; } @@ -903,7 +910,7 @@ int libxl__create_device_model(libxl__gc rc = ERROR_FAIL; goto out; } - args = libxl__build_device_model_args(gc, dm, guest_config, info); + args = libxl__build_device_model_args(gc, dm, guest_config, info, state); if (!args) { rc = ERROR_FAIL; goto out; @@ -984,10 +991,9 @@ out: int libxl__confirm_device_model_startup(libxl__gc *gc, - libxl_device_model_info *dm_info, + libxl__domain_build_state *state, libxl__spawner_starting *starting) { - libxl_ctx *ctx = libxl__gc_owner(gc); char *path; int domid = starting->domid; int ret, ret2; @@ -995,11 +1001,11 @@ int libxl__confirm_device_model_startup( ret = libxl__spawn_confirm_offspring_startup(gc, LIBXL_DEVICE_MODEL_START_TIMEOUT, "Device Model", path, "running", starting); - if (dm_info->saved_state) { - ret2 = unlink(dm_info->saved_state); - if (ret2) LIBXL__LOG_ERRNO(ctx, XTL_ERROR, + if (state->saved_state) { + ret2 = unlink(state->saved_state); + if (ret2) LIBXL__LOG_ERRNO(CTX, XTL_ERROR, "failed to remove device-model state %s\n", - dm_info->saved_state); + state->saved_state); /* Do not clobber spawn_confirm error code with unlink error code. */ if (!ret) ret = ret2; } @@ -1110,10 +1116,11 @@ out: int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, libxl_domain_config *guest_config, libxl_device_model_info *info, + libxl__domain_build_state *state, libxl__spawner_starting **starting_r) { libxl__build_xenpv_qemu_args(gc, domid, info); - libxl__create_device_model(gc, guest_config, info, starting_r); + libxl__create_device_model(gc, guest_config, info, state, starting_r); return 0; } diff -r 3101b9483229 -r 4ef7e58d3879 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 @@ -247,7 +247,10 @@ typedef struct { uint32_t console_port; unsigned long console_mfn; + unsigned long vm_generationid_addr; + + char *saved_state; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, @@ -495,10 +498,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, @@ -508,7 +513,7 @@ _hidden int libxl__need_xenpv_qemu(libxl * return pass *starting_r (which will be non-0) to * libxl__confirm_device_model_startup or libxl__detach_device_model. */ _hidden int libxl__confirm_device_model_startup(libxl__gc *gc, - libxl_device_model_info *dm_info, + libxl__domain_build_state *state, libxl__spawner_starting *starting); _hidden int libxl__detach_device_model(libxl__gc *gc, libxl__spawner_starting *starting); _hidden int libxl__wait_for_device_model(libxl__gc *gc, diff -r 3101b9483229 -r 4ef7e58d3879 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -269,8 +269,6 @@ libxl_domain_build_info = Struct("domain # Device Model Information libxl_device_model_info = Struct("device_model_info",[ ("domid", libxl_domid), - - ("saved_state", string), ], )
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 62bffbc5495b3e897d6fbb654453f2335556e06e # Parent 4ef7e58d38791a1bbcb982e6f948ab1f0c805d5f libxl: remove libxl_device_model_info. All that is left here is the target domain''s domid which we can pass around as a parameter. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl.c Mon Jan 23 16:38:18 2012 +0000 @@ -2370,7 +2370,7 @@ out: } int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, - libxl_device_model_info *dm_info, uint32_t *need_memkb) + uint32_t *need_memkb) { GC_INIT(ctx); int rc = ERROR_INVAL; diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl.h Mon Jan 23 16:38:18 2012 +0000 @@ -230,7 +230,6 @@ enum { typedef struct { libxl_domain_create_info c_info; libxl_domain_build_info b_info; - libxl_device_model_info dm_info; int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs; @@ -258,10 +257,6 @@ int libxl_init_create_info(libxl_ctx *ct int libxl_init_build_info(libxl_ctx *ctx, libxl_domain_build_info *b_info, libxl_domain_create_info *c_info); -int libxl_init_dm_info(libxl_ctx *ctx, - libxl_device_model_info *dm_info, - libxl_domain_create_info *c_info, - libxl_domain_build_info *b_info); typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv); int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid); int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd); @@ -359,7 +354,7 @@ int libxl_set_memory_target(libxl_ctx *c int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t *out_target); /* how much free memory in the system a domain needs to be built */ int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, - libxl_device_model_info *dm_info, uint32_t *need_memkb); + uint32_t *need_memkb); /* how much free memory is available in the system */ int libxl_get_free_memory(libxl_ctx *ctx, uint32_t *memkb); /* wait for a given amount of memory to be free in the system */ diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:18 2012 +0000 @@ -48,7 +48,6 @@ void libxl_domain_config_dispose(libxl_d libxl_domain_create_info_dispose(&d_config->c_info); libxl_domain_build_info_dispose(&d_config->b_info); - libxl_device_model_info_dispose(&d_config->dm_info); } int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info) @@ -127,17 +126,6 @@ int libxl_init_build_info(libxl_ctx *ctx return 0; } -int libxl_init_dm_info(libxl_ctx *ctx, - libxl_device_model_info *dm_info, - libxl_domain_create_info *c_info, - libxl_domain_build_info *b_info) -{ - memset(dm_info, ''\0'', sizeof(*dm_info)); - - - return 0; -} - static int init_console_info(libxl_device_console *console, int dev_num) { memset(console, 0x00, sizeof(libxl_device_console)); @@ -151,7 +139,6 @@ static int init_console_info(libxl_devic int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, - libxl_device_model_info *dm_info, uint32_t domid, libxl__domain_build_state *state) { @@ -167,7 +154,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; @@ -221,8 +208,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; @@ -474,7 +460,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; @@ -511,9 +496,9 @@ static int do_domain_create(libxl__gc *g memset(&state, 0, sizeof(state)); if ( restore_fd >= 0 ) { - ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state, dm_info); + ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state); } else { - ret = libxl__domain_build(gc, &d_config->b_info, dm_info, domid, &state); + ret = libxl__domain_build(gc, &d_config->b_info, domid, &state); } if (ret) { @@ -560,8 +545,7 @@ static int do_domain_create(libxl__gc *g libxl_device_vkb_add(ctx, domid, &vkb); libxl_device_vkb_dispose(&vkb); - dm_info->domid = domid; - ret = libxl__create_device_model(gc, d_config, dm_info, + ret = libxl__create_device_model(gc, domid, d_config, &state, &dm_starting); if (ret < 0) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, @@ -574,7 +558,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]); @@ -596,11 +579,7 @@ static int do_domain_create(libxl__gc *g libxl_device_console_dispose(&console); if (need_qemu) { - /* only copy those useful configs */ - memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); - - libxl__create_xenpv_qemu(gc, domid, d_config, - &xenpv_dm_info, &state, &dm_starting); + libxl__create_xenpv_qemu(gc, domid, d_config, &state, &dm_starting); } break; } diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -73,8 +73,7 @@ static const char *libxl__domain_bios(li } } -static const libxl_vnc_info *dm_vnc(const libxl_domain_config *guest_config, - const libxl_device_model_info *info) +static const libxl_vnc_info *dm_vnc(const libxl_domain_config *guest_config) { const libxl_vnc_info *vnc = NULL; if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) { @@ -85,8 +84,7 @@ static const libxl_vnc_info *dm_vnc(cons return vnc && vnc->enable ? vnc : NULL; } -static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config, - const libxl_device_model_info *info) +static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config) { const libxl_sdl_info *sdl = NULL; if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) { @@ -97,8 +95,7 @@ static const libxl_sdl_info *dm_sdl(cons return sdl && sdl->enable ? sdl : NULL; } -static const char *dm_keymap(const libxl_domain_config *guest_config, - const libxl_device_model_info *info) +static const char *dm_keymap(const libxl_domain_config *guest_config) { if (guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) { return guest_config->b_info.u.hvm.keymap; @@ -109,18 +106,17 @@ static const char *dm_keymap(const libxl } static char ** libxl__build_device_model_args_old(libxl__gc *gc, - const char *dm, + const char *dm, int domid, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, const libxl__domain_build_state *state) { const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_device_nic *vifs = guest_config->vifs; - const libxl_vnc_info *vnc = dm_vnc(guest_config, info); - const libxl_sdl_info *sdl = dm_sdl(guest_config, info); + const libxl_vnc_info *vnc = dm_vnc(guest_config); + const libxl_sdl_info *sdl = dm_sdl(guest_config); const int num_vifs = guest_config->num_vifs; - const char *keymap = dm_keymap(guest_config, info); + const char *keymap = dm_keymap(guest_config); int i; flexarray_t *dm_args; dm_args = flexarray_make(16, 1); @@ -129,7 +125,7 @@ static char ** libxl__build_device_model return NULL; flexarray_vappend(dm_args, dm, - "-d", libxl__sprintf(gc, "%d", info->domid), NULL); + "-d", libxl__sprintf(gc, "%d", domid), NULL); if (c_info->name) flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL); @@ -225,7 +221,8 @@ static char ** libxl__build_device_model LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac)); char *ifname; if (!vifs[i].ifname) - ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, vifs[i].devid); + ifname = libxl__sprintf(gc, + "tap%d.%d", domid, vifs[i].devid); else ifname = vifs[i].ifname; flexarray_vappend(dm_args, @@ -320,9 +317,8 @@ static char *dm_spice_options(libxl__gc } static char ** libxl__build_device_model_args_new(libxl__gc *gc, - const char *dm, + const char *dm, int guest_domid, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, const libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -332,9 +328,9 @@ static char ** libxl__build_device_model const libxl_device_nic *vifs = guest_config->vifs; const int num_disks = guest_config->num_disks; const int num_vifs = guest_config->num_vifs; - const libxl_vnc_info *vnc = dm_vnc(guest_config, info); - const libxl_sdl_info *sdl = dm_sdl(guest_config, info); - const char *keymap = dm_keymap(guest_config, info); + const libxl_vnc_info *vnc = dm_vnc(guest_config); + const libxl_sdl_info *sdl = dm_sdl(guest_config); + const char *keymap = dm_keymap(guest_config); flexarray_t *dm_args; int i; @@ -343,14 +339,14 @@ static char ** libxl__build_device_model return NULL; flexarray_vappend(dm_args, dm, - "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); + "-xen-domid", + libxl__sprintf(gc, "%d", guest_domid), NULL); flexarray_append(dm_args, "-chardev"); flexarray_append(dm_args, libxl__sprintf(gc, "socket,id=libxl-cmd," "path=%s/qmp-libxl-%d,server,nowait", - libxl_run_dir_path(), - info->domid)); + libxl_run_dir_path(), guest_domid)); flexarray_append(dm_args, "-mon"); flexarray_append(dm_args, "chardev=libxl-cmd,mode=control"); @@ -460,7 +456,8 @@ static char ** libxl__build_device_model LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac)); char *ifname; if (!vifs[i].ifname) { - ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, vifs[i].devid); + ifname = libxl__sprintf(gc, "tap%d.%d", + guest_domid, vifs[i].devid); } else { ifname = vifs[i].ifname; } @@ -581,18 +578,21 @@ static char ** libxl__build_device_model } static char ** libxl__build_device_model_args(libxl__gc *gc, - const char *dm, + const char *dm, int guest_domid, const libxl_domain_config *guest_config, - const libxl_device_model_info *info, const libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); switch (guest_config->b_info.device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - return libxl__build_device_model_args_old(gc, dm, guest_config, info, state); + return libxl__build_device_model_args_old(gc, dm, + guest_domid, guest_config, + state); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - return libxl__build_device_model_args_new(gc, dm, guest_config, info, state); + return libxl__build_device_model_args_new(gc, dm, + guest_domid, guest_config, + state); default: LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", guest_config->b_info.device_model_version); @@ -624,7 +624,9 @@ static int libxl__vfb_and_vkb_from_hvm_g return 0; } -static int libxl__write_dmargs(libxl__gc *gc, int domid, int guest_domid, char **args) +static int libxl__write_stub_dmargs(libxl__gc *gc, + int dm_domid, int guest_domid, + char **args) { libxl_ctx *ctx = libxl__gc_owner(gc); int i; @@ -636,7 +638,7 @@ static int libxl__write_dmargs(libxl__gc roperm[0].id = 0; roperm[0].perms = XS_PERM_NONE; - roperm[1].id = domid; + roperm[1].id = dm_domid; roperm[1].perms = XS_PERM_READ; vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/vm", guest_domid)); @@ -673,8 +675,8 @@ retry_transaction: } static int libxl__create_stubdom(libxl__gc *gc, + int guest_domid, libxl_domain_config *guest_config, - libxl_device_model_info *info, libxl__domain_build_state *d_state, libxl__spawner_starting **starting_r) { @@ -685,12 +687,11 @@ static int libxl__create_stubdom(libxl__ libxl_device_vfb vfb; libxl_device_vkb vkb; libxl__domain_build_state stubdom_state; - uint32_t domid; + uint32_t dm_domid; char **args; struct xs_permissions perm[2]; xs_transaction_t t; libxl__spawner_starting *dm_starting = 0; - libxl_device_model_info xenpv_dm_info; if (guest_config->b_info.device_model_version ! LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { @@ -700,7 +701,8 @@ static int libxl__create_stubdom(libxl__ memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info)); dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV; - dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, info->domid)); + dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", + libxl__domid_to_name(gc, guest_domid)); libxl_uuid_generate(&dm_config.c_info.uuid); @@ -713,7 +715,7 @@ static int libxl__create_stubdom(libxl__ dm_config.b_info.type = LIBXL_DOMAIN_TYPE_PV; dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path()); - dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); + dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid); dm_config.b_info.u.pv.ramdisk.path = ""; dm_config.b_info.u.pv.features = ""; @@ -738,62 +740,69 @@ static int libxl__create_stubdom(libxl__ dm_config.num_vkbs = 1; /* fixme: this function can leak the stubdom if it fails */ - domid = 0; - ret = libxl__domain_make(gc, &dm_config.c_info, &domid); + dm_domid = 0; + ret = libxl__domain_make(gc, &dm_config.c_info, &dm_domid); if (ret) goto out; - ret = libxl__domain_build(gc, &dm_config.b_info, info, domid, &stubdom_state); + ret = libxl__domain_build(gc, &dm_config.b_info, dm_domid, &stubdom_state); if (ret) goto out; - args = libxl__build_device_model_args(gc, "stubdom-dm", - guest_config, info, d_state); + args = libxl__build_device_model_args(gc, "stubdom-dm", guest_domid, + guest_config, d_state); if (!args) { ret = ERROR_FAIL; goto out; } - libxl__write_dmargs(gc, domid, info->domid, args); + libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args); libxl__xs_write(gc, XBT_NULL, - libxl__sprintf(gc, "%s/image/device-model-domid", libxl__xs_get_dompath(gc, info->domid)), - "%d", domid); + libxl__sprintf(gc, "%s/image/device-model-domid", + libxl__xs_get_dompath(gc, guest_domid)), + "%d", dm_domid); libxl__xs_write(gc, XBT_NULL, - libxl__sprintf(gc, "%s/target", libxl__xs_get_dompath(gc, domid)), - "%d", info->domid); - ret = xc_domain_set_target(ctx->xch, domid, info->domid); + libxl__sprintf(gc, "%s/target", + libxl__xs_get_dompath(gc, dm_domid)), + "%d", guest_domid); + ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid); if (ret<0) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting target domain %d -> %d", domid, info->domid); + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "setting target domain %d -> %d", + dm_domid, guest_domid); ret = ERROR_FAIL; goto out_free; } - xs_set_target(ctx->xsh, domid, info->domid); + xs_set_target(ctx->xsh, dm_domid, guest_domid); - perm[0].id = domid; + perm[0].id = dm_domid; perm[0].perms = XS_PERM_NONE; - perm[1].id = info->domid; + perm[1].id = guest_domid; perm[1].perms = XS_PERM_READ; retry_transaction: t = xs_transaction_start(ctx->xsh); - xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid)); - xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid), perm, ARRAY_SIZE(perm)); + xs_mkdir(ctx->xsh, t, + libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid)); + xs_set_permissions(ctx->xsh, t, + libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid), + perm, ARRAY_SIZE(perm)); if (!xs_transaction_end(ctx->xsh, t, 0)) if (errno == EAGAIN) goto retry_transaction; for (i = 0; i < dm_config.num_disks; i++) { - ret = libxl_device_disk_add(ctx, domid, &dm_config.disks[i]); + ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i]); if (ret) goto out_free; } for (i = 0; i < dm_config.num_vifs; i++) { - ret = libxl_device_nic_add(ctx, domid, &dm_config.vifs[i]); + ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i]); if (ret) goto out_free; } - ret = libxl_device_vfb_add(ctx, domid, &dm_config.vfbs[0]); + ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config.vfbs[0]); if (ret) goto out_free; - ret = libxl_device_vkb_add(ctx, domid, &dm_config.vkbs[0]); + ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config.vkbs[0]); if (ret) goto out_free; @@ -818,14 +827,14 @@ retry_transaction: char *name; case STUBDOM_CONSOLE_LOGGING: name = libxl__sprintf(gc, "qemu-dm-%s", - libxl_domid_to_name(ctx, info->domid)); + libxl_domid_to_name(ctx, guest_domid)); libxl_create_logfile(ctx, name, &filename); console[i].output = libxl__sprintf(gc, "file:%s", filename); free(filename); break; case STUBDOM_CONSOLE_SAVE: console[i].output = libxl__sprintf(gc, "file:%s", - libxl__device_model_savefile(gc, info->domid)); + libxl__device_model_savefile(gc, guest_domid)); break; case STUBDOM_CONSOLE_RESTORE: if (d_state->saved_state) @@ -836,17 +845,14 @@ retry_transaction: console[i].output = "pty"; break; } - ret = libxl__device_console_add(gc, domid, &console[i], + ret = libxl__device_console_add(gc, dm_domid, &console[i], i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL); if (ret) goto out_free; } - memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info)); - - if (libxl__create_xenpv_qemu(gc, domid, + if (libxl__create_xenpv_qemu(gc, dm_domid, &dm_config, - &xenpv_dm_info, &stubdom_state, &dm_starting) < 0) { ret = ERROR_FAIL; @@ -857,12 +863,12 @@ retry_transaction: goto out_free; } - libxl_domain_unpause(ctx, domid); + libxl_domain_unpause(ctx, dm_domid); if (starting_r) { *starting_r = calloc(1, sizeof(libxl__spawner_starting)); - (*starting_r)->domid = info->domid; - (*starting_r)->dom_path = libxl__xs_get_dompath(gc, info->domid); + (*starting_r)->domid = guest_domid; + (*starting_r)->dom_path = libxl__xs_get_dompath(gc, guest_domid); (*starting_r)->for_spawn = NULL; } @@ -875,15 +881,15 @@ out: } int libxl__create_device_model(libxl__gc *gc, + int domid, libxl_domain_config *guest_config, - libxl_device_model_info *info, libxl__domain_build_state *state, libxl__spawner_starting **starting_r) { libxl_ctx *ctx = libxl__gc_owner(gc); const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; - const libxl_vnc_info *vnc = dm_vnc(guest_config, info); + const libxl_vnc_info *vnc = dm_vnc(guest_config); char *path, *logfile; int logfile_w, null; int rc; @@ -895,7 +901,7 @@ int libxl__create_device_model(libxl__gc const char *dm; if (b_info->device_model_stubdomain) { - rc = libxl__create_stubdom(gc, guest_config, info, state, starting_r); + rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r); goto out; } @@ -910,18 +916,18 @@ int libxl__create_device_model(libxl__gc rc = ERROR_FAIL; goto out; } - args = libxl__build_device_model_args(gc, dm, guest_config, info, state); + args = libxl__build_device_model_args(gc, dm, domid, guest_config, state); if (!args) { rc = ERROR_FAIL; goto out; } - path = xs_get_domain_path(ctx->xsh, info->domid); + path = xs_get_domain_path(ctx->xsh, domid); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/hvmloader/bios", path), "%s", libxl__domain_bios(gc, b_info)); free(path); - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid); + path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid); xs_mkdir(ctx->xsh, XBT_NULL, path); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !b_info->u.hvm.xen_platform_pci); @@ -945,8 +951,8 @@ int libxl__create_device_model(libxl__gc p->for_spawn = NULL; } - p->domid = info->domid; - p->dom_path = libxl__xs_get_dompath(gc, info->domid); + p->domid = domid; + p->dom_path = libxl__xs_get_dompath(gc, domid); p->pid_path = "image/device-model-pid"; if (!p->dom_path) { rc = ERROR_FAIL; @@ -1068,14 +1074,6 @@ out: return ret; } -static int libxl__build_xenpv_qemu_args(libxl__gc *gc, - uint32_t domid, - libxl_device_model_info *info) -{ - info->domid = domid; - return 0; -} - int libxl__need_xenpv_qemu(libxl__gc *gc, int nr_consoles, libxl_device_console *consoles, int nr_vfbs, libxl_device_vfb *vfbs, @@ -1115,12 +1113,10 @@ out: int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, libxl_domain_config *guest_config, - libxl_device_model_info *info, libxl__domain_build_state *state, libxl__spawner_starting **starting_r) { - libxl__build_xenpv_qemu_args(gc, domid, info); - libxl__create_device_model(gc, guest_config, info, state, starting_r); + libxl__create_device_model(gc, domid, guest_config, state, starting_r); return 0; } diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dom.c Mon Jan 23 16:38:18 2012 +0000 @@ -290,8 +290,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; @@ -319,12 +318,11 @@ static const char *libxl__domain_firmwar int libxl__build_hvm(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, - libxl_device_model_info *dm_info, libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); int ret, rc = ERROR_FAIL; - const char *firmware = libxl__domain_firmware(gc, info, dm_info); + const char *firmware = libxl__domain_firmware(gc, info); if (!firmware) goto out; diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_internal.h Mon Jan 23 16:38:18 2012 +0000 @@ -263,7 +263,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, @@ -485,10 +484,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); @@ -496,13 +496,12 @@ _hidden int libxl__domain_build(libxl__g _hidden const char *libxl__domain_device_model(libxl__gc *gc, const libxl_domain_build_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, + int domid, libxl_domain_config *guest_config, - libxl_device_model_info *info, libxl__domain_build_state *state, libxl__spawner_starting **starting_r); _hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, libxl_domain_config *guest_config, - libxl_device_model_info *dm_info, libxl__domain_build_state *state, libxl__spawner_starting **starting_r); _hidden int libxl__need_xenpv_qemu(libxl__gc *gc, diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:18 2012 +0000 @@ -266,12 +266,6 @@ libxl_domain_build_info = Struct("domain ], ) -# Device Model Information -libxl_device_model_info = Struct("device_model_info",[ - ("domid", libxl_domid), - ], -) - libxl_device_vfb = Struct("device_vfb", [ ("backend_domid", libxl_domid), ("devid", integer), diff -r 4ef7e58d3879 -r 62bffbc5495b tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:18 2012 +0000 @@ -289,8 +289,7 @@ static void dolog(const char *file, int } static void printf_info(int domid, - libxl_domain_config *d_config, - libxl_device_model_info *dm_info) + libxl_domain_config *d_config) { int i; libxl_dominfo info; @@ -571,8 +570,7 @@ static void split_string_into_string_lis static void parse_config_data(const char *configfile_filename_report, const char *configfile_data, int configfile_len, - libxl_domain_config *d_config, - libxl_device_model_info *dm_info) + libxl_domain_config *d_config) { const char *buf; long l; @@ -1110,9 +1108,6 @@ skip_vfb: break; } - /* init dm from c and b */ - if (libxl_init_dm_info(ctx, dm_info, c_info, b_info)) - exit(1); /* parse device model arguments, this works for pv, hvm and stubdom */ if (!xlu_cfg_get_string (config, "device_model", &buf, 0)) { fprintf(stderr, @@ -1363,7 +1358,7 @@ struct domain_create { int no_incr_generationid; }; -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; @@ -1371,7 +1366,7 @@ static int freemem(libxl_domain_build_in if (!autoballoon) return 0; - rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb); + rc = libxl_domain_need_memory(ctx, b_info, &need_memkb); if (rc < 0) return rc; @@ -1554,7 +1549,7 @@ static int create_domain(struct domain_c if (!dom_info->quiet) printf("Parsing config file %s\n", config_file); - parse_config_data(config_file, config_data, config_len, &d_config, &d_config.dm_info); + parse_config_data(config_file, config_data, config_len, &d_config); if (migrate_fd >= 0) { if (d_config.c_info.name) { @@ -1579,7 +1574,7 @@ static int create_domain(struct domain_c dom_info->no_incr_generationid; 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) @@ -1592,7 +1587,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; @@ -2336,7 +2331,6 @@ static void list_domains_details(const l char *config_file; uint8_t *data; int i, len, rc; - libxl_device_model_info dm_info; for (i = 0; i < nb_domain; i++) { /* no detailed info available on dom0 */ @@ -2347,8 +2341,8 @@ static void list_domains_details(const l continue; CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid)); memset(&d_config, 0x00, sizeof(d_config)); - parse_config_data(config_file, (char *)data, len, &d_config, &dm_info); - printf_info(info[i].domid, &d_config, &dm_info); + parse_config_data(config_file, (char *)data, len, &d_config); + printf_info(info[i].domid, &d_config); libxl_domain_config_dispose(&d_config); free(data); free(config_file);
Ian Campbell
2012-Jan-23 16:45 UTC
[PATCH 20 of 20] libxl: only write "disable_pf" key to xenstore when it makes sense
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1327336698 0 # Node ID 5f20c5ddd4e42242bfb32b85652c5957c40ba320 # Parent 62bffbc5495b3e897d6fbb654453f2335556e06e libxl: only write "disable_pf" key to xenstore when it makes sense This key is only used by the traditional qemu-dm when servicing an HVM domain. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 62bffbc5495b -r 5f20c5ddd4e4 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:18 2012 +0000 @@ -929,8 +929,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),
Ian Jackson
2012-Jan-31 14:36 UTC
Re: [PATCH 03 of 20] ocaml: use libxl IDL type helpers for C argument passing
Ian Campbell writes ("[PATCH 03 of 20] ocaml: use libxl IDL type helpers for C argument passing"):> ocaml: use libxl IDL type helpers for C argument passingAcked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson
2012-Jan-31 14:45 UTC
Re: [PATCH 08 of 20] libxl: now that dm creation takes domain_config stop passing down devices
Ian Campbell writes ("[PATCH 08 of 20] libxl: now that dm creation takes domain_config stop passing down devices"):> libxl: now that dm creation takes domain_config stop passing down devices.Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson
2012-Jan-31 15:28 UTC
Re: [PATCH 17 of 20] libxl: move device model selection variables to b_info
Ian Campbell writes ("[PATCH 17 of 20] libxl: move device model selection variables to b_info"):> 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.Your explanation here isn''t entirely clear I think. AFAICT from reading the code, both before and after this patch we assume that both device models are of the same version and there is only one version knob to twiddle in the config file. But I didn''t peer into the whole thing in detail... Ian.
Ian Campbell
2012-Jan-31 15:38 UTC
Re: [PATCH 17 of 20] libxl: move device model selection variables to b_info
On Tue, 2012-01-31 at 15:28 +0000, Ian Jackson wrote:> Ian Campbell writes ("[PATCH 17 of 20] libxl: move device model selection variables to b_info"): > > 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. > > Your explanation here isn''t entirely clear I think. AFAICT from > reading the code, both before and after this patch we assume that both > device models are of the same version and there is only one version > knob to twiddle in the config file.That''s right. I have just moved where that one nob was. The comment was (now I look at it, misleadingly worded,) musing on whether we should have two nobs or not and/or how that would look. Ian.