Message ID | 1355149790-8125-2-git-send-email-aliguori@us.ibm.com |
---|---|
State | New |
Headers | show |
On 10 December 2012 14:29, Anthony Liguori <aliguori@us.ibm.com> wrote: > Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> > --- > qemu-file.h | 7 +++++++ > savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+) > > diff --git a/qemu-file.h b/qemu-file.h > index d64bdbb..ac5286c 100644 > --- a/qemu-file.h > +++ b/qemu-file.h > @@ -94,6 +94,9 @@ static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) > void qemu_put_be16(QEMUFile *f, unsigned int v); > void qemu_put_be32(QEMUFile *f, unsigned int v); > void qemu_put_be64(QEMUFile *f, uint64_t v); > +void qemu_put_le16(QEMUFile *f, unsigned int v); > +void qemu_put_le32(QEMUFile *f, unsigned int v); > +void qemu_put_le64(QEMUFile *f, uint64_t v); Do we want to add a comment here somewhere that says the le versions are for backcompat with a specific thing and the be ones are the ones to use in new code (well, new code not using vmstate)? -- PMM
Peter Maydell <peter.maydell@linaro.org> writes: > On 10 December 2012 14:29, Anthony Liguori <aliguori@us.ibm.com> wrote: >> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> >> --- >> qemu-file.h | 7 +++++++ >> savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 52 insertions(+) >> >> diff --git a/qemu-file.h b/qemu-file.h >> index d64bdbb..ac5286c 100644 >> --- a/qemu-file.h >> +++ b/qemu-file.h >> @@ -94,6 +94,9 @@ static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) >> void qemu_put_be16(QEMUFile *f, unsigned int v); >> void qemu_put_be32(QEMUFile *f, unsigned int v); >> void qemu_put_be64(QEMUFile *f, uint64_t v); >> +void qemu_put_le16(QEMUFile *f, unsigned int v); >> +void qemu_put_le32(QEMUFile *f, unsigned int v); >> +void qemu_put_le64(QEMUFile *f, uint64_t v); > > Do we want to add a comment here somewhere that says the le versions > are for backcompat with a specific thing and the be ones are the > ones to use in new code (well, new code not using vmstate)? Yeah, that's a good idea. I've unfortunately found a couple more cases of this (writing native endian to the wire). Regards, Anthony Liguori > > -- PMM
diff --git a/qemu-file.h b/qemu-file.h index d64bdbb..ac5286c 100644 --- a/qemu-file.h +++ b/qemu-file.h @@ -94,6 +94,9 @@ static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) void qemu_put_be16(QEMUFile *f, unsigned int v); void qemu_put_be32(QEMUFile *f, unsigned int v); void qemu_put_be64(QEMUFile *f, uint64_t v); +void qemu_put_le16(QEMUFile *f, unsigned int v); +void qemu_put_le32(QEMUFile *f, unsigned int v); +void qemu_put_le64(QEMUFile *f, uint64_t v); int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); int qemu_get_byte(QEMUFile *f); @@ -108,6 +111,10 @@ unsigned int qemu_get_be16(QEMUFile *f); unsigned int qemu_get_be32(QEMUFile *f); uint64_t qemu_get_be64(QEMUFile *f); +unsigned int qemu_get_le16(QEMUFile *f); +unsigned int qemu_get_le32(QEMUFile *f); +uint64_t qemu_get_le64(QEMUFile *f); + int qemu_file_rate_limit(QEMUFile *f); int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_get_rate_limit(QEMUFile *f); diff --git a/savevm.c b/savevm.c index 5d04d59..f6ae0ba 100644 --- a/savevm.c +++ b/savevm.c @@ -749,6 +749,26 @@ void qemu_put_be64(QEMUFile *f, uint64_t v) qemu_put_be32(f, v); } +void qemu_put_le16(QEMUFile *f, unsigned int v) +{ + qemu_put_byte(f, v); + qemu_put_byte(f, v >> 8); +} + +void qemu_put_le32(QEMUFile *f, unsigned int v) +{ + qemu_put_byte(f, v); + qemu_put_byte(f, v >> 8); + qemu_put_byte(f, v >> 16); + qemu_put_byte(f, v >> 24); +} + +void qemu_put_le64(QEMUFile *f, uint64_t v) +{ + qemu_put_be32(f, v); + qemu_put_be32(f, v >> 32); +} + unsigned int qemu_get_be16(QEMUFile *f) { unsigned int v; @@ -775,6 +795,31 @@ uint64_t qemu_get_be64(QEMUFile *f) return v; } +unsigned int qemu_get_le16(QEMUFile *f) +{ + unsigned int v; + v = qemu_get_byte(f); + v |= qemu_get_byte(f) << 8; + return v; +} + +unsigned int qemu_get_le32(QEMUFile *f) +{ + unsigned int v; + v = qemu_get_byte(f); + v |= qemu_get_byte(f) << 8; + v |= qemu_get_byte(f) << 16; + v |= qemu_get_byte(f) << 24; + return v; +} + +uint64_t qemu_get_le64(QEMUFile *f) +{ + uint64_t v; + v = qemu_get_be32(f); + v |= (uint64_t)qemu_get_be32(f) << 32; + return v; +} /* timer */
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- qemu-file.h | 7 +++++++ savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)