xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update
@ 2020-06-17  2:19 Igor Druzhinin
  2020-06-17  8:39 ` Paul Durrant
  0 siblings, 1 reply; 3+ messages in thread
From: Igor Druzhinin @ 2020-06-17  2:19 UTC (permalink / raw)
  To: xen-devel; +Cc: Igor Druzhinin, ian.jackson, xadimgnik, wl

Otherwise it's difficult to know if operation failed inside the automation.

While at it, also switch to returning 1 and 2 instead of errno to avoid
incompatibilies between errno and special exit code numbers.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
Changes in v3:
- conventionally return 1 and 2 instead of errno as exit code
---
 tools/misc/xen-ucode.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c
index 0c257f4..ad32fac 100644
--- a/tools/misc/xen-ucode.c
+++ b/tools/misc/xen-ucode.c
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
         fprintf(stderr,
                 "xen-ucode: Xen microcode updating tool\n"
                 "Usage: %s <microcode blob>\n", argv[0]);
-        return 0;
+        exit(2);
     }
 
     filename = argv[1];
@@ -34,14 +34,14 @@ int main(int argc, char *argv[])
     {
         fprintf(stderr, "Could not open %s. (err: %s)\n",
                 filename, strerror(errno));
-        return errno;
+        exit(1);
     }
 
     if ( fstat(fd, &st) != 0 )
     {
         fprintf(stderr, "Could not get the size of %s. (err: %s)\n",
                 filename, strerror(errno));
-        return errno;
+        exit(1);
     }
 
     len = st.st_size;
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
     if ( buf == MAP_FAILED )
     {
         fprintf(stderr, "mmap failed. (error: %s)\n", strerror(errno));
-        return errno;
+        exit(1);
     }
 
     xch = xc_interface_open(NULL, NULL, 0);
@@ -57,20 +57,23 @@ int main(int argc, char *argv[])
     {
         fprintf(stderr, "Error opening xc interface. (err: %s)\n",
                 strerror(errno));
-        return errno;
+        exit(1);
     }
 
     ret = xc_microcode_update(xch, buf, len);
     if ( ret )
+    {
         fprintf(stderr, "Failed to update microcode. (err: %s)\n",
                 strerror(errno));
+        exit(1);
+    }
 
     xc_interface_close(xch);
 
     if ( munmap(buf, len) )
     {
         printf("Could not unmap: %d(%s)\n", errno, strerror(errno));
-        return errno;
+        exit(1);
     }
     close(fd);
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update
  2020-06-17  2:19 [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update Igor Druzhinin
@ 2020-06-17  8:39 ` Paul Durrant
  2020-06-18 15:44   ` Ian Jackson
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Durrant @ 2020-06-17  8:39 UTC (permalink / raw)
  To: 'Igor Druzhinin', xen-devel; +Cc: ian.jackson, xadimgnik, wl

> -----Original Message-----
> From: Igor Druzhinin <igor.druzhinin@citrix.com>
> Sent: 17 June 2020 03:19
> To: xen-devel@lists.xenproject.org
> Cc: ian.jackson@eu.citrix.com; wl@xen.org; xadimgnik@gmail.com; Igor Druzhinin
> <igor.druzhinin@citrix.com>
> Subject: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update
> 
> Otherwise it's difficult to know if operation failed inside the automation.
> 
> While at it, also switch to returning 1 and 2 instead of errno to avoid
> incompatibilies between errno and special exit code numbers.
> 
> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>

Reviewed-by: Paul Durrant <paul@xen.org>
Release-acked-by: Paul Durrant <paul@xen.org>

> ---
> Changes in v3:
> - conventionally return 1 and 2 instead of errno as exit code
> ---
>  tools/misc/xen-ucode.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c
> index 0c257f4..ad32fac 100644
> --- a/tools/misc/xen-ucode.c
> +++ b/tools/misc/xen-ucode.c
> @@ -25,7 +25,7 @@ int main(int argc, char *argv[])
>          fprintf(stderr,
>                  "xen-ucode: Xen microcode updating tool\n"
>                  "Usage: %s <microcode blob>\n", argv[0]);
> -        return 0;
> +        exit(2);
>      }
> 
>      filename = argv[1];
> @@ -34,14 +34,14 @@ int main(int argc, char *argv[])
>      {
>          fprintf(stderr, "Could not open %s. (err: %s)\n",
>                  filename, strerror(errno));
> -        return errno;
> +        exit(1);
>      }
> 
>      if ( fstat(fd, &st) != 0 )
>      {
>          fprintf(stderr, "Could not get the size of %s. (err: %s)\n",
>                  filename, strerror(errno));
> -        return errno;
> +        exit(1);
>      }
> 
>      len = st.st_size;
> @@ -49,7 +49,7 @@ int main(int argc, char *argv[])
>      if ( buf == MAP_FAILED )
>      {
>          fprintf(stderr, "mmap failed. (error: %s)\n", strerror(errno));
> -        return errno;
> +        exit(1);
>      }
> 
>      xch = xc_interface_open(NULL, NULL, 0);
> @@ -57,20 +57,23 @@ int main(int argc, char *argv[])
>      {
>          fprintf(stderr, "Error opening xc interface. (err: %s)\n",
>                  strerror(errno));
> -        return errno;
> +        exit(1);
>      }
> 
>      ret = xc_microcode_update(xch, buf, len);
>      if ( ret )
> +    {
>          fprintf(stderr, "Failed to update microcode. (err: %s)\n",
>                  strerror(errno));
> +        exit(1);
> +    }
> 
>      xc_interface_close(xch);
> 
>      if ( munmap(buf, len) )
>      {
>          printf("Could not unmap: %d(%s)\n", errno, strerror(errno));
> -        return errno;
> +        exit(1);
>      }
>      close(fd);
> 
> --
> 2.7.4




^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update
  2020-06-17  8:39 ` Paul Durrant
@ 2020-06-18 15:44   ` Ian Jackson
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2020-06-18 15:44 UTC (permalink / raw)
  To: paul; +Cc: Igor Druzhinin, xadimgnik, wl, xen-devel

Paul Durrant writes ("RE: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update"):
> > -----Original Message-----
> > From: Igor Druzhinin <igor.druzhinin@citrix.com>
> > Sent: 17 June 2020 03:19
> > To: xen-devel@lists.xenproject.org
> > Cc: ian.jackson@eu.citrix.com; wl@xen.org; xadimgnik@gmail.com; Igor Druzhinin
> > <igor.druzhinin@citrix.com>
> > Subject: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update
> > 
> > Otherwise it's difficult to know if operation failed inside the automation.
> > 
> > While at it, also switch to returning 1 and 2 instead of errno to avoid
> > incompatibilies between errno and special exit code numbers.
> > 
> > Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>

Thanks, this looks good to me.

> Reviewed-by: Paul Durrant <paul@xen.org>
> Release-acked-by: Paul Durrant <paul@xen.org>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

I will commit this in a moment.

Ian.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-18 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17  2:19 [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update Igor Druzhinin
2020-06-17  8:39 ` Paul Durrant
2020-06-18 15:44   ` Ian Jackson

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).