All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: qemu-devel@nongnu.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Greg Kurz <gkurz@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2 10/27] fsdev: break out 9p-marshal.{c, h} from virtio-9p-marshal.{c, h}
Date: Thu, 7 Jan 2016 19:56:07 +0000	[thread overview]
Message-ID: <1452196584-17259-11-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1452196584-17259-1-git-send-email-wei.liu2@citrix.com>

Break out some generic functions for marshaling 9p state. Pure code
motion plus minor fixes for build system.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v2: remove my name and email
---
 Makefile                  |  2 +-
 fsdev/9p-marshal.c        | 56 +++++++++++++++++++++++++++++++
 fsdev/9p-marshal.h        | 84 +++++++++++++++++++++++++++++++++++++++++++++++
 fsdev/Makefile.objs       |  2 +-
 fsdev/virtio-9p-marshal.c | 31 -----------------
 fsdev/virtio-9p-marshal.h | 79 +-------------------------------------------
 6 files changed, 143 insertions(+), 111 deletions(-)
 create mode 100644 fsdev/9p-marshal.c
 create mode 100644 fsdev/9p-marshal.h

diff --git a/Makefile b/Makefile
index 82b2fc8..7e881d8 100644
--- a/Makefile
+++ b/Makefile
@@ -240,7 +240,7 @@ qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(qom-obj-y) libqemuu
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 
-fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
+fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
 fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
 
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
diff --git a/fsdev/9p-marshal.c b/fsdev/9p-marshal.c
new file mode 100644
index 0000000..991e35d
--- /dev/null
+++ b/fsdev/9p-marshal.c
@@ -0,0 +1,56 @@
+/*
+ * 9p backend
+ *
+ * Copyright IBM, Corp. 2010
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/time.h>
+#include <utime.h>
+#include <sys/uio.h>
+#include <string.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include "qemu/compiler.h"
+#include "9p-marshal.h"
+
+void v9fs_string_free(V9fsString *str)
+{
+    g_free(str->data);
+    str->data = NULL;
+    str->size = 0;
+}
+
+void v9fs_string_null(V9fsString *str)
+{
+    v9fs_string_free(str);
+}
+
+void GCC_FMT_ATTR(2, 3)
+v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
+{
+    va_list ap;
+
+    v9fs_string_free(str);
+
+    va_start(ap, fmt);
+    str->size = g_vasprintf(&str->data, fmt, ap);
+    va_end(ap);
+}
+
+void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
+{
+    v9fs_string_free(lhs);
+    v9fs_string_sprintf(lhs, "%s", rhs->data);
+}
diff --git a/fsdev/9p-marshal.h b/fsdev/9p-marshal.h
new file mode 100644
index 0000000..e91b24e
--- /dev/null
+++ b/fsdev/9p-marshal.h
@@ -0,0 +1,84 @@
+#ifndef _QEMU_9P_MARSHAL_H
+#define _QEMU_9P_MARSHAL_H
+
+typedef struct V9fsString
+{
+    uint16_t size;
+    char *data;
+} V9fsString;
+
+typedef struct V9fsQID
+{
+    int8_t type;
+    int32_t version;
+    int64_t path;
+} V9fsQID;
+
+typedef struct V9fsStat
+{
+    int16_t size;
+    int16_t type;
+    int32_t dev;
+    V9fsQID qid;
+    int32_t mode;
+    int32_t atime;
+    int32_t mtime;
+    int64_t length;
+    V9fsString name;
+    V9fsString uid;
+    V9fsString gid;
+    V9fsString muid;
+    /* 9p2000.u */
+    V9fsString extension;
+    int32_t n_uid;
+    int32_t n_gid;
+    int32_t n_muid;
+} V9fsStat;
+
+typedef struct V9fsIattr
+{
+    int32_t valid;
+    int32_t mode;
+    int32_t uid;
+    int32_t gid;
+    int64_t size;
+    int64_t atime_sec;
+    int64_t atime_nsec;
+    int64_t mtime_sec;
+    int64_t mtime_nsec;
+} V9fsIattr;
+
+typedef struct V9fsStatDotl {
+    uint64_t st_result_mask;
+    V9fsQID qid;
+    uint32_t st_mode;
+    uint32_t st_uid;
+    uint32_t st_gid;
+    uint64_t st_nlink;
+    uint64_t st_rdev;
+    uint64_t st_size;
+    uint64_t st_blksize;
+    uint64_t st_blocks;
+    uint64_t st_atime_sec;
+    uint64_t st_atime_nsec;
+    uint64_t st_mtime_sec;
+    uint64_t st_mtime_nsec;
+    uint64_t st_ctime_sec;
+    uint64_t st_ctime_nsec;
+    uint64_t st_btime_sec;
+    uint64_t st_btime_nsec;
+    uint64_t st_gen;
+    uint64_t st_data_version;
+} V9fsStatDotl;
+
+static inline void v9fs_string_init(V9fsString *str)
+{
+    str->data = NULL;
+    str->size = 0;
+}
+extern void v9fs_string_free(V9fsString *str);
+extern void v9fs_string_null(V9fsString *str);
+extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...);
+extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs);
+
+#endif
diff --git a/fsdev/Makefile.objs b/fsdev/Makefile.objs
index c27dad3..8357851 100644
--- a/fsdev/Makefile.objs
+++ b/fsdev/Makefile.objs
@@ -1,7 +1,7 @@
 ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
 # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add.
 # only pull in the actual virtio-9p device if we also enabled virtio.
-common-obj-y = qemu-fsdev.o virtio-9p-marshal.o
+common-obj-y = qemu-fsdev.o 9p-marshal.o virtio-9p-marshal.o
 else
 common-obj-y = qemu-fsdev-dummy.o
 endif
diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 7748d32..f236bab 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -25,37 +25,6 @@
 #include "virtio-9p-marshal.h"
 #include "qemu/bswap.h"
 
-void v9fs_string_free(V9fsString *str)
-{
-    g_free(str->data);
-    str->data = NULL;
-    str->size = 0;
-}
-
-void v9fs_string_null(V9fsString *str)
-{
-    v9fs_string_free(str);
-}
-
-void GCC_FMT_ATTR(2, 3)
-v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
-{
-    va_list ap;
-
-    v9fs_string_free(str);
-
-    va_start(ap, fmt);
-    str->size = g_vasprintf(&str->data, fmt, ap);
-    va_end(ap);
-}
-
-void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
-{
-    v9fs_string_free(lhs);
-    v9fs_string_sprintf(lhs, "%s", rhs->data);
-}
-
-
 static ssize_t v9fs_packunpack(void *addr, struct iovec *sg, int sg_count,
                                size_t offset, size_t size, int pack)
 {
diff --git a/fsdev/virtio-9p-marshal.h b/fsdev/virtio-9p-marshal.h
index 5df65a8..0709bcd 100644
--- a/fsdev/virtio-9p-marshal.h
+++ b/fsdev/virtio-9p-marshal.h
@@ -1,85 +1,8 @@
 #ifndef _QEMU_VIRTIO_9P_MARSHAL_H
 #define _QEMU_VIRTIO_9P_MARSHAL_H
 
-typedef struct V9fsString
-{
-    uint16_t size;
-    char *data;
-} V9fsString;
+#include "9p-marshal.h"
 
-typedef struct V9fsQID
-{
-    int8_t type;
-    int32_t version;
-    int64_t path;
-} V9fsQID;
-
-typedef struct V9fsStat
-{
-    int16_t size;
-    int16_t type;
-    int32_t dev;
-    V9fsQID qid;
-    int32_t mode;
-    int32_t atime;
-    int32_t mtime;
-    int64_t length;
-    V9fsString name;
-    V9fsString uid;
-    V9fsString gid;
-    V9fsString muid;
-    /* 9p2000.u */
-    V9fsString extension;
-   int32_t n_uid;
-    int32_t n_gid;
-    int32_t n_muid;
-} V9fsStat;
-
-typedef struct V9fsIattr
-{
-    int32_t valid;
-    int32_t mode;
-    int32_t uid;
-    int32_t gid;
-    int64_t size;
-    int64_t atime_sec;
-    int64_t atime_nsec;
-    int64_t mtime_sec;
-    int64_t mtime_nsec;
-} V9fsIattr;
-
-typedef struct V9fsStatDotl {
-    uint64_t st_result_mask;
-    V9fsQID qid;
-    uint32_t st_mode;
-    uint32_t st_uid;
-    uint32_t st_gid;
-    uint64_t st_nlink;
-    uint64_t st_rdev;
-    uint64_t st_size;
-    uint64_t st_blksize;
-    uint64_t st_blocks;
-    uint64_t st_atime_sec;
-    uint64_t st_atime_nsec;
-    uint64_t st_mtime_sec;
-    uint64_t st_mtime_nsec;
-    uint64_t st_ctime_sec;
-    uint64_t st_ctime_nsec;
-    uint64_t st_btime_sec;
-    uint64_t st_btime_nsec;
-    uint64_t st_gen;
-    uint64_t st_data_version;
-} V9fsStatDotl;
-
-static inline void v9fs_string_init(V9fsString *str)
-{
-    str->data = NULL;
-    str->size = 0;
-}
-extern void v9fs_string_free(V9fsString *str);
-extern void v9fs_string_null(V9fsString *str);
-extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...);
-extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs);
 
 ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset,
                   const void *src, size_t size);
-- 
2.1.4

  parent reply	other threads:[~2016-01-07 20:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 19:55 [Qemu-devel] [PATCH v2 00/27] 9pfs: disentangling virtio and generic code Wei Liu
2016-01-07 19:55 ` [Qemu-devel] [PATCH v2 01/27] 9pfs: rename virtio-9p-coth.{c, h} to coth.{c, h} Wei Liu
2016-01-07 19:55 ` [Qemu-devel] [PATCH v2 02/27] 9pfs: rename virtio-9p-handle.c to 9p-handle.c Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 03/27] 9pfs: rename virtio-9p-local.c to 9p-local.c Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 04/27] 9pfs: rename virtio-9p-posix-acl.c to 9p-posix-acl.c Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 05/27] 9pfs: rename virtio-9p-proxy.{c, h} to 9p-proxy.{c, h} Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 06/27] 9pfs: rename virtio-9p-synth.{c, h} to 9p-synth.{c, h} Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 07/27] 9pfs: rename virtio-9p-xattr{, -user}.{c, h} to 9p-xattr{, -user}.{c, h} Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 08/27] 9pfs: merge hw/virtio/virtio-9p.h into hw/9pfs/virtio-9p.h Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 09/27] 9pfs: remove dead code Wei Liu
2016-01-07 19:56 ` Wei Liu [this message]
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 11/27] fsdev: 9p-marshal: introduce V9fsBlob Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 12/27] 9pfs: use V9fsBlob to transmit xattr Wei Liu
2016-01-08  8:30   ` Aneesh Kumar K.V
2016-01-08 17:56     ` Wei Liu
2016-01-08 18:48       ` Aneesh Kumar K.V
2016-01-08 18:54         ` Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 13/27] fsdev: rename virtio-9p-marshal.{c, h} to 9p-iov-marshal.{c, h} Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 14/27] 9pfs: PDU processing functions don't need to take V9fsState as argument Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 15/27] 9pfs: PDU processing functions should start pdu_ prefix Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 16/27] 9pfs: make pdu_{, un}marshal proper functions Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 17/27] 9pfs: factor out virtio_pdu_{, un}marshal Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 18/27] 9pfs: factor out pdu_push_and_notify Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 19/27] 9pfs: break out virtio_init_iov_from_pdu Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 20/27] 9pfs: break out 9p.h from virtio-9p.h Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 21/27] 9pfs: factor out virtio_9p_push_and_notify Wei Liu
2016-01-08  9:57   ` Aneesh Kumar K.V
2016-01-08 17:57     ` Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 22/27] 9pfs: export pdu_{submit, alloc, free} Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 23/27] 9pfs: move handle_9p_output and make it static function Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 24/27] 9pfs: rename virtio_9p_set_fd_limit to use v9fs_ prefix Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 25/27] 9pfs: rename virtio-9p.c to 9p.c Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 26/27] 9pfs: factor out v9fs_device_{, un}realize_common Wei Liu
2016-01-07 19:56 ` [Qemu-devel] [PATCH v2 27/27] 9pfs: disentangle V9fsState Wei Liu
2016-01-08  6:09   ` Aneesh Kumar K.V
2016-01-08 18:54     ` Wei Liu
2016-01-08 10:49 ` [Qemu-devel] [PATCH v2 00/27] 9pfs: disentangling virtio and generic code Aneesh Kumar K.V
2016-01-08 18:54   ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452196584-17259-11-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.