qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Amit Shah <amit@kernel.org>
Subject: Re: [Qemu-devel] [RFC PATCH for 2.11] tests: Introduce generic device hot-plug/hot-unplug functions
Date: Wed, 13 Sep 2017 20:22:27 +0800	[thread overview]
Message-ID: <20170913122227.GH3617@pxdev.xzpeter.org> (raw)
In-Reply-To: <8046ee88-1d7e-b34c-e5db-f55c67f98a7e@redhat.com>

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	other threads:[~2017-09-13 12:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15  9:22 [Qemu-devel] [RFC PATCH for 2.11] tests: Introduce generic device hot-plug/hot-unplug functions Thomas Huth
2017-09-13 10:41 ` Peter Xu
2017-09-13 10:56   ` Thomas Huth
2017-09-13 12:22     ` Peter Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170913122227.GH3617@pxdev.xzpeter.org \
    --to=peterx@redhat.com \
    --cc=amit@kernel.org \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).