[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] libqtest: add qmp_device_del()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] libqtest: add qmp_device_del() |
Date: |
Mon, 2 Oct 2017 12:33:25 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/02/2017 12:25 PM, Markus Armbruster wrote:
> Peter Xu <address@hidden> writes:
>
>> Device deletion is tricky since we'll get both a response and an event,
>> while the order of arrival may vary. Provide a helper to handle this
>> complexity.
>>
>> Signed-off-by: Peter Xu <address@hidden>
>> ---
>> tests/libqtest.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>> tests/libqtest.h | 8 ++++++++
>> 2 files changed, 56 insertions(+)
>>
>> diff --git a/tests/libqtest.c b/tests/libqtest.c
>> index b9a1f18..a34d8c4 100644
>> --- a/tests/libqtest.c
>> +++ b/tests/libqtest.c
>> @@ -925,6 +925,54 @@ QDict *qmp(const char *fmt, ...)
>> return response;
>> }
>>
>> +void qmp_device_del(const char *id)
>> +
>> + response2 = qmp("");
>> + g_assert(response2);
>> + g_assert(!qdict_haskey(response2, "error"));
>
> qmp_receive() would be cleaner than qmp("").
>
>> +
>> + if (qdict_haskey(response1, "event")) {
>> + event = response1;
>> + } else if (qdict_haskey(response2, "event")) {
>> + event = response2;
>> + }
>> + g_assert(event);
>> + g_assert(!strcmp(qdict_get_str(event, "event"), "DEVICE_DELETED"));
>> +
>> + QDECREF(response1);
>> + QDECREF(response2);
>> +}
>> +
>
> Uh, this looks similar to existing qtest_qmp_device_del(). Do we need both?
In fact, if I'm reading correctly, this is an early version, which was
retitled into commit acd80015 adding qtest_qmp_device_del().
At any rate, when I post my respin of my libqtest cleanups, I have the
qmp("") slated to be fixed.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature