From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brendan Cully Subject: Re: [PATCH 3 of 7] Make suspend return 1 when a domain is resumed Date: Fri, 19 Jan 2007 16:22:33 -0800 Message-ID: <20070120002233.GC3732@ventoux.cs.ubc.ca> References: <477813c50e5db59ae08d.1168891513@ventoux.cs.ubc.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LyciRD1jyfeSSjG0" Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --LyciRD1jyfeSSjG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Friday, 19 January 2007 at 15:32, Keir Fraser wrote: > xc_set_vcpucontext() is a nice thing to have, but it belongs in xc_domain.c > and it would be great if all direct users of the domctl could be ported to > use it. I'd gladly take that patch. :-) Here's the cleanup patch. lock_pages happens later now (just before the domctl). If that matters, I think it's harmless to leave the original call in, so that mlock would get called twice. --LyciRD1jyfeSSjG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xc-use-vcpu_setcontext.patch" # HG changeset patch # User Brendan Cully # Date 1169252138 28800 # Node ID 2048d2698d461070786a655e7d0d24f015b6cb8b # Parent f89126a590738ad804463772230dde0b4a6640ba Use xc_vcpu_setcontext instead of the lowlevel domctl. Signed-off-by: Brendan Cully diff -r f89126a59073 -r 2048d2698d46 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c Fri Jan 19 16:11:31 2007 +0000 +++ b/tools/libxc/xc_hvm_build.c Fri Jan 19 16:15:38 2007 -0800 @@ -270,7 +270,6 @@ static int xc_hvm_build_internal(int xc_ char *image, unsigned long image_size) { - struct xen_domctl launch_domctl; vcpu_guest_context_t ctxt; int rc; @@ -287,20 +286,7 @@ static int xc_hvm_build_internal(int xc_ goto error_out; } - if ( lock_pages(&ctxt, sizeof(ctxt) ) ) - { - PERROR("%s: ctxt mlock failed", __func__); - goto error_out; - } - - memset(&launch_domctl, 0, sizeof(launch_domctl)); - launch_domctl.domain = (domid_t)domid; - launch_domctl.u.vcpucontext.vcpu = 0; - set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, &ctxt); - launch_domctl.cmd = XEN_DOMCTL_setvcpucontext; - rc = xc_domctl(xc_handle, &launch_domctl); - - unlock_pages(&ctxt, sizeof(ctxt)); + rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt); return rc; diff -r f89126a59073 -r 2048d2698d46 tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Fri Jan 19 16:11:31 2007 +0000 +++ b/tools/libxc/xc_linux_build.c Fri Jan 19 16:15:38 2007 -0800 @@ -1092,7 +1092,6 @@ static int xc_linux_build_internal(int x unsigned int console_evtchn, unsigned long *console_mfn) { - struct xen_domctl launch_domctl; DECLARE_DOMCTL; int rc; struct vcpu_guest_context st_ctxt, *ctxt = &st_ctxt; @@ -1109,12 +1108,6 @@ static int xc_linux_build_internal(int x } memset(ctxt, 0, sizeof(*ctxt)); - - if ( lock_pages(ctxt, sizeof(*ctxt) ) ) - { - PERROR("%s: ctxt lock failed", __func__); - return 1; - } domctl.cmd = XEN_DOMCTL_getdomaininfo; domctl.domain = (domid_t)domid; @@ -1170,14 +1163,7 @@ static int xc_linux_build_internal(int x ctxt->kernel_sp = ctxt->user_regs.esp; #endif /* x86 */ - memset(&launch_domctl, 0, sizeof(launch_domctl)); - - launch_domctl.domain = (domid_t)domid; - launch_domctl.u.vcpucontext.vcpu = 0; - set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, ctxt); - - launch_domctl.cmd = XEN_DOMCTL_setvcpucontext; - rc = xc_domctl(xc_handle, &launch_domctl); + rc = xc_vcpu_setcontext(xc_handle, domid, 0, ctxt); return rc; diff -r f89126a59073 -r 2048d2698d46 tools/libxc/xc_linux_restore.c --- a/tools/libxc/xc_linux_restore.c Fri Jan 19 16:11:31 2007 +0000 +++ b/tools/libxc/xc_linux_restore.c Fri Jan 19 16:15:38 2007 -0800 @@ -195,12 +195,6 @@ int xc_linux_restore(int xc_handle, int if(!get_platform_info(xc_handle, dom, &max_mfn, &hvirt_start, &pt_levels)) { ERROR("Unable to get platform info."); - return 1; - } - - if (lock_pages(&ctxt, sizeof(ctxt))) { - /* needed for build domctl, but might as well do early */ - ERROR("Unable to lock ctxt"); return 1; } @@ -845,12 +839,7 @@ int xc_linux_restore(int xc_handle, int DPRINTF("Domain ready to be built.\n"); - domctl.cmd = XEN_DOMCTL_setvcpucontext; - domctl.domain = (domid_t)dom; - domctl.u.vcpucontext.vcpu = 0; - set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt); - rc = xc_domctl(xc_handle, &domctl); - + rc = xc_vcpu_setcontext(xc_handle, dom, 0, &ctxt); if (rc != 0) { ERROR("Couldn't build the domain"); goto out; --LyciRD1jyfeSSjG0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --LyciRD1jyfeSSjG0--