[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2] tests: Introduce generic device hot-plug/hot-unplug functions |
Date: |
Tue, 19 Sep 2017 08:38:00 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
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.
>
> Signed-off-by: Thomas Huth <address@hidden>
> ---
> + */
> +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. We really want
to have two low-level functions (one to send, one to receive), and then
have qmp() be the combination of both in a row; we have qmp_async() for
the send, and only qtest_receive() for the receive, so I'll have to
revive my work on unifying things...
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature