John Eckersberg
2014-Dec-11 13:38 UTC
[Libguestfs] [PATCH] p2v: show error dialog if virt-v2v fails (RHBZ#1167601)
Ensure the control connection exits with the same status code as virt-v2v, and return an error from start_conversion if virt-v2v failed. --- p2v/conversion.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/p2v/conversion.c b/p2v/conversion.c index 9f5a3ad..4ff7ecc 100644 --- a/p2v/conversion.c +++ b/p2v/conversion.c @@ -100,6 +100,7 @@ start_conversion (struct config *config, void (*notify_ui) (int type, const char *data)) { int ret = -1; + int status; size_t i, len; size_t nr_disks = guestfs___count_strings (config->disks); struct data_conn data_conns[nr_disks]; @@ -276,7 +277,7 @@ start_conversion (struct config *config, if (mexp_printf (control_h, " ) | tee %s/virt-v2v-conversion-log.txt", remote_dir) == -1) goto printf_fail; - if (mexp_printf (control_h, "; exit") == -1) + if (mexp_printf (control_h, "; exit $(< %s/status)", remote_dir) == -1) goto printf_fail; if (mexp_printf (control_h, "\n") == -1) goto printf_fail; @@ -313,8 +314,18 @@ start_conversion (struct config *config, ret = 0; out: - if (control_h) - mexp_close (control_h); + if (control_h) { + if ((status = mexp_close (control_h)) == -1) { + set_conversion_error ("mexp_close: %m"); + ret = -1; + } else if (ret == 0 && + WIFEXITED (status) && + WEXITSTATUS (status) != 0) { + set_conversion_error ("virt-v2v exited with status %d", + WEXITSTATUS (status)); + ret = -1; + } + } cleanup_data_conns (data_conns, nr_disks); return ret; } -- 2.1.0
Richard W.M. Jones
2014-Dec-11 14:12 UTC
Re: [Libguestfs] [PATCH] p2v: show error dialog if virt-v2v fails (RHBZ#1167601)
On Thu, Dec 11, 2014 at 08:38:49AM -0500, John Eckersberg wrote:> Ensure the control connection exits with the same status code as > virt-v2v, and return an error from start_conversion if virt-v2v > failed. > --- > p2v/conversion.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/p2v/conversion.c b/p2v/conversion.c > index 9f5a3ad..4ff7ecc 100644 > --- a/p2v/conversion.c > +++ b/p2v/conversion.c > @@ -100,6 +100,7 @@ start_conversion (struct config *config, > void (*notify_ui) (int type, const char *data)) > { > int ret = -1; > + int status; > size_t i, len; > size_t nr_disks = guestfs___count_strings (config->disks); > struct data_conn data_conns[nr_disks]; > @@ -276,7 +277,7 @@ start_conversion (struct config *config, > if (mexp_printf (control_h, " ) | tee %s/virt-v2v-conversion-log.txt", > remote_dir) == -1) > goto printf_fail; > - if (mexp_printf (control_h, "; exit") == -1) > + if (mexp_printf (control_h, "; exit $(< %s/status)", remote_dir) == -1) > goto printf_fail; > if (mexp_printf (control_h, "\n") == -1) > goto printf_fail; > @@ -313,8 +314,18 @@ start_conversion (struct config *config, > > ret = 0; > out: > - if (control_h) > - mexp_close (control_h); > + if (control_h) { > + if ((status = mexp_close (control_h)) == -1) { > + set_conversion_error ("mexp_close: %m"); > + ret = -1; > + } else if (ret == 0 && > + WIFEXITED (status) && > + WEXITSTATUS (status) != 0) { > + set_conversion_error ("virt-v2v exited with status %d", > + WEXITSTATUS (status)); > + ret = -1; > + } > + } > cleanup_data_conns (data_conns, nr_disks); > return ret; > }ACK. I'll push this later today, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Maybe Matching Threads
- [PATCH 0/4] p2v: Send ^C to remote end to cancel the conversion.
- [PATCH 0/7] p2v: Multiple improvements to the look of virt-p2v.
- [PATCH] p2v: require a non-interative sudo (RHBZ#1340809)
- [PATCH] p2v: Send physical server 'dmesg' output to debug dir on conversion server.
- Re: [PATCH] p2v: require a non-interative sudo (RHBZ#1340809)