libxl: Restore scheduling parameters after migrate in best-effort fashion
authorGeorge Dunlap <george.dunlap@citrix.com>
Wed, 10 Oct 2018 11:36:25 +0000 (12:36 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Wed, 10 Oct 2018 11:36:25 +0000 (12:36 +0100)
commit162fc8295f31240dc3670190a91e9bbc03b0d7be
tree0817bee3dbcdc275339f859c8639cb17f5b1f519
parent5e00f02763f66dbbf0c86eee333c798fa8565a19
libxl: Restore scheduling parameters after migrate in best-effort fashion

Commit 3b4adba ("tools/libxl: include scheduler parameters in the
output of xl list -l") added scheduling parameters to the set of
information collected by libxl_retrieve_domain_configuration(), in
order to report that information in `xl list -l`.

Unfortunately, libxl_retrieve_domain_configuration() is also called by
the migration / save code, and the results passed to the restore /
receive code.  This meant scheduler parameters were inadvertently
added to the migration stream, without proper consideration for how to
handle corner cases.  The result was that if migrating from a host
running one scheduler to a host running a different scheduler, the
migration would fail with an error like the following:

libxl: error: libxl_sched.c:232:sched_credit_domain_set: Domain 1:Getting domain sched credit: Invalid argument
libxl: error: libxl_create.c:1275:domcreate_rebuild_done: Domain 1:cannot (re-)build domain: -3

Luckily there's a fairly straightforward way to set parameters in a
"best-effort" fashion.  libxl provides a single struct containing the
parameters of all schedulers, as well as a parameter specifying which
scheduler.  Parameters not used by a given scheduler are ignored.
Additionally, the struct contains a parameter to specify the
scheduler.  If you specify a specific scheduler,
libxl_domain_sched_params_set() will fail if there's a different
scheduler.  However, if you pass LIBXL_SCHEDULER_UNKNOWN, it will use
the value of the current scheduler for that domain.

In domcreate_stream_done(), before calling libxl__build_post(), set
the scheduler to LIBXL_SCHEDULER_UNKNOWN.  This will propagate
scheduler parameters from the previous instantiation on a best-effort
basis.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_create.c