Skip to content

Commit

Permalink
p2v: show error dialog if virt-v2v fails (RHBZ#1167601)
Browse files Browse the repository at this point in the history
Ensure the control connection exits with the same status code as
virt-v2v, and return an error from start_conversion if virt-v2v
failed.
  • Loading branch information
jeckersb authored and rwmjones committed Dec 11, 2014
1 parent 3d7ea11 commit 841aa0f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions p2v/conversion.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 841aa0f

Please sign in to comment.