diff mbox series

tools/xl: use libxl_domain_info to get domain type for vcpu-pin

Message ID 1554497508-32708-1-git-send-email-igor.druzhinin@citrix.com (mailing list archive)
State Superseded
Headers show
Series tools/xl: use libxl_domain_info to get domain type for vcpu-pin | expand

Commit Message

Igor Druzhinin April 5, 2019, 8:51 p.m. UTC
Parsing the config seems to be an overkill for this particular task
and the config might simply be absent. Type returned should be either
LIBXL_DOMAIN_TYPE_HVM or LIBXL_DOMAIN_TYPE_PV but in that context
distinction between PVH and HVM should be irrelevant.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 tools/xl/xl_vcpu.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Wei Liu April 9, 2019, 9:40 a.m. UTC | #1
On Fri, Apr 05, 2019 at 09:51:48PM +0100, Igor Druzhinin wrote:
> Parsing the config seems to be an overkill for this particular task
> and the config might simply be absent. Type returned should be either
> LIBXL_DOMAIN_TYPE_HVM or LIBXL_DOMAIN_TYPE_PV but in that context
> distinction between PVH and HVM should be irrelevant.

Right, this makes sense.

But please make it complete by removing the LIBXL_DOMAIN_TYPE_PVH branch
in apply_global_affinity_masks, and add a comment to note that PVH and
HVM use the same mask ...

> 
> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
> ---
>  tools/xl/xl_vcpu.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
> index 71d3a5c..4a4d0fa 100644
> --- a/tools/xl/xl_vcpu.c
> +++ b/tools/xl/xl_vcpu.c
> @@ -284,19 +284,14 @@ int main_vcpupin(int argc, char **argv)
>  
>      /* Only hard affinity matters here */
>      if (!ignore_masks) {
> -        libxl_domain_config d_config;
> +        libxl_dominfo dominfo;
>  

... here.

> -        libxl_domain_config_init(&d_config);
> -        rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
> -        if (rc) {
> -            fprintf(stderr, "Could not retrieve domain configuration\n");
> -            libxl_domain_config_dispose(&d_config);
> +        if (libxl_domain_info(ctx, &dominfo, domid)) {
> +            fprintf(stderr, "Could not get domain info\n");
>              goto out;
>          }
>  
> -        apply_global_affinity_masks(d_config.b_info.type, hard, 1);
> -
> -        libxl_domain_config_dispose(&d_config);
> +        apply_global_affinity_masks(dominfo.domain_type, hard, 1);
>      }
>  
>      if (force) {
> -- 
> 2.7.4
>
diff mbox series

Patch

diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
index 71d3a5c..4a4d0fa 100644
--- a/tools/xl/xl_vcpu.c
+++ b/tools/xl/xl_vcpu.c
@@ -284,19 +284,14 @@  int main_vcpupin(int argc, char **argv)
 
     /* Only hard affinity matters here */
     if (!ignore_masks) {
-        libxl_domain_config d_config;
+        libxl_dominfo dominfo;
 
-        libxl_domain_config_init(&d_config);
-        rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
-        if (rc) {
-            fprintf(stderr, "Could not retrieve domain configuration\n");
-            libxl_domain_config_dispose(&d_config);
+        if (libxl_domain_info(ctx, &dominfo, domid)) {
+            fprintf(stderr, "Could not get domain info\n");
             goto out;
         }
 
-        apply_global_affinity_masks(d_config.b_info.type, hard, 1);
-
-        libxl_domain_config_dispose(&d_config);
+        apply_global_affinity_masks(dominfo.domain_type, hard, 1);
     }
 
     if (force) {