tests/x86: add helper qtest_qmp_device_del_send()

Move sending 'device_del' command to separate function.
Function can be used in case of addition action is needed to start
actual removing device after sending command.

Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
Message-Id: <20220929223547.1429580-2-michael.labiuk@virtuozzo.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
[thuth: Fixed typo]
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Michael Labiuk 2022-09-30 01:35:39 +03:00 committed by Thomas Huth
parent 770beadb98
commit ea42a6c405
5 changed files with 25 additions and 32 deletions

View file

@ -15,17 +15,6 @@
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
static void device_del(QTestState *qtest, const char *id)
{
QDict *resp;
resp = qtest_qmp(qtest,
"{'execute': 'device_del', 'arguments': { 'id': %s } }", id);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
}
static void system_reset(QTestState *qtest)
{
QDict *resp;
@ -68,7 +57,7 @@ static void process_device_remove(QTestState *qtest, const char *id)
* be processed. However during system reset, the removal will be
* handled, removing the device.
*/
device_del(qtest, id);
qtest_qmp_device_del_send(qtest, id);
system_reset(qtest);
wait_device_deleted_event(qtest, id);
}
@ -112,7 +101,7 @@ static void test_ccw_unplug(void)
{
QTestState *qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
device_del(qtest, "dev0");
qtest_qmp_device_del_send(qtest, "dev0");
wait_device_deleted_event(qtest, "dev0");
qtest_quit(qtest);