[Libguestfs] [PATCH] daemon: grub: show grub-install's output on error if verbose

Pino Toscano ptoscano at redhat.com
Tue Jun 10 13:18:37 UTC 2014


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




More information about the Libguestfs mailing list