Message ID | 20161018095400.GD2190@work-vm (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 18/10/2016 11:54, Dr. David Alan Gilbert wrote: > I've not quite figured it out but we're linked against the stubs/ monitor > code rather than the real monitor code; and the stubs monitor_vprintf discards > and the stubs monitor_cur_is_qmp() always returns false, so to silence things > we just have to make cur_mon non-NULL. > Unfortunately cur_mon is of type Monitor * and Monitor isn't defined publicly, > so we can't know it's size. The following evil hack does silence things > for anyone desperate, but I do need to find a neater way; perhaps the right > thing is just to link against monitor and create a dummy "null" chardev as you > say. If error_printf/error_vprintf are to a separate file, then stubs/ can be changed to use vfprintf unconditionally. And then I wonder what we actually use cur_mon for, perhaps with this change we can remove stubs/mon*. Paolo
* Paolo Bonzini (pbonzini@redhat.com) wrote: > > > On 18/10/2016 11:54, Dr. David Alan Gilbert wrote: > > I've not quite figured it out but we're linked against the stubs/ monitor > > code rather than the real monitor code; and the stubs monitor_vprintf discards > > and the stubs monitor_cur_is_qmp() always returns false, so to silence things > > we just have to make cur_mon non-NULL. > > Unfortunately cur_mon is of type Monitor * and Monitor isn't defined publicly, > > so we can't know it's size. The following evil hack does silence things > > for anyone desperate, but I do need to find a neater way; perhaps the right > > thing is just to link against monitor and create a dummy "null" chardev as you > > say. > > If error_printf/error_vprintf are to a separate file, then stubs/ can be > changed to use vfprintf unconditionally. Moving code out of util/qemu-error.c just so they can be stubbed separately seems a little odd. > And then I wonder what we actually use cur_mon for, perhaps with this > change we can remove stubs/mon*. I've just posted a slightly cleaner version of that nasty hack that gives a value to assign to cur_mon. Dave > Paolo -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 20/10/2016 12:41, Dr. David Alan Gilbert wrote: > * Paolo Bonzini (pbonzini@redhat.com) wrote: >> >> >> On 18/10/2016 11:54, Dr. David Alan Gilbert wrote: >>> I've not quite figured it out but we're linked against the stubs/ monitor >>> code rather than the real monitor code; and the stubs monitor_vprintf discards >>> and the stubs monitor_cur_is_qmp() always returns false, so to silence things >>> we just have to make cur_mon non-NULL. >>> Unfortunately cur_mon is of type Monitor * and Monitor isn't defined publicly, >>> so we can't know it's size. The following evil hack does silence things >>> for anyone desperate, but I do need to find a neater way; perhaps the right >>> thing is just to link against monitor and create a dummy "null" chardev as you >>> say. >> >> If error_printf/error_vprintf are to a separate file, then stubs/ can be >> changed to use vfprintf unconditionally. > > Moving code out of util/qemu-error.c just so they can be stubbed separately > seems a little odd. Why? It is part of how static libraries work, and allowing fine-grained inclusion is the reason why libqemustub.a and libqemuutil.a are static libraries. Paolo >> And then I wonder what we actually use cur_mon for, perhaps with this >> change we can remove stubs/mon*. > > I've just posted a slightly cleaner version of that nasty hack that gives > a value to assign to cur_mon. > > Dave > >> Paolo > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index d8da26f..c39d3dc 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -27,6 +27,7 @@ #include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "monitor/monitor.h" #include "qemu/coroutine.h" #include "io/channel-file.h" @@ -134,6 +135,11 @@ static int load_vmstate(const VMStateDescription *desc, { /* We test with zero size */ obj_copy(obj_clone, obj); + /* NASTY HACK! Silence error_report - relies on the fact we're using the + * stubs code rather than the real monitor. As long as cur_mon is + * non-null error_report won't print. + */ + cur_mon = g_malloc(1); FAILURE(load_vmstate_one(desc, obj, version, wire, 0)); /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be @@ -154,6 +160,9 @@ static int load_vmstate(const VMStateDescription *desc, FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2)); } + /* Unsilence error-report - we shouldn't get any errors here */ + g_free(cur_mon); + cur_mon = NULL; obj_copy(obj, obj_clone); return load_vmstate_one(desc, obj, version, wire, size); }