|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/2] tools/libxc: Fix error handling in get_cpuid_domain_info()
get_cpuid_domain_info() has two conflicting return styles - either -error for
local failures, or -1/errno for hypercall failures. Switch to consistently
use -error.
While fixing the xc_get_cpu_featureset(), take the opportunity to remove the
redundancy and move it to be adjacent to the other featureset handling.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
---
tools/libxc/xc_cpuid_x86.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 13862b9..098affe 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -336,13 +336,22 @@ static int get_cpuid_domain_info(xc_interface *xch,
uint32_t domid,
if ( featureset[i] != 0 )
return -EOPNOTSUPP;
}
+ else
+ {
+ rc = xc_get_cpu_featureset(xch, (info->hvm
+ ? XEN_SYSCTL_cpu_featureset_hvm
+ : XEN_SYSCTL_cpu_featureset_pv),
+ &host_nr_features, info->featureset);
+ if ( rc )
+ return -errno;
+ }
/* Get xstate information. */
domctl.cmd = XEN_DOMCTL_getvcpuextstate;
domctl.domain = domid;
rc = do_domctl(xch, &domctl);
if ( rc )
- return rc;
+ return -errno;
info->xfeature_mask = domctl.u.vcpuextstate.xfeature_mask;
@@ -352,23 +361,15 @@ static int get_cpuid_domain_info(xc_interface *xch,
uint32_t domid,
rc = xc_hvm_param_get(xch, domid, HVM_PARAM_PAE_ENABLED, &val);
if ( rc )
- return rc;
+ return -errno;
info->pae = !!val;
rc = xc_hvm_param_get(xch, domid, HVM_PARAM_NESTEDHVM, &val);
if ( rc )
- return rc;
+ return -errno;
info->nestedhvm = !!val;
-
- if ( !featureset )
- {
- rc = xc_get_cpu_featureset(xch, XEN_SYSCTL_cpu_featureset_hvm,
- &host_nr_features, info->featureset);
- if ( rc )
- return rc;
- }
}
else
{
@@ -376,17 +377,9 @@ static int get_cpuid_domain_info(xc_interface *xch,
uint32_t domid,
rc = xc_domain_get_guest_width(xch, domid, &width);
if ( rc )
- return rc;
+ return -errno;
info->pv64 = (width == 8);
-
- if ( !featureset )
- {
- rc = xc_get_cpu_featureset(xch, XEN_SYSCTL_cpu_featureset_pv,
- &host_nr_features, info->featureset);
- if ( rc )
- return rc;
- }
}
return 0;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |