qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	David Gibson <david@gibson.dropbear.id.au>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 1/4] savevm: introduce little endian variants of savevm routines
Date: Mon, 10 Dec 2012 08:29:47 -0600	[thread overview]
Message-ID: <1355149790-8125-2-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1355149790-8125-1-git-send-email-aliguori@us.ibm.com>

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);
 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 */
 
-- 
1.8.0

  reply	other threads:[~2012-12-10 14:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 14:29 [Qemu-devel] [RFC 0/4] virtio: stabilize migration format Anthony Liguori
2012-12-10 14:29 ` Anthony Liguori [this message]
2012-12-10 14:33   ` [Qemu-devel] [PATCH 1/4] savevm: introduce little endian variants of savevm routines Peter Maydell
2012-12-10 15:24     ` Anthony Liguori
2012-12-10 14:29 ` [Qemu-devel] [PATCH 2/4] virtio: add wrapper for saving/restoring virtqueue elements Anthony Liguori
2012-12-14 11:46   ` Paolo Bonzini
2012-12-14 13:54     ` Anthony Liguori
2012-12-10 14:29 ` [Qemu-devel] [PATCH 3/4] virtio: modify savevm to have a stable wire format Anthony Liguori
2012-12-11  0:32   ` Rusty Russell
2012-12-11  0:54     ` Anthony Liguori
2012-12-14  0:57       ` Rusty Russell
2012-12-14 11:50         ` Paolo Bonzini
2012-12-14 13:59           ` Anthony Liguori
2012-12-10 14:29 ` [Qemu-devel] [PATCH 4/4] virtio: bump migration version number Anthony Liguori
2012-12-11  9:02 ` [Qemu-devel] [RFC 0/4] virtio: stabilize migration format Stefan Hajnoczi

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=1355149790-8125-2-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    /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).