Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Xen: Changelog

[xen-unstable] Merge

 

 

Xen changelog RSS feed   Index | Next | Previous | View Threaded


patchbot at xen

Mar 2, 2012, 8:33 PM

Post #1 of 6 (90 views)
Permalink
[xen-unstable] Merge

# HG changeset patch
# User Ian Jackson <Ian.Jackson [at] eu>
# Date 1330605075 0
# Node ID d64aa013a82e591f628abd7a2cac7cc82da41a4f
# Parent d7fe4cd831a0d8d7b3cd71ca302ca0280e3a5096
# Parent 17bfd4d2ffce56b65e7849a5779471ef4f5e4aea
Merge
---


diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/gentest.py
--- a/tools/libxl/gentest.py Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/gentest.py Thu Mar 01 12:31:15 2012 +0000
@@ -1,5 +1,6 @@
#!/usr/bin/python

+import os
import sys
import re
import random
@@ -30,7 +31,7 @@
elif isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
@@ -54,6 +55,8 @@
ty.pass_arg(v, parent is None))
elif ty.typename in ["bool"]:
s += "%s = rand() %% 2;\n" % v
+ elif ty.typename in ["libxl_defbool"]:
+ s += "libxl_defbool_set(%s, !!rand() %% 1);\n" % v
elif ty.typename in ["char *"]:
s += "%s = rand_str();\n" % v
elif ty.private:
@@ -72,7 +75,7 @@
print >>sys.stderr, "Usage: gentest.py <idl> <implementation>"
sys.exit(1)

- random.seed()
+ random.seed(os.getenv('LIBXL_TESTIDL_SEED'))

(builtins,types) = idl.parse(sys.argv[1])

@@ -196,6 +199,7 @@
}
""")
for ty in builtins + types:
+ if isinstance(ty, idl.Number): continue
if ty.typename not in handcoded:
f.write("static void %s_rand_init(%s);\n" % \
(ty.typename,
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/gentypes.py Thu Mar 01 12:31:15 2012 +0000
@@ -32,6 +32,9 @@
s += "} %s" % ty.typename

elif isinstance(ty, idl.Aggregate):
+ if isinstance(ty, idl.KeyedUnion):
+ s += libxl_C_instance_of(ty.keyvar.type, ty.keyvar.name) + ";\n"
+
if ty.typename is None:
s += "%s {\n" % ty.kind
else:
@@ -56,7 +59,7 @@
if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
@@ -75,6 +78,88 @@
s = indent + s
return s.replace("\n", "\n%s" % indent).rstrip(indent)

+def libxl_init_members(ty, nesting = 0):
+ """Returns a list of members of ty which require a separate init"""
+
+ if isinstance(ty, idl.Aggregate):
+ return [f for f in ty.fields if not f.const and isinstance(f.type,idl.KeyedUnion)]
+ else:
+ return []
+
+def _libxl_C_type_init(ty, v, indent = " ", parent = None, subinit=False):
+ s = ""
+ if isinstance(ty, idl.KeyedUnion):
+ if parent is None:
+ raise Exception("KeyedUnion type must have a parent")
+ if subinit:
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
+ for f in ty.fields:
+ (nparent,fexpr) = ty.member(v, f, parent is None)
+ s += "case %s:\n" % f.enumname
+ s += _libxl_C_type_init(f.type, fexpr, " ", nparent)
+ s += " break;\n"
+ s += "}\n"
+ else:
+ if ty.keyvar.init_val:
+ s += "%s = %s;\n" % (parent + ty.keyvar.name, ty.keyvar.init_val)
+ elif ty.keyvar.type.init_val:
+ s += "%s = %s;\n" % (parent + ty.keyvar.name, ty.keyvar.type.init_val)
+ elif isinstance(ty, idl.Struct) and (parent is None or ty.init_fn is None):
+ for f in [f for f in ty.fields if not f.const]:
+ (nparent,fexpr) = ty.member(v, f, parent is None)
+ if f.init_val is not None:
+ s += "%s = %s;\n" % (fexpr, f.init_val)
+ else:
+ s += _libxl_C_type_init(f.type, fexpr, "", nparent)
+ else:
+ if ty.init_val is not None:
+ s += "%s = %s;\n" % (ty.pass_arg(v, parent is None), ty.init_val)
+ elif ty.init_fn is not None:
+ s += "%s(%s);\n" % (ty.init_fn, ty.pass_arg(v, parent is None))
+
+ if s != "":
+ s = indent + s
+ return s.replace("\n", "\n%s" % indent).rstrip(indent)
+
+def libxl_C_type_init(ty):
+ s = ""
+ s += "void %s(%s)\n" % (ty.init_fn, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE))
+ s += "{\n"
+ s += " memset(p, '\\0', sizeof(*p));\n"
+ s += _libxl_C_type_init(ty, "p")
+ s += "}\n"
+ s += "\n"
+ return s
+
+def libxl_C_type_member_init(ty, field):
+ if not isinstance(field.type, idl.KeyedUnion):
+ raise Exception("Only KeyedUnion is supported for member init")
+
+ ku = field.type
+
+ s = ""
+ s += "void %s(%s, %s)\n" % (ty.init_fn + "_" + ku.keyvar.name,
+ ty.make_arg("p", passby=idl.PASS_BY_REFERENCE),
+ ku.keyvar.type.make_arg(ku.keyvar.name))
+ s += "{\n"
+
+ if ku.keyvar.init_val:
+ init_val = ku.keyvar.init_val
+ elif ku.keyvar.type.init_val:
+ init_val = ku.keyvar.type.init_val
+ else:
+ init_val = None
+
+ if init_val is not None:
+ (nparent,fexpr) = ty.member(ty.pass_arg("p"), ku.keyvar, isref=True)
+ s += " assert(%s == %s);\n" % (fexpr, init_val)
+ s += " %s = %s;\n" % (fexpr, ku.keyvar.name)
+ (nparent,fexpr) = ty.member(ty.pass_arg("p"), field, isref=True)
+ s += _libxl_C_type_init(ku, fexpr, parent=nparent, subinit=True)
+ s += "}\n"
+ s += "\n"
+ return s
+
def libxl_C_type_gen_json(ty, v, indent = " ", parent = None):
s = ""
if parent is None:
@@ -86,7 +171,7 @@
elif isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
@@ -196,6 +281,15 @@
f.write(libxl_C_type_define(ty) + ";\n")
if ty.dispose_fn is not None:
f.write("void %s(%s);\n" % (ty.dispose_fn, ty.make_arg("p")))
+ if ty.init_fn is not None:
+ f.write("void %s(%s);\n" % (ty.init_fn, ty.make_arg("p")))
+ for field in libxl_init_members(ty):
+ if not isinstance(field.type, idl.KeyedUnion):
+ raise Exception("Only KeyedUnion is supported for member init")
+ ku = field.type
+ f.write("void %s(%s, %s);\n" % (ty.init_fn + "_" + ku.keyvar.name,
+ ty.make_arg("p"),
+ ku.keyvar.type.make_arg(ku.keyvar.name)))
if ty.json_fn is not None:
f.write("char *%s_to_json(libxl_ctx *ctx, %s);\n" % (ty.typename, ty.make_arg("p")))
if isinstance(ty, idl.Enumeration):
@@ -224,7 +318,7 @@

""" % (header_json_define, header_json_define, " ".join(sys.argv)))

- for ty in [ty for ty in types+builtins if ty.json_fn is not None]:
+ for ty in [ty for ty in types if ty.json_fn is not None]:
f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" % (ty.typename, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE)))

f.write("\n")
@@ -261,6 +355,11 @@
f.write(" memset(p, LIBXL_DTOR_POISON, sizeof(*p));\n")
f.write("}\n")
f.write("\n")
+
+ for ty in [.t for t in types if t.init_fn is not None and t.autogenerate_init_fn]:
+ f.write(libxl_C_type_init(ty))
+ for field in libxl_init_members(ty):
+ f.write(libxl_C_type_member_init(ty, field))

for ty in [t for t in types if isinstance(t,idl.Enumeration)]:
f.write("const char *%s_to_string(%s e)\n" % (ty.typename, ty.typename))
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/idl.py
--- a/tools/libxl/idl.py Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/idl.py Thu Mar 01 12:31:15 2012 +0000
@@ -51,6 +51,10 @@

self.autogenerate_dispose_fn = kwargs.setdefault('autogenerate_dispose_fn', True)

+ self.init_fn = kwargs.setdefault('init_fn', None)
+ self.init_val = kwargs.setdefault('init_val', None)
+ self.autogenerate_init_fn = kwargs.setdefault('autogenerate_init_fn', False)
+
if self.typename is not None and not self.private:
self.json_fn = kwargs.setdefault('json_fn', self.typename + "_gen_json")
else:
@@ -144,12 +148,20 @@
self.name = name
self.const = kwargs.setdefault('const', False)
self.enumname = kwargs.setdefault('enumname', None)
+ self.init_val = kwargs.setdefault('init_val', None)

class Aggregate(Type):
"""A type containing a collection of other types"""
def __init__(self, kind, typename, fields, **kwargs):
Type.__init__(self, typename, **kwargs)

+ if self.typename is not None:
+ self.init_fn = kwargs.setdefault('init_fn', self.typename + "_init")
+ else:
+ self.init_fn = kwargs.setdefault('init_fn', None)
+
+ self.autogenerate_init_fn = kwargs.setdefault('autogenerate_init_fn', True)
+
self.kind = kind

self.fields = []
@@ -206,8 +218,9 @@
if not isinstance(keyvar_type, Enumeration):
raise ValueError

- self.keyvar_name = keyvar_name
- self.keyvar_type = keyvar_type
+ kv_kwargs = dict([(x.lstrip('keyvar_'),y) for (x,y) in kwargs.items() if x.startswith('keyvar_')])
+
+ self.keyvar = Field(keyvar_type, keyvar_name, **kv_kwargs)

for f in fields:
# (name, enum, type)
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/idl.txt
--- a/tools/libxl/idl.txt Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/idl.txt Thu Mar 01 12:31:15 2012 +0000
@@ -44,6 +44,22 @@
Indicates if the above named Type.dispose_fn should be
autogenerated.

+Type.init_val: (default: None)
+
+ C expression for the value to initialise instances of this type to.
+
+ If present takes precendence over init_fn (see below).
+
+Type.init_fn: (default: typename + "_init" if dir in [IN, BOTH] and
+ type != None)
+
+ The name of the C function which will initialist Type.
+
+Type.autogenerate_init_fn: (default: True if dir in [IN, BOTH])
+
+ Indicates if the above named Type.init_fn should be
+ autogenerated.
+
Type.json_fn: (default: typename + "_gen_json" or None if type == None)

The name of the C function which will generate a YAJL data structure
@@ -105,10 +121,13 @@

Each field has the following properties:

- Field.type The type of the member (a idl.Type).
- Field.name The name of the member (can be None for anonymous
- fields).
- Field.const Boolean, true if the member is const.
+ Field.type The type of the member (a idl.Type).
+ Field.name The name of the member (can be None for anonymous
+ fields).
+ Field.const Boolean, true if the member is const.
+ Field.init_val The initialisation value for this field. Takes
+ precendence over both Field.type.init_val and
+ Field.type.init_fn.

idl.Struct

@@ -128,10 +147,9 @@
where the currently valid member of the union can be determined based
upon another member in the containing type.

- The KeyedUnion.keyvar_name must contain the name of the member of the
+ The KeyedUnion.keyvar contains an idl.type the member of the
containing type which determines the valid member of the union. The
- member referenced by KeyedUnion.keyvar_name has type
- KeyedUnion.keyvar_type which must be an instance of the Enumeration type.
+ must be an instance of the Enumeration type.

Standard Types
--------------
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl.c Thu Mar 01 12:31:15 2012 +0000
@@ -184,6 +184,47 @@
free(kvl);
}

+#define LIBXL__DEFBOOL_DEFAULT (0)
+#define LIBXL__DEFBOOL_FALSE (-1)
+#define LIBXL__DEFBOOL_TRUE (1)
+
+void libxl_defbool_set(libxl_defbool *db, bool b)
+{
+ db->val = b ? LIBXL__DEFBOOL_TRUE : LIBXL__DEFBOOL_FALSE;
+}
+
+void libxl_defbool_unset(libxl_defbool *db)
+{
+ db->val = LIBXL__DEFBOOL_DEFAULT;
+}
+
+bool libxl_defbool_is_default(libxl_defbool db)
+{
+ return !db.val;
+}
+
+void libxl_defbool_setdefault(libxl_defbool *db, bool b)
+{
+ if (libxl_defbool_is_default(*db))
+ libxl_defbool_set(db, b);
+}
+
+bool libxl_defbool_val(libxl_defbool db)
+{
+ assert(!libxl_defbool_is_default(db));
+ return db.val > 0;
+}
+
+const char *libxl_defbool_to_string(libxl_defbool b)
+{
+ if (b.val < 0)
+ return "False";
+ else if (b.val > 0)
+ return "True";
+ else
+ return "<default>";
+}
+
/******************************************************************************/


@@ -442,6 +483,7 @@
ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info);
if (ret<0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
+ free(ptr);
return NULL;
}

@@ -464,7 +506,8 @@
}
if (ret==0 || xcinfo.domain != domid) return ERROR_INVAL;

- xcinfo2xlinfo(&xcinfo, info_r);
+ if (info_r)
+ xcinfo2xlinfo(&xcinfo, info_r);
return 0;
}

@@ -491,7 +534,7 @@
}
ptr = tmp;
ptr[i].poolid = info->cpupool_id;
- ptr[i].sched_id = info->sched_id;
+ ptr[i].sched = info->sched_id;
ptr[i].n_dom = info->n_dom;
if (libxl_cpumap_alloc(ctx, &ptr[i].cpumap)) {
xc_cpupool_infofree(ctx->xch, info);
@@ -986,13 +1029,12 @@
int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
{
GC_INIT(ctx);
- libxl_dominfo dominfo;
char *dom_path;
char *vm_path;
char *pid;
int rc, dm_present;

- rc = libxl_domain_info(ctx, &dominfo, domid);
+ rc = libxl_domain_info(ctx, NULL, domid);
switch(rc) {
case 0:
break;
@@ -1185,10 +1227,14 @@

/******************************************************************************/

-int libxl_device_disk_init(libxl_ctx *ctx, libxl_device_disk *disk)
+int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk)
{
- memset(disk, 0x00, sizeof(libxl_device_disk));
- return 0;
+ int rc;
+
+ rc = libxl__device_disk_set_backend(gc, disk);
+ if (rc) return rc;
+
+ return rc;
}

static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
@@ -1240,10 +1286,7 @@
libxl__device device;
int major, minor, rc;

- rc = libxl__device_disk_set_backend(gc, disk);
- if (rc) goto out;
-
- rc = libxl__device_disk_set_backend(gc, disk);
+ rc = libxl__device_disk_setdefault(gc, disk);
if (rc) goto out;

front = flexarray_make(16, 1);
@@ -1395,7 +1438,7 @@
unsigned int len;
char *tmp;

- libxl_device_disk_init(ctx, disk);
+ libxl_device_disk_init(disk);

tmp = xs_read(ctx->xsh, XBT_NULL,
libxl__sprintf(gc, "%s/params", be_path), &len);
@@ -1439,7 +1482,7 @@
char *dompath, *path;
int rc = ERROR_FAIL;

- libxl_device_disk_init(ctx, disk);
+ libxl_device_disk_init(disk);

dompath = libxl__xs_get_dompath(gc, domid);
if (!dompath) {
@@ -1603,7 +1646,7 @@
char *ret = NULL;
int rc;

- rc = libxl__device_disk_set_backend(gc, disk);
+ rc = libxl__device_disk_setdefault(gc, disk);
if (rc) goto out;

switch (disk->backend) {
@@ -1670,32 +1713,39 @@
}

/******************************************************************************/
-int libxl_device_nic_init(libxl_ctx *ctx, libxl_device_nic *nic)
+
+int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic)
{
- const uint8_t *r;
- libxl_uuid uuid;
-
- libxl_uuid_generate(&uuid);
- r = libxl_uuid_bytearray(&uuid);
- memset(nic, '\0', sizeof(*nic));
-
- nic->backend_domid = 0;
- nic->devid = -1;
- nic->mtu = 1492;
- nic->model = strdup("rtl8139");
- nic->mac[0] = 0x00;
- nic->mac[1] = 0x16;
- nic->mac[2] = 0x3e;
- nic->mac[3] = r[0] & 0x7f;
- nic->mac[4] = r[1];
- nic->mac[5] = r[2];
- nic->ifname = NULL;
- nic->bridge = strdup("xenbr0");
- nic->ip = NULL;
- if ( asprintf(&nic->script, "%s/vif-bridge",
- libxl_xen_script_dir_path()) < 0 )
+ if (!nic->mtu)
+ nic->mtu = 1492;
+ if (!nic->model) {
+ nic->model = strdup("rtl8139");
+ if (!nic->model) return ERROR_NOMEM;
+ }
+ if (!nic->mac[0] && !nic->mac[1] && !nic->mac[2] &&
+ !nic->mac[3] && !nic->mac[4] && !nic->mac[5]) {
+ const uint8_t *r;
+ libxl_uuid uuid;
+
+ libxl_uuid_generate(&uuid);
+ r = libxl_uuid_bytearray(&uuid);
+
+ nic->mac[0] = 0x00;
+ nic->mac[1] = 0x16;
+ nic->mac[2] = 0x3e;
+ nic->mac[3] = r[0] & 0x7f;
+ nic->mac[4] = r[1];
+ nic->mac[5] = r[2];
+ }
+ if (!nic->bridge) {
+ nic->bridge = strdup("xenbr0");
+ if (!nic->bridge) return ERROR_NOMEM;
+ }
+ if ( !nic->script && asprintf(&nic->script, "%s/vif-bridge",
+ libxl_xen_script_dir_path()) < 0 )
return ERROR_FAIL;
- nic->nictype = LIBXL_NIC_TYPE_IOEMU;
+ if (!nic->nictype)
+ nic->nictype = LIBXL_NIC_TYPE_IOEMU;
return 0;
}

@@ -1722,6 +1772,9 @@
char *dompath, **l;
unsigned int nb, rc;

+ rc = libxl__device_nic_setdefault(gc, nic);
+ if (rc) goto out;
+
front = flexarray_make(16, 1);
if (!front) {
rc = ERROR_NOMEM;
@@ -2002,7 +2055,7 @@

/******************************************************************************/
int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
- libxl_device_console *console,
+ libxl__device_console *console,
libxl__domain_build_state *state)
{
flexarray_t *front;
@@ -2049,7 +2102,7 @@
flexarray_append(front, "limit");
flexarray_append(front, libxl__sprintf(gc, "%d", LIBXL_XENCONSOLE_LIMIT));
flexarray_append(front, "type");
- if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED)
+ if (console->consback == LIBXL__CONSOLE_BACKEND_XENCONSOLED)
flexarray_append(front, "xenconsoled");
else
flexarray_append(front, "ioemu");
@@ -2080,9 +2133,9 @@
}

/******************************************************************************/
-int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb)
+
+int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb)
{
- memset(vkb, 0x00, sizeof(libxl_device_vkb));
return 0;
}

@@ -2108,6 +2161,9 @@
libxl__device device;
int rc;

+ rc = libxl__device_vkb_setdefault(gc, vkb);
+ if (rc) goto out;
+
front = flexarray_make(16, 1);
if (!front) {
rc = ERROR_NOMEM;
@@ -2185,19 +2241,24 @@
}

/******************************************************************************/
-int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb)
+
+int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb)
{
- memset(vfb, 0x00, sizeof(libxl_device_vfb));
- vfb->vnc.enable = 1;
- vfb->vnc.passwd = NULL;
- vfb->vnc.listen = strdup("127.0.0.1");
- vfb->vnc.display = 0;
- vfb->vnc.findunused = 1;
- vfb->keymap = NULL;
- vfb->sdl.enable = 0;
- vfb->sdl.opengl = 0;
- vfb->sdl.display = NULL;
- vfb->sdl.xauthority = NULL;
+ libxl_defbool_setdefault(&vfb->vnc.enable, true);
+ if (libxl_defbool_val(vfb->vnc.enable)) {
+ if (!vfb->vnc.listen) {
+ vfb->vnc.listen = strdup("127.0.0.1");
+ if (!vfb->vnc.listen) return ERROR_NOMEM;
+ }
+
+ libxl_defbool_setdefault(&vfb->vnc.findunused, true);
+ }
+
+ libxl_defbool_setdefault(&vfb->sdl.enable, false);
+ if (libxl_defbool_val(vfb->sdl.enable)) {
+ libxl_defbool_setdefault(&vfb->sdl.opengl, false);
+ }
+
return 0;
}

@@ -2222,6 +2283,9 @@
libxl__device device;
int rc;

+ rc = libxl__device_vfb_setdefault(gc, vfb);
+ if (rc) goto out;
+
front = flexarray_make(16, 1);
if (!front) {
rc = ERROR_NOMEM;
@@ -2241,17 +2305,17 @@
flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1));
flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid));
flexarray_append_pair(back, "vnc",
- libxl__sprintf(gc, "%d", vfb->vnc.enable));
+ libxl_defbool_val(vfb->vnc.enable) ? "1" : "0");
flexarray_append_pair(back, "vnclisten", vfb->vnc.listen);
flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd);
flexarray_append_pair(back, "vncdisplay",
libxl__sprintf(gc, "%d", vfb->vnc.display));
flexarray_append_pair(back, "vncunused",
- libxl__sprintf(gc, "%d", vfb->vnc.findunused));
+ libxl_defbool_val(vfb->vnc.findunused) ? "1" : "0");
flexarray_append_pair(back, "sdl",
- libxl__sprintf(gc, "%d", vfb->sdl.enable));
+ libxl_defbool_val(vfb->sdl.enable) ? "1" : "0");
flexarray_append_pair(back, "opengl",
- libxl__sprintf(gc, "%d", vfb->sdl.opengl));
+ libxl_defbool_val(vfb->sdl.opengl) ? "1" : "0");
if (vfb->sdl.xauthority) {
flexarray_append_pair(back, "xauthority", vfb->sdl.xauthority);
}
@@ -2624,18 +2688,23 @@
uint32_t *need_memkb)
{
GC_INIT(ctx);
- int rc = ERROR_INVAL;
+ int rc;
+
+ rc = libxl__domain_build_info_setdefault(gc, b_info);
+ if (rc) goto out;
+
*need_memkb = b_info->target_memkb;
switch (b_info->type) {
case LIBXL_DOMAIN_TYPE_HVM:
*need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
- if (b_info->device_model_stubdomain)
+ if (libxl_defbool_val(b_info->device_model_stubdomain))
*need_memkb += 32 * 1024;
break;
case LIBXL_DOMAIN_TYPE_PV:
*need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY;
break;
default:
+ rc = ERROR_INVAL;
goto out;
}
if (*need_memkb % (2 * 1024))
@@ -2750,7 +2819,10 @@
physinfo->sharing_used_frames = xc_sharing_used_frames(ctx->xch);
physinfo->nr_nodes = xcphysinfo.nr_nodes;
memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));
- physinfo->phys_cap = xcphysinfo.capabilities;
+
+ physinfo->cap_hvm = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm);
+ physinfo->cap_hvm_directio =
+ !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm_directio);

return 0;
}
@@ -2961,14 +3033,11 @@
return rc;
}

-/*
- * returns one of the XEN_SCHEDULER_* constants from public/domctl.h
- */
-int libxl_get_sched_id(libxl_ctx *ctx)
+libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
{
- int sched, ret;
-
- if ((ret = xc_sched_id(ctx->xch, &sched)) != 0) {
+ libxl_scheduler sched, ret;
+
+ if ((ret = xc_sched_id(ctx->xch, (int *)&sched)) != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
return ERROR_FAIL;
}
@@ -2981,6 +3050,8 @@
struct xen_domctl_sched_credit sdom;
int rc;

+ libxl_sched_credit_domain_init(scinfo);
+
rc = xc_sched_credit_domain_get(ctx->xch, domid, &sdom);
if (rc != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain sched credit");
@@ -3040,6 +3111,8 @@
struct xen_domctl_sched_credit2 sdom;
int rc;

+ libxl_sched_credit2_domain_init(scinfo);
+
rc = xc_sched_credit2_domain_get(ctx->xch, domid, &sdom);
if (rc != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
@@ -3097,6 +3170,8 @@
uint16_t weight;
int rc;

+ libxl_sched_sedf_domain_init(scinfo);
+
rc = xc_sedf_domain_get(ctx->xch, domid, &period, &slice, &latency,
&extratime, &weight);
if (rc != 0) {
@@ -3443,7 +3518,8 @@
return 0;
}

-int libxl_cpupool_create(libxl_ctx *ctx, const char *name, int schedid,
+int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
+ libxl_scheduler sched,
libxl_cpumap cpumap, libxl_uuid *uuid,
uint32_t *poolid)
{
@@ -3459,7 +3535,7 @@
return ERROR_NOMEM;
}

- rc = xc_cpupool_create(ctx->xch, poolid, schedid);
+ rc = xc_cpupool_create(ctx->xch, poolid, sched);
if (rc) {
LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Could not create cpupool");
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl.h Thu Mar 01 12:31:15 2012 +0000
@@ -124,6 +124,50 @@
* Therefore public functions which initialize a libxl__gc MUST call
* libxl__free_all() before returning.
*/
+/*
+ * libxl types
+ *
+ * Most libxl types are defined by the libxl IDL (see
+ * libxl_types.idl). The library provides a common set of methods for
+ * initialising and freeing these types.
+ *
+ * void libxl_<type>_init(<type> *p):
+ *
+ * Initialises the members of "p" to all defaults. These may either
+ * be special value which indicates to the library that it should
+ * select an appropriate default when using this field or actual
+ * default values.
+ *
+ * Some fields within a data type (e.g. unions) cannot be sensibly
+ * initialised without further information. In these cases a
+ * separate subfield initialisation function is provided (see
+ * below).
+ *
+ * An instance which has been initialised using this method can
+ * always be safely passed to the dispose function (see
+ * below). This is true even if the data type contains fields which
+ * require a separate call to a subfield initialisation function.
+ *
+ * This method is provided for any aggregate type which is used as
+ * an input parameter.
+ *
+ * void libxl_<type>_init_<subfield>(<type> *p, subfield):
+ *
+ * Initialise those parts of "p" which are not initialised by the
+ * main init function due to the unknown value of "subfield". Sets
+ * p->subfield as well as initialising any fields to their default
+ * values.
+ *
+ * p->subfield must not have been previously initialised.
+ *
+ * This method is provided for any aggregate type.
+ *
+ * void libxl_<type>_dispose(instance *p):
+ *
+ * Frees any dynamically allocated memory used by the members of
+ * "p" but not the storage used by "p" itself (this allows for the
+ * allocation of arrays of types and for the composition of types).
+ */
#ifndef LIBXL_H
#define LIBXL_H

@@ -137,9 +181,6 @@

#include <xentoollog.h>

-#include <xen/sched.h>
-#include <xen/sysctl.h>
-
#include <libxl_uuid.h>
#include <_libxl_list.h>

@@ -202,9 +243,34 @@
struct libxl_event;
typedef LIBXL_TAILQ_ENTRY(struct libxl_event) libxl_ev_link;

+/*
+ * A boolean variable with an explicit default state.
+ *
+ * Users should treat this struct as opaque and use the following
+ * defined macros and accessor functions.
+ *
+ * To allow users of the library to naively select all defaults this
+ * state is represented as 0. False is < 0 and True is > 0.
+ */
+typedef struct {
+ int val;
+} libxl_defbool;
+
+void libxl_defbool_set(libxl_defbool *db, bool b);
+/* Resets to default */
+void libxl_defbool_unset(libxl_defbool *db);
+/* Sets db only if it is currently == default */
+void libxl_defbool_setdefault(libxl_defbool *db, bool b);
+bool libxl_defbool_is_default(libxl_defbool db);
+/* db must not be == default */
+bool libxl_defbool_val(libxl_defbool db);
+
+const char *libxl_defbool_to_string(libxl_defbool b);
+
typedef struct libxl__ctx libxl_ctx;

-#define LIBXL_TIMER_MODE_DEFAULT LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS
+#define LIBXL_TIMER_MODE_DEFAULT -1
+#define LIBXL_MEMKB_DEFAULT ~0ULL

#include "_libxl_types.h"

@@ -315,10 +381,6 @@
int libxl_ctx_postfork(libxl_ctx *ctx);

/* domain related functions */
-int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info);
-int libxl_init_build_info(libxl_ctx *ctx,
- libxl_domain_build_info *b_info,
- libxl_domain_create_info *c_info);
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);
@@ -390,11 +452,14 @@
* guests using pygrub. */
int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm);

+/* May be called with info_r == NULL to check for domain's existance */
int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r,
uint32_t domid);
libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain);
+void libxl_dominfo_list_free(libxl_dominfo *list, int nr);
libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool);
libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm);
+void libxl_vminfo_list_free(libxl_vminfo *list, int nr);

/*
* Devices
@@ -405,8 +470,9 @@
* additional data type libxl_device_<TYPE>_getinfo which contains
* further runtime information about the device.
*
- * A common set of methods are available for each device type. These
- * are described below.
+ * In addition to the general methods available for libxl types (see
+ * "libxl types" above) a common set of methods are available for each
+ * device type. These are described below.
*
* Querying
* --------
@@ -424,10 +490,6 @@
* Creation / Control
* ------------------
*
- * libxl_device_<type>_init(ctx, device):
- *
- * Initalises device to a default configuration.
- *
* libxl_device_<type>_add(ctx, domid, device):
*
* Adds the given device to the specified domain. This can be called
@@ -457,7 +519,6 @@
*/

/* Disks */
-int libxl_device_disk_init(libxl_ctx *ctx, libxl_device_disk *disk);
int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
int libxl_device_disk_remove(libxl_ctx *ctx, uint32_t domid,
libxl_device_disk *disk,
@@ -483,7 +544,6 @@
int libxl_device_disk_local_detach(libxl_ctx *ctx, libxl_device_disk *disk);

/* Network Interfaces */
-int libxl_device_nic_init(libxl_ctx *ctx, libxl_device_nic *nic);
int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic);
int libxl_device_nic_remove(libxl_ctx *ctx, uint32_t domid,
libxl_device_nic *nic,
@@ -495,7 +555,6 @@
libxl_device_nic *nic, libxl_nicinfo *nicinfo);

/* Keyboard */
-int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb);
int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
libxl_device_vkb *vkb,
@@ -503,7 +562,6 @@
int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);

/* Framebuffer */
-int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb);
int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);
int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
libxl_device_vfb *vfb,
@@ -511,7 +569,6 @@
int libxl_device_vfb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);

/* PCI Passthrough */
-int libxl_device_pci_init(libxl_ctx *ctx, libxl_device_pci *pci);
int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev);
int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev);
int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev);
@@ -584,7 +641,7 @@
unsigned int max_vcpus, libxl_cpumap *cpumap);
int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_cpumap *cpumap);

-int libxl_get_sched_id(libxl_ctx *ctx);
+libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx);


int libxl_sched_credit_domain_get(libxl_ctx *ctx, uint32_t domid,
@@ -627,7 +684,8 @@
int libxl_tmem_freeable(libxl_ctx *ctx);

int libxl_get_freecpus(libxl_ctx *ctx, libxl_cpumap *cpumap);
-int libxl_cpupool_create(libxl_ctx *ctx, const char *name, int schedid,
+int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
+ libxl_scheduler sched,
libxl_cpumap cpumap, libxl_uuid *uuid,
uint32_t *poolid);
int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
@@ -638,12 +696,7 @@
int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid);

-static inline int libxl_domid_valid_guest(uint32_t domid)
-{
- /* returns 1 if the value _could_ be a valid guest domid, 0 otherwise
- * does not check whether the domain actually exists */
- return domid > 0 && domid < DOMID_FIRST_RESERVED;
-}
+int libxl_domid_valid_guest(uint32_t domid);

int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
uint32_t *ssidref);
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_bootloader.c
--- a/tools/libxl/libxl_bootloader.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_bootloader.c Thu Mar 01 12:31:15 2012 +0000
@@ -346,9 +346,15 @@

struct stat st_buf;

+ rc = libxl__domain_build_info_setdefault(gc, info);
+ if (rc) goto out;
+
if (info->type != LIBXL_DOMAIN_TYPE_PV || !info->u.pv.bootloader)
goto out;

+ rc = libxl__domain_build_info_setdefault(gc, info);
+ if (rc) goto out;
+
rc = ERROR_INVAL;
if (!disk)
goto out;
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_create.c Thu Mar 01 12:31:15 2012 +0000
@@ -50,79 +50,141 @@
libxl_domain_build_info_dispose(&d_config->b_info);
}

-int libxl_init_create_info(libxl_ctx *ctx, libxl_domain_create_info *c_info)
+int libxl__domain_create_info_setdefault(libxl__gc *gc,
+ libxl_domain_create_info *c_info)
{
- memset(c_info, '\0', sizeof(*c_info));
- c_info->xsdata = NULL;
- c_info->platformdata = NULL;
- c_info->hap = 1;
- c_info->type = LIBXL_DOMAIN_TYPE_HVM;
- c_info->oos = 1;
- c_info->ssidref = 0;
- c_info->poolid = 0;
+ if (!c_info->type)
+ return ERROR_INVAL;
+
+ if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+ libxl_defbool_setdefault(&c_info->hap, true);
+ libxl_defbool_setdefault(&c_info->oos, true);
+ }
+
return 0;
}

-int libxl_init_build_info(libxl_ctx *ctx,
- libxl_domain_build_info *b_info,
- libxl_domain_create_info *c_info)
+int libxl__domain_build_info_setdefault(libxl__gc *gc,
+ libxl_domain_build_info *b_info)
{
- memset(b_info, '\0', sizeof(*b_info));
- b_info->max_vcpus = 1;
- b_info->cur_vcpus = 1;
- if (libxl_cpumap_alloc(ctx, &b_info->cpumap))
- return ERROR_NOMEM;
- libxl_cpumap_set_any(&b_info->cpumap);
- b_info->max_memkb = 32 * 1024;
- b_info->target_memkb = b_info->max_memkb;
- b_info->disable_migrate = 0;
- b_info->cpuid = NULL;
- b_info->shadow_memkb = 0;
- b_info->type = c_info->type;
+ if (!b_info->device_model_version)
+ b_info->device_model_version =
+ LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;

- b_info->device_model_version =
- LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
- b_info->device_model_stubdomain = false;
- b_info->device_model = NULL;
+ if (!b_info->u.hvm.bios)
+ switch (b_info->device_model_version) {
+ case 1: b_info->u.hvm.bios = LIBXL_BIOS_TYPE_ROMBIOS; break;
+ case 2: b_info->u.hvm.bios = LIBXL_BIOS_TYPE_SEABIOS; break;
+ default:return ERROR_INVAL;
+ }
+
+ /* Enforce BIOS<->Device Model version relationship */
+ switch (b_info->device_model_version) {
+ case 1:
+ if (b_info->u.hvm.bios != LIBXL_BIOS_TYPE_ROMBIOS)
+ return ERROR_INVAL;
+ break;
+ case 2:
+ if (b_info->u.hvm.bios == LIBXL_BIOS_TYPE_ROMBIOS)
+ return ERROR_INVAL;
+ break;
+ default:abort();
+ }
+
+ libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+
+ if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
+ b_info->device_model_version !=
+ LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+ libxl_defbool_val(b_info->device_model_stubdomain)) {
+ LIBXL__LOG(CTX, XTL_ERROR,
+ "device model stubdomains require \"qemu-xen-traditional\"");
+ return ERROR_INVAL;
+ }
+
+ if (!b_info->max_vcpus)
+ b_info->max_vcpus = 1;
+ if (!b_info->cur_vcpus)
+ b_info->cur_vcpus = 1;
+
+ if (!b_info->cpumap.size) {
+ if (libxl_cpumap_alloc(CTX, &b_info->cpumap))
+ return ERROR_NOMEM;
+ libxl_cpumap_set_any(&b_info->cpumap);
+ }
+
+ if (b_info->max_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->max_memkb = 32 * 1024;
+ if (b_info->target_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->target_memkb = b_info->max_memkb;
+
+ libxl_defbool_setdefault(&b_info->disable_migrate, false);

switch (b_info->type) {
case LIBXL_DOMAIN_TYPE_HVM:
- b_info->video_memkb = 8 * 1024;
- b_info->u.hvm.firmware = NULL;
- b_info->u.hvm.bios = 0;
- b_info->u.hvm.pae = 1;
- b_info->u.hvm.apic = 1;
- b_info->u.hvm.acpi = 1;
- b_info->u.hvm.acpi_s3 = 1;
- b_info->u.hvm.acpi_s4 = 1;
- b_info->u.hvm.nx = 1;
- b_info->u.hvm.viridian = 0;
- b_info->u.hvm.hpet = 1;
- b_info->u.hvm.vpt_align = 1;
- b_info->u.hvm.timer_mode = 1;
- b_info->u.hvm.nested_hvm = 0;
- b_info->u.hvm.no_incr_generationid = 0;
+ if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->shadow_memkb = 0;
+ if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->video_memkb = 8 * 1024;
+ if (b_info->u.hvm.timer_mode == LIBXL_TIMER_MODE_DEFAULT)
+ b_info->u.hvm.timer_mode =
+ LIBXL_TIMER_MODE_NO_DELAY_FOR_MISSED_TICKS;

- b_info->u.hvm.stdvga = 0;
- b_info->u.hvm.vnc.enable = 1;
- b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
- b_info->u.hvm.vnc.display = 0;
- b_info->u.hvm.vnc.findunused = 1;
- b_info->u.hvm.keymap = NULL;
- b_info->u.hvm.sdl.enable = 0;
- b_info->u.hvm.sdl.opengl = 0;
- b_info->u.hvm.nographic = 0;
- b_info->u.hvm.serial = NULL;
- b_info->u.hvm.boot = strdup("cda");
- b_info->u.hvm.usb = 0;
- b_info->u.hvm.usbdevice = NULL;
- b_info->u.hvm.xen_platform_pci = 1;
+ libxl_defbool_setdefault(&b_info->u.hvm.pae, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.apic, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.acpi, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.acpi_s3, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.acpi_s4, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.nx, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.viridian, false);
+ libxl_defbool_setdefault(&b_info->u.hvm.hpet, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.vpt_align, true);
+ libxl_defbool_setdefault(&b_info->u.hvm.nested_hvm, false);
+ libxl_defbool_setdefault(&b_info->u.hvm.incr_generationid, false);
+ libxl_defbool_setdefault(&b_info->u.hvm.usb, false);
+ libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true);
+
+ if (!b_info->u.hvm.boot) {
+ b_info->u.hvm.boot = strdup("cda");
+ if (!b_info->u.hvm.boot) return ERROR_NOMEM;
+ }
+
+ libxl_defbool_setdefault(&b_info->u.hvm.stdvga, false);
+ libxl_defbool_setdefault(&b_info->u.hvm.vnc.enable, true);
+ if (libxl_defbool_val(b_info->u.hvm.vnc.enable)) {
+ libxl_defbool_setdefault(&b_info->u.hvm.vnc.findunused, true);
+ if (!b_info->u.hvm.vnc.listen) {
+ b_info->u.hvm.vnc.listen = strdup("127.0.0.1");
+ if (!b_info->u.hvm.vnc.listen) return ERROR_NOMEM;
+ }
+ }
+
+ libxl_defbool_setdefault(&b_info->u.hvm.sdl.enable, false);
+ if (libxl_defbool_val(b_info->u.hvm.sdl.enable)) {
+ libxl_defbool_setdefault(&b_info->u.hvm.sdl.opengl, false);
+ }
+
+ libxl_defbool_setdefault(&b_info->u.hvm.spice.enable, false);
+ if (libxl_defbool_val(b_info->u.hvm.spice.enable)) {
+ libxl_defbool_setdefault(&b_info->u.hvm.spice.disable_ticketing,
+ false);
+ libxl_defbool_setdefault(&b_info->u.hvm.spice.agent_mouse, true);
+ }
+
+ libxl_defbool_setdefault(&b_info->u.hvm.nographic, false);
+
+ libxl_defbool_setdefault(&b_info->u.hvm.gfx_passthru, false);
+
break;
case LIBXL_DOMAIN_TYPE_PV:
- b_info->u.pv.slack_memkb = 8 * 1024;
+ libxl_defbool_setdefault(&b_info->u.pv.e820_host, false);
+ if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->shadow_memkb = 0;
+ if (b_info->u.pv.slack_memkb == LIBXL_MEMKB_DEFAULT)
+ b_info->u.pv.slack_memkb = 0;
break;
default:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
"invalid domain type %s in create info",
libxl_domain_type_to_string(b_info->type));
return ERROR_INVAL;
@@ -130,17 +192,16 @@
return 0;
}

-static int init_console_info(libxl_device_console *console, int dev_num)
+static int init_console_info(libxl__device_console *console, int dev_num)
{
- memset(console, 0x00, sizeof(libxl_device_console));
+ memset(console, 0x00, sizeof(libxl__device_console));
console->devid = dev_num;
- console->consback = LIBXL_CONSOLE_BACKEND_XENCONSOLED;
+ console->consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED;
console->output = strdup("pty");
- if ( NULL == console->output )
+ if (!console->output)
return ERROR_NOMEM;
return 0;
}
-
int libxl__domain_build(libxl__gc *gc,
libxl_domain_build_info *info,
uint32_t domid,
@@ -172,11 +233,11 @@

localents = libxl__calloc(gc, 7, sizeof(char *));
localents[0] = "platform/acpi";
- localents[1] = (info->u.hvm.acpi) ? "1" : "0";
+ localents[1] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
localents[2] = "platform/acpi_s3";
- localents[3] = (info->u.hvm.acpi_s3) ? "1" : "0";
+ localents[3] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
localents[4] = "platform/acpi_s4";
- localents[5] = (info->u.hvm.acpi_s4) ? "1" : "0";
+ localents[5] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0";

break;
case LIBXL_DOMAIN_TYPE_PV:
@@ -320,8 +381,8 @@
flags = 0;
if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
flags |= XEN_DOMCTL_CDF_hvm_guest;
- flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
- flags |= info->oos ? 0 : XEN_DOMCTL_CDF_oos_off;
+ flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
+ flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
}
*domid = -1;

@@ -378,7 +439,6 @@
xs_rm(ctx->xsh, t, dom_path);
libxl__xs_mkdir(gc, t, dom_path, roperm, ARRAY_SIZE(roperm));

-
xs_rm(ctx->xsh, t, vm_path);
libxl__xs_mkdir(gc, t, vm_path, roperm, ARRAY_SIZE(roperm));

@@ -470,6 +530,12 @@

domid = 0;

+ ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
+ if (ret) goto error_out;
+
+ ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
+ if (ret) goto error_out;
+
ret = libxl__domain_make(gc, &d_config->c_info, &domid);
if (ret) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
@@ -482,9 +548,11 @@
goto error_out;
}

+ ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
+ if (ret) goto error_out;

for (i = 0; i < d_config->num_disks; i++) {
- ret = libxl__device_disk_set_backend(gc, &d_config->disks[i]);
+ ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]);
if (ret) goto error_out;
}

@@ -534,18 +602,16 @@
switch (d_config->c_info.type) {
case LIBXL_DOMAIN_TYPE_HVM:
{
- libxl_device_console console;
+ libxl__device_console console;
libxl_device_vkb vkb;

ret = init_console_info(&console, 0);
if ( ret )
goto error_out;
libxl__device_console_add(gc, domid, &console, &state);
- libxl_device_console_dispose(&console);
+ libxl__device_console_dispose(&console);

- ret = libxl_device_vkb_init(ctx, &vkb);
- if ( ret )
- goto error_out;
+ libxl_device_vkb_init(&vkb);
libxl_device_vkb_add(ctx, domid, &vkb);
libxl_device_vkb_dispose(&vkb);

@@ -561,7 +627,7 @@
case LIBXL_DOMAIN_TYPE_PV:
{
int need_qemu = 0;
- libxl_device_console console;
+ libxl__device_console console;

for (i = 0; i < d_config->num_vfbs; i++) {
libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
@@ -577,10 +643,10 @@
d_config->num_disks, &d_config->disks[0]);

if (need_qemu)
- console.consback = LIBXL_CONSOLE_BACKEND_IOEMU;
+ console.consback = LIBXL__CONSOLE_BACKEND_IOEMU;

libxl__device_console_add(gc, domid, &console, &state);
- libxl_device_console_dispose(&console);
+ libxl__device_console_dispose(&console);

if (need_qemu) {
libxl__create_xenpv_qemu(gc, domid, d_config, &state, &dm_starting);
@@ -619,7 +685,7 @@
}

if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
- d_config->b_info.u.pv.e820_host) {
+ libxl_defbool_val(d_config->b_info.u.pv.e820_host)) {
int rc;
rc = libxl__e820_alloc(gc, domid, d_config);
if (rc)
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_dm.c Thu Mar 01 12:31:15 2012 +0000
@@ -39,7 +39,7 @@
libxl_ctx *ctx = libxl__gc_owner(gc);
const char *dm;

- if (info->device_model_stubdomain)
+ if (libxl_defbool_val(info->device_model_stubdomain))
return NULL;

if (info->device_model) {
@@ -63,18 +63,6 @@
return dm;
}

-static const char *libxl__domain_bios(libxl__gc *gc,
- const libxl_domain_build_info *info)
-{
- if (info->u.hvm.bios)
- return libxl_bios_type_to_string(info->u.hvm.bios);
- switch (info->device_model_version) {
- case 1: return "rombios";
- case 2: return "seabios";
- default:return NULL;
- }
-}
-
const libxl_vnc_info *libxl__dm_vnc(const libxl_domain_config *guest_config)
{
const libxl_vnc_info *vnc = NULL;
@@ -83,7 +71,7 @@
} else if (guest_config->num_vfbs > 0) {
vnc = &guest_config->vfbs[0].vnc;
}
- return vnc && vnc->enable ? vnc : NULL;
+ return vnc && libxl_defbool_val(vnc->enable) ? vnc : NULL;
}

static const libxl_sdl_info *dm_sdl(const libxl_domain_config *guest_config)
@@ -94,7 +82,7 @@
} else if (guest_config->num_vfbs > 0) {
sdl = &guest_config->vfbs[0].sdl;
}
- return sdl && sdl->enable ? sdl : NULL;
+ return sdl && libxl_defbool_val(sdl->enable) ? sdl : NULL;
}

static const char *dm_keymap(const libxl_domain_config *guest_config)
@@ -156,13 +144,13 @@
flexarray_append(dm_args, "-vnc");
flexarray_append(dm_args, vncarg);

- if (vnc->findunused) {
+ if (libxl_defbool_val(vnc->findunused)) {
flexarray_append(dm_args, "-vncunused");
}
}
if (sdl) {
flexarray_append(dm_args, "-sdl");
- if (!sdl->opengl) {
+ if (!libxl_defbool_val(sdl->opengl)) {
flexarray_append(dm_args, "-disable-opengl");
}
/* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
@@ -177,7 +165,7 @@
flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
}

- if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+ if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
flexarray_append(dm_args, "-nographic");
}

@@ -187,14 +175,14 @@
libxl__sizekb_to_mb(b_info->video_memkb)),
NULL);
}
- if (b_info->u.hvm.stdvga) {
+ if (libxl_defbool_val(b_info->u.hvm.stdvga)) {
flexarray_append(dm_args, "-std-vga");
}

if (b_info->u.hvm.boot) {
flexarray_vappend(dm_args, "-boot", b_info->u.hvm.boot, NULL);
}
- if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
+ if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) {
flexarray_append(dm_args, "-usb");
if (b_info->u.hvm.usbdevice) {
flexarray_vappend(dm_args,
@@ -204,7 +192,7 @@
if (b_info->u.hvm.soundhw) {
flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
}
- if (b_info->u.hvm.acpi) {
+ if (libxl_defbool_val(b_info->u.hvm.acpi)) {
flexarray_append(dm_args, "-acpi");
}
if (b_info->max_vcpus > 1) {
@@ -240,7 +228,7 @@
if ( ioemu_vifs == 0 ) {
flexarray_vappend(dm_args, "-net", "none", NULL);
}
- if (b_info->u.hvm.gfx_passthru) {
+ if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) {
flexarray_append(dm_args, "-gfx_passthru");
}
} else {
@@ -293,7 +281,7 @@
return NULL;
}

- if (!spice->disable_ticketing) {
+ if (!libxl_defbool_val(spice->disable_ticketing)) {
if (!spice->passwd) {
LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
"spice ticketing is enabled but missing password");
@@ -309,12 +297,12 @@
spice->port, spice->tls_port);
if (spice->host)
opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host);
- if (spice->disable_ticketing)
+ if (libxl_defbool_val(spice->disable_ticketing))
opt = libxl__sprintf(gc, "%s,disable-ticketing", opt);
else
opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd);
opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt,
- spice->agent_mouse ? "on" : "off");
+ libxl_defbool_val(spice->agent_mouse) ? "on" : "off");
return opt;
}

@@ -383,7 +371,7 @@
if (vnc->passwd && vnc->passwd[0]) {
vncarg = libxl__sprintf(gc, "%s,password", vncarg);
}
- if (vnc->findunused) {
+ if (libxl_defbool_val(vnc->findunused)) {
/* This option asks to QEMU to try this number of port before to
* give up. So QEMU will try ports between $display and $display +
* 99. This option needs to be the last one of the vnc options. */
@@ -411,11 +399,11 @@
flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
}

- if (b_info->u.hvm.nographic && (!sdl && !vnc)) {
+ if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
flexarray_append(dm_args, "-nographic");
}

- if (b_info->u.hvm.spice.enable) {
+ if (libxl_defbool_val(b_info->u.hvm.spice.enable)) {
const libxl_spice_info *spice = &b_info->u.hvm.spice;
char *spiceoptions = dm_spice_options(gc, spice);
if (!spiceoptions)
@@ -425,7 +413,7 @@
flexarray_append(dm_args, spiceoptions);
}

- if (b_info->u.hvm.stdvga) {
+ if (libxl_defbool_val(b_info->u.hvm.stdvga)) {
flexarray_vappend(dm_args, "-vga", "std", NULL);
}

@@ -433,7 +421,7 @@
flexarray_vappend(dm_args, "-boot",
libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL);
}
- if (b_info->u.hvm.usb || b_info->u.hvm.usbdevice) {
+ if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) {
flexarray_append(dm_args, "-usb");
if (b_info->u.hvm.usbdevice) {
flexarray_vappend(dm_args,
@@ -443,7 +431,7 @@
if (b_info->u.hvm.soundhw) {
flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
}
- if (!b_info->u.hvm.acpi) {
+ if (!libxl_defbool_val(b_info->u.hvm.acpi)) {
flexarray_append(dm_args, "-no-acpi");
}
if (b_info->max_vcpus > 1) {
@@ -485,7 +473,7 @@
flexarray_append(dm_args, "-net");
flexarray_append(dm_args, "none");
}
- if (b_info->u.hvm.gfx_passthru) {
+ if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) {
flexarray_append(dm_args, "-gfx_passthru");
}
} else {
@@ -616,8 +604,8 @@
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));
+ libxl_device_vfb_init(vfb);
+ libxl_device_vkb_init(vkb);

vfb->backend_domid = 0;
vfb->devid = 0;
@@ -688,7 +676,7 @@
{
libxl_ctx *ctx = libxl__gc_owner(gc);
int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret;
- libxl_device_console *console;
+ libxl__device_console *console;
libxl_domain_config dm_config;
libxl_device_vfb vfb;
libxl_device_vkb vkb;
@@ -705,7 +693,7 @@
goto out;
}

- memset(&dm_config.c_info, 0x00, sizeof(libxl_domain_create_info));
+ libxl_domain_create_info_init(&dm_config.c_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, guest_domid));
@@ -713,13 +701,13 @@

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;
+ libxl_domain_build_info_init(&dm_config.b_info);
+ libxl_domain_build_info_init_type(&dm_config.b_info, LIBXL_DOMAIN_TYPE_PV);
+
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", guest_domid);
@@ -740,6 +728,11 @@
dm_config.vifs = guest_config->vifs;
dm_config.num_vifs = guest_config->num_vifs;

+ ret = libxl__domain_create_info_setdefault(gc, &dm_config.c_info);
+ if (ret) goto out;
+ ret = libxl__domain_build_info_setdefault(gc, &dm_config.b_info);
+ if (ret) goto out;
+
libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb);
dm_config.vfbs = &vfb;
dm_config.num_vfbs = 1;
@@ -816,7 +809,7 @@
if (guest_config->b_info.u.hvm.serial)
num_console++;

- console = libxl__calloc(gc, num_console, sizeof(libxl_device_console));
+ console = libxl__calloc(gc, num_console, sizeof(libxl__device_console));
if (!console) {
ret = ERROR_NOMEM;
goto out_free;
@@ -824,7 +817,7 @@

for (i = 0; i < num_console; i++) {
console[i].devid = i;
- console[i].consback = LIBXL_CONSOLE_BACKEND_IOEMU;
+ console[i].consback = LIBXL__CONSOLE_BACKEND_IOEMU;
/* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging
* STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file
* STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file
@@ -907,7 +900,7 @@
char **pass_stuff;
const char *dm;

- if (b_info->device_model_stubdomain) {
+ if (libxl_defbool_val(b_info->device_model_stubdomain)) {
rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r);
goto out;
}
@@ -929,10 +922,13 @@
goto out;
}

- 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);
+ if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+ path = xs_get_domain_path(ctx->xsh, domid);
+ libxl__xs_write(gc, XBT_NULL,
+ libxl__sprintf(gc, "%s/hvmloader/bios", path),
+ "%s", libxl_bios_type_to_string(b_info->u.hvm.bios));
+ free(path);
+ }

path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid);
xs_mkdir(ctx->xsh, XBT_NULL, path);
@@ -941,7 +937,7 @@
b_info->device_model_version
== LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL)
libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
- "%d", !b_info->u.hvm.xen_platform_pci);
+ "%d", !libxl_defbool_val(b_info->u.hvm.xen_platform_pci));

libxl_create_logfile(ctx,
libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
@@ -1088,7 +1084,7 @@
}

int libxl__need_xenpv_qemu(libxl__gc *gc,
- int nr_consoles, libxl_device_console *consoles,
+ int nr_consoles, libxl__device_console *consoles,
int nr_vfbs, libxl_device_vfb *vfbs,
int nr_disks, libxl_device_disk *disks)
{
@@ -1100,7 +1096,7 @@
}

for (i = 0; i < nr_consoles; i++) {
- if (consoles[i].consback == LIBXL_CONSOLE_BACKEND_IOEMU) {
+ if (consoles[i].consback == LIBXL__CONSOLE_BACKEND_IOEMU) {
ret = 1;
goto out;
}
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_dom.c Thu Mar 01 12:31:15 2012 +0000
@@ -88,7 +88,7 @@
abort();
}
xc_domain_set_tsc_info(ctx->xch, domid, tsc_mode, 0, 0, 0);
- if ( info->disable_migrate )
+ if (libxl_defbool_val(info->disable_migrate))
xc_domain_disable_migrate(ctx->xch, domid);

if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
@@ -129,11 +129,12 @@

ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
ents[0] = "memory/static-max";
- ents[1] = libxl__sprintf(gc, "%d", info->max_memkb);
+ ents[1] = libxl__sprintf(gc, "%"PRId64, info->max_memkb);
ents[2] = "memory/target";
- ents[3] = libxl__sprintf(gc, "%d", info->target_memkb - info->video_memkb);
+ ents[3] = libxl__sprintf(gc, "%"PRId64,
+ info->target_memkb - info->video_memkb);
ents[4] = "memory/videoram";
- ents[5] = libxl__sprintf(gc, "%d", info->video_memkb);
+ ents[5] = libxl__sprintf(gc, "%"PRId64, info->video_memkb);
ents[6] = "domid";
ents[7] = libxl__sprintf(gc, "%d", domid);
ents[8] = "store/port";
@@ -291,7 +292,7 @@
return -1;

va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
- va_hvm->apic_mode = info->u.hvm.apic;
+ va_hvm->apic_mode = libxl_defbool_val(info->u.hvm.apic);
va_hvm->nr_vcpus = info->max_vcpus;
memcpy(va_hvm->vcpu_online, &info->cur_vcpus, sizeof(info->cur_vcpus));
for (i = 0, sum = 0; i < va_hvm->length; i++)
@@ -301,14 +302,19 @@

xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
- xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED,
+ libxl_defbool_val(info->u.hvm.pae));
#if defined(__i386__) || defined(__x86_64__)
- xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
- xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) info->u.hvm.hpet);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN,
+ libxl_defbool_val(info->u.hvm.viridian));
+ xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED,
+ libxl_defbool_val(info->u.hvm.hpet));
#endif
xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, timer_mode(info));
- xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->u.hvm.vpt_align);
- xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM, info->u.hvm.nested_hvm);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN,
+ libxl_defbool_val(info->u.hvm.vpt_align));
+ xc_set_hvm_param(handle, domid, HVM_PARAM_NESTEDHVM,
+ libxl_defbool_val(info->u.hvm.nested_hvm));
xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);

@@ -399,8 +405,8 @@
case LIBXL_DOMAIN_TYPE_HVM:
hvm = 1;
superpages = 1;
- pae = info->u.hvm.pae;
- no_incr_generationid = info->u.hvm.no_incr_generationid;
+ pae = libxl_defbool_val(info->u.hvm.pae);
+ no_incr_generationid = !libxl_defbool_val(info->u.hvm.incr_generationid);
break;
case LIBXL_DOMAIN_TYPE_PV:
hvm = 0;
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_internal.h Thu Mar 01 12:31:15 2012 +0000
@@ -187,6 +187,16 @@
* version of the _evdisable_FOO function; the internal one is
* used during cleanup.
*/
+_hidden int libxl__domain_create_info_setdefault(libxl__gc *gc,
+ libxl_domain_create_info *c_info);
+_hidden int libxl__domain_build_info_setdefault(libxl__gc *gc,
+ libxl_domain_build_info *b_info);
+_hidden int libxl__device_disk_setdefault(libxl__gc *gc,
+ libxl_device_disk *disk);
+_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic);
+_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
+_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);
+_hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci);

struct libxl__evgen_domain_death {
uint32_t domid;
@@ -652,7 +662,7 @@
int *pdisk, int *ppartition);

_hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
- libxl_device_console *console,
+ libxl__device_console *console,
libxl__domain_build_state *state);

_hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
@@ -665,6 +675,19 @@
_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid);
_hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);

+/*
+ * For each aggregate type which can be used as an input we provide:
+ *
+ * int libxl__<type>_setdefault(gc, <type> *p):
+ *
+ * Idempotently sets any members of "p" which is currently set to
+ * a special value indicating that the defaults should be used
+ * (per libxl_<type>_init) to a specific value.
+ *
+ * All libxl API functions are expected to have arranged for this
+ * to be called before using any values within these structures.
+ */
+
/* Arranges that dev will be removed from its guest. When
* this is done, the ao will be completed. An error
* return from libxl__initiate_device_remove means that the ao
@@ -882,7 +905,7 @@
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,
+ int nr_consoles, libxl__device_console *consoles,
int nr_vfbs, libxl_device_vfb *vfbs,
int nr_disks, libxl_device_disk *disks);
/* Caller must either: pass starting_r==0, or on successful
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_json.c
--- a/tools/libxl/libxl_json.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_json.c Thu Mar 01 12:31:15 2012 +0000
@@ -85,6 +85,12 @@
/*
* YAJL generators for builtin libxl types.
*/
+yajl_gen_status libxl_defbool_gen_json(yajl_gen hand,
+ libxl_defbool *db)
+{
+ return libxl__yajl_gen_asciiz(hand, libxl_defbool_to_string(*db));
+}
+
yajl_gen_status libxl_uuid_gen_json(yajl_gen hand,
libxl_uuid *uuid)
{
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_json.h
--- a/tools/libxl/libxl_json.h Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_json.h Thu Mar 01 12:31:15 2012 +0000
@@ -22,6 +22,20 @@
# include <yajl/yajl_version.h>
#endif

+yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, libxl_defbool *p);
+yajl_gen_status libxl_domid_gen_json(yajl_gen hand, libxl_domid *p);
+yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, libxl_uuid *p);
+yajl_gen_status libxl_mac_gen_json(yajl_gen hand, libxl_mac *p);
+yajl_gen_status libxl_cpumap_gen_json(yajl_gen hand, libxl_cpumap *p);
+yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
+ libxl_cpuid_policy_list *p);
+yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, libxl_string_list *p);
+yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand,
+ libxl_key_value_list *p);
+yajl_gen_status libxl_file_reference_gen_json(yajl_gen hand,
+ libxl_file_reference *p);
+yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, libxl_hwcap *p);
+
#include <_libxl_types_json.h>

/* YAJL version check */
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_pci.c Thu Mar 01 12:31:15 2012 +0000
@@ -765,6 +765,11 @@
return -1;
}

+int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci)
+{
+ return 0;
+}
+
int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev)
{
GC_INIT(ctx);
@@ -782,6 +787,9 @@
int num_assigned, i, rc;
int stubdomid = 0;

+ rc = libxl__device_pci_setdefault(gc, pcidev);
+ if (rc) goto out;
+
rc = get_all_assigned_devices(gc, &assigned, &num_assigned);
if ( rc ) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot determine if device is assigned, refusing to continue");
@@ -1365,7 +1373,7 @@
return ERROR_INVAL;

b_info = &d_config->b_info;
- if (!b_info->u.pv.e820_host)
+ if (!libxl_defbool_val(b_info->u.pv.e820_host))
return ERROR_INVAL;

rc = xc_get_machine_memory_map(ctx->xch, map, E820MAX);
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_types.idl Thu Mar 01 12:31:15 2012 +0000
@@ -5,6 +5,8 @@

namespace("libxl_")

+libxl_defbool = Builtin("defbool", passby=PASS_BY_REFERENCE)
+
libxl_domid = Builtin("domid", json_fn = "yajl_gen_integer", autogenerate_json = False)
libxl_uuid = Builtin("uuid", passby=PASS_BY_REFERENCE)
libxl_mac = Builtin("mac", passby=PASS_BY_REFERENCE)
@@ -18,6 +20,12 @@
libxl_hwcap = Builtin("hwcap", passby=PASS_BY_REFERENCE)

#
+# Specific integer types
+#
+
+MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
+
+#
# Constants / Enumerations
#

@@ -36,11 +44,6 @@
(2, "PV"),
])

-libxl_console_backend = Enumeration("console_backend", [
- (1, "XENCONSOLED"),
- (2, "IOEMU"),
- ])
-
libxl_disk_format = Enumeration("disk_format", [.
(0, "UNKNOWN"),
(1, "QCOW"),
@@ -97,7 +100,7 @@
(1, "no_delay_for_missed_ticks"),
(2, "no_missed_ticks_pending"),
(3, "one_missed_tick_pending"),
- ])
+ ], init_val = "LIBXL_TIMER_MODE_DEFAULT")

libxl_bios_type = Enumeration("bios_type", [
(1, "rombios"),
@@ -105,35 +108,52 @@
(3, "ovmf"),
])

+# Consistent with values defined in domctl.h
+libxl_scheduler = Enumeration("scheduler", [.
+ (4, "sedf"),
+ (5, "credit"),
+ (6, "credit2"),
+ (7, "arinc653"),
+ ])
+
+# Consistent with SHUTDOWN_* in sched.h
+libxl_shutdown_reason = Enumeration("shutdown_reason", [.
+ (0, "poweroff"),
+ (1, "reboot"),
+ (2, "suspend"),
+ (3, "crash"),
+ (4, "watchdog"),
+ ])
+
#
# Complex libxl types
#
libxl_vnc_info = Struct("vnc_info", [
- ("enable", bool),
+ ("enable", libxl_defbool),
# "address:port" that should be listened on
("listen", string),
("passwd", string),
("display", integer),
# If set then try to find an unused port
- ("findunused", bool),
+ ("findunused", libxl_defbool),
])

libxl_spice_info = Struct("spice_info", [
- ("enable", bool),
+ ("enable", libxl_defbool),
# At least one of spice port or spicetls_post must be given
("port", integer),
("tls_port", integer),
# Interface to bind to
("host", string),
# enable client connection with no password
- ("disable_ticketing", bool),
+ ("disable_ticketing", libxl_defbool),
("passwd", string),
- ("agent_mouse", bool),
+ ("agent_mouse", libxl_defbool),
])

libxl_sdl_info = Struct("sdl_info", [.
- ("enable", bool),
- ("opengl", bool),
+ ("enable", libxl_defbool),
+ ("opengl", libxl_defbool),
("display", string),
("xauthority", string),
])
@@ -148,31 +168,31 @@
("shutdown", bool),
("dying", bool),

- # Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying).
+ # Valid 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),
+ # LIBXL_SHUTDOWN_REASON_* constant.
+ ("shutdown_reason", libxl_shutdown_reason),
+ ("current_memkb", MemKB),
+ ("shared_memkb", MemKB),
+ ("max_memkb", MemKB),
("cpu_time", uint64),
("vcpu_max_id", uint32),
("vcpu_online", uint32),
("cpupool", uint32),
- ], dispose_fn=None)
+ ], dir=DIR_OUT)

libxl_cpupoolinfo = Struct("cpupoolinfo", [.
("poolid", uint32),
- ("sched_id", uint32),
+ ("sched", libxl_scheduler),
("n_dom", uint32),
("cpumap", libxl_cpumap)
- ])
+ ], dir=DIR_OUT)

libxl_vminfo = Struct("vminfo", [
("uuid", libxl_uuid),
("domid", libxl_domid),
- ], dispose_fn=None)
+ ], dir=DIR_OUT)

libxl_version_info = Struct("version_info", [.
("xen_version_major", integer),
@@ -187,19 +207,21 @@
("virt_start", uint64),
("pagesize", integer),
("commandline", string),
- ])
+ ], dir=DIR_OUT)

libxl_domain_create_info = Struct("domain_create_info",[.
("type", libxl_domain_type),
- ("hap", bool),
- ("oos", bool),
+ ("hap", libxl_defbool),
+ ("oos", libxl_defbool),
("ssidref", uint32),
("name", string),
("uuid", libxl_uuid),
("xsdata", libxl_key_value_list),
("platformdata", libxl_key_value_list),
("poolid", uint32),
- ])
+ ], dir=DIR_IN)
+
+MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")

# Instances of libxl_file_reference contained in this struct which
# have been mapped (with libxl_file_reference_map) will be unmapped
@@ -211,17 +233,16 @@
("cur_vcpus", integer),
("cpumap", libxl_cpumap),
("tsc_mode", libxl_tsc_mode),
- ("max_memkb", uint32),
- ("target_memkb", uint32),
- ("video_memkb", uint32),
- ("shadow_memkb", uint32),
- ("disable_migrate", bool),
+ ("max_memkb", MemKB),
+ ("target_memkb", MemKB),
+ ("video_memkb", MemKB),
+ ("shadow_memkb", MemKB),
+ ("disable_migrate", libxl_defbool),
("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_stubdomain", libxl_defbool),
+ # if you set device_model you must set device_model_version too
("device_model", string),
("device_model_ssidref", uint32),

@@ -233,53 +254,53 @@
("extra_hvm", libxl_string_list),

("u", KeyedUnion(None, libxl_domain_type, "type",
- [.("hvm", Struct(None, [.("firmware", string),
- ("bios", libxl_bios_type),
- ("pae", bool),
- ("apic", bool),
- ("acpi", bool),
- ("acpi_s3", bool),
- ("acpi_s4", bool),
- ("nx", bool),
- ("viridian", bool),
- ("timeoffset", string),
- ("hpet", bool),
- ("vpt_align", bool),
- ("timer_mode", libxl_timer_mode),
- ("nested_hvm", bool),
- ("no_incr_generationid", bool),
- ("nographic", bool),
- ("stdvga", bool),
+ [.("hvm", Struct(None, [.("firmware", string),
+ ("bios", libxl_bios_type),
+ ("pae", libxl_defbool),
+ ("apic", libxl_defbool),
+ ("acpi", libxl_defbool),
+ ("acpi_s3", libxl_defbool),
+ ("acpi_s4", libxl_defbool),
+ ("nx", libxl_defbool),
+ ("viridian", libxl_defbool),
+ ("timeoffset", string),
+ ("hpet", libxl_defbool),
+ ("vpt_align", libxl_defbool),
+ ("timer_mode", libxl_timer_mode),
+ ("nested_hvm", libxl_defbool),
+ ("incr_generationid",libxl_defbool),
+ ("nographic", libxl_defbool),
+ ("stdvga", libxl_defbool),
("vnc", libxl_vnc_info),
# keyboard layout, default is en-us keyboard
("keymap", string),
("sdl", libxl_sdl_info),
("spice", libxl_spice_info),

- ("gfx_passthru", bool),
+ ("gfx_passthru", libxl_defbool),

("serial", string),
("boot", string),
- ("usb", bool),
+ ("usb", libxl_defbool),
# usbdevice:
# - "tablet" for absolute mouse,
# - "mouse" for PS/2 protocol relative mouse
("usbdevice", string),
("soundhw", string),
- ("xen_platform_pci", bool),
+ ("xen_platform_pci", libxl_defbool),
])),
("pv", Struct(None, [.("kernel", libxl_file_reference),
- ("slack_memkb", uint32),
+ ("slack_memkb", MemKB),
("bootloader", string),
("bootloader_args", libxl_string_list),
("cmdline", string),
("ramdisk", libxl_file_reference),
("features", string, {'const': True}),
# Use host's E820 for PCI passthrough.
- ("e820_host", bool),
+ ("e820_host", libxl_defbool),
])),
- ])),
- ],
+ ], keyvar_init_val = "-1")),
+ ], dir=DIR_IN
)

libxl_device_vfb = Struct("device_vfb", [
@@ -296,13 +317,6 @@
("devid", integer),
])

-libxl_device_console = Struct("device_console", [.
- ("backend_domid", libxl_domid),
- ("devid", integer),
- ("consback", libxl_console_backend),
- ("output", string),
- ])
-
libxl_device_disk = Struct("device_disk", [.
("backend_domid", libxl_domid),
("pdev_path", string),
@@ -348,7 +362,7 @@
("state", integer),
("evtch", integer),
("rref", integer),
- ])
+ ], dir=DIR_OUT)

libxl_nicinfo = Struct("nicinfo", [.
("backend", string),
@@ -360,7 +374,7 @@
("evtch", integer),
("rref_tx", integer),
("rref_rx", integer),
- ])
+ ], dir=DIR_OUT)

libxl_vcpuinfo = Struct("vcpuinfo", [.
("vcpuid", uint32),
@@ -370,7 +384,7 @@
("running", bool),
("vcpu_time", uint64), # total vcpu time ran (ns)
("cpumap", libxl_cpumap), # current cpu's affinities
- ])
+ ], dir=DIR_OUT)

libxl_physinfo = Struct("physinfo", [.
("threads_per_core", uint32),
@@ -388,23 +402,25 @@

("nr_nodes", uint32),
("hw_cap", libxl_hwcap),
- ("phys_cap", uint32),
- ], dispose_fn=None, dir=DIR_OUT)
+
+ ("cap_hvm", bool),
+ ("cap_hvm_directio", bool),
+ ], dir=DIR_OUT)

libxl_cputopology = Struct("cputopology", [
("core", uint32),
("socket", uint32),
("node", uint32),
- ])
+ ], dir=DIR_OUT)

libxl_sched_credit_domain = Struct("sched_credit_domain", [
("weight", integer),
("cap", integer),
- ], dispose_fn=None)
+ ])

libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
("weight", integer),
- ], dispose_fn=None)
+ ])

libxl_sched_sedf_domain = Struct("sched_sedf_domain", [.
("period", integer),
@@ -412,7 +428,7 @@
("latency", integer),
("extratime", integer),
("weight", integer),
- ], dispose_fn=None)
+ ])

libxl_event_type = Enumeration("event_type", [.
(1, "DOMAIN_SHUTDOWN"),
@@ -432,7 +448,6 @@
("domid", libxl_domid),
("domuuid", libxl_uuid),
("for_user", libxl_ev_user),
- ("type", libxl_event_type),
("u", KeyedUnion(None, libxl_event_type, "type",
[.("domain_shutdown", Struct(None, [.
("shutdown_reason", uint8),
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_types_internal.idl
--- a/tools/libxl/libxl_types_internal.idl Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_types_internal.idl Thu Mar 01 12:31:15 2012 +0000
@@ -1,5 +1,7 @@
namespace("libxl__")

+libxl_domid = Builtin("domid", namespace="libxl_", json_fn = "yajl_gen_integer")
+
libxl__qmp_message_type = Enumeration("qmp_message_type", [.
(1, "QMP"),
(2, "return"),
@@ -17,3 +19,15 @@
(6, "VKBD"),
(7, "CONSOLE"),
])
+
+libxl__console_backend = Enumeration("console_backend", [
+ (1, "XENCONSOLED"),
+ (2, "IOEMU"),
+ ])
+
+libxl__device_console = Struct("device_console", [.
+ ("backend_domid", libxl_domid),
+ ("devid", integer),
+ ("consback", libxl__console_backend),
+ ("output", string),
+ ])
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_utils.c Thu Mar 01 12:31:15 2012 +0000
@@ -19,18 +19,6 @@

#include "libxl_internal.h"

-struct schedid_name {
- char *name;
- int id;
-};
-
-static struct schedid_name schedid_name[] = {
- { "credit", XEN_SCHEDULER_CREDIT },
- { "sedf", XEN_SCHEDULER_SEDF },
- { "credit2", XEN_SCHEDULER_CREDIT2 },
- { NULL, -1 }
-};
-
const char *libxl_basename(const char *name)
{
const char *filename;
@@ -151,28 +139,6 @@
return ret;
}

-int libxl_name_to_schedid(libxl_ctx *ctx, const char *name)
-{
- int i;
-
- for (i = 0; schedid_name[i].name != NULL; i++)
- if (strcmp(name, schedid_name[i].name) == 0)
- return schedid_name[i].id;
-
- return ERROR_INVAL;
-}
-
-char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid)
-{
- int i;
-
- for (i = 0; schedid_name[i].name != NULL; i++)
- if (schedid_name[i].id == schedid)
- return schedid_name[i].name;
-
- return "unknown";
-}
-
int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid)
{
GC_INIT(ctx);
@@ -541,6 +507,29 @@
free(list);
}

+void libxl_dominfo_list_free(libxl_dominfo *list, int nr)
+{
+ int i;
+ for (i = 0; i < nr; i++)
+ libxl_dominfo_dispose(&list[i]);
+ free(list);
+}
+
+void libxl_vminfo_list_free(libxl_vminfo *list, int nr)
+{
+ int i;
+ for (i = 0; i < nr; i++)
+ libxl_vminfo_dispose(&list[i]);
+ free(list);
+}
+
+int libxl_domid_valid_guest(uint32_t domid)
+{
+ /* returns 1 if the value _could_ be a valid guest domid, 0 otherwise
+ * does not check whether the domain actually exists */
+ return domid > 0 && domid < DOMID_FIRST_RESERVED;
+}
+
/*
* Local variables:
* mode: C
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxl_utils.h Thu Mar 01 12:31:15 2012 +0000
@@ -24,8 +24,6 @@
char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, uint32_t *poolid);
char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid);
-int libxl_name_to_schedid(libxl_ctx *ctx, const char *name);
-char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid);
int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid);
int libxl_is_stubdom(libxl_ctx *ctx, uint32_t domid, uint32_t *target_domid);
int libxl_create_logfile(libxl_ctx *ctx, char *name, char **full_name);
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxlu_cfg.c
--- a/tools/libxl/libxlu_cfg.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxlu_cfg.c Thu Mar 01 12:31:15 2012 +0000
@@ -237,6 +237,17 @@
return 0;
}

+int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, libxl_defbool *b,
+ int dont_warn)
+{
+ int ret;
+ long l;
+
+ ret = xlu_cfg_get_long(cfg, n, &l, dont_warn);
+ if (ret) return ret;
+ libxl_defbool_set(b, !!l);
+ return 0;
+}

int xlu_cfg_get_list(const XLU_Config *cfg, const char *n,
XLU_ConfigList **list_r, int *entries_r, int dont_warn) {
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/libxlutil.h
--- a/tools/libxl/libxlutil.h Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/libxlutil.h Thu Mar 01 12:31:15 2012 +0000
@@ -52,6 +52,8 @@
char **value_r, int dont_warn);
int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r,
int dont_warn);
+int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b,
+ int dont_warn);

int xlu_cfg_get_list(const XLU_Config*, const char *n,
XLU_ConfigList **list_r /* may be 0 */,
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c Thu Mar 01 12:31:15 2012 +0000
@@ -144,7 +144,6 @@
static int domain_qualifier_to_domid(const char *p, uint32_t *domid_r,
int *was_name_r)
{
- libxl_dominfo dominfo;
int was_name, rc;

was_name = qualifier_to_id(p, domid_r);
@@ -156,7 +155,7 @@
if (rc)
return rc;
} else {
- rc = libxl_domain_info(ctx, &dominfo, *domid_r);
+ rc = libxl_domain_info(ctx, NULL, *domid_r);
/* error only if domain does not exist */
if (rc == ERROR_INVAL)
return rc;
@@ -383,7 +382,7 @@
{
int e;

- libxl_device_disk_init(ctx, disk);
+ libxl_device_disk_init(disk);

if (!*config) {
*config = xlu_cfg_init(stderr, "command line");
@@ -536,8 +535,7 @@
exit(1);
}

- if (libxl_init_create_info(ctx, c_info))
- exit(1);
+ libxl_domain_create_info_init(c_info);

if (!xlu_cfg_get_string (config, "seclabel", &buf, 0)) {
e = libxl_flask_context_to_sid(ctx, (char *)buf, strlen(buf),
@@ -557,8 +555,7 @@
!strncmp(buf, "hvm", strlen(buf)))
c_info->type = LIBXL_DOMAIN_TYPE_HVM;

- if (!xlu_cfg_get_long (config, "hap", &l, 0))
- c_info->hap = l;
+ xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);

if (xlu_cfg_replace_string (config, "name", &c_info->name, 0)) {
fprintf(stderr, "Domain name must be specified.\n");
@@ -574,8 +571,7 @@
libxl_uuid_generate(&c_info->uuid);
}

- if (!xlu_cfg_get_long(config, "oos", &l, 0))
- c_info->oos = l;
+ xlu_cfg_get_defbool(config, "oos", &c_info->oos, 0);

if (!xlu_cfg_get_string (config, "pool", &buf, 0)) {
c_info->poolid = -1;
@@ -586,8 +582,8 @@
exit(1);
}

- if (libxl_init_build_info(ctx, b_info, c_info))
- exit(1);
+ libxl_domain_build_info_init(b_info);
+ libxl_domain_build_info_init_type(b_info, c_info->type);

/* the following is the actual config parsing with overriding values in the structures */
if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
@@ -601,6 +597,11 @@
if (!xlu_cfg_get_list (config, "cpus", &cpus, 0, 1)) {
int i, n_cpus = 0;

+ if (libxl_cpumap_alloc(ctx, &b_info->cpumap)) {
+ fprintf(stderr, "Unable to allocate cpumap\n");
+ exit(1);
+ }
+
libxl_cpumap_set_none(&b_info->cpumap);
while ((buf = xlu_cfg_get_listitem(cpus, n_cpus)) != NULL) {
i = atoi(buf);
@@ -615,6 +616,11 @@
else if (!xlu_cfg_get_string (config, "cpus", &buf, 0)) {
char *buf2 = strdup(buf);

+ if (libxl_cpumap_alloc(ctx, &b_info->cpumap)) {
+ fprintf(stderr, "Unable to allocate cpumap\n");
+ exit(1);
+ }
+
libxl_cpumap_set_none(&b_info->cpumap);
if (vcpupin_parse(buf2, &b_info->cpumap))
exit(1);
@@ -666,8 +672,7 @@
: libxl_get_required_shadow_memory(b_info->max_memkb,
b_info->max_vcpus);

- if (!xlu_cfg_get_long (config, "nomigrate", &l, 0))
- b_info->disable_migrate = l;
+ xlu_cfg_get_defbool(config, "nomigrate", &b_info->disable_migrate, 0);

if (!xlu_cfg_get_long(config, "tsc_mode", &l, 1)) {
const char *s = libxl_tsc_mode_to_string(l);
@@ -695,7 +700,7 @@
if (!xlu_cfg_get_long (config, "videoram", &l, 0))
b_info->video_memkb = l * 1024;

- switch(c_info->type) {
+ switch(b_info->type) {
case LIBXL_DOMAIN_TYPE_HVM:
if (!xlu_cfg_get_string (config, "kernel", &buf, 0))
fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. "
@@ -709,24 +714,16 @@
buf);
exit (1);
}
- if (!xlu_cfg_get_long (config, "pae", &l, 0))
- b_info->u.hvm.pae = l;
- if (!xlu_cfg_get_long (config, "apic", &l, 0))
- b_info->u.hvm.apic = l;
- if (!xlu_cfg_get_long (config, "acpi", &l, 0))
- b_info->u.hvm.acpi = l;
- if (!xlu_cfg_get_long (config, "acpi_s3", &l, 0))
- b_info->u.hvm.acpi_s3 = l;
- if (!xlu_cfg_get_long (config, "acpi_s4", &l, 0))
- b_info->u.hvm.acpi_s4 = l;
- if (!xlu_cfg_get_long (config, "nx", &l, 0))
- b_info->u.hvm.nx = l;
- if (!xlu_cfg_get_long (config, "viridian", &l, 0))
- b_info->u.hvm.viridian = l;
- if (!xlu_cfg_get_long (config, "hpet", &l, 0))
- b_info->u.hvm.hpet = l;
- if (!xlu_cfg_get_long (config, "vpt_align", &l, 0))
- b_info->u.hvm.vpt_align = l;
+
+ xlu_cfg_get_defbool(config, "pae", &b_info->u.hvm.pae, 0);
+ xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
+ xlu_cfg_get_defbool(config, "acpi", &b_info->u.hvm.acpi, 0);
+ xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0);
+ xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
+ xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
+ xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
+ xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
+ xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);

if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) {
const char *s = libxl_timer_mode_to_string(l);
@@ -751,8 +748,7 @@
}
}

- if (!xlu_cfg_get_long (config, "nestedhvm", &l, 0))
- b_info->u.hvm.nested_hvm = l;
+ xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0);
break;
case LIBXL_DOMAIN_TYPE_PV:
{
@@ -837,7 +833,7 @@

d_config->vifs = (libxl_device_nic *) realloc(d_config->vifs, sizeof (libxl_device_nic) * (d_config->num_vifs+1));
nic = d_config->vifs + d_config->num_vifs;
- CHK_ERRNO( libxl_device_nic_init(ctx, nic) );
+ libxl_device_nic_init(nic);
nic->devid = d_config->num_vifs;

if (default_vifscript) {
@@ -933,12 +929,12 @@

d_config->vfbs = (libxl_device_vfb *) realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
vfb = d_config->vfbs + d_config->num_vfbs;
- libxl_device_vfb_init(ctx, vfb);
+ libxl_device_vfb_init(vfb);
vfb->devid = d_config->num_vfbs;

d_config->vkbs = (libxl_device_vkb *) realloc(d_config->vkbs, sizeof(libxl_device_vkb) * (d_config->num_vkbs + 1));
vkb = d_config->vkbs + d_config->num_vkbs;
- libxl_device_vkb_init(ctx, vkb);
+ libxl_device_vkb_init(vkb);
vkb->devid = d_config->num_vkbs;

p = strtok(buf2, ",");
@@ -951,7 +947,7 @@
break;
*p2 = '\0';
if (!strcmp(p, "vnc")) {
- vfb->vnc.enable = atoi(p2 + 1);
+ libxl_defbool_set(&vfb->vnc.enable, atoi(p2 + 1));
} else if (!strcmp(p, "vnclisten")) {
free(vfb->vnc.listen);
vfb->vnc.listen = strdup(p2 + 1);
@@ -961,14 +957,14 @@
} else if (!strcmp(p, "vncdisplay")) {
vfb->vnc.display = atoi(p2 + 1);
} else if (!strcmp(p, "vncunused")) {
- vfb->vnc.findunused = atoi(p2 + 1);
+ libxl_defbool_set(&vfb->vnc.findunused, atoi(p2 + 1));
} else if (!strcmp(p, "keymap")) {
free(vfb->keymap);
vfb->keymap = strdup(p2 + 1);
} else if (!strcmp(p, "sdl")) {
- vfb->sdl.enable = atoi(p2 + 1);
+ libxl_defbool_set(&vfb->sdl.enable, atoi(p2 + 1));
} else if (!strcmp(p, "opengl")) {
- vfb->sdl.opengl = atoi(p2 + 1);
+ libxl_defbool_set(&vfb->sdl.opengl, atoi(p2 + 1));
} else if (!strcmp(p, "display")) {
free(vfb->sdl.display);
vfb->sdl.display = strdup(p2 + 1);
@@ -992,19 +988,10 @@

/* To be reworked (automatically enabled) once the auto ballooning
* after guest starts is done (with PCI devices passed in). */
- if (!xlu_cfg_get_long (config, "e820_host", &l, 0)) {
- switch (c_info->type) {
- case LIBXL_DOMAIN_TYPE_HVM:
- fprintf(stderr, "Can't do e820_host in HVM mode!");
- break;
- case LIBXL_DOMAIN_TYPE_PV:
- if (l)
- b_info->u.pv.e820_host = true;
- break;
- default:
- abort();
- }
- }
+ if (c_info->type == LIBXL_DOMAIN_TYPE_PV) {
+ xlu_cfg_get_defbool(config, "e820_host", &b_info->u.pv.e820_host, 0);
+ }
+
if (!xlu_cfg_get_list (config, "pci", &pcis, 0, 0)) {
int i;
d_config->num_pcidevs = 0;
@@ -1014,7 +1001,7 @@

d_config->pcidevs = (libxl_device_pci *) realloc(d_config->pcidevs, sizeof (libxl_device_pci) * (d_config->num_pcidevs + 1));
pcidev = d_config->pcidevs + d_config->num_pcidevs;
- memset(pcidev, 0x00, sizeof(libxl_device_pci));
+ libxl_device_pci_init(pcidev);

pcidev->msitranslate = pci_msitranslate;
pcidev->power_mgmt = pci_power_mgmt;
@@ -1022,7 +1009,7 @@
d_config->num_pcidevs++;
}
if (d_config->num_pcidevs && c_info->type == LIBXL_DOMAIN_TYPE_PV)
- b_info->u.pv.e820_host = true;
+ libxl_defbool_set(&b_info->u.pv.e820_host, true);
}

switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) {
@@ -1139,8 +1126,8 @@
}
} else if (b_info->device_model)
fprintf(stderr, "WARNING: device model override given without specific DM version\n");
- if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0))
- b_info->device_model_stubdomain = l;
+ xlu_cfg_get_defbool (config, "device_model_stubdomain_override",
+ &b_info->device_model_stubdomain, 0);

if (!xlu_cfg_get_string (config, "device_model_stubdomain_seclabel",
&buf, 0)) {
@@ -1177,49 +1164,43 @@
#undef parse_extra_args

if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) {
- if (!xlu_cfg_get_long (config, "stdvga", &l, 0))
- b_info->u.hvm.stdvga = l;
- if (!xlu_cfg_get_long (config, "vnc", &l, 0))
- b_info->u.hvm.vnc.enable = l;
- xlu_cfg_replace_string (config, "vnclisten", &b_info->u.hvm.vnc.listen, 0);
- xlu_cfg_replace_string (config, "vncpasswd", &b_info->u.hvm.vnc.passwd, 0);
+ xlu_cfg_get_defbool(config, "stdvga", &b_info->u.hvm.stdvga, 0);
+ xlu_cfg_get_defbool(config, "vnc", &b_info->u.hvm.vnc.enable, 0);
+ xlu_cfg_replace_string (config, "vnclisten",
+ &b_info->u.hvm.vnc.listen, 0);
+ xlu_cfg_replace_string (config, "vncpasswd",
+ &b_info->u.hvm.vnc.passwd, 0);
if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0))
b_info->u.hvm.vnc.display = l;
- if (!xlu_cfg_get_long (config, "vncunused", &l, 0))
- b_info->u.hvm.vnc.findunused = l;
+ xlu_cfg_get_defbool(config, "vncunused",
+ &b_info->u.hvm.vnc.findunused, 0);
xlu_cfg_replace_string (config, "keymap", &b_info->u.hvm.keymap, 0);
- if (!xlu_cfg_get_long (config, "sdl", &l, 0))
- b_info->u.hvm.sdl.enable = l;
- if (!xlu_cfg_get_long (config, "opengl", &l, 0))
- b_info->u.hvm.sdl.opengl = l;
- if (!xlu_cfg_get_long (config, "spice", &l, 0))
- b_info->u.hvm.spice.enable = l;
+ xlu_cfg_get_defbool(config, "sdl", &b_info->u.hvm.sdl.enable, 0);
+ xlu_cfg_get_defbool(config, "opengl", &b_info->u.hvm.sdl.opengl, 0);
+ xlu_cfg_get_defbool (config, "spice", &b_info->u.hvm.spice.enable, 0);
if (!xlu_cfg_get_long (config, "spiceport", &l, 0))
b_info->u.hvm.spice.port = l;
if (!xlu_cfg_get_long (config, "spicetls_port", &l, 0))
b_info->u.hvm.spice.tls_port = l;
xlu_cfg_replace_string (config, "spicehost",
&b_info->u.hvm.spice.host, 0);
- if (!xlu_cfg_get_long (config, "spicedisable_ticketing", &l, 0))
- b_info->u.hvm.spice.disable_ticketing = l;
+ xlu_cfg_get_defbool(config, "spicedisable_ticketing",
+ &b_info->u.hvm.spice.disable_ticketing, 0);
xlu_cfg_replace_string (config, "spicepasswd",
&b_info->u.hvm.spice.passwd, 0);
- if (!xlu_cfg_get_long (config, "spiceagent_mouse", &l, 0))
- b_info->u.hvm.spice.agent_mouse = l;
- else
- b_info->u.hvm.spice.agent_mouse = 1;
- if (!xlu_cfg_get_long (config, "nographic", &l, 0))
- b_info->u.hvm.nographic = l;
- if (!xlu_cfg_get_long (config, "gfx_passthru", &l, 0))
- b_info->u.hvm.gfx_passthru = l;
+ xlu_cfg_get_defbool(config, "spiceagent_mouse",
+ &b_info->u.hvm.spice.agent_mouse, 0);
+ xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
+ xlu_cfg_get_defbool(config, "gfx_passthru",
+ &b_info->u.hvm.gfx_passthru, 0);
xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
- if (!xlu_cfg_get_long (config, "usb", &l, 0))
- b_info->u.hvm.usb = l;
- xlu_cfg_replace_string (config, "usbdevice", &b_info->u.hvm.usbdevice, 0);
+ xlu_cfg_get_defbool(config, "usb", &b_info->u.hvm.usb, 0);
+ xlu_cfg_replace_string (config, "usbdevice",
+ &b_info->u.hvm.usbdevice, 0);
xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0);
- if (!xlu_cfg_get_long (config, "xen_platform_pci", &l, 0))
- b_info->u.hvm.xen_platform_pci = l;
+ xlu_cfg_get_defbool(config, "xen_platform_pci",
+ &b_info->u.hvm.xen_platform_pci, 0);
}

xlu_cfg_destroy(config);
@@ -1235,19 +1216,19 @@
libxl_action_on_shutdown action;

switch (event->u.domain_shutdown.shutdown_reason) {
- case SHUTDOWN_poweroff:
+ case LIBXL_SHUTDOWN_REASON_POWEROFF:
action = d_config->on_poweroff;
break;
- case SHUTDOWN_reboot:
+ case LIBXL_SHUTDOWN_REASON_REBOOT:
action = d_config->on_reboot;
break;
- case SHUTDOWN_suspend:
+ case LIBXL_SHUTDOWN_REASON_SUSPEND:
LOG("Domain has suspended.");
return 0;
- case SHUTDOWN_crash:
+ case LIBXL_SHUTDOWN_REASON_CRASH:
action = d_config->on_crash;
break;
- case SHUTDOWN_watchdog:
+ case LIBXL_SHUTDOWN_REASON_WATCHDOG:
action = d_config->on_watchdog;
break;
default:
@@ -1371,7 +1352,7 @@
const char *restore_file;
int migrate_fd; /* -1 means none */
char **migration_domname_r; /* from malloc */
- int no_incr_generationid;
+ int incr_generationid;
};

static int freemem(libxl_domain_build_info *b_info)
@@ -1622,8 +1603,8 @@
}

if (d_config.c_info.type == LIBXL_DOMAIN_TYPE_HVM)
- d_config.b_info.u.hvm.no_incr_generationid =
- dom_info->no_incr_generationid;
+ libxl_defbool_set(&d_config.b_info.u.hvm.incr_generationid,
+ dom_info->incr_generationid);

if (debug || dom_info->dryrun)
printf_info(default_output_format, -1, &d_config);
@@ -2505,7 +2486,7 @@
info[i].domid, domname);
free(domname);
}
- free(info);
+ libxl_vminfo_list_free(info, nb_vm);
}

static void save_domain_core_begin(const char *domain_spec,
@@ -2898,7 +2879,7 @@
dom_info.restore_file = "incoming migration stream";
dom_info.migrate_fd = 0; /* stdin */
dom_info.migration_domname_r = &migration_domname;
- dom_info.no_incr_generationid = 1;
+ dom_info.incr_generationid = 0;

rc = create_domain(&dom_info);
if (rc < 0) {
@@ -3023,6 +3004,7 @@
dom_info.restore_file = checkpoint_file;
dom_info.migrate_fd = -1;
dom_info.console_autoconnect = console_autoconnect;
+ dom_info.incr_generationid = 1;

rc = create_domain(&dom_info);
if (rc < 0)
@@ -3302,7 +3284,10 @@
else
list_domains(verbose, context, info, nb_domain);

- free(info_free);
+ if (info_free)
+ libxl_dominfo_list_free(info, nb_domain);
+ else
+ libxl_dominfo_dispose(info);

return 0;
}
@@ -3405,6 +3390,7 @@
dom_info.extra_config = extra_config;
dom_info.migrate_fd = -1;
dom_info.console_autoconnect = console_autoconnect;
+ dom_info.incr_generationid = 0;

rc = create_domain(&dom_info);
if (rc < 0)
@@ -3565,8 +3551,7 @@
for (i = 0; i<nb_domain; i++)
print_domain_vcpuinfo(dominfo[i].domid, physinfo.nr_cpus);

- free(dominfo);
-
+ libxl_dominfo_list_free(dominfo, nb_domain);
} else {
for (; argc > 0; ++argv, --argc) {
if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) {
@@ -3578,7 +3563,7 @@
}
}
vcpulist_out:
- ;
+ libxl_physinfo_dispose(&physinfo);
}

int main_vcpulist(int argc, char **argv)
@@ -3693,15 +3678,15 @@
static void output_xeninfo(void)
{
const libxl_version_info *info;
- int sched_id;
+ libxl_scheduler sched;

if (!(info = libxl_get_version_info(ctx))) {
fprintf(stderr, "libxl_get_version_info failed.\n");
return;
}

- if ((sched_id = libxl_get_sched_id(ctx)) < 0) {
- fprintf(stderr, "get_sched_id sysctl failed.\n");
+ if ((sched = libxl_get_scheduler(ctx)) < 0) {
+ fprintf(stderr, "get_scheduler sysctl failed.\n");
return;
}

@@ -3709,7 +3694,7 @@
printf("xen_minor : %d\n", info->xen_version_minor);
printf("xen_extra : %s\n", info->xen_version_extra);
printf("xen_caps : %s\n", info->capabilities);
- printf("xen_scheduler : %s\n", libxl_schedid_to_name(ctx, sched_id));
+ printf("xen_scheduler : %s\n", libxl_scheduler_to_string(sched));
printf("xen_pagesize : %u\n", info->pagesize);
printf("platform_params : virt_start=0x%"PRIx64"\n", info->virt_start);
printf("xen_changeset : %s\n", info->changeset);
@@ -3757,9 +3742,9 @@
for (i = 0; i < 8; i++)
printf("%08x%c", info.hw_cap[i], i < 7 ? ':' : '\n');
printf("virt_caps :");
- if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm)
+ if (info.cap_hvm)
printf(" hvm");
- if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
+ if (info.cap_hvm_directio)
printf(" hvm_directio");
printf("\n");
vinfo = libxl_get_version_info(ctx);
@@ -3778,6 +3763,7 @@
free(cpumap.map);
}

+ libxl_physinfo_dispose(&info);
return;
}

@@ -3912,7 +3898,9 @@
sharing(info, nb_domain);

if (info_free)
- free(info_free);
+ libxl_dominfo_list_free(info_free, nb_domain);
+ else
+ libxl_dominfo_dispose(info);

return 0;
}
@@ -3934,6 +3922,7 @@
{
int rc;

+
rc = libxl_sched_credit_domain_set(ctx, domid, scinfo);
if (rc)
fprintf(stderr, "libxl_sched_credit_domain_set failed.\n");
@@ -3962,6 +3951,7 @@
scinfo.weight,
scinfo.cap);
free(domname);
+ libxl_sched_credit_domain_dispose(&scinfo);
return 0;
}

@@ -4009,6 +3999,7 @@
domid,
scinfo.weight);
free(domname);
+ libxl_sched_credit2_domain_dispose(&scinfo);
return 0;
}

@@ -4032,7 +4023,6 @@
rc = libxl_sched_sedf_domain_set(ctx, domid, scinfo);
if (rc)
fprintf(stderr, "libxl_sched_sedf_domain_set failed.\n");
-
return rc;
}

@@ -4061,11 +4051,12 @@
scinfo.extratime,
scinfo.weight);
free(domname);
+ libxl_sched_sedf_domain_dispose(&scinfo);
return 0;
}

static int sched_domain_output(
- uint32_t sched, int (*output)(int), const char *cpupool)
+ libxl_scheduler sched, int (*output)(int), const char *cpupool)
{
libxl_dominfo *info;
libxl_cpupoolinfo *poolinfo = NULL;
@@ -4094,7 +4085,7 @@
}

for (p = 0; !rc && (p < n_pools); p++) {
- if ((poolinfo[p].sched_id != sched) ||
+ if ((poolinfo[p].sched != sched) ||
(cpupool && (poolid != poolinfo[p].poolid)))
continue;

@@ -4175,7 +4166,7 @@
}

if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_CREDIT,
+ return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
sched_credit_domain_output, cpupool);
} else {
find_domain(dom);
@@ -4193,6 +4184,7 @@
if (opt_c)
scinfo.cap = cap;
rc = sched_credit_domain_set(domid, &scinfo);
+ libxl_sched_credit_domain_dispose(&scinfo);
if (rc)
return -rc;
}
@@ -4251,7 +4243,7 @@
}

if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_CREDIT2,
+ return -sched_domain_output(LIBXL_SCHEDULER_CREDIT2,
sched_credit2_domain_output, cpupool);
} else {
find_domain(dom);
@@ -4267,6 +4259,7 @@
if (opt_w)
scinfo.weight = weight;
rc = sched_credit2_domain_set(domid, &scinfo);
+ libxl_sched_credit2_domain_dispose(&scinfo);
if (rc)
return -rc;
}
@@ -4353,7 +4346,7 @@
}

if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_SEDF,
+ return -sched_domain_output(LIBXL_SCHEDULER_SEDF,
sched_sedf_domain_output, cpupool);
} else {
find_domain(dom);
@@ -4385,6 +4378,7 @@
scinfo.slice = 0;
}
rc = sched_sedf_domain_set(domid, &scinfo);
+ libxl_sched_sedf_domain_dispose(&scinfo);
if (rc)
return -rc;
}
@@ -4602,7 +4596,7 @@
fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
return 1;
}
- libxl_device_nic_init(ctx, &nic);
+ libxl_device_nic_init(&nic);
for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) {
if (MATCH_OPTION("type", *argv, oparg)) {
if (!strcmp("vif", oparg)) {
@@ -4968,6 +4962,7 @@
info = libxl_list_vm(ctx, &nb_vm);
for (i = 0; i < nb_vm; i++)
print_domU_uptime(info[i].domid, short_mode, now);
+ libxl_vminfo_list_free(info, nb_vm);
} else {
for (i = 0; i < nb_doms; i++) {
if (doms[i] == 0)
@@ -5292,9 +5287,8 @@
XLU_Config *config;
const char *buf;
const char *name;
- const char *sched;
uint32_t poolid;
- int schedid = -1;
+ libxl_scheduler sched = 0;
XLU_ConfigList *cpus;
XLU_ConfigList *nodes;
int n_cpus, n_nodes, i, n;
@@ -5389,17 +5383,16 @@
}

if (!xlu_cfg_get_string (config, "sched", &buf, 0)) {
- if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) {
+ if ((libxl_scheduler_from_string(buf, &sched)) < 0) {
fprintf(stderr, "Unknown scheduler\n");
return -ERROR_FAIL;
}
} else {
- if ((schedid = libxl_get_sched_id(ctx)) < 0) {
- fprintf(stderr, "get_sched_id sysctl failed.\n");
+ if ((sched = libxl_get_scheduler(ctx)) < 0) {
+ fprintf(stderr, "get_scheduler sysctl failed.\n");
return -ERROR_FAIL;
}
}
- sched = libxl_schedid_to_name(ctx, schedid);

if (libxl_get_freecpus(ctx, &freemap)) {
fprintf(stderr, "libxl_get_freecpus failed\n");
@@ -5467,14 +5460,14 @@

printf("Using config file \"%s\"\n", filename);
printf("cpupool name: %s\n", name);
- printf("scheduler: %s\n", sched);
+ printf("scheduler: %s\n", libxl_scheduler_to_string(sched));
printf("number of cpus: %d\n", n_cpus);

if (dryrun_only)
return 0;

poolid = 0;
- if (libxl_cpupool_create(ctx, name, schedid, cpumap, &uuid, &poolid)) {
+ if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid)) {
fprintf(stderr, "error on creating cpupool\n");
return -ERROR_FAIL;
}
@@ -5559,7 +5552,7 @@
}
if (!opt_cpus) {
printf("%3d %9s y %4d", n,
- libxl_schedid_to_name(ctx, poolinfo[p].sched_id),
+ libxl_scheduler_to_string(poolinfo[p].sched),
poolinfo[p].n_dom);
}
printf("\n");
@@ -5744,7 +5737,7 @@
int c;
int n;
uint32_t poolid;
- int schedid;
+ libxl_scheduler sched;
int n_pools;
int node;
int n_cpus;
@@ -5765,7 +5758,7 @@
return -ERROR_NOMEM;
}
poolid = poolinfo[0].poolid;
- schedid = poolinfo[0].sched_id;
+ sched = poolinfo[0].sched;
for (p = 0; p < n_pools; p++) {
libxl_cpupoolinfo_dispose(poolinfo + p);
}
@@ -5845,7 +5838,7 @@
snprintf(name, 15, "Pool-node%d", node);
libxl_uuid_generate(&uuid);
poolid = 0;
- ret = -libxl_cpupool_create(ctx, name, schedid, cpumap, &uuid, &poolid);
+ ret = -libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid);
if (ret) {
fprintf(stderr, "error on creating cpupool\n");
goto out;
diff -r d7fe4cd831a0 -r d64aa013a82e tools/libxl/xl_sxp.c
--- a/tools/libxl/xl_sxp.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/libxl/xl_sxp.c Thu Mar 01 12:31:15 2012 +0000
@@ -21,6 +21,7 @@
#include "libxl_osdeps.h"

#include <stdlib.h>
+#include <inttypes.h>

#include "libxl.h"
#include "libxl_utils.h"
@@ -40,8 +41,8 @@
printf("(domain\n\t(domid %d)\n", domid);
printf("\t(create_info)\n");
printf("\t(hvm %d)\n", c_info->type == LIBXL_DOMAIN_TYPE_HVM);
- printf("\t(hap %d)\n", c_info->hap);
- printf("\t(oos %d)\n", c_info->oos);
+ printf("\t(hap %s)\n", libxl_defbool_to_string(c_info->hap));
+ printf("\t(oos %s)\n", libxl_defbool_to_string(c_info->oos));
printf("\t(ssidref %d)\n", c_info->ssidref);
printf("\t(name %s)\n", c_info->name);

@@ -68,9 +69,10 @@
printf("\t(build_info)\n");
printf("\t(max_vcpus %d)\n", b_info->max_vcpus);
printf("\t(tsc_mode %s)\n", libxl_tsc_mode_to_string(b_info->tsc_mode));
- printf("\t(max_memkb %d)\n", b_info->max_memkb);
- printf("\t(target_memkb %d)\n", b_info->target_memkb);
- printf("\t(nomigrate %d)\n", b_info->disable_migrate);
+ printf("\t(max_memkb %"PRId64")\n", b_info->max_memkb);
+ printf("\t(target_memkb %"PRId64")\n", b_info->target_memkb);
+ printf("\t(nomigrate %s)\n",
+ libxl_defbool_to_string(b_info->disable_migrate));

if (c_info->type == LIBXL_DOMAIN_TYPE_PV && b_info->u.pv.bootloader) {
int i;
@@ -88,43 +90,57 @@
case LIBXL_DOMAIN_TYPE_HVM:
printf("\t\t(hvm\n");
printf("\t\t\t(firmware %s)\n", b_info->u.hvm.firmware);
- printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb);
- printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb);
- printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae);
- printf("\t\t\t(apic %d)\n", b_info->u.hvm.apic);
- printf("\t\t\t(acpi %d)\n", b_info->u.hvm.acpi);
- printf("\t\t\t(nx %d)\n", b_info->u.hvm.nx);
- printf("\t\t\t(viridian %d)\n", b_info->u.hvm.viridian);
- printf("\t\t\t(hpet %d)\n", b_info->u.hvm.hpet);
- printf("\t\t\t(vpt_align %d)\n", b_info->u.hvm.vpt_align);
+ printf("\t\t\t(video_memkb %"PRId64")\n", b_info->video_memkb);
+ printf("\t\t\t(shadow_memkb %"PRId64")\n", b_info->shadow_memkb);
+ printf("\t\t\t(pae %s)\n", libxl_defbool_to_string(b_info->u.hvm.pae));
+ printf("\t\t\t(apic %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.apic));
+ printf("\t\t\t(acpi %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.acpi));
+ printf("\t\t\t(nx %s)\n", libxl_defbool_to_string(b_info->u.hvm.nx));
+ printf("\t\t\t(viridian %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.viridian));
+ printf("\t\t\t(hpet %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.hpet));
+ printf("\t\t\t(vpt_align %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.vpt_align));
printf("\t\t\t(timer_mode %s)\n",
libxl_timer_mode_to_string(b_info->u.hvm.timer_mode));
- printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm);
- 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(nestedhvm %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.nested_hvm));
+ printf("\t\t\t(no_incr_generationid %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.incr_generationid));
+ printf("\t\t\t(stdvga %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.stdvga));
+ printf("\t\t\t(vnc %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.vnc.enable));
printf("\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen);
printf("\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display);
- printf("\t\t\t(vncunused %d)\n", b_info->u.hvm.vnc.findunused);
+ printf("\t\t\t(vncunused %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.vnc.findunused));
printf("\t\t\t(keymap %s)\n", b_info->u.hvm.keymap);
- printf("\t\t\t(sdl %d)\n", b_info->u.hvm.sdl.enable);
- printf("\t\t\t(opengl %d)\n", b_info->u.hvm.sdl.opengl);
- printf("\t\t\t(nographic %d)\n", b_info->u.hvm.nographic);
- printf("\t\t\t(spice %d)\n", b_info->u.hvm.spice.enable);
+ printf("\t\t\t(sdl %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.sdl.enable));
+ printf("\t\t\t(opengl %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.sdl.opengl));
+ printf("\t\t\t(nographic %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.nographic));
+ printf("\t\t\t(spice %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.spice.enable));
printf("\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port);
printf("\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port);
printf("\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host);
- printf("\t\t\t(spicedisable_ticketing %d)\n",
- b_info->u.hvm.spice.disable_ticketing);
- printf("\t\t\t(spiceagent_mouse %d)\n", b_info->u.hvm.spice.agent_mouse);
+ printf("\t\t\t(spicedisable_ticketing %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.spice.disable_ticketing));
+ printf("\t\t\t(spiceagent_mouse %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.spice.agent_mouse));

printf("\t\t\t(device_model %s)\n", b_info->device_model ? : "default");
- printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
+ printf("\t\t\t(gfx_passthru %s)\n",
+ libxl_defbool_to_string(b_info->u.hvm.gfx_passthru));
printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
- printf("\t\t\t(usb %d)\n", b_info->u.hvm.usb);
+ printf("\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb));
printf("\t\t\t(usbdevice %s)\n", b_info->u.hvm.usbdevice);
printf("\t\t)\n");
break;
@@ -133,7 +149,8 @@
printf("\t\t\t(kernel %s)\n", b_info->u.pv.kernel.path);
printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline);
printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path);
- printf("\t\t\t(e820_host %d)\n", b_info->u.pv.e820_host);
+ printf("\t\t\t(e820_host %s)\n",
+ libxl_defbool_to_string(b_info->u.pv.e820_host));
printf("\t\t)\n");
break;
default:
@@ -195,13 +212,17 @@
printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid);
printf("\t\t\t(frontend_domid %d)\n", domid);
printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid);
- printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable);
+ printf("\t\t\t(vnc %s)\n",
+ libxl_defbool_to_string(d_config->vfbs[i].vnc.enable));
printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen);
printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display);
- printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused);
+ printf("\t\t\t(vncunused %s)\n",
+ libxl_defbool_to_string(d_config->vfbs[i].vnc.findunused));
printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap);
- printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl.enable);
- printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].sdl.opengl);
+ printf("\t\t\t(sdl %s)\n",
+ libxl_defbool_to_string(d_config->vfbs[i].sdl.enable));
+ printf("\t\t\t(opengl %s)\n",
+ libxl_defbool_to_string(d_config->vfbs[i].sdl.opengl));
printf("\t\t\t(display %s)\n", d_config->vfbs[i].sdl.display);
printf("\t\t\t(xauthority %s)\n", d_config->vfbs[i].sdl.xauthority);
printf("\t\t)\n");
diff -r d7fe4cd831a0 -r d64aa013a82e tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py Thu Mar 01 12:31:15 2012 +0000
@@ -10,6 +10,7 @@
"int": ("int", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
"char *": ("string", "%(c)s = dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"),
"libxl_domid": ("domid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "libxl_defbool": ("bool option", "%(c)s = Defbool_val(%(o)s)", "Val_defbool(%(c)s)" ),
"libxl_uuid": ("int array", "Uuid_val(gc, lg, &%(c)s, %(o)s)", "Val_uuid(&%(c)s)"),
"libxl_key_value_list": ("(string * string) list", None, None),
"libxl_mac": ("int array", "Mac_val(gc, lg, &%(c)s, %(o)s)", "Val_mac(&%(c)s)"),
diff -r d7fe4cd831a0 -r d64aa013a82e tools/ocaml/libs/xl/xenlight_stubs.c
--- a/tools/ocaml/libs/xl/xenlight_stubs.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c Thu Mar 01 12:31:15 2012 +0000
@@ -195,6 +195,33 @@
CAMLreturn(0);
}

+static value Val_defbool(libxl_defbool c_val)
+{
+ CAMLparam0();
+ CAMLlocal1(v);
+
+ if (libxl_defbool_is_default(c_val))
+ v = Val_none;
+ else {
+ bool b = libxl_defbool_val(c_val);
+ v = Val_some(b ? Val_bool(true) : Val_bool(false));
+ }
+ CAMLreturn(v);
+}
+
+static libxl_defbool Defbool_val(value v)
+{
+ CAMLparam1(v);
+ libxl_defbool db;
+ if (v == Val_none)
+ libxl_defbool_unset(&db);
+ else {
+ bool b = Bool_val(Some_val(v));
+ libxl_defbool_set(&db, b);
+ }
+ return db;
+}
+
static value Val_hwcap(libxl_hwcap *c_val)
{
CAMLparam0();
diff -r d7fe4cd831a0 -r d64aa013a82e tools/python/genwrap.py
--- a/tools/python/genwrap.py Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/python/genwrap.py Thu Mar 01 12:31:15 2012 +0000
@@ -4,11 +4,13 @@

import idl

-(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5)
+(TYPE_DEFBOOL, TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(6)

def py_type(ty):
if ty == idl.bool:
return TYPE_BOOL
+ if ty.typename == "libxl_defbool":
+ return TYPE_DEFBOOL
if isinstance(ty, idl.Enumeration):
return TYPE_UINT
if isinstance(ty, idl.Number):
@@ -44,6 +46,8 @@
for f in ty.fields:
if py_type(f.type) is not None:
continue
+ if py_type(f.type) == TYPE_DEFBOOL:
+ continue
if ty.marshal_out():
l.append('_hidden PyObject *attrib__%s_get(%s *%s);'%(\
fsanitize(f.type.typename), f.type.typename, f.name))
@@ -62,6 +66,8 @@
l.append(' ret = (self->obj.%s) ? Py_True : Py_False;'%f.name)
l.append(' Py_INCREF(ret);')
l.append(' return ret;')
+ elif t == TYPE_DEFBOOL:
+ l.append(' return genwrap__defbool_get(&self->obj.%s);'%f.name)
elif t == TYPE_INT:
l.append(' return genwrap__ll_get(self->obj.%s);'%f.name)
elif t == TYPE_UINT:
@@ -85,6 +91,8 @@
if t == TYPE_BOOL:
l.append(' self->obj.%s = (NULL == v || Py_None == v || Py_False == v) ? 0 : 1;'%f.name)
l.append(' return 0;')
+ elif t == TYPE_DEFBOOL:
+ l.append(' return genwrap__defbool_set(v, &self->obj.%s);'%f.name)
elif t == TYPE_UINT or t == TYPE_INT:
l.append(' %slong long tmp;'%(t == TYPE_UINT and 'unsigned ' or ''))
l.append(' int ret;')
@@ -275,6 +283,8 @@
_hidden int genwrap__ull_set(PyObject *v, unsigned long long *val, unsigned long long mask);
_hidden PyObject *genwrap__ll_get(long long val);
_hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask);
+_hidden PyObject *genwrap__defbool_get(libxl_defbool *db);
+_hidden int genwrap__defbool_set(PyObject *v, libxl_defbool *db);

""" % " ".join(sys.argv))
for ty in [ty for ty in types if isinstance(ty, idl.Aggregate)]:
diff -r d7fe4cd831a0 -r d64aa013a82e tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Feb 29 17:01:41 2012 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c Thu Mar 01 12:31:15 2012 +0000
@@ -156,6 +156,21 @@
return 0;
}

+PyObject *genwrap__defbool_get(libxl_defbool *db)
+{
+ PyObject *ret;
+ ret = libxl_defbool_val(*db) ? Py_True : Py_False;
+ Py_INCREF(ret);
+ return ret;
+}
+
+int genwrap__defbool_set(PyObject *v, libxl_defbool *db)
+{
+ bool val = !(NULL == v || Py_None == v || Py_False == v);
+ libxl_defbool_set(db, val);
+ return 0;
+}
+
static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len)
{
char *tmp;
@@ -762,11 +777,11 @@
Py_INCREF(xl_error_obj);
PyModule_AddObject(m, "Error", xl_error_obj);

- _INT_CONST(m, SHUTDOWN_poweroff);
- _INT_CONST(m, SHUTDOWN_reboot);
- _INT_CONST(m, SHUTDOWN_suspend);
- _INT_CONST(m, SHUTDOWN_crash);
- _INT_CONST(m, SHUTDOWN_watchdog);
+ _INT_CONST_LIBXL(m, SHUTDOWN_REASON_POWEROFF);
+ _INT_CONST_LIBXL(m, SHUTDOWN_REASON_REBOOT);
+ _INT_CONST_LIBXL(m, SHUTDOWN_REASON_SUSPEND);
+ _INT_CONST_LIBXL(m, SHUTDOWN_REASON_CRASH);
+ _INT_CONST_LIBXL(m, SHUTDOWN_REASON_WATCHDOG);

genwrap__init(m);
}

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog


patchbot at xen

Mar 2, 2012, 8:33 PM

Post #2 of 6 (89 views)
Permalink
[xen-unstable] Merge [In reply to]

# HG changeset patch
# User Ian Jackson <Ian.Jackson [at] eu>
# Date 1330620516 0
# Node ID 08392a9cde1e858644ecce6a4ee0dea0dd4a5968
# Parent 01d95561350bd249fa0fe67741b3eacea66ee153
# Parent 3ea51ace058283c2db577d85d05fd680e321f84d
Merge
---


diff -r 01d95561350b -r 08392a9cde1e .hgignore
--- a/.hgignore Thu Mar 01 16:41:56 2012 +0000
+++ b/.hgignore Thu Mar 01 16:48:36 2012 +0000
@@ -202,6 +202,7 @@
^tools/misc/xenperf$
^tools/misc/xenpm$
^tools/misc/xen-hvmctx$
+^tools/misc/xen-lowmemd$
^tools/misc/gtraceview$
^tools/misc/gtracestat$
^tools/misc/xenlockprof$
diff -r 01d95561350b -r 08392a9cde1e tools/libxc/xc_cpufeature.h
--- a/tools/libxc/xc_cpufeature.h Thu Mar 01 16:41:56 2012 +0000
+++ b/tools/libxc/xc_cpufeature.h Thu Mar 01 16:48:36 2012 +0000
@@ -129,10 +129,12 @@
/* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */
#define X86_FEATURE_FSGSBASE 0 /* {RD,WR}{FS,GS}BASE instructions */
#define X86_FEATURE_BMI1 3 /* 1st group bit manipulation extensions */
+#define X86_FEATURE_HLE 4 /* Hardware Lock Elision */
#define X86_FEATURE_AVX2 5 /* AVX2 instructions */
#define X86_FEATURE_SMEP 7 /* Supervisor Mode Execution Protection */
#define X86_FEATURE_BMI2 8 /* 2nd group bit manipulation extensions */
#define X86_FEATURE_ERMS 9 /* Enhanced REP MOVSB/STOSB */
#define X86_FEATURE_INVPCID 10 /* Invalidate Process Context ID */
+#define X86_FEATURE_RTM 11 /* Restricted Transactional Memory */

#endif /* __LIBXC_CPUFEATURE_H */
diff -r 01d95561350b -r 08392a9cde1e tools/libxc/xc_cpuid_x86.c
--- a/tools/libxc/xc_cpuid_x86.c Thu Mar 01 16:41:56 2012 +0000
+++ b/tools/libxc/xc_cpuid_x86.c Thu Mar 01 16:48:36 2012 +0000
@@ -363,11 +363,13 @@
case 0x00000007: /* Intel-defined CPU features */
if ( input[1] == 0 ) {
regs[1] &= (bitmaskof(X86_FEATURE_BMI1) |
+ bitmaskof(X86_FEATURE_HLE) |
bitmaskof(X86_FEATURE_AVX2) |
bitmaskof(X86_FEATURE_SMEP) |
bitmaskof(X86_FEATURE_BMI2) |
bitmaskof(X86_FEATURE_ERMS) |
bitmaskof(X86_FEATURE_INVPCID) |
+ bitmaskof(X86_FEATURE_RTM) |
bitmaskof(X86_FEATURE_FSGSBASE));
} else
regs[1] = 0;
@@ -496,9 +498,11 @@
case 0x00000007:
if ( input[1] == 0 )
regs[1] &= (bitmaskof(X86_FEATURE_BMI1) |
+ bitmaskof(X86_FEATURE_HLE) |
bitmaskof(X86_FEATURE_AVX2) |
bitmaskof(X86_FEATURE_BMI2) |
bitmaskof(X86_FEATURE_ERMS) |
+ bitmaskof(X86_FEATURE_RTM) |
bitmaskof(X86_FEATURE_FSGSBASE));
else
regs[1] = 0;
diff -r 01d95561350b -r 08392a9cde1e tools/misc/Makefile
--- a/tools/misc/Makefile Thu Mar 01 16:41:56 2012 +0000
+++ b/tools/misc/Makefile Thu Mar 01 16:48:36 2012 +0000
@@ -5,11 +5,12 @@

CFLAGS += $(CFLAGS_libxenctrl)
CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS += $(CFLAGS_libxenstore)

HDRS = $(wildcard *.h)

TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash xen-lowmemd
TARGETS-$(CONFIG_MIGRATE) += xen-hptool
TARGETS := $(TARGETS-y)

@@ -21,7 +22,7 @@
INSTALL_BIN-$(CONFIG_X86) += xen-detect
INSTALL_BIN := $(INSTALL_BIN-y)

-INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xen-ringwatch
+INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xen-ringwatch xen-lowmemd
INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvmcrash
INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
INSTALL_SBIN := $(INSTALL_SBIN-y)
@@ -70,6 +71,9 @@
xenwatchdogd: xenwatchdogd.o
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)

+xen-lowmemd: xen-lowmemd.o
+ $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
+
gtraceview: gtraceview.o
$(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(APPEND_LDFLAGS)

diff -r 01d95561350b -r 08392a9cde1e tools/misc/xen-lowmemd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/misc/xen-lowmemd.c Thu Mar 01 16:48:36 2012 +0000
@@ -0,0 +1,148 @@
+/*
+ * xen-lowmemd: demo VIRQ_ENOMEM
+ * Andres Lagar-Cavilla (GridCentric Inc.)
+ */
+
+#include <stdio.h>
+#include <xenctrl.h>
+#include <xs.h>
+#include <stdlib.h>
+#include <string.h>
+
+static evtchn_port_t virq_port = -1;
+static xc_evtchn *xce_handle = NULL;
+static xc_interface *xch = NULL;
+static struct xs_handle *xs_handle = NULL;
+
+void cleanup(void)
+{
+ if (virq_port > -1)
+ xc_evtchn_unbind(xce_handle, virq_port);
+ if (xce_handle)
+ xc_evtchn_close(xce_handle);
+ if (xch)
+ xc_interface_close(xch);
+ if (xs_handle)
+ xs_daemon_close(xs_handle);
+}
+
+/* Never shrink dom0 below 1 GiB */
+#define DOM0_FLOOR (1 << 30)
+#define DOM0_FLOOR_PG ((DOM0_FLOOR) >> 12)
+
+/* Act if free memory is less than 92 MiB */
+#define THRESHOLD (92 << 20)
+#define THRESHOLD_PG ((THRESHOLD) >> 12)
+
+#define BUFSZ 512
+void handle_low_mem(void)
+{
+ xc_dominfo_t dom0_info;
+ xc_physinfo_t info;
+ unsigned long long free_pages, dom0_pages, diff, dom0_target;
+ char data[BUFSZ], error[BUFSZ];
+
+ if (xc_physinfo(xch, &info) < 0)
+ {
+ perror("Getting physinfo failed");
+ return;
+ }
+
+ free_pages = (unsigned long long) info.free_pages;
+ printf("Available free pages: 0x%llx:%llux\n",
+ free_pages, free_pages);
+
+ /* Don't do anything if we have more than the threshold free */
+ if ( free_pages >= THRESHOLD_PG )
+ return;
+ diff = THRESHOLD_PG - free_pages;
+
+ if (xc_domain_getinfo(xch, 0, 1, &dom0_info) < 1)
+ {
+ perror("Failed to get dom0 info");
+ return;
+ }
+
+ dom0_pages = (unsigned long long) dom0_info.nr_pages;
+ printf("Dom0 pages: 0x%llx:%llu\n", dom0_pages, dom0_pages);
+ dom0_target = dom0_pages - diff;
+ if (dom0_target <= DOM0_FLOOR_PG)
+ return;
+
+ printf("Shooting for dom0 target 0x%llx:%llu\n",
+ dom0_target, dom0_target);
+
+ snprintf(data, BUFSZ, "%llu", dom0_target);
+ if (!xs_write(xs_handle, XBT_NULL,
+ "/local/domain/0/memory/target", data, strlen(data)))
+ {
+ snprintf(error, BUFSZ,"Failed to write target %s to xenstore", data);
+ perror(error);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int rc;
+
+ atexit(cleanup);
+
+ xch = xc_interface_open(NULL, NULL, 0);
+ if (xch == NULL)
+ {
+ perror("Failed to open xc interface");
+ return 1;
+ }
+
+ xce_handle = xc_evtchn_open(NULL, 0);
+ if (xce_handle == NULL)
+ {
+ perror("Failed to open evtchn device");
+ return 2;
+ }
+
+ xs_handle = xs_daemon_open();
+ if (xs_handle == NULL)
+ {
+ perror("Failed to open xenstore connection");
+ return 3;
+ }
+
+ if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_ENOMEM)) == -1)
+ {
+ perror("Failed to bind to domain exception virq port");
+ return 4;
+ }
+
+ virq_port = rc;
+
+ while(1)
+ {
+ evtchn_port_t port;
+
+ if ((port = xc_evtchn_pending(xce_handle)) == -1)
+ {
+ perror("Failed to listen for pending event channel");
+ return 5;
+ }
+
+ if (port != virq_port)
+ {
+ char data[BUFSZ];
+ snprintf(data, BUFSZ, "Wrong port, got %d expected %d", port, virq_port);
+ perror(data);
+ return 6;
+ }
+
+ if (xc_evtchn_unmask(xce_handle, port) == -1)
+ {
+ perror("Failed to unmask port");
+ return 7;
+ }
+
+ printf("Got a virq kick, time to get work\n");
+ handle_low_mem();
+ }
+
+ return 0;
+}
diff -r 01d95561350b -r 08392a9cde1e xen/arch/x86/hvm/rtc.c
--- a/xen/arch/x86/hvm/rtc.c Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/arch/x86/hvm/rtc.c Thu Mar 01 16:48:36 2012 +0000
@@ -33,6 +33,8 @@
#define vrtc_domain(x) (container_of((x), struct domain, \
arch.hvm_domain.pl_time.vrtc))
#define vrtc_vcpu(x) (pt_global_vcpu_target(vrtc_domain(x)))
+#define epoch_year 1900
+#define get_year(x) (x + epoch_year)

static void rtc_periodic_cb(struct vcpu *v, void *opaque)
{
@@ -165,7 +167,7 @@

ASSERT(spin_is_locked(&s->lock));

- before = mktime(tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+ before = mktime(get_year(tm->tm_year), tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);

tm->tm_sec = from_bcd(s, s->hw.cmos_data[RTC_SECONDS]);
@@ -179,7 +181,7 @@
tm->tm_mon = from_bcd(s, s->hw.cmos_data[RTC_MONTH]) - 1;
tm->tm_year = from_bcd(s, s->hw.cmos_data[RTC_YEAR]) + 100;

- after = mktime(tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+ after = mktime(get_year(tm->tm_year), tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);

/* We use the guest's setting of the RTC to define the local-time
@@ -257,7 +259,7 @@
if ( (unsigned)tm->tm_wday >= 7 )
tm->tm_wday = 0;
days_in_month = get_days_in_month(tm->tm_mon,
- tm->tm_year + 1900);
+ get_year(tm->tm_year));
tm->tm_mday++;
if ( tm->tm_mday < 1 )
{
diff -r 01d95561350b -r 08392a9cde1e xen/common/grant_table.c
--- a/xen/common/grant_table.c Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/common/grant_table.c Thu Mar 01 16:48:36 2012 +0000
@@ -585,6 +585,8 @@
act->start = 0;
act->length = PAGE_SIZE;
act->is_sub_page = 0;
+ act->trans_domain = rd;
+ act->trans_gref = op->ref;
}
}

diff -r 01d95561350b -r 08392a9cde1e xen/common/page_alloc.c
--- a/xen/common/page_alloc.c Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/common/page_alloc.c Thu Mar 01 16:48:36 2012 +0000
@@ -35,6 +35,7 @@
#include <xen/perfc.h>
#include <xen/numa.h>
#include <xen/nodemask.h>
+#include <xen/event.h>
#include <xen/tmem.h>
#include <xen/tmem_xen.h>
#include <public/sysctl.h>
@@ -300,6 +301,107 @@
return needed;
}

+/* Default to 64 MiB */
+#define DEFAULT_LOW_MEM_VIRQ (((paddr_t) 64) << 20)
+#define MAX_LOW_MEM_VIRQ (((paddr_t) 1024) << 20)
+
+static paddr_t __read_mostly opt_low_mem_virq = ((paddr_t) -1);
+size_param("low_mem_virq_limit", opt_low_mem_virq);
+
+/* Thresholds to control hysteresis. In pages */
+/* When memory grows above this threshold, reset hysteresis.
+ * -1 initially to not reset until at least one virq issued. */
+static unsigned long low_mem_virq_high = -1UL;
+/* Threshold at which we issue virq */
+static unsigned long low_mem_virq_th = 0;
+/* Original threshold after all checks completed */
+static unsigned long low_mem_virq_orig = 0;
+/* Order for current threshold */
+static unsigned int low_mem_virq_th_order = 0;
+
+/* Perform bootstrapping checks and set bounds */
+static void __init setup_low_mem_virq(void)
+{
+ unsigned int order;
+ paddr_t threshold;
+ bool_t halve;
+
+ /* If the user specifies zero, then he/she doesn't want this virq
+ * to ever trigger. */
+ if ( opt_low_mem_virq == 0 )
+ {
+ low_mem_virq_th = -1UL;
+ return;
+ }
+
+ /* If the user did not specify a knob, remember that */
+ halve = (opt_low_mem_virq == ((paddr_t) -1));
+ threshold = halve ? DEFAULT_LOW_MEM_VIRQ : opt_low_mem_virq;
+
+ /* Dom0 has already been allocated by now. So check we won't be
+ * complaining immediately with whatever's left of the heap. */
+ threshold = min(threshold,
+ ((paddr_t) total_avail_pages) << PAGE_SHIFT);
+
+ /* Then, cap to some predefined maximum */
+ threshold = min(threshold, MAX_LOW_MEM_VIRQ);
+
+ /* If the user specified no knob, and we are at the current available
+ * level, halve the threshold. */
+ if ( halve &&
+ (threshold == (((paddr_t) total_avail_pages) << PAGE_SHIFT)) )
+ threshold >>= 1;
+
+ /* Zero? Have to fire immediately */
+ threshold = max(threshold, (paddr_t) PAGE_SIZE);
+
+ /* Threshold bytes -> pages */
+ low_mem_virq_th = threshold >> PAGE_SHIFT;
+
+ /* Next, round the threshold down to the next order */
+ order = get_order_from_pages(low_mem_virq_th);
+ if ( (1UL << order) > low_mem_virq_th )
+ order--;
+
+ /* Set bounds, ready to go */
+ low_mem_virq_th = low_mem_virq_orig = 1UL << order;
+ low_mem_virq_th_order = order;
+
+ printk("Initial low memory virq threshold set at 0x%lx pages.\n",
+ low_mem_virq_th);
+}
+
+static void check_low_mem_virq(void)
+{
+ if ( unlikely(total_avail_pages <= low_mem_virq_th) )
+ {
+ send_global_virq(VIRQ_ENOMEM);
+
+ /* Update thresholds. Next warning will be when we drop below
+ * next order. However, we wait until we grow beyond one
+ * order above us to complain again at the current order */
+ low_mem_virq_high = 1UL << (low_mem_virq_th_order + 1);
+ if ( low_mem_virq_th_order > 0 )
+ low_mem_virq_th_order--;
+ low_mem_virq_th = 1UL << low_mem_virq_th_order;
+ return;
+ }
+
+ if ( unlikely(total_avail_pages >= low_mem_virq_high) )
+ {
+ /* Reset hysteresis. Bring threshold up one order.
+ * If we are back where originally set, set high
+ * threshold to -1 to avoid further growth of
+ * virq threshold. */
+ low_mem_virq_th_order++;
+ low_mem_virq_th = 1UL << low_mem_virq_th_order;
+ if ( low_mem_virq_th == low_mem_virq_orig )
+ low_mem_virq_high = -1UL;
+ else
+ low_mem_virq_high = 1UL << (low_mem_virq_th_order + 2);
+ }
+}
+
/* Allocate 2^@order contiguous pages. */
static struct page_info *alloc_heap_pages(
unsigned int zone_lo, unsigned int zone_hi,
@@ -420,6 +522,8 @@
total_avail_pages -= request;
ASSERT(total_avail_pages >= 0);

+ check_low_mem_virq();
+
if ( d != NULL )
d->last_alloc_node = node;

@@ -1022,6 +1126,10 @@
}

printk("done.\n");
+
+ /* Now that the heap is initialized, run checks and set bounds
+ * for the low mem virq algorithm. */
+ setup_low_mem_virq();
}


diff -r 01d95561350b -r 08392a9cde1e xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/drivers/passthrough/amd/iommu_init.c Thu Mar 01 16:48:36 2012 +0000
@@ -367,6 +367,8 @@
u32 tail, head, *entry, tail_offest, head_offset;

BUG_ON(!iommu || ((log != &iommu->event_log) && (log != &iommu->ppr_log)));
+
+ spin_lock(&log->lock);

/* make sure there's an entry in the log */
tail_offest = ( log == &iommu->event_log ) ?
@@ -396,6 +398,8 @@
writel(head, iommu->mmio_base + head_offset);
}

+ spin_unlock(&log->lock);
+
return 0;
}

@@ -618,11 +622,11 @@
u32 entry;
unsigned long flags;

- spin_lock_irqsave(&iommu->lock, flags);
-
iommu_read_log(iommu, &iommu->event_log,
sizeof(event_entry_t), parse_event_log_entry);

+ spin_lock_irqsave(&iommu->lock, flags);
+
/*check event overflow */
entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);

@@ -651,14 +655,10 @@
bus = PCI_BUS(device_id);
devfn = PCI_DEVFN2(device_id);

- local_irq_enable();
-
spin_lock(&pcidevs_lock);
pdev = pci_get_pdev(iommu->seg, bus, devfn);
spin_unlock(&pcidevs_lock);

- local_irq_disable();
-
if ( pdev == NULL )
return;

@@ -672,10 +672,10 @@
u32 entry;
unsigned long flags;

- spin_lock_irqsave(&iommu->lock, flags);
-
iommu_read_log(iommu, &iommu->ppr_log,
sizeof(ppr_entry_t), parse_ppr_log_entry);
+
+ spin_lock_irqsave(&iommu->lock, flags);

/*check event overflow */
entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
@@ -852,6 +852,8 @@
ring_buf->head = 0;
ring_buf->tail = 0;

+ spin_lock_init(&ring_buf->lock);
+
ring_buf->alloc_size = PAGE_SIZE << get_order_from_bytes(entries *
entry_size);
ring_buf->entries = ring_buf->alloc_size / entry_size;
diff -r 01d95561350b -r 08392a9cde1e xen/include/asm-x86/amd-iommu.h
--- a/xen/include/asm-x86/amd-iommu.h Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/include/asm-x86/amd-iommu.h Thu Mar 01 16:48:36 2012 +0000
@@ -65,6 +65,7 @@
unsigned long alloc_size;
uint32_t tail;
uint32_t head;
+ spinlock_t lock; /* protect buffer pointers */
};

typedef struct iommu_cap {
diff -r 01d95561350b -r 08392a9cde1e xen/include/public/xen.h
--- a/xen/include/public/xen.h Thu Mar 01 16:41:56 2012 +0000
+++ b/xen/include/public/xen.h Thu Mar 01 16:48:36 2012 +0000
@@ -158,6 +158,7 @@
#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */
#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */
#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */
+#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */

/* Architecture-specific VIRQ definitions. */
#define VIRQ_ARCH_0 16

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog


patchbot at xen

Mar 14, 2012, 5:33 AM

Post #3 of 6 (84 views)
Permalink
[xen-unstable] Merge [In reply to]

# HG changeset patch
# User Ian Jackson <Ian.Jackson [at] eu>
# Date 1331652521 0
# Node ID d54cf3fa7ee6d57acf7500cd53da135e0c584948
# Parent 703a339e11abf1ea14ee528f4194b308fcb3ea88
# Parent 773d0367087212c43faf8cdcc21cf443b1ea0046
Merge
---


diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/Makefile
--- a/xen/arch/arm/Makefile Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/Makefile Tue Mar 13 15:28:41 2012 +0000
@@ -13,6 +13,7 @@
obj-y += kernel.o
obj-y += mm.o
obj-y += p2m.o
+obj-y += percpu.o
obj-y += guestcopy.o
obj-y += setup.o
obj-y += time.o
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/domain.c
--- a/xen/arch/arm/domain.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/domain.c Tue Mar 13 15:28:41 2012 +0000
@@ -31,12 +31,14 @@
{
for ( ; ; )
{
- /* TODO
- if ( cpu_is_offline(smp_processor_id()) )
- play_dead();
- (*pm_idle)();
- BUG();
- */
+ if ( cpu_is_offline(smp_processor_id()) )
+ stop_cpu();
+
+ local_irq_disable();
+ if ( cpu_is_haltable(smp_processor_id()) )
+ asm volatile ("dsb; wfi");
+ local_irq_enable();
+
do_tasklet();
do_softirq();
}
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/dummy.S
--- a/xen/arch/arm/dummy.S Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/dummy.S Tue Mar 13 15:28:41 2012 +0000
@@ -7,14 +7,10 @@
x: mov pc, lr

/* SMP support */
-DUMMY(__cpu_die);
-DUMMY(__cpu_disable);
-DUMMY(__cpu_up);
DUMMY(per_cpu__cpu_core_mask);
DUMMY(per_cpu__cpu_sibling_mask);
DUMMY(node_online_map);
DUMMY(smp_send_state_dump);
-DUMMY(__per_cpu_offset);

/* PIRQ support */
DUMMY(alloc_pirq_struct);
@@ -62,5 +58,4 @@
DUMMY(hypercall_create_continuation);
DUMMY(send_timer_event);
DUMMY(share_xen_page_with_privileged_guests);
-DUMMY(__udelay);
DUMMY(wallclock_time);
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/gic.c
--- a/xen/arch/arm/gic.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/gic.c Tue Mar 13 15:28:41 2012 +0000
@@ -224,7 +224,9 @@
{
int i;

- /* Disable all PPI and enable all SGI */
+ /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so
+ * even though they are controlled with GICD registers, they must
+ * be set up here with the other per-cpu state. */
GICD[GICD_ICENABLER] = 0xffff0000; /* Disable all PPI */
GICD[GICD_ISENABLER] = 0x0000ffff; /* Enable all SGI */
/* Set PPI and SGI priorities */
@@ -237,20 +239,29 @@
GICC[GICC_CTLR] = GICC_CTL_ENABLE|GICC_CTL_EOI; /* Turn on delivery */
}

+static void gic_cpu_disable(void)
+{
+ GICC[GICC_CTLR] = 0;
+}
+
static void __cpuinit gic_hyp_init(void)
{
uint32_t vtr;

vtr = GICH[GICH_VTR];
nr_lrs = (vtr & GICH_VTR_NRLRGS) + 1;
- printk("GICH: %d list registers available\n", nr_lrs);

GICH[GICH_HCR] = GICH_HCR_EN;
GICH[GICH_MISR] = GICH_MISR_EOI;
}

+static void __cpuinit gic_hyp_disable(void)
+{
+ GICH[GICH_HCR] = 0;
+}
+
/* Set up the GIC */
-void gic_init(void)
+int __init gic_init(void)
{
/* XXX FIXME get this from devicetree */
gic.dbase = GIC_BASE_ADDRESS + GIC_DR_OFFSET;
@@ -272,6 +283,26 @@
gic_hyp_init();

spin_unlock(&gic.lock);
+
+ return gic.cpus;
+}
+
+/* Set up the per-CPU parts of the GIC for a secondary CPU */
+void __cpuinit gic_init_secondary_cpu(void)
+{
+ spin_lock(&gic.lock);
+ gic_cpu_init();
+ gic_hyp_init();
+ spin_unlock(&gic.lock);
+}
+
+/* Shut down the per-CPU GIC interface */
+void gic_disable_cpu(void)
+{
+ spin_lock(&gic.lock);
+ gic_cpu_disable();
+ gic_hyp_disable();
+ spin_unlock(&gic.lock);
}

void gic_route_irqs(void)
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/gic.h
--- a/xen/arch/arm/gic.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/gic.h Tue Mar 13 15:28:41 2012 +0000
@@ -138,8 +138,12 @@

/* Accept an interrupt from the GIC and dispatch its handler */
extern void gic_interrupt(struct cpu_user_regs *regs, int is_fiq);
-/* Bring up the interrupt controller */
-extern void gic_init(void);
+/* Bring up the interrupt controller, and report # cpus attached */
+extern int gic_init(void);
+/* Bring up a secondary CPU's per-CPU GIC interface */
+extern void gic_init_secondary_cpu(void);
+/* Take down a CPU's per-CPU GIC interface */
+extern void gic_disable_cpu(void);
/* setup the gic virtual interface for a guest */
extern void gicv_setup(struct domain *d);
#endif
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/head.S
--- a/xen/arch/arm/head.S Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/head.S Tue Mar 13 15:28:41 2012 +0000
@@ -62,22 +62,36 @@
#endif

/* Are we the boot CPU? */
+ mov r12, #0 /* r12 := CPU ID */
mrc CP32(r0, MPIDR)
tst r0, #(1<<31) /* Multiprocessor extension supported? */
beq boot_cpu
tst r0, #(1<<30) /* Uniprocessor system? */
bne boot_cpu
- bics r0, r0, #(0xff << 24) /* Ignore flags */
- beq boot_cpu /* If all other fields are 0, we win */
+ bics r12, r0, #(0xff << 24) /* Mask out flags to get CPU ID */
+ beq boot_cpu /* If we're CPU 0, boot now */

-1: wfi
- b 1b
-
+ /* Non-boot CPUs wait here to be woken up one at a time.
+ * This is basically an open-coded spin-lock to serialize. */
+ ldr r0, =boot_gate /* VA of gate */
+ add r0, r0, r10 /* PA of gate */
+ mov r1, #1 /* (1 == locked) */
+1: wfe
+ ldrex r2, [r0] /* Linked read of current value */
+ teq r2, #0 /* (0 == unlocked) */
+ strexeq r2, r1, [r0] /* Matching update -> locked */
+ teq r2, #0 /* (0 == succeeded) */
+ bne 1b
+
boot_cpu:
#ifdef EARLY_UART_ADDRESS
- /* Say hello */
ldr r11, =EARLY_UART_ADDRESS /* r11 := UART base address */
- bl init_uart
+ teq r12, #0 /* CPU 0 sets up the UART too */
+ bleq init_uart
+ PRINT("- CPU ")
+ mov r0, r12
+ bl putn
+ PRINT(" booting -\r\n")
#endif

/* Check that this CPU has Hyp mode */
@@ -85,7 +99,6 @@
and r0, r0, #0xf000 /* Bits 12-15 define virt extensions */
teq r0, #0x1000 /* Must == 0x1 or may be incompatible */
beq 1f
- bl putn
PRINT("- CPU doesn't support the virtualization extensions -\r\n")
b fail
1:
@@ -185,6 +198,10 @@
mov r5, #0 /* r4:r5 is paddr (xen_pagetable) */
mcrr CP64(r4, r5, HTTBR)

+ /* Non-boot CPUs don't need to rebuild the pagetable */
+ teq r12, #0
+ bne pt_ready
+
/* Build the baseline idle pagetable's first-level entries */
ldr r1, =xen_second
add r1, r1, r10 /* r1 := paddr (xen_second) */
@@ -226,6 +243,7 @@
add r4, r4, #8
strd r2, r3, [r1, r4] /* Map it in the early boot slot */

+pt_ready:
PRINT("- Turning on paging -\r\n")

ldr r1, =paging /* Explicit vaddr, not RIP-relative */
@@ -238,7 +256,7 @@
paging:

#ifdef EARLY_UART_ADDRESS
- /* Recover the UART address in the new address space */
+ /* Recover the UART address in the new address space. */
lsl r11, #11
lsr r11, #11 /* UART base's offset from 2MB base */
adr r0, start
@@ -246,15 +264,66 @@
add r11, r11, r0 /* r11 := vaddr (UART base address) */
#endif

- PRINT("- Entering C -\r\n")
+ PRINT("- Ready -\r\n")

- ldr sp, =init_stack /* Supply a stack */
+ /* The boot CPU should go straight into C now */
+ teq r12, #0
+ beq launch
+
+ /* Signal the next non-boot CPU to come and join us here */
+ ldr r0, =boot_gate /* VA of gate */
+ add r0, r0, r10 /* PA of gate */
+ mov r1, #0 /* (0 == unlocked) */
+ str r1, [r0]
+ dsb
+ isb
+ sev
+
+ /* Move on to the relocated pagetables */
+ mov r0, #0
+ ldr r4, =boot_httbr /* VA of HTTBR value stashed by CPU 0 */
+ add r4, r4, r10 /* PA of it */
+ ldrd r4, r5, [r4] /* Actual value */
+ mcrr CP64(r4, r5, HTTBR)
+ mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */
+ mcr CP32(r0, BPIALL) /* Flush branch predictor */
+ dsb /* Ensure completion of TLB+BP flush */
+ isb
+ /* Now, the UART is in its proper fixmap address */
+ ldrne r11, =FIXMAP_ADDR(FIXMAP_CONSOLE)
+
+ /* Non-boot CPUs report that they've got this far */
+ ldr r0, =ready_cpus
+1: ldrex r1, [r0] /* { read # of ready CPUs } */
+ add r1, r1, #1 /* Atomically { ++ } */
+ strex r2, r1, [r0] /* { writeback } */
+ teq r2, #0
+ bne 1b
+ dsb
+
+ /* Here, the non-boot CPUs must wait again -- they're now running on
+ * the boot CPU's pagetables so it's safe for the boot CPU to
+ * overwrite the non-relocated copy of Xen. Once it's done that,
+ * and brought up the memory allocator, non-boot CPUs can get their
+ * own stacks and enter C. */
+1: wfe
+ dsb
+ ldr r0, =smp_up_cpu
+ ldr r1, [r0] /* Which CPU is being booted? */
+ teq r1, r12 /* Is it us? */
+ bne 1b
+
+launch:
+ ldr r0, =init_stack /* Find the boot-time stack */
+ ldr sp, [r0]
add sp, #STACK_SIZE /* (which grows down from the top). */
sub sp, #CPUINFO_sizeof /* Make room for CPU save record */
mov r0, r10 /* Marshal args: - phys_offset */
mov r1, r7 /* - machine type */
mov r2, r8 /* - ATAG address */
- b start_xen /* and disappear into the land of C */
+ movs r3, r12 /* - CPU ID */
+ beq start_xen /* and disappear into the land of C */
+ b start_secondary /* (to the appropriate entry point) */

/* Fail-stop
* r0: string explaining why */
@@ -288,7 +357,7 @@
tst r2, #0x8 /* Check BUSY bit */
bne puts /* Wait for the UART to be ready */
ldrb r2, [r0], #1 /* Load next char */
- teq r2, #0 /* Exit on nul*/
+ teq r2, #0 /* Exit on nul */
moveq pc, lr
str r2, [r11] /* -> UARTDR (Data Register) */
b puts
@@ -308,10 +377,8 @@
lsl r0, #4 /* Roll it through one nybble at a time */
subs r3, r3, #1
bne 1b
- adr r0, crlf /* Finish with a newline */
- b puts
+ mov pc, lr

-crlf: .asciz "\r\n"
hex: .ascii "0123456789abcdef"
.align 2

diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/mm.c
--- a/xen/arch/arm/mm.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/mm.c Tue Mar 13 15:28:41 2012 +0000
@@ -36,6 +36,9 @@
static lpae_t xen_fixmap[LPAE_ENTRIES] __attribute__((__aligned__(4096)));
static lpae_t xen_xenmap[LPAE_ENTRIES] __attribute__((__aligned__(4096)));

+/* Non-boot CPUs use this to find the correct pagetables. */
+uint64_t boot_httbr;
+
/* Limits of the Xen heap */
unsigned long xenheap_mfn_start, xenheap_mfn_end;
unsigned long xenheap_virt_end;
@@ -45,6 +48,8 @@

unsigned long max_page;

+extern char __init_begin[], __init_end[];
+
/* Map a 4k page in a fixmap entry */
void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes)
{
@@ -156,14 +161,6 @@
lpae_t pte, *p;
int i;

- if ( boot_phys_offset != 0 )
- {
- /* Remove the old identity mapping of the boot paddr */
- pte.bits = 0;
- dest_va = (unsigned long)_start + boot_phys_offset;
- write_pte(xen_second + second_linear_offset(dest_va), pte);
- }
-
xen_paddr = device_tree_get_xen_paddr();

/* Map the destination in the boot misc area. */
@@ -186,11 +183,18 @@
for ( i = 0; i < 4; i++)
p[i].pt.base += (phys_offset - boot_phys_offset) >> PAGE_SHIFT;
p = (void *) xen_second + dest_va - (unsigned long) _start;
+ if ( boot_phys_offset != 0 )
+ {
+ /* Remove the old identity mapping of the boot paddr */
+ unsigned long va = (unsigned long)_start + boot_phys_offset;
+ p[second_linear_offset(va)].bits = 0;
+ }
for ( i = 0; i < 4 * LPAE_ENTRIES; i++)
if ( p[i].pt.valid )
p[i].pt.base += (phys_offset - boot_phys_offset) >> PAGE_SHIFT;

/* Change pagetables to the copy in the relocated Xen */
+ boot_httbr = (unsigned long) xen_pgtable + phys_offset;
asm volatile (
STORE_CP64(0, HTTBR) /* Change translation base */
"dsb;" /* Ensure visibility of HTTBR update */
@@ -198,22 +202,12 @@
STORE_CP32(0, BPIALL) /* Flush branch predictor */
"dsb;" /* Ensure completion of TLB+BP flush */
"isb;"
- : : "r" ((unsigned long) xen_pgtable + phys_offset) : "memory");
+ : : "r" (boot_httbr) : "memory");

/* Undo the temporary map */
pte.bits = 0;
write_pte(xen_second + second_table_offset(dest_va), pte);
- /*
- * Have removed a mapping previously used for .text. Flush everything
- * for safety.
- */
- asm volatile (
- "dsb;" /* Ensure visibility of PTE write */
- STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */
- STORE_CP32(0, BPIALL) /* Flush branch predictor */
- "dsb;" /* Ensure completion of TLB+BP flush */
- "isb;"
- : : "r" (i /*dummy*/) : "memory");
+ flush_xen_text_tlb();

/* Link in the fixmap pagetable */
pte = mfn_to_xen_entry((((unsigned long) xen_fixmap) + phys_offset)
@@ -249,18 +243,19 @@
pte.pt.table = 1;
write_pte(xen_second + second_linear_offset(XEN_VIRT_START), pte);
/* Have changed a mapping used for .text. Flush everything for safety. */
- asm volatile (
- "dsb;" /* Ensure visibility of PTE write */
- STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */
- STORE_CP32(0, BPIALL) /* Flush branch predictor */
- "dsb;" /* Ensure completion of TLB+BP flush */
- "isb;"
- : : "r" (i /*dummy*/) : "memory");
+ flush_xen_text_tlb();

/* From now on, no mapping may be both writable and executable. */
WRITE_CP32(READ_CP32(HSCTLR) | SCTLR_WXN, HSCTLR);
}

+/* MMU setup for secondary CPUS (which already have paging enabled) */
+void __cpuinit mmu_init_secondary_cpu(void)
+{
+ /* From now on, no mapping may be both writable and executable. */
+ WRITE_CP32(READ_CP32(HSCTLR) | SCTLR_WXN, HSCTLR);
+}
+
/* Create Xen's mappings of memory.
* Base and virt must be 32MB aligned and size a multiple of 32MB. */
static void __init create_mappings(unsigned long virt,
@@ -319,6 +314,64 @@
frametable_virt_end = FRAMETABLE_VIRT_START + (nr_pages * sizeof(struct page_info));
}

+enum mg { mg_clear, mg_ro, mg_rw, mg_rx };
+static void set_pte_flags_on_range(const char *p, unsigned long l, enum mg mg)
+{
+ lpae_t pte;
+ int i;
+
+ ASSERT(is_kernel(p) && is_kernel(p + l));
+
+ /* Can only guard in page granularity */
+ ASSERT(!((unsigned long) p & ~PAGE_MASK));
+ ASSERT(!(l & ~PAGE_MASK));
+
+ for ( i = (p - _start) / PAGE_SIZE;
+ i < (p + l - _start) / PAGE_SIZE;
+ i++ )
+ {
+ pte = xen_xenmap[i];
+ switch ( mg )
+ {
+ case mg_clear:
+ pte.pt.valid = 0;
+ break;
+ case mg_ro:
+ pte.pt.valid = 1;
+ pte.pt.pxn = 1;
+ pte.pt.xn = 1;
+ pte.pt.ro = 1;
+ break;
+ case mg_rw:
+ pte.pt.valid = 1;
+ pte.pt.pxn = 1;
+ pte.pt.xn = 1;
+ pte.pt.ro = 0;
+ break;
+ case mg_rx:
+ pte.pt.valid = 1;
+ pte.pt.pxn = 0;
+ pte.pt.xn = 0;
+ pte.pt.ro = 1;
+ break;
+ }
+ write_pte(xen_xenmap + i, pte);
+ }
+ flush_xen_text_tlb();
+}
+
+/* Release all __init and __initdata ranges to be reused */
+void free_init_memory(void)
+{
+ paddr_t pa = virt_to_maddr(__init_begin);
+ unsigned long len = __init_end - __init_begin;
+ set_pte_flags_on_range(__init_begin, len, mg_rw);
+ memset(__init_begin, 0xcc, len);
+ set_pte_flags_on_range(__init_begin, len, mg_clear);
+ init_domheap_pages(pa, pa + len);
+ printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
+}
+
void arch_dump_shared_mem_info(void)
{
}
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/percpu.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/arm/percpu.c Tue Mar 13 15:28:41 2012 +0000
@@ -0,0 +1,85 @@
+#include <xen/config.h>
+#include <xen/percpu.h>
+#include <xen/cpu.h>
+#include <xen/init.h>
+#include <xen/mm.h>
+#include <xen/rcupdate.h>
+
+unsigned long __per_cpu_offset[NR_CPUS];
+#define INVALID_PERCPU_AREA (-(long)__per_cpu_start)
+#define PERCPU_ORDER (get_order_from_bytes(__per_cpu_data_end-__per_cpu_start))
+
+void __init percpu_init_areas(void)
+{
+ unsigned int cpu;
+ for ( cpu = 1; cpu < NR_CPUS; cpu++ )
+ __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
+}
+
+static int init_percpu_area(unsigned int cpu)
+{
+ char *p;
+ if ( __per_cpu_offset[cpu] != INVALID_PERCPU_AREA )
+ return -EBUSY;
+ if ( (p = alloc_xenheap_pages(PERCPU_ORDER, 0)) == NULL )
+ return -ENOMEM;
+ memset(p, 0, __per_cpu_data_end - __per_cpu_start);
+ __per_cpu_offset[cpu] = p - __per_cpu_start;
+ return 0;
+}
+
+struct free_info {
+ unsigned int cpu;
+ struct rcu_head rcu;
+};
+static DEFINE_PER_CPU(struct free_info, free_info);
+
+static void _free_percpu_area(struct rcu_head *head)
+{
+ struct free_info *info = container_of(head, struct free_info, rcu);
+ unsigned int cpu = info->cpu;
+ char *p = __per_cpu_start + __per_cpu_offset[cpu];
+ free_xenheap_pages(p, PERCPU_ORDER);
+ __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
+}
+
+static void free_percpu_area(unsigned int cpu)
+{
+ struct free_info *info = &per_cpu(free_info, cpu);
+ info->cpu = cpu;
+ call_rcu(&info->rcu, _free_percpu_area);
+}
+
+static int cpu_percpu_callback(
+ struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+ unsigned int cpu = (unsigned long)hcpu;
+ int rc = 0;
+
+ switch ( action )
+ {
+ case CPU_UP_PREPARE:
+ rc = init_percpu_area(cpu);
+ break;
+ case CPU_UP_CANCELED:
+ case CPU_DEAD:
+ free_percpu_area(cpu);
+ break;
+ default:
+ break;
+ }
+
+ return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+}
+
+static struct notifier_block cpu_percpu_nfb = {
+ .notifier_call = cpu_percpu_callback,
+ .priority = 100 /* highest priority */
+};
+
+static int __init percpu_presmp_init(void)
+{
+ register_cpu_notifier(&cpu_percpu_nfb);
+ return 0;
+}
+presmp_initcall(percpu_presmp_init);
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/setup.c
--- a/xen/arch/arm/setup.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/setup.c Tue Mar 13 15:28:41 2012 +0000
@@ -38,22 +38,14 @@
#include <asm/setup.h>
#include "gic.h"

-/* maxcpus: maximum number of CPUs to activate. */
-static unsigned int __initdata max_cpus = NR_CPUS;
-
-/* Xen stack for bringing up the first CPU. */
-unsigned char __initdata init_stack[STACK_SIZE] __attribute__((__aligned__(STACK_SIZE)));
-
-extern char __init_begin[], __init_end[], __bss_start[];
+/* Spinlock for serializing CPU bringup */
+unsigned long __initdata boot_gate = 1;
+/* Number of non-boot CPUs ready to enter C */
+unsigned long __initdata ready_cpus = 0;

static __attribute_used__ void init_done(void)
{
- /* TODO: free (or page-protect) the init areas.
- memset(__init_begin, 0xcc, __init_end - __init_begin);
- free_xen_data(__init_begin, __init_end);
- */
- printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
-
+ free_init_memory();
startup_cpu_idle_loop();
}

@@ -151,14 +143,17 @@
end_boot_allocator();
}

+/* C entry point for boot CPU */
void __init start_xen(unsigned long boot_phys_offset,
unsigned long arm_type,
- unsigned long atag_paddr)
-
+ unsigned long atag_paddr,
+ unsigned long cpuid)
{
void *fdt;
size_t fdt_size;
- int i;
+ int cpus, i;
+ paddr_t gate_pa;
+ unsigned long *gate;

fdt = (void *)BOOT_MISC_VIRT_START
+ (atag_paddr & ((1 << SECOND_SHIFT) - 1));
@@ -174,15 +169,29 @@
console_init_preirq();
#endif

+ percpu_init_areas();
+ set_processor_id(0); /* needed early, for smp_processor_id() */
+
+ cpus = gic_init();
+
+ printk("Waiting for %i other CPUs to be ready\n", cpus - 1);
+ /* Bring the other CPUs up to paging before the original
+ * copy of .text gets overwritten. We need to use the unrelocated
+ * copy of boot_gate as that's the one the others can see. */
+ gate_pa = ((unsigned long) &boot_gate) + boot_phys_offset;
+ gate = map_domain_page(gate_pa >> PAGE_SHIFT) + (gate_pa & ~PAGE_MASK);
+ *gate = 0;
+ unmap_domain_page(gate);
+ /* Now send an event to wake the first non-boot CPU */
+ asm volatile("dsb; isb; sev");
+ /* And wait for them all to be ready. */
+ while ( ready_cpus + 1 < cpus )
+ smp_rmb();
+
__set_current((struct vcpu *)0xfffff000); /* debug sanity */
idle_vcpu[0] = current;
- set_processor_id(0); /* needed early, for smp_processor_id() */

- /* TODO: smp_prepare_boot_cpu(void) */
- cpumask_set_cpu(smp_processor_id(), &cpu_online_map);
- cpumask_set_cpu(smp_processor_id(), &cpu_present_map);
-
- smp_prepare_cpus(max_cpus);
+ smp_prepare_cpus(cpus);

init_xen_time();

@@ -208,8 +217,6 @@

init_IRQ();

- gic_init();
-
gic_route_irqs();

init_maintenance_interrupt();
@@ -231,7 +238,7 @@

for_each_present_cpu ( i )
{
- if ( (num_online_cpus() < max_cpus) && !cpu_online(i) )
+ if ( (num_online_cpus() < cpus) && !cpu_online(i) )
{
int ret = cpu_up(i);
if ( ret != 0 )
@@ -269,7 +276,11 @@

domain_unpause_by_systemcontroller(dom0);

- reset_stack_and_jump(init_done);
+ /* Switch on to the dynamically allocated stack for the idle vcpu
+ * since the static one we're running on is about to be freed. */
+ memcpy(idle_vcpu[0]->arch.cpu_info, get_cpu_info(),
+ sizeof(struct cpu_info));
+ switch_stack_and_jump(idle_vcpu[0]->arch.cpu_info, init_done);
}

void arch_get_xen_caps(xen_capabilities_info_t *info)
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/shutdown.c
--- a/xen/arch/arm/shutdown.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/shutdown.c Tue Mar 13 15:28:41 2012 +0000
@@ -1,18 +1,64 @@
#include <xen/config.h>
+#include <xen/console.h>
+#include <xen/cpu.h>
+#include <xen/delay.h>
#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/smp.h>
+
+static void raw_machine_reset(void)
+{
+ /* XXX get this from device tree */
+#ifdef SP810_ADDRESS
+ /* Use the SP810 system controller to force a reset */
+ volatile uint32_t *sp810;
+ set_fixmap(FIXMAP_MISC, SP810_ADDRESS >> PAGE_SHIFT, DEV_SHARED);
+ sp810 = ((uint32_t *)
+ (FIXMAP_ADDR(FIXMAP_MISC) + (SP810_ADDRESS & ~PAGE_MASK)));
+ sp810[0] = 0x3; /* switch to slow mode */
+ dsb(); isb();
+ sp810[1] = 0x1; /* writing any value to SCSYSSTAT reg will reset system */
+ dsb(); isb();
+ clear_fixmap(FIXMAP_MISC);
+#endif
+}
+
+static void halt_this_cpu(void *arg)
+{
+ __cpu_disable();
+ stop_cpu();
+}

void machine_halt(void)
{
- /* TODO: halt */
- while(1) ;
+ watchdog_disable();
+ console_start_sync();
+ local_irq_enable();
+ smp_call_function(halt_this_cpu, NULL, 0);
+ halt_this_cpu(NULL);
}

void machine_restart(unsigned int delay_millisecs)
{
- /* TODO: restart */
- printk("Cannot restart yet\n");
- while(1);
+ int timeout = 10;
+
+ local_irq_enable();
+ smp_call_function(halt_this_cpu, NULL, 0);
+ local_irq_disable();
+
+ mdelay(delay_millisecs);
+
+ /* Wait at most another 10ms for all other CPUs to go offline. */
+ while ( (num_online_cpus() > 1) && (timeout-- > 0) )
+ mdelay(1);
+
+ while ( 1 )
+ {
+ raw_machine_reset();
+ mdelay(100);
+ }
}
+
/*
* Local variables:
* mode: C
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/smpboot.c
--- a/xen/arch/arm/smpboot.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/smpboot.c Tue Mar 13 15:28:41 2012 +0000
@@ -16,9 +16,16 @@
* GNU General Public License for more details.
*/

+#include <xen/cpu.h>
#include <xen/cpumask.h>
+#include <xen/delay.h>
+#include <xen/errno.h>
+#include <xen/init.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
#include <xen/smp.h>
-#include <xen/init.h>
+#include <xen/softirq.h>
+#include "gic.h"

cpumask_t cpu_online_map;
EXPORT_SYMBOL(cpu_online_map);
@@ -27,19 +34,142 @@
cpumask_t cpu_possible_map;
EXPORT_SYMBOL(cpu_possible_map);

+/* Xen stack for bringing up the first CPU. */
+static unsigned char __initdata cpu0_boot_stack[STACK_SIZE]
+ __attribute__((__aligned__(STACK_SIZE)));
+
+/* Pointer to the stack, used by head.S when entering C */
+unsigned char *init_stack = cpu0_boot_stack;
+
void __init
smp_prepare_cpus (unsigned int max_cpus)
{
- set_processor_id(0); /* needed early, for smp_processor_id() */
+ int i;
+ set_processor_id(0); /* needed early, for smp_processor_id() */

- cpumask_clear(&cpu_online_map);
- cpumask_clear(&cpu_present_map);
- cpumask_clear(&cpu_possible_map);
- cpumask_set_cpu(0, &cpu_online_map);
- cpumask_set_cpu(0, &cpu_present_map);
- cpumask_set_cpu(0, &cpu_possible_map);
- return;
+ cpumask_clear(&cpu_online_map);
+ cpumask_set_cpu(0, &cpu_online_map);
+
+ cpumask_clear(&cpu_possible_map);
+ for ( i = 0; i < max_cpus; i++ )
+ cpumask_set_cpu(i, &cpu_possible_map);
+ cpumask_copy(&cpu_present_map, &cpu_possible_map);
}
+
+/* Shared state for coordinating CPU bringup */
+unsigned long smp_up_cpu = 0;
+static bool_t cpu_is_dead = 0;
+
+/* Boot the current CPU */
+void __cpuinit start_secondary(unsigned long boot_phys_offset,
+ unsigned long arm_type,
+ unsigned long atag_paddr,
+ unsigned long cpuid)
+{
+ memset(get_cpu_info(), 0, sizeof (struct cpu_info));
+
+ /* TODO: handle boards where CPUIDs are not contiguous */
+ set_processor_id(cpuid);
+
+ /* Setup Hyp vector base */
+ WRITE_CP32((uint32_t) hyp_traps_vector, HVBAR);
+
+ dprintk(XENLOG_DEBUG, "CPU %li awake.\n", cpuid);
+
+ mmu_init_secondary_cpu();
+ gic_init_secondary_cpu();
+
+ set_current(idle_vcpu[cpuid]);
+ this_cpu(curr_vcpu) = current;
+
+ /* Run local notifiers */
+ notify_cpu_starting(cpuid);
+ wmb();
+
+ /* Now report this CPU is up */
+ cpumask_set_cpu(cpuid, &cpu_online_map);
+ wmb();
+
+ local_irq_enable();
+
+ dprintk(XENLOG_DEBUG, "CPU %li booted.\n", cpuid);
+
+ startup_cpu_idle_loop();
+}
+
+/* Shut down the current CPU */
+void __cpu_disable(void)
+{
+ unsigned int cpu = get_processor_id();
+
+ local_irq_disable();
+ gic_disable_cpu();
+ /* Allow any queued timer interrupts to get serviced */
+ local_irq_enable();
+ mdelay(1);
+ local_irq_disable();
+
+ /* It's now safe to remove this processor from the online map */
+ cpumask_clear_cpu(cpu, &cpu_online_map);
+
+ if ( cpu_disable_scheduler(cpu) )
+ BUG();
+ mb();
+
+ /* Return to caller; eventually the IPI mechanism will unwind and the
+ * scheduler will drop to the idle loop, which will call stop_cpu(). */
+}
+
+void stop_cpu(void)
+{
+ local_irq_disable();
+ cpu_is_dead = 1;
+ /* Make sure the write happens before we sleep forever */
+ dsb();
+ isb();
+ while ( 1 )
+ asm volatile("wfi");
+}
+
+/* Bring up a remote CPU */
+int __cpu_up(unsigned int cpu)
+{
+ /* Tell the remote CPU which stack to boot on. */
+ init_stack = idle_vcpu[cpu]->arch.stack;
+
+ /* Unblock the CPU. It should be waiting in the loop in head.S
+ * for an event to arrive when smp_up_cpu matches its cpuid. */
+ smp_up_cpu = cpu;
+ asm volatile("dsb; isb; sev");
+
+ while ( !cpu_online(cpu) )
+ {
+ cpu_relax();
+ process_pending_softirqs();
+ }
+
+ return 0;
+}
+
+/* Wait for a remote CPU to die */
+void __cpu_die(unsigned int cpu)
+{
+ unsigned int i = 0;
+
+ while ( !cpu_is_dead )
+ {
+ mdelay(100);
+ cpu_relax();
+ process_pending_softirqs();
+ if ( (++i % 10) == 0 )
+ printk(KERN_ERR "CPU %u still not dead...\n", cpu);
+ mb();
+ }
+ cpu_is_dead = 0;
+ mb();
+}
+
+
/*
* Local variables:
* mode: C
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/arch/arm/time.c
--- a/xen/arch/arm/time.c Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/arch/arm/time.c Tue Mar 13 15:28:41 2012 +0000
@@ -171,6 +171,16 @@
request_irq(30, timer_interrupt, 0, "phytimer", NULL);
}

+/* Wait a set number of microseconds */
+void udelay(unsigned long usecs)
+{
+ s_time_t deadline = get_s_time() + 1000 * (s_time_t) usecs;
+ while ( get_s_time() - deadline < 0 )
+ ;
+ dsb();
+ isb();
+}
+
/*
* Local variables:
* mode: C
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/config.h
--- a/xen/include/asm-arm/config.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/config.h Tue Mar 13 15:28:41 2012 +0000
@@ -119,6 +119,9 @@
#define GIC_CR_OFFSET 0x2000
#define GIC_HR_OFFSET 0x4000 /* Guess work http://lists.infradead.org/pipermail/linux-arm-kernel/2011-September/064219.html */
#define GIC_VR_OFFSET 0x6000 /* Virtual Machine CPU interface) */
+/* Board-specific: base address of system controller */
+#define SP810_ADDRESS 0x1C020000
+

#endif /* __ARM_CONFIG_H__ */
/*
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/current.h
--- a/xen/include/asm-arm/current.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/current.h Tue Mar 13 15:28:41 2012 +0000
@@ -40,17 +40,19 @@
#define get_current() (this_cpu(curr_vcpu))
#define __set_current(vcpu) (this_cpu(curr_vcpu) = (vcpu))
#define set_current(vcpu) do { \
- vcpu->arch.cpu_info->processor_id = get_processor_id(); \
+ int cpu = get_processor_id(); \
+ vcpu->arch.cpu_info->processor_id = cpu; \
+ vcpu->arch.cpu_info->per_cpu_offset = __per_cpu_offset[cpu]; \
__set_current(vcpu); \
} while (0)
#define current (get_current())

#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)

-#define reset_stack_and_jump(__fn) \
- __asm__ __volatile__ ( \
- "mov sp,%0; b "STR(__fn) \
- : : "r" (guest_cpu_user_regs()) : "memory" )
+#define switch_stack_and_jump(stack, fn) \
+ asm volatile ("mov sp,%0; b " STR(fn) : : "r" (stack) : "memory" )
+
+#define reset_stack_and_jump(fn) switch_stack_and_jump(get_cpu_info(), fn)

#endif

diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/delay.h
--- a/xen/include/asm-arm/delay.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/delay.h Tue Mar 13 15:28:41 2012 +0000
@@ -1,8 +1,7 @@
#ifndef _ARM_DELAY_H
#define _ARM_DELAY_H

-extern void __udelay(unsigned long usecs);
-#define udelay(n) __udelay(n)
+extern void udelay(unsigned long usecs);

#endif /* defined(_ARM_DELAY_H) */
/*
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/mm.h
--- a/xen/include/asm-arm/mm.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/mm.h Tue Mar 13 15:28:41 2012 +0000
@@ -136,6 +136,8 @@

/* Boot-time pagetable setup */
extern void setup_pagetables(unsigned long boot_phys_offset);
+/* MMU setup for seccondary CPUS (which already have paging enabled) */
+extern void __cpuinit mmu_init_secondary_cpu(void);
/* Set up the xenheap: up to 1GB of contiguous, always-mapped memory.
* Base must be 32MB aligned and size a multiple of 32MB. */
extern void setup_xenheap_mappings(unsigned long base_mfn, unsigned long nr_mfns);
@@ -276,6 +278,10 @@
#define memguard_guard_stack(_p) ((void)0)
#define memguard_guard_range(_p,_l) ((void)0)
#define memguard_unguard_range(_p,_l) ((void)0)
+
+/* Release all __init and __initdata ranges to be reused */
+void free_init_memory(void);
+
int guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
unsigned int order);

diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/page.h
--- a/xen/include/asm-arm/page.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/page.h Tue Mar 13 15:28:41 2012 +0000
@@ -203,6 +203,22 @@
}

/*
+ * Flush all hypervisor mappings from the TLB and branch predictor.
+ * This is needed after changing Xen code mappings.
+ */
+static inline void flush_xen_text_tlb(void)
+{
+ register unsigned long r0 asm ("r0");
+ asm volatile (
+ "dsb;" /* Ensure visibility of PTE writes */
+ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */
+ STORE_CP32(0, BPIALL) /* Flush branch predictor */
+ "dsb;" /* Ensure completion of TLB+BP flush */
+ "isb;"
+ : : "r" (r0) /*dummy*/ : "memory");
+}
+
+/*
* Flush all hypervisor mappings from the data TLB. This is not
* sufficient when changing code mappings or for self modifying code.
*/
diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/percpu.h
--- a/xen/include/asm-arm/percpu.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/percpu.h Tue Mar 13 15:28:41 2012 +0000
@@ -12,8 +12,11 @@
__attribute__((__section__(".bss.percpu" #suffix))) \
__typeof__(type) per_cpu_##name

-#define per_cpu(var, cpu) ((&per_cpu__##var)[cpu?0:0])
-#define __get_cpu_var(var) per_cpu__##var
+
+#define per_cpu(var, cpu) \
+ (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
+#define __get_cpu_var(var) \
+ (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))

#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name

diff -r 703a339e11ab -r d54cf3fa7ee6 xen/include/asm-arm/smp.h
--- a/xen/include/asm-arm/smp.h Tue Mar 13 15:23:35 2012 +0000
+++ b/xen/include/asm-arm/smp.h Tue Mar 13 15:28:41 2012 +0000
@@ -14,6 +14,8 @@

#define raw_smp_processor_id() (get_processor_id())

+extern void stop_cpu(void);
+
#endif
/*
* Local variables:

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog


patchbot at xen

Mar 14, 2012, 5:33 AM

Post #4 of 6 (86 views)
Permalink
[xen-unstable] Merge [In reply to]

# HG changeset patch
# User Ian Jackson <Ian.Jackson [at] eu>
# Date 1331654870 0
# Node ID 6ba199b5fd7f591dc6db3060e281986326d0d6da
# Parent e0d02f48a6123a137b8d9c91bbaa3d1963064b7f
# Parent b8a5e8100c5d5d4e162a99f4582186fa77080391
Merge
---


diff -r e0d02f48a612 -r 6ba199b5fd7f xen/arch/arm/traps.c
--- a/xen/arch/arm/traps.c Tue Mar 13 15:40:42 2012 +0000
+++ b/xen/arch/arm/traps.c Tue Mar 13 16:07:50 2012 +0000
@@ -367,7 +367,6 @@
}

typedef unsigned long arm_hypercall_t(
- unsigned int, unsigned int, unsigned int, unsigned int, unsigned int,
unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);

#define HYPERCALL(x) \
@@ -407,18 +406,30 @@

static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss)
{
+ arm_hypercall_t *call = NULL;
local_irq_enable();

- regs->r0 = arm_hypercall_table[iss](regs->r0,
- regs->r1,
- regs->r2,
- regs->r3,
- regs->r4,
- regs->r5,
- regs->r6,
- regs->r7,
- regs->r8,
- regs->r9);
+ if ( iss != XEN_HYPERCALL_TAG )
+ {
+ printk("%s %d: received an alien hypercall iss=%lx\n", __func__ ,
+ __LINE__ , iss);
+ regs->r0 = -EINVAL;
+ return;
+ }
+
+ call = arm_hypercall_table[regs->r12];
+ if ( call == NULL )
+ {
+ regs->r0 = -ENOSYS;
+ return;
+ }
+
+ regs->r0 = call(regs->r0, regs->r1, regs->r2, regs->r3, regs->r4);
+
+#ifndef NDEBUG
+ /* clobber registers */
+ regs->r1 = regs->r2 = regs->r3 = regs->r4 = regs->r12 = 0xDEADBEEF;
+#endif
}

static void do_cp15_32(struct cpu_user_regs *regs,
diff -r e0d02f48a612 -r 6ba199b5fd7f xen/include/public/arch-arm.h
--- a/xen/include/public/arch-arm.h Tue Mar 13 15:40:42 2012 +0000
+++ b/xen/include/public/arch-arm.h Tue Mar 13 16:07:50 2012 +0000
@@ -27,6 +27,29 @@
#ifndef __XEN_PUBLIC_ARCH_ARM_H__
#define __XEN_PUBLIC_ARCH_ARM_H__

+/* hypercall calling convention
+ * ----------------------------
+ *
+ * A hypercall is issued using the ARM HVC instruction.
+ *
+ * A hypercall can take up to 5 arguments. These are passed in
+ * registers, the first argument in r0, the second argument in r1, the
+ * third in r2, the forth in r3 and the fifth in r4.
+ *
+ * The hypercall number is passed in r12.
+ *
+ * The HVC ISS must contain a Xen specific TAG: XEN_HYPERCALL_TAG.
+ *
+ * The return value is in r0.
+ *
+ * The hypercall will always clobber r0, r1, r2, r3, r4 and r12,
+ * regardless of how many arguments the particular hypercall takes.
+ *
+ */
+
+#define XEN_HYPERCALL_TAG 0XEA1
+
+
#ifndef __ASSEMBLY__
#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
typedef struct { type *p; } __guest_handle_ ## name

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog


patchbot at xen

Mar 15, 2012, 9:33 PM

Post #5 of 6 (86 views)
Permalink
[xen-unstable] Merge [In reply to]

# HG changeset patch
# User Ian Jackson <Ian.Jackson [at] eu>
# Date 1331723017 0
# Node ID d7e4b0725e978368253ab2ae42a0d13b3ab8d9f1
# Parent 21376d9d27df8c50d56d7f8111a5e8136f569f2d
# Parent e0704f25593110469d08346e85804ae89ecd909e
Merge
---


diff -r 21376d9d27df -r d7e4b0725e97 .gitignore
--- a/.gitignore Wed Mar 14 11:03:13 2012 +0000
+++ b/.gitignore Wed Mar 14 11:03:37 2012 +0000
@@ -289,6 +289,8 @@
xen/.banner*
xen/BLOG
xen/System.map
+xen/arch/arm/asm-offsets.s
+xen/arch/arm/xen.lds
xen/arch/x86/asm-offsets.s
xen/arch/x86/boot/mkelf32
xen/arch/x86/xen.lds
diff -r 21376d9d27df -r d7e4b0725e97 .hgignore
--- a/.hgignore Wed Mar 14 11:03:13 2012 +0000
+++ b/.hgignore Wed Mar 14 11:03:37 2012 +0000
@@ -314,6 +314,8 @@
^xen/\.banner.*$
^xen/BLOG$
^xen/System.map$
+^xen/arch/arm/asm-offsets\.s$
+^xen/arch/arm/xen\.lds$
^xen/arch/x86/asm-offsets\.s$
^xen/arch/x86/boot/mkelf32$
^xen/arch/x86/xen\.lds$

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog


patchbot at xen

Mar 22, 2012, 2:33 PM

Post #6 of 6 (80 views)
Permalink
[xen-unstable] Merge [In reply to]

# HG changeset patch
# User Tim Deegan <tim [at] xen>
# Date 1332412005 0
# Node ID 8180cb3895af71d090fa82d66b012f1f65029055
# Parent 4347c2a26913b02e84c337a7969d8c4b33ab96ba
# Parent 6bf50858c3c5e2cc1e863336628111e00cbf09fc
Merge
---


diff -r 4347c2a26913 -r 8180cb3895af .hgignore
--- a/.hgignore Thu Mar 22 10:23:28 2012 +0000
+++ b/.hgignore Thu Mar 22 10:26:45 2012 +0000
@@ -289,6 +289,8 @@
^tools/xm-test/lib/XmTestLib/config.py$
^tools/xm-test/lib/XmTestReport/xmtest.py$
^tools/xm-test/tests/.*\.test$
+^tools/firmware/ovmf-remote
+^tools/firmware/ovmf$
^tools/qemu-xen-traditional-dir-remote
^tools/qemu-xen-traditional-dir$
^tools/qemu-xen-dir-remote
diff -r 4347c2a26913 -r 8180cb3895af Config.mk
--- a/Config.mk Thu Mar 22 10:23:28 2012 +0000
+++ b/Config.mk Thu Mar 22 10:26:45 2012 +0000
@@ -191,12 +191,15 @@
endif

ifeq ($(GIT_HTTP),y)
+OVMF_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/ovmf.git
QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-upstream-unstable.git
SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git
else
+OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git
QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-upstream-unstable.git
SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
endif
+OVMF_UPSTREAM_REVISION ?= b0855f925c6e2e0b21fbb03fab4b5fb5b6876871
QEMU_UPSTREAM_REVISION ?= master
SEABIOS_UPSTREAM_TAG ?= rel-1.6.3.2
# Sun Mar 11 09:27:07 2012 -0400
@@ -204,7 +207,7 @@

ETHERBOOT_NICS ?= rtl8139 8086100e

-CONFIG_OVMF ?= n
+CONFIG_OVMF ?= $(CONFIG_Linux)
CONFIG_ROMBIOS ?= y
CONFIG_SEABIOS ?= y

diff -r 4347c2a26913 -r 8180cb3895af docs/misc/xen-command-line.markdown
--- a/docs/misc/xen-command-line.markdown Thu Mar 22 10:23:28 2012 +0000
+++ b/docs/misc/xen-command-line.markdown Thu Mar 22 10:26:45 2012 +0000
@@ -8,7 +8,7 @@

Most parameters take the form `option=value`. Different options on the command line should be space delimited.

-### Boolean
+### Boolean (`<boolean>`)

All boolean option may be explicitly enabled using a `value` of
> `yes`, `on`, `true`, `enable` or `1`
@@ -29,11 +29,11 @@
Enable synchronous console mode
> `sync_console`

-### Integer
+### Integer (`<integer>`)

An integer parameter will default to decimal and may be prefixed with a `-` for negative numbers. Alternativly, a hexidecimal number may be used by prefixing the number with `0x`, or an octal number may be used if a leading `0` is present.

-### Size
+### Size (`<size>`)

A size parameter may be any integer, with a size suffix

@@ -96,7 +96,7 @@
### ats
### availmem
### badpage
-> `= List of [ <integer> | <ingeter>-<integer> ]`
+> `= List of [ <integer> | <integer>-<integer> ]`

Specify that certain pages, or certain ranges of pages contain bad bytes and should not be used. For example, if your memory tester says that byte `0x12345678` is bad, you would place `badpage=0x12345` on Xen's command line.

@@ -219,13 +219,22 @@
Specify the total size for dom0.

### dom0\_mem (x86)
-> `= List of ( min:<value> | max: <value> | <value> )`
+> `= List of ( min:<size> | max:<size> | <size> )`

-each `<value>` is a size parameter. If the size is positive, it represents an absolute value. If the size is negative, the size specified is subtracted from the total available memory.
+Set the amount of memory for the initial domain (dom0). If a size is
+positive, it represents an absolute value. If a size is negative, the
+size specified is subtracted from the total available memory.

-* `min:<value>` specifies the minimum amount of memory allocated to dom0.
-* `max:<value>` specifies the maximum amount of memory allocated to dom0.
-* `<value>` specified the exact amount of memory allocated to dom0.
+* `min:<size>` specifies the minimum amount of memory allocated to dom0.
+* `max:<size>` specifies the maximum amount of memory allocated to dom0.
+* `<size>` specified the exact amount of memory allocated to dom0.
+
+`max:<size>` also sets the maximum reservation (the maximum amount of
+memory dom0 can balloon up to). If this is omitted then the maximum
+reservation is unlimited.
+
+For example, to set dom0's memory to 512 MB but no more than 1 GB use
+`dom0_mem=512M,max:1G`.

### dom0\_shadow
### dom0\_vcpus\_pin
diff -r 4347c2a26913 -r 8180cb3895af tools/firmware/Makefile
--- a/tools/firmware/Makefile Thu Mar 22 10:23:28 2012 +0000
+++ b/tools/firmware/Makefile Thu Mar 22 10:26:45 2012 +0000
@@ -6,12 +6,17 @@
INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)

SUBDIRS-y :=
+SUBDIRS-$(CONFIG_OVMF) += ovmf
SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir
SUBDIRS-$(CONFIG_ROMBIOS) += rombios
SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
SUBDIRS-$(CONFIG_ROMBIOS) += etherboot
SUBDIRS-y += hvmloader

+ovmf:
+ GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf
+ cp ovmf-makefile ovmf/Makefile;
+
seabios-dir:
GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(SEABIOS_UPSTREAM_URL) $(SEABIOS_UPSTREAM_TAG) seabios-dir
cp seabios-config seabios-dir/.config;
@@ -44,9 +49,35 @@
subdir-distclean-etherboot: .phony
$(MAKE) -C etherboot distclean

+subdir-distclean-ovmf: .phony
+ rm -rf ovmf ovmf-remote
+
subdir-distclean-seabios-dir: .phony
rm -rf seabios-dir seabios-dir-remote

+.PHONY: ovmf-find
+ovmf-find:
+ if test -d $(OVMF_UPSTREAM_URL) ; then \
+ mkdir -p ovmf; \
+ else \
+ export GIT=$(GIT); \
+ $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf ; \
+ fi
+
+.PHONY: ovmf-force-update
+ovmf-force-update:
+ set -ex; \
+ if [ "$(OVMF_UPSTREAM_REVISION)" ]; then \
+ cd ovmf-remote; \
+ $(GIT) fetch origin; \
+ $(GIT) reset --hard $(OVMF_UPSTREAM_REVISION); \
+ fi
+
+subdir-clean-ovmf:
+ set -e; if test -d ovmf/.; then \
+ $(MAKE) -C ovmf clean; \
+ fi
+
.PHONY: seabios-dir-force-update
seabios-dir-force-update:
set -ex; \
diff -r 4347c2a26913 -r 8180cb3895af tools/firmware/ovmf-makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/ovmf-makefile Thu Mar 22 10:26:45 2012 +0000
@@ -0,0 +1,17 @@
+# OVMF building system is not ready yet to run in parallel.
+# Force it to be serial in order to exploit parallelism for neighbors.
+
+.NOTPARALLEL:
+MAKEFLAGS += -j1
+
+.PHONY: all
+all: ovmf.bin
+
+.PHONY: ovmf.bin
+ovmf.bin:
+ OvmfPkg/build.sh -a X64
+ cp Build/OvmfX64/DEBUG_GCC44/FV/OVMF.fd ovmf.bin
+
+.PHONY: clean
+clean:
+ rm -rf ovmf.bin Build/*

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog

Xen changelog RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.