Skip to contentSkip to conversation

xen/tools: VM forking toolstack side

PATCH Superseded Tamas K Lengyel 3 participants 11 messages Apr 6, 2020 – Apr 27, 2020 1 message not in the archive

v14 of 19 Superseded Latest is v19 →

lore
Share & tools
lore
#1 lore raw

PATCH v14 3/3 xen/tools: VM forking toolstack side

In reply to a message not in the archive

Add necessary bits to implement "xl fork-vm" commands. The command allows the user to specify how to launch the device model allowing for a late-launch model in which the user can execute the fork without the device model and decide to only later launch it.

---
 docs/man/xl.1.pod.in          |  44 +++++
 tools/libxc/include/xenctrl.h |  13 ++
 tools/libxc/xc_memshr.c       |  22 +++
 tools/libxl/libxl.h           |  11 ++
 tools/libxl/libxl_create.c    | 361 +++++++++++++++++++---------------
 tools/libxl/libxl_dm.c        |   2 +-
 tools/libxl/libxl_dom.c       |  43 +++-
 tools/libxl/libxl_internal.h  |   7 +
 tools/libxl/libxl_types.idl   |   1 +
 tools/libxl/libxl_x86.c       |  41 ++++
 tools/xl/Makefile             |   2 +-
 tools/xl/xl.h                 |   5 +
 tools/xl/xl_cmdtable.c        |  15 ++
 tools/xl/xl_forkvm.c          | 144 ++++++++++++++
 tools/xl/xl_vmcontrol.c       |  14 ++
 15 files changed, 559 insertions(+), 166 deletions(-)
 create mode 100644 tools/xl/xl_forkvm.c
docs/man/xl.1.pod.in +44 -0
index 09339282e6..59c03c6427 100644
@@ -708,6 +708,50 @@ above).
 
 =back
 
+=item B<fork-vm> [I<OPTIONS>] I<domain-id>
+
+Create a fork of a running VM.  The domain will be paused after the operation
+and remains paused while forks of it exist.  Experimental and x86 only.
+Forks can only be made of domains with HAP enabled and on Intel hardware.  The
+parent domain must be created with the xl toolstack and its configuration must
+not manually define max_grant_frames, max_maptrack_frames or max_event_channels.
+
+B<OPTIONS>
+
+=over 4
+
+=item B<-p>
+
+Leave the fork paused after creating it.
+
+=item B<--launch-dm>
+
+Specify whether the device model (QEMU) should be launched for the fork. Late
+launch allows to start the device model for an already running fork.
+
+=item B<-C>
+
+The config file to use when launching the device model.  Currently required when
+launching the device model.  Most config settings MUST match the parent domain
+exactly, only change VM name, disk path and network configurations.
+
+=item B<-Q>
+
+The path to the qemu save file to use when launching the device model.  Currently
+required when launching the device model.
+
+=item B<--fork-reset>
+
+Perform a reset operation of an already running fork.  Note that resetting may
+be less performant then creating a new fork depending on how much memory the
+fork has deduplicated during its runtime.
+
+=item B<--max-vcpus>
+
+Specify the max-vcpus matching the parent domain when not launching the dm.
+
+=back
+
 =item B<sharing> [I<domain-id>]
 
 Display the number of shared pages for a specified domain. If no domain is
tools/libxc/include/xenctrl.h +13 -0
index 58fa931de1..631750a242 100644
@@ -2225,6 +2225,19 @@ int xc_memshr_range_share(xc_interface *xch,
                           uint64_t first_gfn,
                           uint64_t last_gfn);
 
+int xc_memshr_fork(xc_interface *xch,
+                   uint32_t source_domain,
+                   uint32_t client_domain);
+
+/*
+ * Note: this function is only intended to be used on short-lived forks that
+ * haven't yet aquired a lot of memory. In case the fork has a lot of memory
+ * it is likely more performant to create a new fork with xc_memshr_fork.
+ *
+ * With VMs that have a lot of memory this call may block for a long time.
+ */
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain);
+
 /* Debug calls: return the number of pages referencing the shared frame backing
  * the input argument. Should be one or greater.
  *
tools/libxc/xc_memshr.c +22 -0
index 97e2e6a8d9..d0e4ee225b 100644
@@ -239,6 +239,28 @@ int xc_memshr_debug_gref(xc_interface *xch,
     return xc_memshr_memop(xch, domid, &mso);
 }
 
+int xc_memshr_fork(xc_interface *xch, uint32_t pdomid, uint32_t domid)
+{
+    xen_mem_sharing_op_t mso;
+
+    memset(&mso, 0, sizeof(mso));
+
+    mso.op = XENMEM_sharing_op_fork;
+    mso.u.fork.parent_domain = pdomid;
+
+    return xc_memshr_memop(xch, domid, &mso);
+}
+
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t domid)
+{
+    xen_mem_sharing_op_t mso;
+
+    memset(&mso, 0, sizeof(mso));
+    mso.op = XENMEM_sharing_op_fork_reset;
+
+    return xc_memshr_memop(xch, domid, &mso);
+}
+
 int xc_memshr_audit(xc_interface *xch)
 {
     xen_mem_sharing_op_t mso;
tools/libxl/libxl.h +11 -0
index 71709dc585..088e81c78b 100644
@@ -2666,6 +2666,17 @@ int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
                           unsigned int lvl, unsigned int *nr,
                           libxl_psr_hw_info **info);
 void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
+
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_domain_fork_launch_dm(libxl_ctx *ctx, libxl_domain_config *d_config,
+                                uint32_t domid,
+                                const libxl_asyncprogress_how *aop_console_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_domain_fork_reset(libxl_ctx *ctx, uint32_t domid)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
 #endif
 
 /* misc */
tools/libxl/libxl_create.c +204 -157

482 lines not on this page · raw message

tools/libxl/libxl_dm.c +1 -1
index f4007bbe50..b615f1fc88 100644
@@ -2803,7 +2803,7 @@ static void device_model_spawn_outcome(libxl__egc *egc,
 
     libxl__domain_build_state *state = dmss->build_state;
 
-    if (state->saved_state) {
+    if (state->saved_state && !state->forked_vm) {
         ret2 = unlink(state->saved_state);
         if (ret2) {
             LOGED(ERROR, dmss->guest_domid, "%s: failed to remove device-model state %s",
tools/libxl/libxl_dom.c +36 -7

105 lines not on this page · raw message

tools/libxl/libxl_internal.h +7 -0
index 5f39e44cb9..d05ff31e83 100644
@@ -1374,6 +1374,7 @@ typedef struct {
 
     char *saved_state;
     int dm_monitor_fd;
+    bool forked_vm;
 
     libxl__file_reference pv_kernel;
     libxl__file_reference pv_ramdisk;
@@ -4818,6 +4819,12 @@ _hidden int libxl__domain_pvcontrol(libxl__egc *egc,
 /* Check whether a domid is recent */
 int libxl__is_domid_recent(libxl__gc *gc, uint32_t domid, bool *recent);
 
+_hidden int libxl__do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
+                                    uint32_t *domid, int restore_fd, int send_back_fd,
+                                    const libxl_domain_restore_params *params,
+                                    const libxl_asyncop_how *ao_how,
+                                    const libxl_asyncprogress_how *aop_console_how);
+
 #endif
 
 /*
tools/libxl/libxl_types.idl +1 -0
index f7c473be74..2bb5e6319e 100644
@@ -958,6 +958,7 @@ libxl_domain_config = Struct("domain_config", [
     ("on_watchdog", libxl_action_on_shutdown),
     ("on_crash", libxl_action_on_shutdown),
     ("on_soft_reset", libxl_action_on_shutdown),
+    ("dm_restore_file", string, {'const': True}),
     ], dir=DIR_IN)
 
 libxl_diskinfo = Struct("diskinfo", [
tools/libxl/libxl_x86.c +41 -0

53 lines not on this page · raw message

tools/xl/Makefile +1 -1
index af4912e67a..073222233b 100644
@@ -15,7 +15,7 @@ LDFLAGS += $(PTHREAD_LDFLAGS)
 CFLAGS_XL += $(CFLAGS_libxenlight)
 CFLAGS_XL += -Wshadow
 
-XL_OBJS-$(CONFIG_X86) = xl_psr.o
+XL_OBJS-$(CONFIG_X86) = xl_psr.o xl_forkvm.o
 XL_OBJS = xl.o xl_cmdtable.o xl_sxp.o xl_utils.o $(XL_OBJS-y)
 XL_OBJS += xl_parse.o xl_cpupool.o xl_flask.o
 XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
tools/xl/xl.h +5 -0
index 06569c6c4a..1105c34b15 100644
@@ -31,6 +31,7 @@ struct cmd_spec {
 };
 
 struct domain_create {
+    uint32_t ddomid; /* fork launch dm for this domid */
     int debug;
     int daemonize;
     int monitor; /* handle guest reboots etc */
@@ -45,6 +46,7 @@ struct domain_create {
     const char *config_file;
     char *extra_config; /* extra config string */
     const char *restore_file;
+    const char *dm_restore_file;
     char *colo_proxy_script;
     bool userspace_colo_proxy;
     int migrate_fd; /* -1 means none */
@@ -128,6 +130,8 @@ int main_pciassignable_remove(int argc, char **argv);
 int main_pciassignable_list(int argc, char **argv);
 #ifndef LIBXL_HAVE_NO_SUSPEND_RESUME
 int main_restore(int argc, char **argv);
+int main_fork_launch_dm(int argc, char **argv);
+int main_fork_reset(int argc, char **argv);
 int main_migrate_receive(int argc, char **argv);
 int main_save(int argc, char **argv);
 int main_migrate(int argc, char **argv);
@@ -212,6 +216,7 @@ int main_psr_cat_cbm_set(int argc, char **argv);
 int main_psr_cat_show(int argc, char **argv);
 int main_psr_mba_set(int argc, char **argv);
 int main_psr_mba_show(int argc, char **argv);
+int main_fork_vm(int argc, char **argv);
 #endif
 int main_qemu_monitor_command(int argc, char **argv);
 
tools/xl/xl_cmdtable.c +15 -0
index 08335394e5..ef634abf32 100644
@@ -187,6 +187,21 @@ struct cmd_spec cmd_table[] = {
       "Restore a domain from a saved state",
       "- for internal use only",
     },
+#if defined(__i386__) || defined(__x86_64__)
+    { "fork-vm",
+      &main_fork_vm, 0, 1,
+      "Fork a domain from the running parent domid. Experimental. Most config settings must match parent.",
+      "[options] <Domid>",
+      "-h                           Print this help.\n"
+      "-C <config>                  Use config file for VM fork.\n"
+      "-Q <qemu-save-file>          Use qemu save file for VM fork.\n"
+      "--launch-dm <yes|no|late>    Launch device model (QEMU) for VM fork.\n"
+      "--fork-reset                 Reset VM fork.\n"
+      "--max-vcpus                  Specify max-vcpus matching the parent domain when not launching dm\n"
+      "-p                           Do not unpause fork VM after operation.\n"
+      "-d                           Enable debug messages.\n"
+    },
+#endif
 #endif
     { "dump-core",
       &main_dump_core, 0, 1,
tools/xl/xl_forkvm.c new file +144 -0

144 lines not on this page · raw message

tools/xl/xl_vmcontrol.c +14 -0
index 2e2d427492..782fbbc24b 100644
@@ -676,6 +676,12 @@ int create_domain(struct domain_create *dom_info)
 
     int restoring = (restore_file || (migrate_fd >= 0));
 
+#if defined(__i386__) || defined(__x86_64__)
+    /* VM forking */
+    uint32_t ddomid = dom_info->ddomid; // launch dm for this domain iff set
+    const char *dm_restore_file = dom_info->dm_restore_file;
+#endif
+
     libxl_domain_config_init(&d_config);
 
     if (restoring) {
@@ -926,6 +932,14 @@ start:
          * restore/migrate-receive it again.
          */
         restoring = 0;
+#if defined(__i386__) || defined(__x86_64__)
+    } else if ( ddomid ) {
+        d_config.dm_restore_file = dm_restore_file;
+        ret = libxl_domain_fork_launch_dm(ctx, &d_config, ddomid,
+                                          autoconnect_console_how);
+        domid = ddomid;
+        ddomid = INVALID_DOMID;
+#endif
     } else if (domid_soft_reset != INVALID_DOMID) {
         /* Do soft reset. */
         ret = libxl_domain_soft_reset(ctx, &d_config, domid_soft_reset,
Signature · 1 line
2.20.1
#2 lore raw
Quoted 7 lines · Tamas K Lengyel

Add necessary bits to implement "xl fork-vm" commands. The command allows the user to specify how to launch the device model allowing for a late-launch model in which the user can execute the fork without the device model and decide to only later launch it.

---

[...]

tools/libxl/libxl_create.c retry_transaction: · line 738

Quoted 4 lines
tools/libxl/libxl_create.c +3 -0
+int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
+                       libxl__domain_build_state *state,
+                       uint32_t *domid, bool soft_reset)

It would have been nice if you could split the refactoring out to a separate patch.

Quoted 13 lines

static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *b_info)
{

tools/libxl/libxl_create.c +2 -4
@@ -1191,16 +1207,32 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_config_setdefault(gc,d_config,domid);
     if (ret) goto error_out;
 
-    ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
-                             dcs->soft_reset);
-    if (ret) {
-        LOGD(ERROR, domid, "cannot make domain: %d", ret);
+    if ( !d_config->dm_restore_file )
+    {

tools/libxl/libxl_create.c static void initiate_domain_create(libxl__egc *egc, · line 1221

Quoted 10 lines
tools/libxl/libxl_create.c +9 -0
+        ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
+                                 dcs->soft_reset);
         dcs->guest_domid = domid;
+
+        if (ret) {
+            LOGD(ERROR, domid, "cannot make domain: %d", ret);
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
+    } else if ( dcs->guest_domid != INVALID_DOMID ) {

Coding style issue here.

There are quite a few of them. I won't point them out one by one though. Let's focus on the interface first.

Quoted 7 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Wei.

#3 lore raw
Quoted 9 lines · Wei Liu
Quoted 7 lines · Tamas K Lengyel

Add necessary bits to implement "xl fork-vm" commands. The command allows the user to specify how to launch the device model allowing for a late-launch model in which the user can execute the fork without the device model and decide to only later launch it.

---

Quoted 8 lines

[...]

tools/libxl/libxl_create.c retry_transaction: · line 738

Quoted 4 lines
tools/libxl/libxl_create.c +3 -0
+int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
+                       libxl__domain_build_state *state,
+                       uint32_t *domid, bool soft_reset)

It would have been nice if you could split the refactoring out to a separate patch.

I found the toolstack to be way harder to work with then the hypervisor code-base. Splitting the patches would have been nice but I don't even know how to begin that since it's all such a spaghetti.

Quoted 27 lines
Quoted 14 lines

static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *b_info)
{

tools/libxl/libxl_create.c +2 -4
@@ -1191,16 +1207,32 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_config_setdefault(gc,d_config,domid);
     if (ret) goto error_out;
 
-    ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
-                             dcs->soft_reset);
-    if (ret) {
-        LOGD(ERROR, domid, "cannot make domain: %d", ret);
+    if ( !d_config->dm_restore_file )
+    {

tools/libxl/libxl_create.c static void initiate_domain_create(libxl__egc *egc, · line 1221

Quoted 10 lines
tools/libxl/libxl_create.c +9 -0
+        ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
+                                 dcs->soft_reset);
         dcs->guest_domid = domid;
+
+        if (ret) {
+            LOGD(ERROR, domid, "cannot make domain: %d", ret);
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
+    } else if ( dcs->guest_domid != INVALID_DOMID ) {

Coding style issue here.

Quoted 2 lines

There are quite a few of them. I won't point them out one by one though. Let's focus on the interface first.

Do we have an automatic formatter we could just run on this code-base? I don't know what style issue you are referring to and given that the coding style here is different here compared to the hypervisor I find it very hard to figure it out what other issues you spotted. Please report them because I won't be able to spot them manually. To me it all looks fine as-is.

Quoted 21 lines
Quoted 7 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Tamas

#4 lore raw
Quoted 16 lines · Tamas K Lengyel
Quoted 15 lines · Wei Liu
Quoted 7 lines · Tamas K Lengyel

Add necessary bits to implement "xl fork-vm" commands. The command allows the user to specify how to launch the device model allowing for a late-launch model in which the user can execute the fork without the device model and decide to only later launch it.

---

[...]

Quoted 4 lines
tools/libxl/libxl_create.c +3 -0
+int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
+                       libxl__domain_build_state *state,
+                       uint32_t *domid, bool soft_reset)
Quoted 6 lines
Quoted 2 lines

It would have been nice if you could split the refactoring out to a separate patch.

I found the toolstack to be way harder to work with then the hypervisor code-base. Splitting the patches would have been nice but I don't even know how to begin that since it's all such a spaghetti.

In this case you've split out some code from a function to make a new function. That is a self-contained task, which can be in its own patch.

Quoted 31 lines
Quoted 28 lines
Quoted 15 lines

static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *b_info)
{

tools/libxl/libxl_create.c +2 -4
@@ -1191,16 +1207,32 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_config_setdefault(gc,d_config,domid);
     if (ret) goto error_out;
 
-    ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
-                             dcs->soft_reset);
-    if (ret) {
-        LOGD(ERROR, domid, "cannot make domain: %d", ret);
+    if ( !d_config->dm_restore_file )
+    {

tools/libxl/libxl_create.c static void initiate_domain_create(libxl__egc *egc, · line 1221

Quoted 10 lines
tools/libxl/libxl_create.c +9 -0
+        ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
+                                 dcs->soft_reset);
         dcs->guest_domid = domid;
+
+        if (ret) {
+            LOGD(ERROR, domid, "cannot make domain: %d", ret);
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
+    } else if ( dcs->guest_domid != INVALID_DOMID ) {

Coding style issue here.

Quoted 2 lines

There are quite a few of them. I won't point them out one by one though. Let's focus on the interface first.

Quoted 6 lines

Do we have an automatic formatter we could just run on this code-base? I don't know what style issue you are referring to and given that the coding style here is different here compared to the hypervisor I find it very hard to figure it out what other issues you spotted. Please report them because I won't be able to spot them manually. To me it all looks fine as-is.

I feel your pain. There was work in progress to provide a style checker, but we're not there yet.

Xen and libxc share one coding style while libxl and xl share another. There is a CODING_STYLE file under libxl directory. The problem here is you should not have spaces inside ().

Generally I think pointing out coding style issues tend to distract people from discussing more important things, so I would leave them last to fix.

Quoted 28 lines
Quoted 22 lines
Quoted 8 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

I can see two solutions: 1. batch forking to reduce the number of queries needed; 2. make a proper domctl which duplicates the source domain structure inside Xen.

Both of these require extra work. I think option 2 is better. But this is not asking you to do the work now. See below.

While we want to make libxl APIs stable, we've had cases like COLO which we explicitly declared unstable. Seeing this is a niche feature, this probably falls into the same category. In that case we reserve the right to rework the interface when necessary.

Ian and Anthony, your opinions?

Wei.

Quoted 2 lines

Tamas

#5 lore raw
Quoted 69 lines · Wei Liu
Quoted 16 lines · Tamas K Lengyel
Quoted 15 lines · Wei Liu
Quoted 7 lines · Tamas K Lengyel

Add necessary bits to implement "xl fork-vm" commands. The command allows the user to specify how to launch the device model allowing for a late-launch model in which the user can execute the fork without the device model and decide to only later launch it.

---

[...]

Quoted 4 lines
tools/libxl/libxl_create.c +3 -0
+int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
+                       libxl__domain_build_state *state,
+                       uint32_t *domid, bool soft_reset)
Quoted 6 lines
Quoted 2 lines

It would have been nice if you could split the refactoring out to a separate patch.

I found the toolstack to be way harder to work with then the hypervisor code-base. Splitting the patches would have been nice but I don't even know how to begin that since it's all such a spaghetti.

In this case you've split out some code from a function to make a new function. That is a self-contained task, which can be in its own patch.

Quoted 31 lines
Quoted 28 lines
Quoted 15 lines

static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *b_info)
{

tools/libxl/libxl_create.c +2 -4
@@ -1191,16 +1207,32 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_config_setdefault(gc,d_config,domid);
     if (ret) goto error_out;
 
-    ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
-                             dcs->soft_reset);
-    if (ret) {
-        LOGD(ERROR, domid, "cannot make domain: %d", ret);
+    if ( !d_config->dm_restore_file )
+    {

tools/libxl/libxl_create.c static void initiate_domain_create(libxl__egc *egc, · line 1221

Quoted 10 lines
tools/libxl/libxl_create.c +9 -0
+        ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid,
+                                 dcs->soft_reset);
         dcs->guest_domid = domid;
+
+        if (ret) {
+            LOGD(ERROR, domid, "cannot make domain: %d", ret);
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
+    } else if ( dcs->guest_domid != INVALID_DOMID ) {

Coding style issue here.

Quoted 2 lines

There are quite a few of them. I won't point them out one by one though. Let's focus on the interface first.

Quoted 6 lines

Do we have an automatic formatter we could just run on this code-base? I don't know what style issue you are referring to and given that the coding style here is different here compared to the hypervisor I find it very hard to figure it out what other issues you spotted. Please report them because I won't be able to spot them manually. To me it all looks fine as-is.

I feel your pain. There was work in progress to provide a style checker, but we're not there yet.

Quoted 7 lines

Xen and libxc share one coding style while libxl and xl share another. There is a CODING_STYLE file under libxl directory. The problem here is you should not have spaces inside ().

Generally I think pointing out coding style issues tend to distract people from discussing more important things, so I would leave them last to fix.

I agree. I would highly prefer if we would get to a spot where they wouldn't even have to be pointed out other then "run this command to fix up the style". I submitted an astyle template already for Xen, others prefer clang to do it, yet it's been like a year and doesn't look like we will go anywhere with either. Just a waste of time IMHO.

Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 4 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

Quoted 4 lines

I can see two solutions: 1. batch forking to reduce the number of queries needed; 2. make a proper domctl which duplicates the source domain structure inside Xen.

I've attempted to do that by extending the domain create hypercall so that this information can be copied in the hypervisor. That approach was very unpopular.

Quoted 8 lines

Both of these require extra work. I think option 2 is better. But this is not asking you to do the work now. See below.

While we want to make libxl APIs stable, we've had cases like COLO which we explicitly declared unstable. Seeing this is a niche feature, this probably falls into the same category. In that case we reserve the right to rework the interface when necessary.

I'm fine with making this declared unstable. The hypervisor side bits are also declared experimental and aren't even compiled in the normal case.

Thanks,
Tamas

#6 lore raw

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

Quoted 10 lines
Quoted 5 lines

I can see two solutions: 1. batch forking to reduce the number of queries needed; 2. make a proper domctl which duplicates the source domain structure inside Xen.

I've attempted to do that by extending the domain create hypercall so that this information can be copied in the hypervisor. That approach was very unpopular.

Sigh. Sorry I haven't had the chance to read previous discussions. -ETIME.

Wei.

#7 lore raw
Quoted 60 lines · Wei Liu

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
tools/libxl/libxl_x86.c +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

tools/libxl/libxl_x86.c int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, · line 861

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

Quoted 3 lines

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

I agree. It's not how I wanted to have the interface work but unfortunately this was the least "ugly" of the possible solutions given the circumstances.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

I can see two solutions: 1. batch forking to reduce the number of queries needed; 2. make a proper domctl which duplicates the source domain structure inside Xen.

Quoted 7 lines
Quoted 4 lines

I've attempted to do that by extending the domain create hypercall so that this information can be copied in the hypervisor. That approach was very unpopular.

Sigh. Sorry I haven't had the chance to read previous discussions. -ETIME.

Sigh indeed.

Tamas

#8 lore raw
Quoted 62 lines · Tamas K Lengyel
Quoted 60 lines · Wei Liu

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
(quoted diff) +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

Review

Quoted 10 lines
(quoted diff) +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

Quoted 7 lines
Quoted 3 lines

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

I agree. It's not how I wanted to have the interface work but unfortunately this was the least "ugly" of the possible solutions given the circumstances.

By the way, it would be trivial to query the parent in case max_vcpus is not provided by the user. But I would still like to keep the option available to skip that step if the number is known already. Let me know if you would like me to add that.

Thanks,
Tamas

#9 lore raw
Quoted 68 lines · Tamas K Lengyel
Quoted 66 lines · Tamas K Lengyel
Quoted 63 lines · Wei Liu

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
(quoted diff) +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

Review

Quoted 10 lines
(quoted diff) +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

Quoted 8 lines
Quoted 3 lines

I agree. It's not how I wanted to have the interface work but unfortunately this was the least "ugly" of the possible solutions given the circumstances.

By the way, it would be trivial to query the parent in case max_vcpus is not provided by the user. But I would still like to keep the option available to skip that step if the number is known already. Let me know if you would like me to add that.

I'm still waiting for Ian and Anthony to chime in to see whether they agree to keep this interface unstable.

At the end of the day, if it is unstable, I don't really care that much. I'm happy to let you (the developer and user) have more say in that case. I will instead divert my (limited) time to code that your patch touches which is also used by other stable functions.

Wei.

Quoted 3 lines

Thanks,
Tamas

#10 lore raw
Quoted 79 lines · Wei Liu
Quoted 68 lines · Tamas K Lengyel
Quoted 66 lines · Tamas K Lengyel
Quoted 63 lines · Wei Liu

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
(quoted diff) +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

Review

Quoted 10 lines
(quoted diff) +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

Quoted 8 lines
Quoted 3 lines

I agree. It's not how I wanted to have the interface work but unfortunately this was the least "ugly" of the possible solutions given the circumstances.

By the way, it would be trivial to query the parent in case max_vcpus is not provided by the user. But I would still like to keep the option available to skip that step if the number is known already. Let me know if you would like me to add that.

Quoted 7 lines

I'm still waiting for Ian and Anthony to chime in to see whether they agree to keep this interface unstable.

At the end of the day, if it is unstable, I don't really care that much. I'm happy to let you (the developer and user) have more say in that case. I will instead divert my (limited) time to code that your patch touches which is also used by other stable functions.

SGTM

Thanks,
Tamas

#11 lore raw
Quoted 83 lines · Tamas K Lengyel
Quoted 82 lines · Wei Liu
Quoted 68 lines · Tamas K Lengyel
Quoted 66 lines · Tamas K Lengyel
Quoted 63 lines · Wei Liu

On Thu, Apr 09, 2020 at 10:59:55AM -0600, Tamas K Lengyel wrote:
[...]

Quoted 45 lines
Quoted 35 lines
Quoted 29 lines
Quoted 23 lines
Quoted 9 lines
(quoted diff) +6 -0
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */

Review

Quoted 10 lines
(quoted diff) +10 -0
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t max_vcpus, uint32_t *domid)
+{
+    int rc;
+    struct xen_domctl_createdomain create = {0};
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+    create.ssidref = SECINITSID_DOMU;
+    create.max_vcpus = max_vcpus;

Some questions:

Quoted 5 lines

Why does the caller need to specify the number of vcpus?

Since the parent (source) domain is around, can you retrieve its domain configuration such that you know its max_vcpus and other information including max_evtchn_port and maptrack frames?

Quoted 5 lines

Because we want to avoid having to issue an extra hypercall for these. Normally these pieces of information will be available for the user and won't change, so we save time by not querying for it every time a fork is created. Remember, we might be creating thousands of forks in a very short time, so those extra hypercalls add up.

Quoted 5 lines

I see. Speed is a big concern to you.

What I was referring to doesn't require issuing hypercalls but requires calling libxl_retrieve_domain_configuration. That's likely to be even slower than making a hypercall.

Right. We only want to parse the domain config if the device model is being launched.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

I'm afraid the current incarnation of libxl_domain_fork_vm cannot become supported (as in Xen's support statement) going forward, because it is leaky.

What do you mean by leaky?

It requires the caller to specify the number of max_vcpus. The reason for doing that is because you want to avoid extra hypercall(s). There is nothing that stops someone from coming along in the future claiming some other parameters are required because of the same concern you have today. It is an optimisation, not a must-have in terms of functionality.

To me the number shouldn't be specified by the caller in the first place. It is like forking a process somehow requires you to specify how many threads it will have.

Quoted 8 lines
Quoted 3 lines

I agree. It's not how I wanted to have the interface work but unfortunately this was the least "ugly" of the possible solutions given the circumstances.

By the way, it would be trivial to query the parent in case max_vcpus is not provided by the user. But I would still like to keep the option available to skip that step if the number is known already. Let me know if you would like me to add that.

I'm still waiting for Ian and Anthony to chime in to see whether they agree to keep this interface unstable.

Quoted 6 lines
Quoted 4 lines

At the end of the day, if it is unstable, I don't really care that much. I'm happy to let you (the developer and user) have more say in that case. I will instead divert my (limited) time to code that your patch touches which is also used by other stable functions.

SGTM

Ian and Anthony, your opinions?

Wei.