qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org, anthony@codemonkey.ws
Cc: jschopp@linux.vnet.ibm.com, coreyb@linux.vnet.ibm.com,
	mdroth@linux.vnet.ibm.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH v5 2/8] 3 new file wrappers
Date: Thu, 28 Mar 2013 07:38:13 -0400	[thread overview]
Message-ID: <1364470699-16223-3-git-send-email-stefanb@linux.vnet.ibm.com> (raw)
In-Reply-To: <1364470699-16223-1-git-send-email-stefanb@linux.vnet.ibm.com>

Add 3 very short file wrapper functions to make code that follows more
readable.

Cc: Michael Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
---
 include/migration/qemu-file.h |  3 +++
 util/qemu-file.c              | 30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 7194b84..728b6e2 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -68,6 +68,9 @@ int qemu_fclose(QEMUFile *f);
 int64_t qemu_ftell(QEMUFile *f);
 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
 void qemu_put_byte(QEMUFile *f, int v);
+int qemu_read_bytes(QEMUFile *f, uint8_t *buf, int size);
+int qemu_peek_bytes(QEMUFile *f, uint8_t *buf, int size, size_t offset);
+int qemu_write_bytes(QEMUFile *f, const uint8_t *buf, int size);
 
 static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
 {
diff --git a/util/qemu-file.c b/util/qemu-file.c
index 4fed6d5..f8a54e7 100644
--- a/util/qemu-file.c
+++ b/util/qemu-file.c
@@ -713,3 +713,33 @@ uint64_t qemu_get_be64(QEMUFile *f)
     return v;
 }
 
+int qemu_read_bytes(QEMUFile *f, uint8_t *buf, int size)
+{
+    if (qemu_file_get_error(f)) {
+        return -1;
+    }
+    return qemu_get_buffer(f, buf, size);
+}
+
+int qemu_peek_bytes(QEMUFile *f, uint8_t *buf, int size, size_t offset)
+{
+    if (qemu_file_get_error(f)) {
+        return -1;
+    }
+    return qemu_peek_buffer(f, buf, size, offset);
+}
+
+int qemu_write_bytes(QEMUFile *f, const uint8_t *buf, int size)
+{
+    if (qemu_file_get_error(f)) {
+        return -1;
+    }
+
+    qemu_put_buffer(f, buf, size);
+
+    if (qemu_file_get_error(f)) {
+        return -1;
+    }
+
+    return size;
+}
-- 
1.7.11.7

  parent reply	other threads:[~2013-03-28 11:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 11:38 [Qemu-devel] [PATCH v5 0/8] Implement and test ASN.1 BER visitors Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 1/8] Move some contents of savevm.c to qemu-file.c Stefan Berger
2013-03-28 11:38 ` Stefan Berger [this message]
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 3/8] QEMUSizedBuffer Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 4/8] QAPI: add type_sized_buffer Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 5/8] ASN.1 output visitor Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 6/8] ASN.1 input visitor Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 7/8] Extend test-visitor-serialization with ASN.1 visitor(s) Stefan Berger
2013-03-28 11:38 ` [Qemu-devel] [PATCH v5 8/8] ASN.1 specific test cases Stefan Berger
2013-03-28 11:43 ` [Qemu-devel] [PATCH v5 0/8] Implement and test ASN.1 BER visitors Stefan Berger

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=1364470699-16223-3-git-send-email-stefanb@linux.vnet.ibm.com \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=coreyb@linux.vnet.ibm.com \
    --cc=jschopp@linux.vnet.ibm.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.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).