diff options
author | David 'Digit' Turner <digit@android.com> | 2011-05-10 17:31:15 +0200 |
---|---|---|
committer | David 'Digit' Turner <digit@android.com> | 2011-06-01 17:08:18 +0200 |
commit | 95a83ce7ee413954ba6325584ea659c6685edfd5 (patch) | |
tree | 9d3a33d309a435361b855c9f09eb4629a3b5b2a9 /monitor-android.h | |
parent | 986acc9eba2cf7c9b468c2f84764fa478907ac66 (diff) | |
download | external_qemu-95a83ce7ee413954ba6325584ea659c6685edfd5.zip external_qemu-95a83ce7ee413954ba6325584ea659c6685edfd5.tar.gz external_qemu-95a83ce7ee413954ba6325584ea659c6685edfd5.tar.bz2 |
savevm: Remove OutputBuffer hack.
It's easier to provide a fake Monitor object instead.
Change-Id: Ia45267061d489b147497add6120d3caa9234ac11
Diffstat (limited to 'monitor-android.h')
-rw-r--r-- | monitor-android.h | 49 |
1 files changed, 49 insertions, 0 deletions
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; + } +} |