Skip to contentSkip to conversation

Make qemu_peek_buffer loop until it gets it's data

PATCH Superseded Dr. David Alan Gilbert (git) 1 participant 1 message Mar 27, 2014

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Make qemu_peek_buffer loop until it gets it's data

From: "Dr. David Alan Gilbert" <[email protected]>

Make qemu_peek_buffer repeatedly call fill_buffer until it gets all the data it requires, or until there is an error.

At the moment, qemu_peek_buffer will try one qemu_fill_buffer if there isn't enough data waiting, however the kernel is entitled to return just a few bytes, and still leave qemu_peek_buffer with less bytes than it needed. I've seen this fail in a dev world, and I think it could theoretically fail in the peeking of the subsection headers in the current world.

Comment qemu_peek_byte to point out it's not guaranteed to work for
non-continuous peeks

---

v3:
Make qemu_fill_buffer return ssize_t
Remove the other size_t cleanup from this patch - I'll get back to them later Comment additions/cleanups from review
Stretch my -ve

 include/migration/qemu-file.h |  5 +++++
 qemu-file.c                   | 51 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 3 deletions(-)
include/migration/qemu-file.h +5 -0
index a191fb6..c90f529 100644
@@ -123,6 +123,11 @@ void qemu_put_be32(QEMUFile *f, unsigned int v);
 void qemu_put_be64(QEMUFile *f, uint64_t v);
 int qemu_peek_buffer(QEMUFile *f, uint8_t *buf, int size, size_t offset);
 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
+/*
+ * Note that you can only peek continuous bytes from where the current pointer
+ * is; you aren't guaranteed to be able to peak to +n bytes unless you've
+ * previously peeked +n-1.
+ */
 int qemu_peek_byte(QEMUFile *f, int offset);
 int qemu_get_byte(QEMUFile *f);
 void qemu_file_skip(QEMUFile *f, int size);
qemu-file.c +48 -3

95 lines not on this page · raw message

Signature · 1 line
1.8.5.3