xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH] xl: convert vcpuid to signed in main_vcpupin()
Date: Wed, 20 Aug 2014 17:36:00 +0200	[thread overview]
Message-ID: <20140820153600.20604.97575.stgit@Solace.lan> (raw)

No functional changes, it just looks more correct, considering
that at some point in the function we assign -1 to it (and
at some other later point we check for it to be -1), to
signify 'all vcpus'.

While at it, fix a coding style nit and improve error reporting.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
 tools/libxl/xl_cmdimpl.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index f1c136a..a29a579 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4601,8 +4601,9 @@ int main_vcpupin(int argc, char **argv)
     libxl_vcpuinfo *vcpuinfo;
     libxl_bitmap cpumap_hard, cpumap_soft;;
     libxl_bitmap *soft = &cpumap_soft, *hard = &cpumap_hard;
-    uint32_t vcpuid, domid;
     const char *vcpu, *hard_str, *soft_str;
+    uint32_t domid;
+    long vcpuid;
     char *endptr;
     int opt, nb_cpu, nb_vcpu, rc = -1;
 
@@ -4619,10 +4620,10 @@ int main_vcpupin(int argc, char **argv)
     soft_str = (argc > optind+3) ? argv[optind+3] : NULL;
 
     /* Figure out with which vCPU we are dealing with */
-    vcpuid = strtoul(vcpu, &endptr, 10);
-    if (vcpu == endptr) {
+    vcpuid = strtol(vcpu, &endptr, 10);
+    if (vcpu == endptr || vcpuid < 0) {
         if (strcmp(vcpu, "all")) {
-            fprintf(stderr, "Error: Invalid argument.\n");
+            fprintf(stderr, "Error: Invalid argument %s as VCPU.\n", vcpu);
             goto out;
         }
         vcpuid = -1;
@@ -4688,12 +4689,11 @@ int main_vcpupin(int argc, char **argv)
 
     if (vcpuid != -1) {
         if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, hard, soft)) {
-            fprintf(stderr, "Could not set affinity for vcpu `%u'.\n",
+            fprintf(stderr, "Could not set affinity for vcpu `%ld'.\n",
                     vcpuid);
             goto out;
         }
-    }
-    else {
+    } else {
         if (!(vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nb_cpu))) {
             fprintf(stderr, "libxl_list_vcpu failed.\n");
             goto out;

             reply	other threads:[~2014-08-20 15:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 15:36 Dario Faggioli [this message]
2014-09-03 13:52 ` [PATCH] xl: convert vcpuid to signed in main_vcpupin() Ian Campbell
2014-09-03 15:20   ` Dario Faggioli
2014-09-03 16:09     ` Ian Campbell
2014-09-03 16:42       ` Dario Faggioli
2014-09-03 16:48         ` Ian Campbell
2014-09-03 16:49       ` Andrew Cooper
2014-09-03 16:50       ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140820153600.20604.97575.stgit@Solace.lan \
    --to=dario.faggioli@citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).