diff mbox

[4/9] xl: Improve return and exit codes of main_console(), main_vncviewer() and main_dump_core().

Message ID 1456318407-3635-5-git-send-email-write.harmandeep@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Harmandeep Kaur Feb. 24, 2016, 12:53 p.m. UTC
Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
 tools/libxl/xl_cmdimpl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Dario Faggioli Feb. 25, 2016, 11:33 a.m. UTC | #1
On Wed, 2016-02-24 at 18:23 +0530, Harmandeep Kaur wrote:
> Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
>
"console, vnc and core dump related function"

I'm not sure I'd put main_dump_core() in this patch, rather than in
patch 8, but I think it's just fine wither way.

> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c

> @@ -3457,8 +3457,8 @@ int main_vncviewer(int argc, char **argv)
>      domid = find_domain(argv[optind]);
>  
>      if (vncviewer(domid, autopass))
> -        return 1;
> -    return 0;
> +        return EXIT_FAILURE;
> +    return EXIT_SUCCESS;
>
Have a look at vncviewer() and autoconnect_vncviewer() too.

Thanks and Regards,
Dario
Dario Faggioli March 8, 2016, 2:16 p.m. UTC | #2
[Re-adding xen-devel... please, don't drop it. :-)]

On Tue, 2016-03-08 at 13:08 +0530, Harmandeep Kaur wrote:
> On Thu, Feb 25, 2016 at 5:03 PM, Dario Faggioli
> <dario.faggioli@citrix.com> wrote:
> > 
> 
> > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> > > 
> > > @@ -3457,8 +3457,8 @@ int main_vncviewer(int argc, char **argv)
> > >      domid = find_domain(argv[optind]);
> > > 
> > >      if (vncviewer(domid, autopass))
> > > -        return 1;
> > > -    return 0;
> > > +        return EXIT_FAILURE;
> > > +    return EXIT_SUCCESS;
> > > 
> > Have a look at vncviewer() and autoconnect_vncviewer() too.
> > 
> I am not sure about vncviewer(), do we need something like below:
> 
> static int vncviewer(uint32_t domid, int autopass)
> {
>     if (!libxl_vncviewer_exec(ctx, domid, autopass)) {
>         fprintf(stderr, "Unable to execute vncviewer\n");
>         return 1;
>     }
> }
> 
That won't compile, I think.

It's an internal function, and this patch is changing a bunch of
internal functions into returning -1 on failure ad 0 on success, which
is something vncviewer() is not doing.

It's not too big of a deal, honestly, and you can even let it alone
(we're not going to get 100% consistency anyway), but I thought you may
want to at least consider what to do.

OTOH, autoconnect_vncviewer() does have an _exit() that needs to be
dealt with.

Regards,
Dario
diff mbox

Patch

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 2092c80..e1b4286 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3421,7 +3421,7 @@  int main_console(int argc, char **argv)
             type = LIBXL_CONSOLE_TYPE_SERIAL;
         else {
             fprintf(stderr, "console type supported are: pv, serial\n");
-            return 2;
+            return EXIT_FAILURE;
         }
         break;
     case 'n':
@@ -3435,7 +3435,7 @@  int main_console(int argc, char **argv)
     else
         libxl_console_exec(ctx, domid, num, type);
     fprintf(stderr, "Unable to attach console\n");
-    return 1;
+    return EXIT_FAILURE;
 }
 
 int main_vncviewer(int argc, char **argv)
@@ -3457,8 +3457,8 @@  int main_vncviewer(int argc, char **argv)
     domid = find_domain(argv[optind]);
 
     if (vncviewer(domid, autopass))
-        return 1;
-    return 0;
+        return EXIT_FAILURE;
+    return EXIT_SUCCESS;
 }
 
 static void pcilist(uint32_t domid)
@@ -4013,7 +4013,7 @@  static void core_dump_domain(uint32_t domid, const char *filename)
     int rc;
 
     rc=libxl_domain_core_dump(ctx, domid, filename, NULL);
-    if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); }
+    if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(EXIT_FAILURE); }
 }
 
 #ifndef LIBXL_HAVE_NO_SUSPEND_RESUME
@@ -4774,7 +4774,7 @@  int main_dump_core(int argc, char **argv)
     }
 
     core_dump_domain(find_domain(argv[optind]), argv[optind + 1]);
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_pause(int argc, char **argv)