summaryrefslogtreecommitdiff
path: root/tests/test-vmstate.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-04-27 11:05:08 +0100
committerAmit Shah <amit.shah@redhat.com>2016-05-26 11:31:53 +0530
commit8925839f00cd2d9fd96066154098db476140b715 (patch)
treefb948d6a0f8a62c94c8f51af76bfffff60f98d24 /tests/test-vmstate.c
parent6ddd2d76ca6f86f7a6c29291ec3bca32d15bab24 (diff)
downloadqemu-8925839f00cd2d9fd96066154098db476140b715.tar.gz
migration: convert savevm to use QIOChannel for writing to files
Convert the exec savevm code to use QIOChannel and QEMUFileChannel, instead of the stdio APIs. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1461751518-12128-19-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'tests/test-vmstate.c')
-rw-r--r--tests/test-vmstate.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f337cf6ecd..d19b16a60e 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);