thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
22c213
From 7a3c94e10b087c06635ef72aadb1550184dd5c58 Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Mon, 27 Jan 2020 19:01:58 +0100
22c213
Subject: [PATCH 087/116] virtiofsd: add helper for lo_data cleanup
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Message-id: <20200127190227.40942-84-dgilbert@redhat.com>
22c213
Patchwork-id: 93538
22c213
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 083/112] virtiofsd: add helper for lo_data cleanup
22c213
Bugzilla: 1694164
22c213
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
22c213
22c213
From: Liu Bo <bo.liu@linux.alibaba.com>
22c213
22c213
This offers an helper function for lo_data's cleanup.
22c213
22c213
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
22c213
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
(cherry picked from commit 18a69cbbb6a4caa7c2040c6db4a33b044a32be7e)
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
---
22c213
 tools/virtiofsd/passthrough_ll.c | 37 +++++++++++++++++++++----------------
22c213
 1 file changed, 21 insertions(+), 16 deletions(-)
22c213
22c213
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
22c213
index 056ebe8..e8dc5c7 100644
22c213
--- a/tools/virtiofsd/passthrough_ll.c
22c213
+++ b/tools/virtiofsd/passthrough_ll.c
22c213
@@ -2407,6 +2407,26 @@ static gboolean lo_key_equal(gconstpointer a, gconstpointer b)
22c213
     return la->ino == lb->ino && la->dev == lb->dev;
22c213
 }
22c213
 
22c213
+static void fuse_lo_data_cleanup(struct lo_data *lo)
22c213
+{
22c213
+    if (lo->inodes) {
22c213
+        g_hash_table_destroy(lo->inodes);
22c213
+    }
22c213
+    lo_map_destroy(&lo->fd_map);
22c213
+    lo_map_destroy(&lo->dirp_map);
22c213
+    lo_map_destroy(&lo->ino_map);
22c213
+
22c213
+    if (lo->proc_self_fd >= 0) {
22c213
+        close(lo->proc_self_fd);
22c213
+    }
22c213
+
22c213
+    if (lo->root.fd >= 0) {
22c213
+        close(lo->root.fd);
22c213
+    }
22c213
+
22c213
+    free(lo->source);
22c213
+}
22c213
+
22c213
 int main(int argc, char *argv[])
22c213
 {
22c213
     struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
22c213
@@ -2554,22 +2574,7 @@ err_out2:
22c213
 err_out1:
22c213
     fuse_opt_free_args(&args);
22c213
 
22c213
-    if (lo.inodes) {
22c213
-        g_hash_table_destroy(lo.inodes);
22c213
-    }
22c213
-    lo_map_destroy(&lo.fd_map);
22c213
-    lo_map_destroy(&lo.dirp_map);
22c213
-    lo_map_destroy(&lo.ino_map);
22c213
-
22c213
-    if (lo.proc_self_fd >= 0) {
22c213
-        close(lo.proc_self_fd);
22c213
-    }
22c213
-
22c213
-    if (lo.root.fd >= 0) {
22c213
-        close(lo.root.fd);
22c213
-    }
22c213
-
22c213
-    free(lo.source);
22c213
+    fuse_lo_data_cleanup(&lo);
22c213
 
22c213
     return ret ? 1 : 0;
22c213
 }
22c213
-- 
22c213
1.8.3.1
22c213