From 95a83ce7ee413954ba6325584ea659c6685edfd5 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Tue, 10 May 2011 17:31:15 +0200 Subject: savevm: Remove OutputBuffer hack. It's easier to provide a fake Monitor object instead. Change-Id: Ia45267061d489b147497add6120d3caa9234ac11 --- monitor-android.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 monitor-android.h (limited to 'monitor-android.h') diff --git a/monitor-android.h b/monitor-android.h new file mode 100644 index 0000000..b9b0b37 --- /dev/null +++ b/monitor-android.h @@ -0,0 +1,49 @@ +/* This file is included from monitor.c, it's purpose is to hold as much + * Android-specific stuff as possible to ease upstream integrations. + */ + +Monitor* +monitor_fake_new(void* opaque, MonitorFakeFunc cb) +{ + Monitor* mon; + + assert(cb != NULL); + mon = qemu_mallocz(sizeof(*mon)); + mon->fake_opaque = opaque; + mon->fake_func = cb; + mon->fake_count = 0; + + return mon; +} + +int +monitor_fake_get_bytes(Monitor* mon) +{ + assert(mon->fake_func != NULL); + return mon->fake_count; +} + +void +monitor_fake_free(Monitor* mon) +{ + assert(mon->fake_func != NULL); + free(mon); +} + +/* This replaces the definition in monitor.c which is in a + * #ifndef CONFIG_ANDROID .. #endif block. + */ +void monitor_flush(Monitor *mon) +{ + if (!mon) + return; + + if (mon->fake_func != NULL) { + mon->fake_func(mon->fake_opaque, (void*)mon->outbuf, mon->outbuf_index); + mon->outbuf_index = 0; + mon->fake_count += mon->outbuf_index; + } else if (!mon->mux_out) { + qemu_chr_write(mon->chr, mon->outbuf, mon->outbuf_index); + mon->outbuf_index = 0; + } +} -- cgit v1.1