Pino Toscano
2014-Jun-10 13:18 UTC
[Libguestfs] [PATCH] daemon: grub: show grub-install's output on error if verbose
---
daemon/grub.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/daemon/grub.c b/daemon/grub.c
index c058599..9596d7a 100644
--- a/daemon/grub.c
+++ b/daemon/grub.c
@@ -38,16 +38,19 @@ int
do_grub_install (const char *root, const char *device)
{
int r;
- CLEANUP_FREE char *err = NULL, *buf = NULL;
+ CLEANUP_FREE char *err = NULL, *buf = NULL, *out = NULL;
if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1)
{
reply_with_perror ("asprintf");
return -1;
}
- r = command (NULL, &err, str_grub_install, buf, device, NULL);
+ r = command (verbose ? &out : NULL, &err,
+ str_grub_install, buf, device, NULL);
if (r == -1) {
+ if (verbose)
+ fprintf (stderr, "grub output:\n%s\n", out);
reply_with_error ("%s", err);
return -1;
}
--
1.9.3
Richard W.M. Jones
2014-Jun-10 18:08 UTC
Re: [Libguestfs] [PATCH] daemon: grub: show grub-install's output on error if verbose
On Tue, Jun 10, 2014 at 03:18:37PM +0200, Pino Toscano wrote:> --- > daemon/grub.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/daemon/grub.c b/daemon/grub.c > index c058599..9596d7a 100644 > --- a/daemon/grub.c > +++ b/daemon/grub.c > @@ -38,16 +38,19 @@ int > do_grub_install (const char *root, const char *device) > { > int r; > - CLEANUP_FREE char *err = NULL, *buf = NULL; > + CLEANUP_FREE char *err = NULL, *buf = NULL, *out = NULL; > > if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) { > reply_with_perror ("asprintf"); > return -1; > } > > - r = command (NULL, &err, str_grub_install, buf, device, NULL); > + r = command (verbose ? &out : NULL, &err, > + str_grub_install, buf, device, NULL); > > if (r == -1) { > + if (verbose) > + fprintf (stderr, "grub output:\n%s\n", out); > reply_with_error ("%s", err); > return -1; > } > -- > 1.9.3ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top