xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas.lengyel@intel.com>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Tamas K Lengyel <tamas.lengyel@intel.com>, Wei Liu <wl@xen.org>
Subject: [PATCH v19 for-4.14 11/13] tools/libxl: Add VM forking public functions
Date: Mon,  1 Jun 2020 06:21:45 -0700	[thread overview]
Message-ID: <5c477725d701be72172a6aebf983a1bf956cec40.1591017086.git.tamas.lengyel@intel.com> (raw)
In-Reply-To: <cover.1591017086.git.tamas.lengyel@intel.com>

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
---
 tools/libxl/libxl.h        | 10 +++++++++
 tools/libxl/libxl_create.c | 44 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 71709dc585..79792d6e29 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2704,6 +2704,16 @@ static inline int libxl_qemu_monitor_command_0x041200(libxl_ctx *ctx,
  */
 int libxl_clear_domid_history(libxl_ctx *ctx);
 
+/*
+ * Experimental VM forking functions
+ */
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, 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;
 #endif /* LIBXL_H */
 
 /*
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 27f790cae1..9190e4e263 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -2339,6 +2339,50 @@ int libxl_domain_soft_reset(libxl_ctx *ctx,
                                 aop_console_how);
 }
 
+/*
+ * The parent domain is expected to be created with default settings for
+ * - max_evtch_port
+ * - max_grant_frames
+ * - max_maptrack_frames
+ */
+int libxl_domain_fork_vm(libxl_ctx *ctx, uint32_t pdomid, uint32_t *domid)
+{
+    int rc;
+    xc_dominfo_t info;
+    struct xen_domctl_createdomain create = {0};
+
+    if ( 1 != xc_domain_getinfo(ctx->xch, pdomid, 1, &info) )
+        return ERROR_INVAL;
+
+    if ( info.domid != pdomid || !info.hvm || !info.hap )
+        return ERROR_INVAL;
+
+    create.flags |= XEN_DOMCTL_CDF_hvm;
+    create.flags |= XEN_DOMCTL_CDF_hap;
+    create.flags |= XEN_DOMCTL_CDF_oos_off;
+    create.arch.emulation_flags = info.arch_config.emulation_flags;
+    create.ssidref = info.ssidref;
+    create.max_vcpus = info.max_vcpu_id + 1;
+    create.max_evtchn_port = 1023;
+    create.max_grant_frames = LIBXL_MAX_GRANT_FRAMES_DEFAULT;
+    create.max_maptrack_frames = LIBXL_MAX_MAPTRACK_FRAMES_DEFAULT;
+
+    if ( (rc = xc_domain_create(ctx->xch, domid, &create)) )
+        return rc;
+
+    if ( (rc = xc_memshr_fork(ctx->xch, pdomid, *domid, false, false)) )
+        xc_domain_destroy(ctx->xch, *domid);
+
+    return rc;
+}
+
+int libxl_domain_fork_launch_dm(libxl_ctx *ctx, libxl_domain_config *d_config,
+                                uint32_t domid,
+                                const libxl_asyncprogress_how *aop_console_how)
+{
+    return do_domain_create(ctx, d_config, &domid, -1, -1, 0, 0, aop_console_how);
+}
+
 /*
  * Local variables:
  * mode: C
-- 
2.25.1



  parent reply	other threads:[~2020-06-01 13:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 13:21 [PATCH v19 for-4.14 00/13] VM forking Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 01/13] x86/mem_sharing: block interrupt injection for forks Tamas K Lengyel
2020-06-02  7:43   ` Paul Durrant
2020-06-02 10:26   ` Wei Liu
2020-06-09 23:44   ` Tian, Kevin
     [not found]   ` <MWHPR11MB16457D9235F56F9F10BDFE358C820@MWHPR11MB1645.namprd11.prod.outlook.com>
2020-06-09 23:53     ` Tian, Kevin
2020-06-09 23:54       ` Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 02/13] tools/libxc: xc_memshr_fork with interrupts blocked Tamas K Lengyel
2020-06-02  7:44   ` Paul Durrant
2020-06-02 10:26   ` Wei Liu
2020-06-01 13:21 ` [PATCH v19 for-4.14 03/13] tools/libxl: Split libxl__domain_make Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 04/13] tools/libxl: populate xenstore entries when launching dm for VM fork Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 05/13] tools/libxl: Add checks for dm_restore_file Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 06/13] tools/libxl: adjust domcreate_bootloader_done Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 07/13] tools/libxl: Adjust libxl__build_pre Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 08/13] tools/libxl: Adjust libxl__build_post Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 09/13] tools/libxl: libxl__build_hvm_fork Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 10/13] tools/libxl: set QEMU saved_state from dm_restore_file Tamas K Lengyel
2020-06-01 13:21 ` Tamas K Lengyel [this message]
2020-06-01 13:21 ` [PATCH v19 for-4.14 12/13] tools/xl: Add xl fork-vm command Tamas K Lengyel
2020-06-01 13:21 ` [PATCH v19 for-4.14 13/13] tools/xl: document " Tamas K Lengyel
2020-06-01 15:07 ` [PATCH v19 for-4.14 00/13] VM forking Paul Durrant
2020-06-01 17:11   ` George Dunlap
2020-06-01 18:37     ` Tamas K Lengyel
2020-06-02  7:37       ` Paul Durrant
2020-06-02  9:38         ` Jan Beulich
2020-06-15 19:27           ` Tamas K Lengyel
2020-06-16  7:07             ` Jan Beulich
2020-06-16  8:32 ` Jan Beulich
2020-06-16 13:05   ` Tamas K Lengyel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c477725d701be72172a6aebf983a1bf956cec40.1591017086.git.tamas.lengyel@intel.com \
    --to=tamas.lengyel@intel.com \
    --cc=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).