From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550481973596129.40145254467234; Mon, 18 Feb 2019 01:26:13 -0800 (PST) Received: from localhost ([127.0.0.1]:55209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvfBk-0004SP-J5 for importer@patchew.org; Mon, 18 Feb 2019 04:26:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf85-0001tO-2t for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf84-0002hL-DW for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf84-0002gp-7P; Mon, 18 Feb 2019 04:22:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F51C7AEAF; Mon, 18 Feb 2019 09:22:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05CCC26DCC; Mon, 18 Feb 2019 09:22:19 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:21:57 +0100 Message-Id: <20190218092202.26683-2-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 09:22:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/6] cpus: Properly release the iothread lock when killing a dummy VCPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enables CPU unplug under qtest. Reviewed-by: Michael S. Tsirkin Reviewed-by: Greg Kurz Reviewed-by: Thomas Huth Reviewed-by: David Gibson Signed-off-by: David Hildenbrand --- cpus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpus.c b/cpus.c index 154daf57dc..e83f72b48b 100644 --- a/cpus.c +++ b/cpus.c @@ -1333,6 +1333,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) qemu_wait_io_event(cpu); } while (!cpu->unplug); =20 + qemu_mutex_unlock_iothread(); rcu_unregister_thread(); return NULL; #endif --=20 2.17.2 From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550481863029528.7722926390421; Mon, 18 Feb 2019 01:24:23 -0800 (PST) Received: from localhost ([127.0.0.1]:55155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf9u-0002uy-US for importer@patchew.org; Mon, 18 Feb 2019 04:24:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf88-0001x3-U2 for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf88-0002lk-48 for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf87-0002lF-US; Mon, 18 Feb 2019 04:22:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EBDD1440AB; Mon, 18 Feb 2019 09:22:27 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id A616816E28; Mon, 18 Feb 2019 09:22:23 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:21:58 +0100 Message-Id: <20190218092202.26683-3-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Feb 2019 09:22:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/6] spapr: support memory unplug for qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fake availability of OV5_HP_EVT, so we can test memory unplug in qtest. Reviewed-by: Michael S. Tsirkin Reviewed-by: Greg Kurz Acked-by: David Gibson Signed-off-by: David Hildenbrand --- hw/ppc/spapr_ovec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/ppc/spapr_ovec.c b/hw/ppc/spapr_ovec.c index 318bf33de4..12510b236a 100644 --- a/hw/ppc/spapr_ovec.c +++ b/hw/ppc/spapr_ovec.c @@ -16,6 +16,7 @@ #include "qemu/bitmap.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" +#include "sysemu/qtest.h" #include "trace.h" #include =20 @@ -131,6 +132,11 @@ bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr) g_assert(ov); g_assert(bitnr < OV_MAXBITS); =20 + /* support memory unplug for qtest */ + if (qtest_enabled() && bitnr =3D=3D OV5_HP_EVT) { + return true; + } + return test_bit(bitnr, ov->bitmap) ? true : false; } =20 --=20 2.17.2 From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550482016268938.5106543793618; Mon, 18 Feb 2019 01:26:56 -0800 (PST) Received: from localhost ([127.0.0.1]:55211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvfCO-0004vW-7Z for importer@patchew.org; Mon, 18 Feb 2019 04:26:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf8d-0002Ha-Ur for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:23:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf8c-00039b-Ge for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41364) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf8a-0002zM-Az; Mon, 18 Feb 2019 04:22:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72994B1EF; Mon, 18 Feb 2019 09:22:43 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54F8B411B; Mon, 18 Feb 2019 09:22:27 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:21:59 +0100 Message-Id: <20190218092202.26683-4-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 18 Feb 2019 09:22:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/6] tests/device-plug: Add a simple PCI unplug request test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The issue with testing asynchronous unplug requests it that they usually require a running guest to handle the request. However, to test if unplug of PCI devices works, we can apply a nice little trick on some architectures: On system reset, x86 ACPI, s390x and spapr will perform the unplug, resulting in the device of interest to get deleted and a DEVICE_DELETED event getting sent. On s390x, we still get a warning qemu-system-s390x: -device virtio-mouse-pci,id=3Ddev0: warning: Plugging a PCI/zPCI device without the 'zpci' CPU feature enabled; the guest will not be able to see/use this device This will be fixed soon, when we enable the zpci CPU feature always (Conny already has a patch for this queued). Reviewed-by: Michael S. Tsirkin Reviewed-by: Greg Kurz Reviewed-by: Thomas Huth Reviewed-by: Collin Walling Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Acked-by: Cornelia Huck --- tests/Makefile.include | 4 ++ tests/device-plug-test.c | 93 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/device-plug-test.c diff --git a/tests/Makefile.include b/tests/Makefile.include index b39e989f72..f242d65ea2 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -192,6 +192,7 @@ check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) +=3D tests/ipmi= -kcs-test$(EXESUF) # check-qtest-i386-$(CONFIG_ISA_IPMI_BT) +=3D tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y +=3D tests/i440fx-test$(EXESUF) check-qtest-i386-y +=3D tests/fw_cfg-test$(EXESUF) +check-qtest-i386-y +=3D tests/device-plug-test$(EXESUF) check-qtest-i386-y +=3D tests/drive_del-test$(EXESUF) check-qtest-i386-$(CONFIG_WDT_IB700) +=3D tests/wdt_ib700-test$(EXESUF) check-qtest-i386-y +=3D tests/tco-test$(EXESUF) @@ -256,6 +257,7 @@ check-qtest-ppc-$(CONFIG_M48T59) +=3D tests/m48t59-test= $(EXESUF) =20 check-qtest-ppc64-y +=3D $(check-qtest-ppc-y) check-qtest-ppc64-$(CONFIG_PSERIES) +=3D tests/spapr-phb-test$(EXESUF) +check-qtest-ppc64-$(CONFIG_PSERIES) +=3D tests/device-plug-test$(EXESUF) check-qtest-ppc64-$(CONFIG_POWERNV) +=3D tests/pnv-xscom-test$(EXESUF) check-qtest-ppc64-y +=3D tests/migration-test$(EXESUF) check-qtest-ppc64-$(CONFIG_PSERIES) +=3D tests/rtas-test$(EXESUF) @@ -310,6 +312,7 @@ check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/test-netfi= lter$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-mirror$(EXESUF) check-qtest-s390x-$(CONFIG_POSIX) +=3D tests/test-filter-redirector$(EXESU= F) check-qtest-s390x-y +=3D tests/drive_del-test$(EXESUF) +check-qtest-s390x-y +=3D tests/device-plug-test$(EXESUF) check-qtest-s390x-y +=3D tests/virtio-ccw-test$(EXESUF) check-qtest-s390x-y +=3D tests/cpu-plug-test$(EXESUF) check-qtest-s390x-y +=3D tests/migration-test$(EXESUF) @@ -750,6 +753,7 @@ tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/test-hmp$(EXESUF): tests/test-hmp.o tests/machine-none-test$(EXESUF): tests/machine-none-test.o +tests/device-plug-test$(EXESUF): tests/device-plug-test.o tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-= y) tests/nvme-test$(EXESUF): tests/nvme-test.o $(libqos-pc-obj-y) tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c new file mode 100644 index 0000000000..cd9ada539d --- /dev/null +++ b/tests/device-plug-test.c @@ -0,0 +1,93 @@ +/* + * QEMU device plug/unplug handling + * + * Copyright (C) 2019 Red Hat Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qstring.h" + +static void device_del_request(QTestState *qtest, const char *id) +{ + QDict *resp; + + resp =3D 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; + + resp =3D qtest_qmp(qtest, "{'execute': 'system_reset'}"); + g_assert(qdict_haskey(resp, "return")); + qobject_unref(resp); +} + +static void wait_device_deleted_event(QTestState *qtest, const char *id) +{ + QDict *resp, *data; + QString *qstr; + + /* + * Other devices might get removed along with the removed device. Skip + * these. The device of interest will be the last one. + */ + for (;;) { + resp =3D qtest_qmp_eventwait_ref(qtest, "DEVICE_DELETED"); + data =3D qdict_get_qdict(resp, "data"); + if (!data || !qdict_get(data, "device")) { + qobject_unref(resp); + continue; + } + qstr =3D qobject_to(QString, qdict_get(data, "device")); + g_assert(qstr); + if (!strcmp(qstring_get_str(qstr), id)) { + qobject_unref(resp); + break; + } + qobject_unref(resp); + } +} + +static void test_pci_unplug_request(void) +{ + QTestState *qtest =3D qtest_initf("-device virtio-mouse-pci,id=3Ddev0"= ); + + /* + * Request device removal. As the guest is not running, the request wo= n't + * be processed. However during system reset, the removal will be + * handled, removing the device. + */ + device_del_request(qtest, "dev0"); + system_reset(qtest); + wait_device_deleted_event(qtest, "dev0"); + + qtest_quit(qtest); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + /* + * We need a system that will process unplug requests during system re= sets + * and does not do PCI surprise removal. This holds for x86 ACPI, + * s390x and spapr. + */ + qtest_add_func("/device-plug/pci-unplug-request", + test_pci_unplug_request); + + return g_test_run(); +} --=20 2.17.2 From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550482165787568.1716498609258; Mon, 18 Feb 2019 01:29:25 -0800 (PST) Received: from localhost ([127.0.0.1]:55259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvfEl-0006Wr-Jd for importer@patchew.org; Mon, 18 Feb 2019 04:29:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf8d-0002HW-RQ for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:23:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf8c-00039i-It for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf8a-00031g-Dx; Mon, 18 Feb 2019 04:22:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DDBAC03DFE1; Mon, 18 Feb 2019 09:22:47 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id B79B3411B; Mon, 18 Feb 2019 09:22:43 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:22:00 +0100 Message-Id: <20190218092202.26683-5-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 09:22:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 4/6] tests/device-plug: Add CCW unplug test for s390x X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As CCW unplugs are surprise removals without asking the guest first, we can test this without any guest interaction. Reviewed-by: Michael S. Tsirkin Reviewed-by: Thomas Huth Signed-off-by: David Hildenbrand Acked-by: Cornelia Huck --- tests/device-plug-test.c | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c index cd9ada539d..d1a6c94af2 100644 --- a/tests/device-plug-test.c +++ b/tests/device-plug-test.c @@ -15,17 +15,26 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" =20 -static void device_del_request(QTestState *qtest, const char *id) +static void device_del_start(QTestState *qtest, const char *id) { - QDict *resp; + qtest_qmp_send(qtest, + "{'execute': 'device_del', 'arguments': { 'id': %s } }"= , id); +} + +static void device_del_finish(QTestState *qtest) +{ + QDict *resp =3D qtest_qmp_receive(qtest); =20 - resp =3D qtest_qmp(qtest, - "{'execute': 'device_del', 'arguments': { 'id': %s } = }", - id); g_assert(qdict_haskey(resp, "return")); qobject_unref(resp); } =20 +static void device_del_request(QTestState *qtest, const char *id) +{ + device_del_start(qtest, id); + device_del_finish(qtest); +} + static void system_reset(QTestState *qtest) { QDict *resp; @@ -77,8 +86,25 @@ static void test_pci_unplug_request(void) qtest_quit(qtest); } =20 +static void test_ccw_unplug(void) +{ + QTestState *qtest =3D qtest_initf("-device virtio-balloon-ccw,id=3Ddev= 0"); + + /* + * The DEVICE_DELETED events will be sent before the command + * completes. + */ + device_del_start(qtest, "dev0"); + wait_device_deleted_event(qtest, "dev0"); + device_del_finish(qtest); + + qtest_quit(qtest); +} + int main(int argc, char **argv) { + const char *arch =3D qtest_get_arch(); + g_test_init(&argc, &argv, NULL); =20 /* @@ -89,5 +115,10 @@ int main(int argc, char **argv) qtest_add_func("/device-plug/pci-unplug-request", test_pci_unplug_request); =20 + if (!strcmp(arch, "s390x")) { + qtest_add_func("/device-plug/ccw-unplug", + test_ccw_unplug); + } + return g_test_run(); } --=20 2.17.2 From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550481895395903.6813396459761; Mon, 18 Feb 2019 01:24:55 -0800 (PST) Received: from localhost ([127.0.0.1]:55160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvfAR-0003O7-AU for importer@patchew.org; Mon, 18 Feb 2019 04:24:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf8d-0002H1-5u for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:23:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf8c-00038p-Av for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf8a-000340-AD; Mon, 18 Feb 2019 04:22:56 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E87F0A1F75; Mon, 18 Feb 2019 09:22:50 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64EE74501; Mon, 18 Feb 2019 09:22:47 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:22:01 +0100 Message-Id: <20190218092202.26683-6-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 18 Feb 2019 09:22:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 5/6] tests/device-plug: Add CPU core unplug request test for spapr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can easily test this, just like PCI. On s390x, cpu unplug is not supported. On x86 ACPI, cpu unplug requires guest interaction to work, so it can't be tested that easily. We might add tests for ACPI later. Reviewed-by: Michael S. Tsirkin Reviewed-by: Greg Kurz Reviewed-by: Thomas Huth Signed-off-by: David Hildenbrand --- tests/device-plug-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c index d1a6c94af2..0262ad6be6 100644 --- a/tests/device-plug-test.c +++ b/tests/device-plug-test.c @@ -101,6 +101,21 @@ static void test_ccw_unplug(void) qtest_quit(qtest); } =20 +static void test_spapr_cpu_unplug_request(void) +{ + QTestState *qtest; + + qtest =3D qtest_initf("-cpu power9_v2.0 -smp 1,maxcpus=3D2 " + "-device power9_v2.0-spapr-cpu-core,core-id=3D1,id= =3Ddev0"); + + /* similar to test_pci_unplug_request */ + device_del_request(qtest, "dev0"); + system_reset(qtest); + wait_device_deleted_event(qtest, "dev0"); + + qtest_quit(qtest); +} + int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); @@ -120,5 +135,10 @@ int main(int argc, char **argv) test_ccw_unplug); } =20 + if (!strcmp(arch, "ppc64")) { + qtest_add_func("/device-plug/spapr-cpu-unplug-request", + test_spapr_cpu_unplug_request); + } + return g_test_run(); } --=20 2.17.2 From nobody Sun May 5 15:48:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550482094775141.27597009910573; Mon, 18 Feb 2019 01:28:14 -0800 (PST) Received: from localhost ([127.0.0.1]:55240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvfDd-0005rn-Qh for importer@patchew.org; Mon, 18 Feb 2019 04:28:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvf8d-0002HE-H2 for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:23:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvf8c-00039O-Gi for qemu-devel@nongnu.org; Mon, 18 Feb 2019 04:22:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59062) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvf8a-00036I-Cx; Mon, 18 Feb 2019 04:22:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6FCC3C2CFC; Mon, 18 Feb 2019 09:22:54 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-198.ams2.redhat.com [10.36.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B415411B; Mon, 18 Feb 2019 09:22:51 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2019 10:22:02 +0100 Message-Id: <20190218092202.26683-7-david@redhat.com> In-Reply-To: <20190218092202.26683-1-david@redhat.com> References: <20190218092202.26683-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Feb 2019 09:22:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 6/6] tests/device-plug: Add memory unplug request test for spapr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , "Michael S . Tsirkin" , Pierre Morel , Peter Crosthwaite , Cornelia Huck , David Hildenbrand , Collin Walling , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can easily test this, just like PCI. On x86 ACPI, we need guest interaction to make it work, so it is not that easy to test. We might add tests for that later on. Reviewed-by: Michael S. Tsirkin Reviewed-by: Greg Kurz Reviewed-by: Thomas Huth Signed-off-by: David Hildenbrand --- tests/device-plug-test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c index 0262ad6be6..87593d9ecf 100644 --- a/tests/device-plug-test.c +++ b/tests/device-plug-test.c @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void) qtest_quit(qtest); } =20 +static void test_spapr_memory_unplug_request(void) +{ + QTestState *qtest; + + qtest =3D qtest_initf("-m 256M,slots=3D1,maxmem=3D768M " + "-object memory-backend-ram,id=3Dmem0,size=3D512M " + "-device pc-dimm,id=3Ddev0,memdev=3Dmem0"); + + /* similar to test_pci_unplug_request */ + device_del_request(qtest, "dev0"); + system_reset(qtest); + wait_device_deleted_event(qtest, "dev0"); + + qtest_quit(qtest); +} + int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); @@ -138,6 +154,8 @@ int main(int argc, char **argv) if (!strcmp(arch, "ppc64")) { qtest_add_func("/device-plug/spapr-cpu-unplug-request", test_spapr_cpu_unplug_request); + qtest_add_func("/device-plug/spapr-memory-unplug-request", + test_spapr_memory_unplug_request); } =20 return g_test_run(); --=20 2.17.2