[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] tests: Introduce generic device hot-plug/hot
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCH v2] tests: Introduce generic device hot-plug/hot-unplug functions |
Date: |
Tue, 19 Sep 2017 17:22:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
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
signature.asc
Description: OpenPGP digital signature