qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/4] qemu-file: add function qemu_fseek()


From: Wenchao Xia
Subject: [Qemu-devel] [PATCH 1/4] qemu-file: add function qemu_fseek()
Date: Thu, 28 Feb 2013 16:09:42 +0800

Signed-off-by: Wenchao Xia <address@hidden>
---
 include/migration/qemu-file.h |    1 +
 savevm.c                      |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 46fc11d..210c311 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -82,6 +82,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char 
*mode);
 int qemu_get_fd(QEMUFile *f);
 int qemu_fclose(QEMUFile *f);
 int64_t qemu_ftell(QEMUFile *f);
+int qemu_fseek(QEMUFile *f, int64_t offset);
 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
 void qemu_put_byte(QEMUFile *f, int v);
 
diff --git a/savevm.c b/savevm.c
index a8a53ef..54dc090 100644
--- a/savevm.c
+++ b/savevm.c
@@ -683,6 +683,23 @@ int64_t qemu_ftell(QEMUFile *f)
     }
 }
 
+int qemu_fseek(QEMUFile *f, int64_t offset)
+{
+    /* only support for writing */
+    g_assert(f->is_write);
+
+    int ret;
+    if (f->buf_index) {
+        ret = qemu_fflush(f);
+        if (ret < 0) {
+            qemu_file_set_error(f, ret);
+            return ret;
+        }
+    }
+    f->buf_offset = offset;
+    return 0;
+}
+
 int qemu_file_rate_limit(QEMUFile *f)
 {
     if (f->ops->rate_limit)
-- 
1.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]