902636
From 616407b06517361ce444dcc0960aeaf55b52da33 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:01:41 +0100
902636
Subject: [PATCH 070/116] virtiofsd: Handle hard reboot
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-67-dgilbert@redhat.com>
902636
Patchwork-id: 93521
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 066/112] virtiofsd: Handle hard reboot
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
902636
Handle a
902636
  mount
902636
  hard reboot (without unmount)
902636
  mount
902636
902636
we get another 'init' which FUSE doesn't normally expect.
902636
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit e8556f49098b5d95634e592d79a97f761b76c96e)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/fuse_lowlevel.c | 16 +++++++++++++++-
902636
 1 file changed, 15 insertions(+), 1 deletion(-)
902636
902636
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
902636
index 7d742b5..65f91da 100644
902636
--- a/tools/virtiofsd/fuse_lowlevel.c
902636
+++ b/tools/virtiofsd/fuse_lowlevel.c
902636
@@ -2433,7 +2433,21 @@ void fuse_session_process_buf_int(struct fuse_session *se,
902636
             goto reply_err;
902636
         }
902636
     } else if (in->opcode == FUSE_INIT || in->opcode == CUSE_INIT) {
902636
-        goto reply_err;
902636
+        if (fuse_lowlevel_is_virtio(se)) {
902636
+            /*
902636
+             * TODO: This is after a hard reboot typically, we need to do
902636
+             * a destroy, but we can't reply to this request yet so
902636
+             * we can't use do_destroy
902636
+             */
902636
+            fuse_log(FUSE_LOG_DEBUG, "%s: reinit\n", __func__);
902636
+            se->got_destroy = 1;
902636
+            se->got_init = 0;
902636
+            if (se->op.destroy) {
902636
+                se->op.destroy(se->userdata);
902636
+            }
902636
+        } else {
902636
+            goto reply_err;
902636
+        }
902636
     }
902636
 
902636
     err = EACCES;
902636
-- 
902636
1.8.3.1
902636