From: Vitaly Kuznetsov Subject: [PATCH v5 5/9] libxc: support XEN_DOMCTL_devour Date: Thu, 11 Dec 2014 14:45:37 +0100 Message-ID: <1418305541-5135-6-git-send-email-vkuznets@redhat.com> References: <1418305541-5135-1-git-send-email-vkuznets@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xz44P-00005O-VN for xen-devel@lists.xenproject.org; Thu, 11 Dec 2014 13:46:18 +0000 In-Reply-To: <1418305541-5135-1-git-send-email-vkuznets@redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Andrew Jones , Julien Grall , Keir Fraser , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , Olaf Hering , Tim Deegan , David Vrabel , Jan Beulich , Wei Liu List-Id: xen-devel@lists.xenproject.org Introduce new xc_domain_devour() function to support XEN_DOMCTL_devour. Signed-off-by: Vitaly Kuznetsov --- tools/libxc/include/xenctrl.h | 14 ++++++++++++++ tools/libxc/xc_domain.c | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 0ad8b8d..a789de3 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -558,6 +558,20 @@ int xc_domain_unpause(xc_interface *xch, int xc_domain_destroy(xc_interface *xch, uint32_t domid); +/** + * This function sets a 'recipient' domain for a domain (when the source domain + * releases memory it is being reassigned to the recipient domain instead of + * being freed) and kills the original domain. The destination domain is supposed + * to have enough max_mem and no pages assigned. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the source domain id + * @parm recipient the destrination domain id + * @return 0 on success, -1 on failure + */ +int xc_domain_devour(xc_interface *xch, + uint32_t domid, uint32_t recipient); + /** * This function resumes a suspended domain. The domain should have diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index b864872..5949725 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -122,6 +122,19 @@ int xc_domain_destroy(xc_interface *xch, return ret; } +int xc_domain_devour(xc_interface *xch, uint32_t domid, uint32_t recipient) +{ + int ret; + DECLARE_DOMCTL; + domctl.cmd = XEN_DOMCTL_devour; + domctl.domain = (domid_t)domid; + domctl.u.devour.recipient = (domid_t)recipient; + do { + ret = do_domctl(xch, &domctl); + } while ( ret && (errno == EAGAIN) ); + return ret; +} + int xc_domain_shutdown(xc_interface *xch, uint32_t domid, int reason) -- 1.9.3