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.
For stable-1.2 branch:
- Cherry picked from commit
8161ea9bb046c8450384b5b15e1f4b2f3dca582b
- Rebased for older guestfish code.
/* If we've got mountpoints, we must launch the guest and mount them. */
if (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 (g) == -1) exit (EXIT_FAILURE);
mount_mps (mps);
}