libxl: allow creation of domains with a specified or random domid
authorPaul Durrant <pdurrant@amazon.com>
Mon, 23 Dec 2019 17:16:20 +0000 (17:16 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 24 Feb 2020 17:17:35 +0000 (17:17 +0000)
commit4a3a25678d92d4e32b5ec6b9f255b465104c8d92
tree44ca5d203e2745cb7c3d239aa5fccc5894ac5a17
parent69ad573c2bbbce84d09bce988e7adc3cdafccc06
libxl: allow creation of domains with a specified or random domid

This patch adds a 'domid' field to libxl_domain_create_info and then
modifies libxl__domain_make() to have Xen use that value if it is valid.
If the domid value is invalid then Xen will choose the domid, as before,
unless the value is the new special RANDOM_DOMID value added to the API.
This value instructs libxl__domain_make() to choose a random domid value
for Xen to use.

If Xen determines that a domid specified to or chosen by
libxl__domain_make() co-incides with an existing domain then the create
operation will fail. In this case, if RANDOM_DOMID was specified to
libxl__domain_make() then a new random value will be chosen and the create
operation will be re-tried, otherwise libxl__domain_make() will fail.

After Xen has successfully created a new domain, libxl__domain_make() will
check whether its domid matches any recently used domid values. If it does
then the domain will be destroyed. If the domid used in creation was
specified to libxl__domain_make() then it will fail at this point,
otherwise the create operation will be re-tried with either a new random
or Xen-selected domid value.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.h
tools/libxl/libxl_create.c
tools/libxl/libxl_types.idl