[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3] two new file wrappers
From: |
jschopp |
Subject: |
[Qemu-devel] [PATCH 1/3] two new file wrappers |
Date: |
Tue, 26 Feb 2013 17:03:55 -0600 |
User-agent: |
quilt/0.60-1 |
These patches implement asn1 ber visitors for encoding and decoding data.
References: <address@hidden>
Content-Disposition: inline; filename=qemu_file_bits.diff
Signed-off-by: Stefan Berger <address@hidden>
Signed-off-by: Joel Schopp <address@hidden>
---
include/migration/qemu-file.h | 4 ++++
qemu-file.c | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
Index: b/qemu-file.c
===================================================================
--- a/qemu-file.c
+++ b/qemu-file.c
@@ -367,7 +367,7 @@ static void qemu_file_set_error(QEMUFile
/** Flushes QEMUFile buffer
*
*/
-static int qemu_fflush(QEMUFile *f)
+int qemu_fflush(QEMUFile *f)
{
int ret = 0;
@@ -668,3 +668,34 @@ uint64_t qemu_get_be64(QEMUFile *f)
v |= qemu_get_be32(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;
+}
Index: b/include/migration/qemu-file.h
===================================================================
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -79,11 +79,15 @@ QEMUFile *qemu_fdopen(int fd, const char
QEMUFile *qemu_fopen_socket(int fd);
QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
+int qemu_fflush(QEMUFile *f);
int qemu_get_fd(QEMUFile *f);
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)
{
- [Qemu-devel] [PATCH 1/3] two new file wrappers,
jschopp <=