On Wed, Sep 13, 2017 at 12:56:20PM +0200, Thomas Huth wrote:

[...]

> >> +
> >> +/**
> >> + * Generic hot-plugging test via the device_add QMP command
> >> + */
> >> +void qtest_hot_plug_device(const char *driver, const char *id,
> >> +                           const char *fmt, ...)
> >> +{
> >> +    QDict *response;
> >> +    char *cmd, *opts = NULL;
> >> +    va_list va;
> >> +
> >> +    if (fmt) {
> >> +        va_start(va, fmt);
> >> +        opts = g_strdup_vprintf(fmt, va);
> >> +        va_end(va);
> >> +    }
> >> +
> >> +    cmd = g_strdup_printf("{'execute': 'device_add',"
> >> +                          " 'arguments': { 'driver': '%s', 'id': '%s'%s%s 
> >> }}",
> >> +                          driver, id, opts ? ", " : "", opts ? opts : "");
> >> +    g_free(opts);
> >> +
> >> +    response = qmp(cmd);
> >> +    g_free(cmd);
> >> +    g_assert(response);
> >> +    while (qdict_haskey(response, "event")) {
> >> +        /* We can get DEVICE_DELETED events in case something went wrong 
> >> */
> >> +        g_assert_cmpstr(qdict_get_str(response, "event"), !=, 
> >> "DEVICE_DELETED");
> >> +        QDECREF(response);
> >> +        response = qmp("");
> >> +        g_assert(response);
> >> +    }
> > 
> > I guess we don't need this block for hot plug? :-)
> 
> I'm pretty sure I've seen this happening somewhere ... but maybe it was
> just a fall-out of the mis-behaving usb test...
> I'll replace it with a  g_assert(!qdict_haskey(response, "event"))
> instead, since we should not get any events in this case, should we?

I think we should not, at least there is no such DEVICE_NEW message
defined.  Maybe that's the thing you mentioned? (say, an old test
didn't flush the read pipe so the message from the old one leaked into
a new test)

Thanks,

-- 
Peter Xu

Reply via email to