aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_resume.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
commit5cc436c1d2b3b0be3f42104582f53eec3969b43a (patch)
tree1e30ade146ee7287c486d1309b5d3d2c69a2d9b9 /tools/libxc/xc_resume.c
parent7f9a888af4b65cb8c22cea3c8295d30d0fedd623 (diff)
downloadxen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.gz
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.bz2
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.zip
libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_resume.c')
-rw-r--r--tools/libxc/xc_resume.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c
index c17ae262d3..de93f412b9 100644
--- a/tools/libxc/xc_resume.c
+++ b/tools/libxc/xc_resume.c
@@ -8,12 +8,12 @@
#include <xen/foreign/x86_64.h>
#include <xen/hvm/params.h>
-static int pv_guest_width(int xc_handle, uint32_t domid)
+static int pv_guest_width(xc_interface *xch, uint32_t domid)
{
DECLARE_DOMCTL;
domctl.domain = domid;
domctl.cmd = XEN_DOMCTL_get_address_size;
- if ( xc_domctl(xc_handle, &domctl) != 0 )
+ if ( xc_domctl(xch, &domctl) != 0 )
{
PERROR("Could not get guest address size");
return -1;
@@ -21,7 +21,7 @@ static int pv_guest_width(int xc_handle, uint32_t domid)
return domctl.u.address_size.size / 8;
}
-static int modify_returncode(int xc_handle, uint32_t domid)
+static int modify_returncode(xc_interface *xch, uint32_t domid)
{
vcpu_guest_context_any_t ctxt;
xc_dominfo_t info;
@@ -30,7 +30,7 @@ static int modify_returncode(int xc_handle, uint32_t domid)
struct domain_info_context *dinfo = &_dinfo;
int rc;
- if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
+ if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 )
{
PERROR("Could not get domain info");
return -1;
@@ -40,12 +40,12 @@ static int modify_returncode(int xc_handle, uint32_t domid)
{
/* HVM guests without PV drivers have no return code to modify. */
unsigned long irq = 0;
- xc_get_hvm_param(xc_handle, domid, HVM_PARAM_CALLBACK_IRQ, &irq);
+ xc_get_hvm_param(xch, domid, HVM_PARAM_CALLBACK_IRQ, &irq);
if ( !irq )
return 0;
/* HVM guests have host address width. */
- if ( xc_version(xc_handle, XENVER_capabilities, &caps) != 0 )
+ if ( xc_version(xch, XENVER_capabilities, &caps) != 0 )
{
PERROR("Could not get Xen capabilities\n");
return -1;
@@ -55,17 +55,17 @@ static int modify_returncode(int xc_handle, uint32_t domid)
else
{
/* Probe PV guest address width. */
- dinfo->guest_width = pv_guest_width(xc_handle, domid);
+ dinfo->guest_width = pv_guest_width(xch, domid);
if ( dinfo->guest_width < 0 )
return -1;
}
- if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
+ if ( (rc = xc_vcpu_getcontext(xch, domid, 0, &ctxt)) != 0 )
return rc;
SET_FIELD(&ctxt, user_regs.eax, 1);
- if ( (rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt)) != 0 )
+ if ( (rc = xc_vcpu_setcontext(xch, domid, 0, &ctxt)) != 0 )
return rc;
return 0;
@@ -73,7 +73,7 @@ static int modify_returncode(int xc_handle, uint32_t domid)
#else
-static int modify_returncode(int xc_handle, uint32_t domid)
+static int modify_returncode(xc_interface *xch, uint32_t domid)
{
return 0;
@@ -81,7 +81,7 @@ static int modify_returncode(int xc_handle, uint32_t domid)
#endif
-static int xc_domain_resume_cooperative(int xc_handle, uint32_t domid)
+static int xc_domain_resume_cooperative(xc_interface *xch, uint32_t domid)
{
DECLARE_DOMCTL;
int rc;
@@ -90,15 +90,15 @@ static int xc_domain_resume_cooperative(int xc_handle, uint32_t domid)
* Set hypercall return code to indicate that suspend is cancelled
* (rather than resuming in a new domain context).
*/
- if ( (rc = modify_returncode(xc_handle, domid)) != 0 )
+ if ( (rc = modify_returncode(xch, domid)) != 0 )
return rc;
domctl.cmd = XEN_DOMCTL_resumedomain;
domctl.domain = domid;
- return do_domctl(xc_handle, &domctl);
+ return do_domctl(xch, &domctl);
}
-static int xc_domain_resume_any(int xc_handle, uint32_t domid)
+static int xc_domain_resume_any(xc_interface *xch, uint32_t domid)
{
DECLARE_DOMCTL;
xc_dominfo_t info;
@@ -115,7 +115,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
xen_pfn_t *p2m = NULL;
#endif
- if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
+ if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 )
{
PERROR("Could not get domain info");
return rc;
@@ -131,7 +131,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
return rc;
}
- dinfo->guest_width = pv_guest_width(xc_handle, domid);
+ dinfo->guest_width = pv_guest_width(xch, domid);
if ( dinfo->guest_width != sizeof(long) )
{
ERROR("Cannot resume uncooperative cross-address-size guests");
@@ -139,7 +139,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
}
/* Map the shared info frame */
- shinfo = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+ shinfo = xc_map_foreign_range(xch, domid, PAGE_SIZE,
PROT_READ, info.shared_info_frame);
if ( shinfo == NULL )
{
@@ -150,7 +150,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
dinfo->p2m_size = shinfo->arch.max_pfn;
p2m_frame_list_list =
- xc_map_foreign_range(xc_handle, domid, PAGE_SIZE, PROT_READ,
+ xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ,
shinfo->arch.pfn_to_mfn_frame_list_list);
if ( p2m_frame_list_list == NULL )
{
@@ -158,7 +158,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
goto out;
}
- p2m_frame_list = xc_map_foreign_pages(xc_handle, domid, PROT_READ,
+ p2m_frame_list = xc_map_foreign_pages(xch, domid, PROT_READ,
p2m_frame_list_list,
P2M_FLL_ENTRIES);
if ( p2m_frame_list == NULL )
@@ -171,7 +171,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
the guest must not change which frames are used for this purpose.
(its not clear why it would want to change them, and we'll be OK
from a safety POV anyhow. */
- p2m = xc_map_foreign_pages(xc_handle, domid, PROT_READ,
+ p2m = xc_map_foreign_pages(xch, domid, PROT_READ,
p2m_frame_list,
P2M_FL_ENTRIES);
if ( p2m == NULL )
@@ -186,7 +186,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
goto out;
}
- if ( xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt) )
+ if ( xc_vcpu_getcontext(xch, domid, 0, &ctxt) )
{
ERROR("Could not get vcpu context");
goto out;
@@ -194,7 +194,7 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
mfn = GET_FIELD(&ctxt, user_regs.edx);
- start_info = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+ start_info = xc_map_foreign_range(xch, domid, PAGE_SIZE,
PROT_READ | PROT_WRITE, mfn);
if ( start_info == NULL )
{
@@ -210,12 +210,12 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
/* Reset all secondary CPU states. */
for ( i = 1; i <= info.max_vcpu_id; i++ )
- xc_vcpu_setcontext(xc_handle, domid, i, NULL);
+ xc_vcpu_setcontext(xch, domid, i, NULL);
/* Ready to resume domain execution now. */
domctl.cmd = XEN_DOMCTL_resumedomain;
domctl.domain = domid;
- rc = do_domctl(xc_handle, &domctl);
+ rc = do_domctl(xch, &domctl);
#if defined(__i386__) || defined(__x86_64__)
out:
@@ -242,9 +242,9 @@ static int xc_domain_resume_any(int xc_handle, uint32_t domid)
* (2) should be used only for guests which cannot handle the special
* new return code. (1) is always safe (but slower).
*/
-int xc_domain_resume(int xc_handle, uint32_t domid, int fast)
+int xc_domain_resume(xc_interface *xch, uint32_t domid, int fast)
{
return (fast
- ? xc_domain_resume_cooperative(xc_handle, domid)
- : xc_domain_resume_any(xc_handle, domid));
+ ? xc_domain_resume_cooperative(xch, domid)
+ : xc_domain_resume_any(xch, domid));
}