[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 for-2.7 18/28] migration: convert savevm to use Q
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH v6 for-2.7 18/28] migration: convert savevm to use QIOChannel for writing to files |
Date: |
Wed, 27 Apr 2016 11:05:08 +0100 |
Convert the exec savevm code to use QIOChannel and QEMUFileChannel,
instead of the stdio APIs.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Daniel P. Berrange <address@hidden>
---
migration/savevm.c | 8 +++++---
tests/Makefile | 4 ++--
tests/test-vmstate.c | 11 ++++++++++-
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 06746d0..6fde687 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -51,6 +51,7 @@
#include "block/qapi.h"
#include "qemu/cutils.h"
#include "io/channel-buffer.h"
+#include "io/channel-file.h"
#ifndef ETH_P_RARP
#define ETH_P_RARP 0x8035
@@ -2045,6 +2046,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
void qmp_xen_save_devices_state(const char *filename, Error **errp)
{
QEMUFile *f;
+ QIOChannelFile *ioc;
int saved_vm_running;
int ret;
@@ -2052,11 +2054,11 @@ void qmp_xen_save_devices_state(const char *filename,
Error **errp)
vm_stop(RUN_STATE_SAVE_VM);
global_state_store_running();
- f = qemu_fopen(filename, "wb");
- if (!f) {
- error_setg_file_open(errp, errno, filename);
+ ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+ if (!ioc) {
goto the_end;
}
+ f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
ret = qemu_save_device_state(f);
qemu_fclose(f);
if (ret < 0) {
diff --git a/tests/Makefile b/tests/Makefile
index 797d59e..53b64b0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -435,8 +435,8 @@ tests/test-qdev-global-props$(EXESUF):
tests/test-qdev-global-props.o \
$(test-qapi-obj-y)
tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
migration/vmstate.o migration/qemu-file.o \
- migration/qemu-file-unix.o qjson.o \
- $(test-qom-obj-y)
+ migration/qemu-file-channel.o qjson.o \
+ $(test-io-obj-y)
tests/test-timed-average$(EXESUF): tests/test-timed-average.o qemu-timer.o \
$(test-util-obj-y)
tests/test-base64$(EXESUF): tests/test-base64.o \
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f337cf6..d19b16a 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -29,6 +29,7 @@
#include "migration/migration.h"
#include "migration/vmstate.h"
#include "qemu/coroutine.h"
+#include "io/channel-file.h"
static char temp_file[] = "/tmp/vmst.test.XXXXXX";
static int temp_fd;
@@ -49,11 +50,17 @@ void yield_until_fd_readable(int fd)
static QEMUFile *open_test_file(bool write)
{
int fd = dup(temp_fd);
+ QIOChannel *ioc;
lseek(fd, 0, SEEK_SET);
if (write) {
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
}
- return qemu_fdopen(fd, write ? "wb" : "rb");
+ ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd));
+ if (write) {
+ return qemu_fopen_channel_output(ioc);
+ } else {
+ return qemu_fopen_channel_input(ioc);
+ }
}
#define SUCCESS(val) \
@@ -469,6 +476,8 @@ int main(int argc, char **argv)
{
temp_fd = mkstemp(temp_file);
+ module_call_init(MODULE_INIT_QOM);
+
g_test_init(&argc, &argv, NULL);
g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
--
2.5.5
- [Qemu-devel] [PATCH v6 for-2.7 19/28] migration: delete QEMUFile buffer implementation, (continued)
- [Qemu-devel] [PATCH v6 for-2.7 19/28] migration: delete QEMUFile buffer implementation, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 21/28] migration: delete QEMUFile sockets implementation, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 10/28] migration: add reporting of errors for outgoing migration, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 09/28] migration: add helpers for creating QEMUFile from a QIOChannel, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 14/28] migration: convert tcp socket protocol to use QIOChannel, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 11/28] migration: convert post-copy to use QIOChannelBuffer, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 13/28] migration: rename unix.c to socket.c, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 20/28] migration: delete QEMUSizedBuffer struct, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 17/28] migration: convert RDMA to use QIOChannel interface, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 06/28] migration: introduce set_blocking function in QEMUFileOps, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 18/28] migration: convert savevm to use QIOChannel for writing to files,
Daniel P. Berrange <=
- [Qemu-devel] [PATCH v6 for-2.7 24/28] migration: don't use an array for storing migrate parameters, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 26/28] migration: add support for encrypting data with TLS, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 22/28] migration: delete QEMUFile stdio implementation, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 23/28] migration: move definition of struct QEMUFile back into qemu-file.c, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 28/28] migration: remove qemu_get_fd method from QEMUFile, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 25/28] migration: define 'tls-creds' and 'tls-hostname' migration parameters, Daniel P. Berrange, 2016/04/27
- [Qemu-devel] [PATCH v6 for-2.7 27/28] migration: remove support for non-iovec based write handlers, Daniel P. Berrange, 2016/04/27