[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH -V3 19/32] virtio-9p: Get the correct count values f
From: |
Aneesh Kumar K.V |
Subject: |
[Qemu-devel] [PATCH -V3 19/32] virtio-9p: Get the correct count values from the pdu |
Date: |
Thu, 25 Mar 2010 22:13:27 +0530 |
From: Venkateswararao Jujjuri <address@hidden>
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 <address@hidden>
Signed-off-by: Aneesh Kumar K.V <address@hidden>
---
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.323.g0d092
- [Qemu-devel] [PATCH -V3 04/32] virtio-9p: Implement P9_TSTAT, (continued)
- [Qemu-devel] [PATCH -V3 04/32] virtio-9p: Implement P9_TSTAT, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 10/32] virtio-9p: Implement P9_TCREATE, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 11/32] virtio-9p: Implement P9_TWSTAT, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 12/32] virtio-9p: Implement P9_TREMOVE, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 14/32] virtio-9p: Add multiple mount point support, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 16/32] virtio-9p: Add support for hardlink, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 13/32] virtio-9p: Implement P9_TFLUSH, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 17/32] Implement sync support in 9p server, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 15/32] virtio-9p: Use little endian format on virtio, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 18/32] virtio-9p: Fix sg usage in the code, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 19/32] virtio-9p: Get the correct count values from the pdu,
Aneesh Kumar K.V <=
- [Qemu-devel] [PATCH -V3 22/32] virtio-9p: Update existing fid path on rename, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 21/32] virtio-9p: Remove unnecessary definition of fid, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 23/32] vritio-9p: Fix chmod bug with directory, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 20/32] virtio-9p: Remove BUG_ON and add proper error handling, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 24/32] qemu-malloc: Add qemu_asprintf, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 26/32] virtio-9p: Create a commandline option -fsdev, Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 25/32] virtio-9p: Move V9fs File system specific options to a separate header file., Aneesh Kumar K.V, 2010/03/25
- [Qemu-devel] [PATCH -V3 27/32] virtio-9p: Create qemu_fsdev_opts, Aneesh Kumar K.V, 2010/03/25