fish: Don't fail if -m and --listen flags are both given (RHBZ#612178).
authorRichard Jones <rjones@redhat.com>
Wed, 7 Jul 2010 14:01:38 +0000 (15:01 +0100)
committerRichard Jones <rjones@redhat.com>
Wed, 7 Jul 2010 14:03:51 +0000 (15:03 +0100)
Testing this against a Fedora disk image:

$ ./fish/guestfish --ro -a F13.img -m /dev/sda1 --listen
export GUESTFISH_PID=6033
$ ./fish/guestfish --remote=6033 -- ping-daemon
$ ./fish/guestfish --remote=6033 -- ping-daemon
$ ./fish/guestfish --remote=6033 -- exit

Without this fix the first remote command would fail because
qemu would have already been killed.

fish/fish.c

index 470c625..4276ae1 100644 (file)
@@ -476,6 +476,17 @@ main (int argc, char *argv[])
    * guest and mount them.
    */
   if (next_prepared_drive > 1 || mps != NULL) {
    * guest and mount them.
    */
   if (next_prepared_drive > 1 || mps != NULL) {
+    /* RHBZ#612178: If --listen flag is given, then we will fork into
+     * the background in rc_listen().  However you can't do this while
+     * holding a libguestfs handle open because the recovery process
+     * will think the main program has died and kill qemu.  Therefore
+     * don't use the recovery process for this case.  (A better
+     * solution would be to call launch () etc after the fork, but
+     * that greatly complicates the code here).
+     */
+    if (remote_control_listen)
+      guestfs_set_recovery_proc (g, 0);
+
     if (launch () == -1) exit (EXIT_FAILURE);
     prepare_drives (drvs);
     mount_mps (mps);
     if (launch () == -1) exit (EXIT_FAILURE);
     prepare_drives (drvs);
     mount_mps (mps);