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 v3 1/3] fsdev: 9p-marshal: introduce V9fsBlob
Date: Mon, 11 Jan 2016 09:29:35 +0000 [thread overview]
Message-ID: <1452504577-26751-2-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1452504577-26751-1-git-send-email-wei.liu2@citrix.com>
Introduce a concept of blob. It will be used to pack / unpack xattr
value.
With this change there is no need to expose v9fs_pack to device code
anymore.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v3: use 'd' to encode / decode blob size
---
fsdev/9p-iov-marshal.c | 26 ++++++++++++++++++++++++++
fsdev/9p-marshal.c | 7 +++++++
fsdev/9p-marshal.h | 14 ++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c
index 08d783c..1f9edf3 100644
--- a/fsdev/9p-iov-marshal.c
+++ b/fsdev/9p-iov-marshal.c
@@ -140,6 +140,21 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
}
break;
}
+ case 'B': {
+ V9fsBlob *blob = va_arg(ap, V9fsBlob *);
+ copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
+ "d", &blob->size);
+ if (copied > 0) {
+ offset += copied;
+ blob->data = g_malloc(blob->size);
+ copied = v9fs_unpack(blob->data, out_sg, out_num, offset,
+ blob->size);
+ if (copied < 0) {
+ v9fs_blob_free(blob);
+ }
+ }
+ break;
+ }
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
copied = v9fs_iov_unmarshal(out_sg, out_num, offset, bswap,
@@ -253,6 +268,17 @@ ssize_t v9fs_iov_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
}
break;
}
+ case 'B': {
+ V9fsBlob *blob = va_arg(ap, V9fsBlob *);
+ copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap,
+ "d", blob->size);
+ if (copied > 0) {
+ offset += copied;
+ copied = v9fs_pack(in_sg, in_num, offset, blob->data,
+ blob->size);
+ }
+ break;
+ }
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
copied = v9fs_iov_marshal(in_sg, in_num, offset, bswap, "bdq",
diff --git a/fsdev/9p-marshal.c b/fsdev/9p-marshal.c
index 991e35d..a914244 100644
--- a/fsdev/9p-marshal.c
+++ b/fsdev/9p-marshal.c
@@ -54,3 +54,10 @@ void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
v9fs_string_free(lhs);
v9fs_string_sprintf(lhs, "%s", rhs->data);
}
+
+void v9fs_blob_free(V9fsBlob *blob)
+{
+ g_free(blob->data);
+ blob->data = NULL;
+ blob->size = 0;
+}
diff --git a/fsdev/9p-marshal.h b/fsdev/9p-marshal.h
index e91b24e..54148f4 100644
--- a/fsdev/9p-marshal.h
+++ b/fsdev/9p-marshal.h
@@ -7,6 +7,12 @@ typedef struct V9fsString
char *data;
} V9fsString;
+typedef struct V9fsBlob
+{
+ uint32_t size;
+ void *data;
+} V9fsBlob;
+
typedef struct V9fsQID
{
int8_t type;
@@ -81,4 +87,12 @@ 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);
+static inline void v9fs_blob_init(V9fsBlob *blob)
+{
+ blob->data = NULL;
+ blob->size = 0;
+}
+
+extern void v9fs_blob_free(V9fsBlob *blob);
+
#endif
--
2.1.4
next prev parent reply other threads:[~2016-01-11 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 9:29 [Qemu-devel] [PATCH v3 0/3] 9pfs: disentangling virtio and generic code Wei Liu
2016-01-11 9:29 ` Wei Liu [this message]
2016-01-11 9:29 ` [Qemu-devel] [PATCH v3 2/3] 9pfs: use V9fsBlob to transmit xattr Wei Liu
2016-01-11 13:56 ` Aneesh Kumar K.V
2016-01-11 14:05 ` Wei Liu
2016-01-11 14:26 ` Aneesh Kumar K.V
2016-01-11 15:02 ` Wei Liu
2016-01-11 9:29 ` [Qemu-devel] [PATCH v3 3/3] 9pfs: introduce V9fsVirtioState Wei Liu
2016-01-11 9:37 ` [Qemu-devel] [PATCH v3 0/3] 9pfs: disentangling virtio and generic code 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=1452504577-26751-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).