aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-02-06 21:27:15 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-06 16:35:17 -0600
commit3ab651fc819178cf6a518af5860cc49f42cff455 (patch)
treeff7e205ecb9e4ac0dc68fbf1c19d8b99e7c7ea54 /qemu-char.c
parent82e59a676c01b3df3b53998d428d0a64a55f2439 (diff)
qmp: Clean up design of memchar-read
The data returned has a well-defined size, which makes the size returned along with it redundant at best. Drop it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 9c1dd1326d..b593c50f20 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2788,14 +2788,14 @@ void qmp_memchar_write(const char *device, const char *data,
}
}
-MemCharRead *qmp_memchar_read(const char *device, int64_t size,
- bool has_format, enum DataFormat format,
- Error **errp)
+char *qmp_memchar_read(const char *device, int64_t size,
+ bool has_format, enum DataFormat format,
+ Error **errp)
{
CharDriverState *chr;
guchar *read_data;
- MemCharRead *meminfo;
size_t count;
+ char *data;
chr = qemu_chr_find(device);
if (!chr) {
@@ -2813,26 +2813,23 @@ MemCharRead *qmp_memchar_read(const char *device, int64_t size,
return NULL;
}
- meminfo = g_malloc0(sizeof(MemCharRead));
-
count = qemu_chr_cirmem_count(chr);
if (count == 0) {
- meminfo->data = g_strdup("");
- return meminfo;
+ return g_strdup("");
}
size = size > count ? count : size;
read_data = g_malloc0(size + 1);
- meminfo->count = cirmem_chr_read(chr, read_data, size);
+ cirmem_chr_read(chr, read_data, size);
if (has_format && (format == DATA_FORMAT_BASE64)) {
- meminfo->data = g_base64_encode(read_data, (size_t)meminfo->count);
+ data = g_base64_encode(read_data, size);
} else {
- meminfo->data = (char *)read_data;
+ data = (char *)read_data;
}
- return meminfo;
+ return data;
}
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)