qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Eric Blake <eblake@redhat.com>,
	qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>
Cc: Amit Shah <amit@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] tests: Introduce generic device hot-plug/hot-unplug functions
Date: Tue, 19 Sep 2017 17:22:44 +0200	[thread overview]
Message-ID: <d8375329-3c52-1932-df65-1fbfea488a66@redhat.com> (raw)
In-Reply-To: <f09b7bd0-2055-9f1c-4bb8-ab5f2bbf6837@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1426 bytes --]

On 19.09.2017 15:38, Eric Blake wrote:
> On 09/13/2017 01:40 PM, Thomas Huth wrote:
>> A lot of tests provide code for adding and removing a device via the
>> device_add and device_del QMP commands. Maintaining this code in so many
>> places is cumbersome and error-prone (some of the code parts check the
>> responses for device deletion in an incorrect way, for example, we've got
>> to deal with both, error code and DEVICE_DEL event here). So let's provide
>> some proper generic functions for adding and removing a device instead.
>>
>> The code for correctly unplugging a device has been taken from a patch
>> from Peter Xu.
[...]
>> +void qtest_qmp_device_del(const char *id)
>> +{
>> +    QDict *response1, *response2, *event = NULL;
>> +    char *cmd;
>> +
>> +    cmd = g_strdup_printf("{'execute': 'device_del',"
>> +                          " 'arguments': { 'id': '%s' }}", id);
>> +    response1 = qmp(cmd);
>> +    g_free(cmd);
>> +    g_assert(response1);
>> +    g_assert(!qdict_haskey(response1, "error"));
>> +
>> +    response2 = qmp("");
> 
> Hmm, this new use of qmp("") means I get to rebase the efforts to remove
> the empty qmp command usage from the testsuite efforts.

Sorry about that :-/ I hope it's not too much of a hassle!

Maybe we should finally also add some assert(strlen(fmt) > 0) to that
function to avoid that the problem sneaks in again?

 Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2017-09-19 15:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 18:40 [Qemu-devel] [PATCH v2] tests: Introduce generic device hot-plug/hot-unplug functions Thomas Huth
2017-09-14  4:30 ` Peter Xu
2017-09-19 13:38 ` Eric Blake
2017-09-19 15:22   ` Thomas Huth [this message]
2017-09-19 15:37     ` Eric Blake

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=d8375329-3c52-1932-df65-1fbfea488a66@redhat.com \
    --to=thuth@redhat.com \
    --cc=amit@kernel.org \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).