Message ID | 1382978620-16641-3-git-send-email-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
Am 28.10.2013 um 17:43 hat Paolo Bonzini geschrieben: > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > tests/libqtest.c | 10 +++++++--- > tests/libqtest.h | 17 +++++++++++------ > 2 files changed, 18 insertions(+), 9 deletions(-) > > diff --git a/tests/libqtest.c b/tests/libqtest.c > index bb82069..5205a43 100644 > --- a/tests/libqtest.c > +++ b/tests/libqtest.c > @@ -291,7 +291,7 @@ redo: > return words; > } > > -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap) > +bool qtest_qmpv(QTestState *s, const char *fmt, va_list ap) > { > bool has_reply = false; > int nesting = 0; > @@ -324,15 +324,19 @@ void qtest_qmpv(QTestState *s, const char *fmt, va_list ap) > break; > } > } > + return has_reply; > } > > -void qtest_qmp(QTestState *s, const char *fmt, ...) > +bool qtest_qmp(QTestState *s, const char *fmt, ...) > { > va_list ap; > + bool has_reply; > > va_start(ap, fmt); > - qtest_qmpv(s, fmt, ap); > + has_reply = qtest_qmpv(s, fmt, ap); > va_end(ap); > + > + return has_reply; > } > > const char *qtest_get_arch(void) > diff --git a/tests/libqtest.h b/tests/libqtest.h > index a6e99bd..e8a4e34 100644 > --- a/tests/libqtest.h > +++ b/tests/libqtest.h > @@ -48,9 +48,10 @@ void qtest_quit(QTestState *s); > * @s: #QTestState instance to operate on. > * @fmt...: QMP message to send to qemu > * > - * Sends a QMP message to QEMU > + * Sends a QMP message to QEMU. Returns true if there > + * was a reply. > */ > -void qtest_qmp(QTestState *s, const char *fmt, ...); > +bool qtest_qmp(QTestState *s, const char *fmt, ...); > > /** > * qtest_qmpv: > @@ -58,9 +59,10 @@ void qtest_qmp(QTestState *s, const char *fmt, ...); > * @fmt: QMP message to send to QEMU > * @ap: QMP message arguments > * > - * Sends a QMP message to QEMU. > + * Sends a QMP message to QEMU. Returns true if there > + * was a reply. > */ > -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap); > +bool qtest_qmpv(QTestState *s, const char *fmt, va_list ap); > > /** > * qtest_get_irq: > @@ -336,13 +338,16 @@ static inline void qtest_end(void) > * > * Sends a QMP message to QEMU > */ > -static inline void qmp(const char *fmt, ...) > +static inline bool qmp(const char *fmt, ...) > { > va_list ap; > + bool has_reply; > > va_start(ap, fmt); > - qtest_qmpv(global_qtest, fmt, ap); > + has_reply = qtest_qmpv(global_qtest, fmt, ap); > va_end(ap); > + > + return has_reply; > } Can this ever return false? If there isn't a reply, doesn't it wait until it receives one? Anyway, I think Stefan had some patches to actually get the reply in a usable way. They probably conflict with this. Perhaps just applying Stefan's patches already gives you what you need here? Kevin
Il 30/10/2013 13:06, Kevin Wolf ha scritto: > Anyway, I think Stefan had some patches to actually get the reply in a > usable way. They probably conflict with this. Perhaps just applying > Stefan's patches already gives you what you need here? Yes, especially if they let me get both events and command returns. Paolo
diff --git a/tests/libqtest.c b/tests/libqtest.c index bb82069..5205a43 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -291,7 +291,7 @@ redo: return words; } -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap) +bool qtest_qmpv(QTestState *s, const char *fmt, va_list ap) { bool has_reply = false; int nesting = 0; @@ -324,15 +324,19 @@ void qtest_qmpv(QTestState *s, const char *fmt, va_list ap) break; } } + return has_reply; } -void qtest_qmp(QTestState *s, const char *fmt, ...) +bool qtest_qmp(QTestState *s, const char *fmt, ...) { va_list ap; + bool has_reply; va_start(ap, fmt); - qtest_qmpv(s, fmt, ap); + has_reply = qtest_qmpv(s, fmt, ap); va_end(ap); + + return has_reply; } const char *qtest_get_arch(void) diff --git a/tests/libqtest.h b/tests/libqtest.h index a6e99bd..e8a4e34 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -48,9 +48,10 @@ void qtest_quit(QTestState *s); * @s: #QTestState instance to operate on. * @fmt...: QMP message to send to qemu * - * Sends a QMP message to QEMU + * Sends a QMP message to QEMU. Returns true if there + * was a reply. */ -void qtest_qmp(QTestState *s, const char *fmt, ...); +bool qtest_qmp(QTestState *s, const char *fmt, ...); /** * qtest_qmpv: @@ -58,9 +59,10 @@ void qtest_qmp(QTestState *s, const char *fmt, ...); * @fmt: QMP message to send to QEMU * @ap: QMP message arguments * - * Sends a QMP message to QEMU. + * Sends a QMP message to QEMU. Returns true if there + * was a reply. */ -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap); +bool qtest_qmpv(QTestState *s, const char *fmt, va_list ap); /** * qtest_get_irq: @@ -336,13 +338,16 @@ static inline void qtest_end(void) * * Sends a QMP message to QEMU */ -static inline void qmp(const char *fmt, ...) +static inline bool qmp(const char *fmt, ...) { va_list ap; + bool has_reply; va_start(ap, fmt); - qtest_qmpv(global_qtest, fmt, ap); + has_reply = qtest_qmpv(global_qtest, fmt, ap); va_end(ap); + + return has_reply; } /**
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- tests/libqtest.c | 10 +++++++--- tests/libqtest.h | 17 +++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-)