xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jaeyong Yoo <jaeyong.yoo@samsung.com>
To: xen-devel@lists.xen.org
Cc: Jaeyong Yoo <jaeyong.yoo@samsung.com>
Subject: [PATCH RFC 4/4] Implement XEN_DOMCTL_gethvmcontext part of arch_do_domctl
Date: Wed, 05 Jun 2013 14:46:19 +0900	[thread overview]
Message-ID: <1370411179-13570-5-git-send-email-jaeyong.yoo@samsung.com> (raw)
In-Reply-To: <1370411179-13570-1-git-send-email-jaeyong.yoo@samsung.com>

Signed-off-by: Jaeyong Yoo <jaeyong.yoo@samsung.com>
---
 xen/arch/arm/domctl.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index 851ee40..a1ff570 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -9,12 +9,68 @@
 #include <xen/lib.h>
 #include <xen/errno.h>
 #include <xen/sched.h>
+#include <xen/hvm/save.h>
+#include <xen/guest_access.h>
 #include <public/domctl.h>
 
 long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
                     XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
-    return -ENOSYS;
+    long ret = 0;
+    bool_t copyback = 0;
+    switch ( domctl->cmd )
+    {
+    case XEN_DOMCTL_gethvmcontext:
+    {
+        struct hvm_domain_context c = { 0 };
+
+        ret = -EINVAL;
+        if ( !is_hvm_domain(d) ) {
+            printk("Domain is not hvm... Just go on...\n");
+        } 
+
+        c.size = hvm_save_size(d);
+
+        if ( guest_handle_is_null(domctl->u.hvmcontext.buffer) )
+        {
+            /* Client is querying for the correct buffer size */
+            domctl->u.hvmcontext.size = c.size;
+            ret = 0;
+            goto gethvmcontext_out;
+        }
+
+        /* Check that the client has a big enough buffer */
+        ret = -ENOSPC;
+        if ( domctl->u.hvmcontext.size < c.size )
+            goto gethvmcontext_out;
+
+        /* Allocate our own marshalling buffer */
+        ret = -ENOMEM;
+        if ( (c.data = xmalloc_bytes(c.size)) == NULL )
+            goto gethvmcontext_out;
+
+        domain_pause(d);
+        ret = hvm_save(d, &c);
+        domain_unpause(d);
+
+        domctl->u.hvmcontext.size = c.cur;
+        if ( copy_to_guest(domctl->u.hvmcontext.buffer, c.data, c.size) != 0 )
+            ret = -EFAULT;
+
+    gethvmcontext_out:
+        copyback = 1;
+
+        if ( c.data != NULL )
+            xfree(c.data);
+    }
+    break;
+    default:
+        return -EINVAL;
+    }
+    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
+        ret = -EFAULT;
+
+    return ret;
 }
 
 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
-- 
1.7.9.5

  parent reply	other threads:[~2013-06-05  5:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05  5:46 [PATCH RFC 0/4] arm: regarding live migration Jaeyong Yoo
2013-06-05  5:46 ` [PATCH RFC 1/4] Create new directory for stroing hvm-related files in ARM Jaeyong Yoo
2013-06-05  5:46 ` [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions Jaeyong Yoo
2013-06-05  9:17   ` Ian Campbell
2013-06-05  5:46 ` [PATCH RFC 3/4] Implement save and restore for gic (template impl) Jaeyong Yoo
2013-06-05  9:21   ` Ian Campbell
2013-06-05  5:46 ` Jaeyong Yoo [this message]
2013-06-05  9:24   ` [PATCH RFC 4/4] Implement XEN_DOMCTL_gethvmcontext part of arch_do_domctl Ian Campbell
2013-06-05  9:13 ` [PATCH RFC 0/4] arm: regarding live migration Ian Campbell
2013-06-05  9:23   ` Ian Campbell
2013-06-05  9:26 ` Ian Campbell

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=1370411179-13570-5-git-send-email-jaeyong.yoo@samsung.com \
    --to=jaeyong.yoo@samsung.com \
    --cc=xen-devel@lists.xen.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).