aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_cpuid_x86.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_cpuid_x86.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_cpuid_x86.c')
-rw-r--r--tools/libxc/xc_cpuid_x86.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 54174a297d..0993824c0e 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -31,10 +31,10 @@
#define DEF_MAX_BASE 0x0000000du
#define DEF_MAX_EXT 0x80000008u
-static int hypervisor_is_64bit(int xc)
+static int hypervisor_is_64bit(xc_interface *xch)
{
xen_capabilities_info_t xen_caps = "";
- return ((xc_version(xc, XENVER_capabilities, &xen_caps) == 0) &&
+ return ((xc_version(xch, XENVER_capabilities, &xen_caps) == 0) &&
(strstr(xen_caps, "x86_64") != NULL));
}
@@ -75,7 +75,8 @@ static void xc_cpuid_brand_get(char *str)
}
static void amd_xc_cpuid_policy(
- int xc, domid_t domid, const unsigned int *input, unsigned int *regs,
+ xc_interface *xch, domid_t domid,
+ const unsigned int *input, unsigned int *regs,
int is_pae)
{
switch ( input[0] )
@@ -86,7 +87,7 @@ static void amd_xc_cpuid_policy(
break;
case 0x80000001: {
- int is_64bit = hypervisor_is_64bit(xc) && is_pae;
+ int is_64bit = hypervisor_is_64bit(xch) && is_pae;
if ( !is_pae )
clear_bit(X86_FEATURE_PAE, regs[3]);
@@ -123,7 +124,8 @@ static void amd_xc_cpuid_policy(
}
static void intel_xc_cpuid_policy(
- int xc, domid_t domid, const unsigned int *input, unsigned int *regs,
+ xc_interface *xch, domid_t domid,
+ const unsigned int *input, unsigned int *regs,
int is_pae)
{
switch ( input[0] )
@@ -139,7 +141,7 @@ static void intel_xc_cpuid_policy(
break;
case 0x80000001: {
- int is_64bit = hypervisor_is_64bit(xc) && is_pae;
+ int is_64bit = hypervisor_is_64bit(xch) && is_pae;
/* Only a few features are advertised in Intel's 0x80000001. */
regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0);
@@ -162,13 +164,14 @@ static void intel_xc_cpuid_policy(
}
static void xc_cpuid_hvm_policy(
- int xc, domid_t domid, const unsigned int *input, unsigned int *regs)
+ xc_interface *xch, domid_t domid,
+ const unsigned int *input, unsigned int *regs)
{
char brand[13];
unsigned long pae;
int is_pae;
- xc_get_hvm_param(xc, domid, HVM_PARAM_PAE_ENABLED, &pae);
+ xc_get_hvm_param(xch, domid, HVM_PARAM_PAE_ENABLED, &pae);
is_pae = !!pae;
switch ( input[0] )
@@ -265,17 +268,18 @@ static void xc_cpuid_hvm_policy(
xc_cpuid_brand_get(brand);
if ( strstr(brand, "AMD") )
- amd_xc_cpuid_policy(xc, domid, input, regs, is_pae);
+ amd_xc_cpuid_policy(xch, domid, input, regs, is_pae);
else
- intel_xc_cpuid_policy(xc, domid, input, regs, is_pae);
+ intel_xc_cpuid_policy(xch, domid, input, regs, is_pae);
}
static void xc_cpuid_pv_policy(
- int xc, domid_t domid, const unsigned int *input, unsigned int *regs)
+ xc_interface *xch, domid_t domid,
+ const unsigned int *input, unsigned int *regs)
{
DECLARE_DOMCTL;
- int guest_64bit, xen_64bit = hypervisor_is_64bit(xc);
+ int guest_64bit, xen_64bit = hypervisor_is_64bit(xch);
char brand[13];
xc_cpuid_brand_get(brand);
@@ -283,7 +287,7 @@ static void xc_cpuid_pv_policy(
memset(&domctl, 0, sizeof(domctl));
domctl.domain = domid;
domctl.cmd = XEN_DOMCTL_get_address_size;
- do_domctl(xc, &domctl);
+ do_domctl(xch, &domctl);
guest_64bit = (domctl.u.address_size.size == 64);
if ( (input[0] & 0x7fffffff) == 1 )
@@ -352,23 +356,24 @@ static void xc_cpuid_pv_policy(
}
static int xc_cpuid_policy(
- int xc, domid_t domid, const unsigned int *input, unsigned int *regs)
+ xc_interface *xch, domid_t domid,
+ const unsigned int *input, unsigned int *regs)
{
xc_dominfo_t info;
- if ( xc_domain_getinfo(xc, domid, 1, &info) == 0 )
+ if ( xc_domain_getinfo(xch, domid, 1, &info) == 0 )
return -EINVAL;
if ( info.hvm )
- xc_cpuid_hvm_policy(xc, domid, input, regs);
+ xc_cpuid_hvm_policy(xch, domid, input, regs);
else
- xc_cpuid_pv_policy(xc, domid, input, regs);
+ xc_cpuid_pv_policy(xch, domid, input, regs);
return 0;
}
static int xc_cpuid_do_domctl(
- int xc, domid_t domid,
+ xc_interface *xch, domid_t domid,
const unsigned int *input, const unsigned int *regs)
{
DECLARE_DOMCTL;
@@ -383,7 +388,7 @@ static int xc_cpuid_do_domctl(
domctl.u.cpuid.ecx = regs[2];
domctl.u.cpuid.edx = regs[3];
- return do_domctl(xc, &domctl);
+ return do_domctl(xch, &domctl);
}
static char *alloc_str(void)
@@ -405,7 +410,7 @@ void xc_cpuid_to_str(const unsigned int *regs, char **strs)
}
}
-int xc_cpuid_apply_policy(int xc, domid_t domid)
+int xc_cpuid_apply_policy(xc_interface *xch, domid_t domid)
{
unsigned int input[2] = { 0, 0 }, regs[4];
unsigned int base_max, ext_max;
@@ -422,11 +427,11 @@ int xc_cpuid_apply_policy(int xc, domid_t domid)
for ( ; ; )
{
cpuid(input, regs);
- xc_cpuid_policy(xc, domid, input, regs);
+ xc_cpuid_policy(xch, domid, input, regs);
if ( regs[0] || regs[1] || regs[2] || regs[3] )
{
- rc = xc_cpuid_do_domctl(xc, domid, input, regs);
+ rc = xc_cpuid_do_domctl(xch, domid, input, regs);
if ( rc )
return rc;
@@ -462,7 +467,7 @@ int xc_cpuid_apply_policy(int xc, domid_t domid)
* 's' -> (same) must be the same
*/
int xc_cpuid_check(
- int xc, const unsigned int *input,
+ xc_interface *xch, const unsigned int *input,
const char **config,
char **config_transformed)
{
@@ -522,7 +527,7 @@ int xc_cpuid_check(
* For 's' and 'x' the configuration is overwritten with the value applied.
*/
int xc_cpuid_set(
- int xc, domid_t domid, const unsigned int *input,
+ xc_interface *xch, domid_t domid, const unsigned int *input,
const char **config, char **config_transformed)
{
int rc;
@@ -533,7 +538,7 @@ int xc_cpuid_set(
cpuid(input, regs);
memcpy(polregs, regs, sizeof(regs));
- xc_cpuid_policy(xc, domid, input, polregs);
+ xc_cpuid_policy(xch, domid, input, polregs);
for ( i = 0; i < 4; i++ )
{
@@ -572,7 +577,7 @@ int xc_cpuid_set(
}
}
- rc = xc_cpuid_do_domctl(xc, domid, input, regs);
+ rc = xc_cpuid_do_domctl(xch, domid, input, regs);
if ( rc == 0 )
return 0;