From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: ericvh@gmail.com, aliguori@us.ibm.com,
Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH -v2 19/22] virtio-9p: Get the correct count values from the pdu
Date: Tue, 16 Mar 2010 14:45:17 +0530 [thread overview]
Message-ID: <1268730920-14584-20-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1268730920-14584-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
From: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
PDU contain little endian format for integer values. So
we need to make sure we map them to host format. Also the count
value can be in another sg offset other than 0. Use the righ
functions to get the count value
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
hw/virtio-9p-debug.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c
index ee222db..e8ede8e 100644
--- a/hw/virtio-9p-debug.c
+++ b/hw/virtio-9p-debug.c
@@ -181,20 +181,25 @@ static void pprint_stat(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
static void pprint_strs(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
+ int sg_count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
- int16_t count, i;
+ uint16_t tmp_count, count, i;
+ size_t copied = 0;
fprintf(llogfile, "%s={", name);
- BUG_ON((offset + 2) > sg[0].iov_len);
- memcpy(&count, sg[0].iov_base + offset, 2);
- offset += 2;
+ /* Get the count */
+ copied = do_pdu_unpack(&tmp_count, sg, sg_count, offset, sizeof(tmp_count));
+ BUG_ON(copied != sizeof(tmp_count));
+ count = le16_to_cpupu(&tmp_count);
+ offset += copied;
for (i = 0; i < count; i++) {
char str[512];
- if (i)
+ if (i) {
fprintf(llogfile, ", ");
+ }
snprintf(str, sizeof(str), "[%d]", i);
pprint_str(pdu, rx, &offset, str);
}
@@ -206,20 +211,24 @@ static void pprint_strs(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
static void pprint_qids(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
+ int sg_count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
- int16_t count, i;
+ uint16_t tmp_count, count, i;
+ size_t copied = 0;
fprintf(llogfile, "%s={", name);
- BUG_ON((offset + 2) > sg[0].iov_len);
- memcpy(&count, sg[0].iov_base + offset, 2);
- offset += 2;
+ copied = do_pdu_unpack(&tmp_count, sg, sg_count, offset, sizeof(tmp_count));
+ BUG_ON(copied != sizeof(tmp_count));
+ count = le16_to_cpupu(&tmp_count);
+ offset += copied;
for (i = 0; i < count; i++) {
char str[512];
- if (i)
+ if (i) {
fprintf(llogfile, ", ");
+ }
snprintf(str, sizeof(str), "[%d]", i);
pprint_qid(pdu, rx, &offset, str);
}
--
1.7.0.2.273.gc2413
next prev parent reply other threads:[~2010-03-16 9:16 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 9:14 [Qemu-devel] [PATCH -V2 00/22] virtio-9p: paravirtual file system passthrough Aneesh Kumar K.V
2010-03-16 9:14 ` [Qemu-devel] [PATCH -v2 01/22] vitio-9p: Add a virtio 9p device to qemu Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 02/22] vrtio-9p: Implement P9_TVERSION for 9P Aneesh Kumar K.V
2010-03-26 16:15 ` Anthony Liguori
2010-03-29 7:01 ` Aneesh Kumar K. V
2010-03-29 14:51 ` Anthony Liguori
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 03/22] virtio-9p: Implement P9_TATTACH Aneesh Kumar K.V
2010-03-26 16:17 ` Anthony Liguori
2010-03-26 19:12 ` jvrao
2010-03-26 20:06 ` jvrao
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 04/22] virtio-9p: Implement P9_TSTAT Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 05/22] virtio-9p: Implement P9_TWALK Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 06/22] virtio-9p: Implement P9_TOPEN Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 07/22] virtio-9p: Implement P9_TREAD Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 08/22] virtio-9p: Implement P9_TCLUNK Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 09/22] virtio-9p: Implement P9_TWRITE Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 10/22] virtio-9p: Implement P9_TCREATE Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 11/22] virtio-9p: Implement P9_TWSTAT Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 12/22] virtio-9p: Implement P9_TREMOVE Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 13/22] virtio-9p: Implement P9_TFLUSH Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 14/22] virtio-9p: Add multiple mount point support Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 15/22] virtio-9p: Use little endian format on virtio Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 16/22] virtio-9p: Add support for hardlink Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 17/22] Implement sync support in 9p server Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 18/22] virtio-9p: Fix sg usage in the code Aneesh Kumar K.V
2010-03-16 9:15 ` Aneesh Kumar K.V [this message]
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 20/22] virtio-9p: Remove BUG_ON and add proper error handling Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 21/22] virtio-9p: Remove unnecessary definition of fid Aneesh Kumar K.V
2010-03-16 9:15 ` [Qemu-devel] [PATCH -v2 22/22] virtio-9p: Update existing fid path on rename Aneesh Kumar K.V
2010-03-23 23:17 ` [Qemu-devel] [PATCH -V2 00/22] virtio-9p: paravirtual file system passthrough Luiz Capitulino
2010-03-24 3:58 ` Aneesh Kumar K. V
2010-03-24 15:04 ` Luiz Capitulino
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=1268730920-14584-20-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=ericvh@gmail.com \
--cc=jvrao@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).