From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089792; cv=none; d=zohomail.com; s=zohoarc; b=Vfc73LVbk+YM50E2R8kx4Z/wcsSfDtap3FdZUCw4fL26ZWoPSjU8WcygVMFRENZoVJpNmdzeGDlGubWv7cOTxMWB99Y+KyJwxlBVOqf4zfpAnWRyhpFgmebfy47k8xJi0/fSjr3UWc+yMalJrOvCgMWrAxxXw2W81I3+kQ8RsQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089792; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RxEnr9OgTsaxRnNcqrFO9mwEThypEltoPLodmgEnhOw=; b=ZSIAywo2HcYhmyhAWyIEiuqee8B/QHGrFAfT/pAdwH/2oBbK+XuU0VOO4GuqAFa4xQaOkNe0VJchA01KrNUW/myVsZ2VZGjrGtFOTjgYzznOb2SSfveTDm9Nl2nJhwjLEYFxq8RIy49SmDG5HGD2GSQ90KbuXHfiTkNfs8IO3z8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689089792661662.6448566733088; Tue, 11 Jul 2023 08:36:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOg-00080U-BD; Tue, 11 Jul 2023 11:35:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOa-0007vJ-0U for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOW-0005qU-A7 for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-oaGRBzSlOIiVLgU8Ndupew-1; Tue, 11 Jul 2023 11:35:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DA03848185; Tue, 11 Jul 2023 15:18:03 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id D024FC09A09; Tue, 11 Jul 2023 15:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RxEnr9OgTsaxRnNcqrFO9mwEThypEltoPLodmgEnhOw=; b=TMTr2U4ghNXPVm/RD75A4J4x3TfL2/LN7kSEGixX3L6lB9ng6IFMskrAdskXesfuxbQxv0 zbfBf6Yb28U3YibuU7nFqCramEVLFzkE9otoezo2qfQxsEu8tcB788+EewkjBqcxzYvVny pdxkzapl6y4387fqzJxfEBfm3/T2dKM= X-MC-Unique: oaGRBzSlOIiVLgU8Ndupew-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 1/7] virtio-md-pci: New parent type for virtio-mem-pci and virtio-pmem-pci Date: Tue, 11 Jul 2023 17:34:39 +0200 Message-ID: <20230711153445.514112-2-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089794898100003 Content-Type: text/plain; charset="utf-8" Let's add a new abstract "virtio memory device" type, and use it as parent class of virtio-mem-pci and virtio-pmem-pci. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- MAINTAINERS | 6 ++++++ hw/virtio/Kconfig | 8 +++++-- hw/virtio/meson.build | 1 + hw/virtio/virtio-md-pci.c | 33 +++++++++++++++++++++++++++++ hw/virtio/virtio-mem-pci.c | 5 +---- hw/virtio/virtio-mem-pci.h | 6 +++--- hw/virtio/virtio-pmem-pci.c | 5 +---- hw/virtio/virtio-pmem-pci.h | 6 +++--- include/hw/virtio/virtio-md-pci.h | 35 +++++++++++++++++++++++++++++++ 9 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 hw/virtio/virtio-md-pci.c create mode 100644 include/hw/virtio/virtio-md-pci.h diff --git a/MAINTAINERS b/MAINTAINERS index e158a25cfe..bb4626faf7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2229,6 +2229,12 @@ F: hw/virtio/virtio-crypto.c F: hw/virtio/virtio-crypto-pci.c F: include/hw/virtio/virtio-crypto.h =20 +virtio based memory device +M: David Hildenbrand +S: Supported +F: hw/virtio/virtio-md-pci.c +F: include/hw/virtio/virtio-md-pci.h + virtio-mem M: David Hildenbrand S: Supported diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index a9ee09062f..92c9cf6c96 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -35,6 +35,10 @@ config VIRTIO_CRYPTO default y depends on VIRTIO =20 +config VIRTIO_MD + bool + select MEM_DEVICE + config VIRTIO_PMEM_SUPPORTED bool =20 @@ -43,7 +47,7 @@ config VIRTIO_PMEM default y depends on VIRTIO depends on VIRTIO_PMEM_SUPPORTED - select MEM_DEVICE + select VIRTIO_MD =20 config VIRTIO_MEM_SUPPORTED bool @@ -54,7 +58,7 @@ config VIRTIO_MEM depends on VIRTIO depends on LINUX depends on VIRTIO_MEM_SUPPORTED - select MEM_DEVICE + select VIRTIO_MD =20 config VHOST_VSOCK_COMMON bool diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index c4f4fe05fa..13e7c6c272 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -63,6 +63,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: fi= les('virtio-pmem-pci.c' virtio_pci_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iomm= u-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pc= i.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-= pci.c')) +virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.= c')) =20 specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_= ss) =20 diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c new file mode 100644 index 0000000000..6b02ff908e --- /dev/null +++ b/hw/virtio/virtio-md-pci.c @@ -0,0 +1,33 @@ +/* + * Abstract virtio based memory device + * + * Copyright (C) 2023 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/virtio/virtio-md-pci.h" +#include "hw/mem/memory-device.h" + +static const TypeInfo virtio_md_pci_info =3D { + .name =3D TYPE_VIRTIO_MD_PCI, + .parent =3D TYPE_VIRTIO_PCI, + .instance_size =3D sizeof(VirtIOMDPCI), + .class_size =3D sizeof(VirtIOMDPCIClass), + .abstract =3D true, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_MEMORY_DEVICE }, + { } + }, +}; + +static void virtio_md_pci_register(void) +{ + type_register_static(&virtio_md_pci_info); +} +type_init(virtio_md_pci_register) diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index b85c12668d..2ef0f07630 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -142,14 +142,11 @@ static void virtio_mem_pci_instance_init(Object *obj) =20 static const VirtioPCIDeviceTypeInfo virtio_mem_pci_info =3D { .base_name =3D TYPE_VIRTIO_MEM_PCI, + .parent =3D TYPE_VIRTIO_MD_PCI, .generic_name =3D "virtio-mem-pci", .instance_size =3D sizeof(VirtIOMEMPCI), .instance_init =3D virtio_mem_pci_instance_init, .class_init =3D virtio_mem_pci_class_init, - .interfaces =3D (InterfaceInfo[]) { - { TYPE_MEMORY_DEVICE }, - { } - }, }; =20 static void virtio_mem_pci_register_types(void) diff --git a/hw/virtio/virtio-mem-pci.h b/hw/virtio/virtio-mem-pci.h index e636e1a48d..c50b51d608 100644 --- a/hw/virtio/virtio-mem-pci.h +++ b/hw/virtio/virtio-mem-pci.h @@ -13,21 +13,21 @@ #ifndef QEMU_VIRTIO_MEM_PCI_H #define QEMU_VIRTIO_MEM_PCI_H =20 -#include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-md-pci.h" #include "hw/virtio/virtio-mem.h" #include "qom/object.h" =20 typedef struct VirtIOMEMPCI VirtIOMEMPCI; =20 /* - * virtio-mem-pci: This extends VirtioPCIProxy. + * virtio-mem-pci: This extends VirtIOMDPCI. */ #define TYPE_VIRTIO_MEM_PCI "virtio-mem-pci-base" DECLARE_INSTANCE_CHECKER(VirtIOMEMPCI, VIRTIO_MEM_PCI, TYPE_VIRTIO_MEM_PCI) =20 struct VirtIOMEMPCI { - VirtIOPCIProxy parent_obj; + VirtIOMDPCI parent_obj; VirtIOMEM vdev; Notifier size_change_notifier; }; diff --git a/hw/virtio/virtio-pmem-pci.c b/hw/virtio/virtio-pmem-pci.c index 197d219204..cfe7f3b67c 100644 --- a/hw/virtio/virtio-pmem-pci.c +++ b/hw/virtio/virtio-pmem-pci.c @@ -110,13 +110,10 @@ static void virtio_pmem_pci_instance_init(Object *obj) static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info =3D { .base_name =3D TYPE_VIRTIO_PMEM_PCI, .generic_name =3D "virtio-pmem-pci", + .parent =3D TYPE_VIRTIO_MD_PCI, .instance_size =3D sizeof(VirtIOPMEMPCI), .instance_init =3D virtio_pmem_pci_instance_init, .class_init =3D virtio_pmem_pci_class_init, - .interfaces =3D (InterfaceInfo[]) { - { TYPE_MEMORY_DEVICE }, - { } - }, }; =20 static void virtio_pmem_pci_register_types(void) diff --git a/hw/virtio/virtio-pmem-pci.h b/hw/virtio/virtio-pmem-pci.h index 63cfe727f7..88b01ce2db 100644 --- a/hw/virtio/virtio-pmem-pci.h +++ b/hw/virtio/virtio-pmem-pci.h @@ -14,21 +14,21 @@ #ifndef QEMU_VIRTIO_PMEM_PCI_H #define QEMU_VIRTIO_PMEM_PCI_H =20 -#include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-md-pci.h" #include "hw/virtio/virtio-pmem.h" #include "qom/object.h" =20 typedef struct VirtIOPMEMPCI VirtIOPMEMPCI; =20 /* - * virtio-pmem-pci: This extends VirtioPCIProxy. + * virtio-pmem-pci: This extends VirtIOMDPCI. */ #define TYPE_VIRTIO_PMEM_PCI "virtio-pmem-pci-base" DECLARE_INSTANCE_CHECKER(VirtIOPMEMPCI, VIRTIO_PMEM_PCI, TYPE_VIRTIO_PMEM_PCI) =20 struct VirtIOPMEMPCI { - VirtIOPCIProxy parent_obj; + VirtIOMDPCI parent_obj; VirtIOPMEM vdev; }; =20 diff --git a/include/hw/virtio/virtio-md-pci.h b/include/hw/virtio/virtio-m= d-pci.h new file mode 100644 index 0000000000..a241b54fcd --- /dev/null +++ b/include/hw/virtio/virtio-md-pci.h @@ -0,0 +1,35 @@ +/* + * Abstract virtio based memory device + * + * Copyright (C) 2023 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_VIRTIO_MD_PCI_H +#define HW_VIRTIO_MD_PCI_H + +#include "hw/virtio/virtio-pci.h" +#include "qom/object.h" + +/* + * virtio-md-pci: This extends VirtioPCIProxy. + */ +#define TYPE_VIRTIO_MD_PCI "virtio-md-pci" + +OBJECT_DECLARE_TYPE(VirtIOMDPCI, VirtIOMDPCIClass, VIRTIO_MD_PCI) + +struct VirtIOMDPCIClass { + /* private */ + VirtioPCIClass parent; +}; + +struct VirtIOMDPCI { + VirtIOPCIProxy parent_obj; +}; + +#endif --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089723; cv=none; d=zohomail.com; s=zohoarc; b=ZzMVW8wla9jZ3xgqCBDtwxAYQfTw21D0pNa3bjR+dIl52akyI/KlRDipd3wY13qlaGmVoXKBmx+rUvTQ8Ij9s8BCiQKgl7dHG5L6qurzBw6OPwjpvzX2yXZioAQ1ukl0Ucr4o0ph9IIPTiTt44JroXtNTWmgBs7xYiePrrFBb5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089723; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ie29s7FEVop4WjIreoVUee2qq6+X+IofOGQT6UFtNyw=; b=TKzQAR9koK+9G99CtBY8dcI0nUFgIt2ODuicIF32+ZNeiBQUGtQfH0559JleCEg+ZPH4si6I5xlDyf2zMLUhHm9MA3w9zbuyUBstCBxC333S6W56LsNpzGUmBuonwJY8/9P/RmGgeQgo0neIFlbbLylGsgGeoO+l7bUWRlqKIu8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16890897228881023.0913202420468; Tue, 11 Jul 2023 08:35:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOR-0007rF-CQ; Tue, 11 Jul 2023 11:35:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOL-0007mV-AA for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOH-0005c6-Tu for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-MufhpuM_Oueeq5SFlNboSg-1; Tue, 11 Jul 2023 11:34:54 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 484D3382C972; Tue, 11 Jul 2023 15:34:54 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 968CDC09A09; Tue, 11 Jul 2023 15:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ie29s7FEVop4WjIreoVUee2qq6+X+IofOGQT6UFtNyw=; b=iNmqNtSrUVlRCAErCnQT5zkU2/w63rsTA2ju3jBOGIGjPUjNRUfb8Nt1uzXhjF8FjxGitx qXwYxxpmtB5w8QvxwdXylNPLrbvYWgP9sfWoeWoAhnDBcIiP4LbyNSYYUVBl71W0oloV40 Y/8OHpVFD9hE3AygEDhC8CldKQbwcWY= X-MC-Unique: MufhpuM_Oueeq5SFlNboSg-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 2/7] pc: Factor out (un)plug handling of virtio-md-pci devices Date: Tue, 11 Jul 2023 17:34:40 +0200 Message-ID: <20230711153445.514112-3-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089724688100003 Content-Type: text/plain; charset="utf-8" Let's factor out (un)plug handling, to be reused from arm/virt code. Provide stubs for the case that CONFIG_VIRTIO_MD is not selected because neither virtio-mem nor virtio-pmem is enabled. While this cannot currently happen for x86, it will be possible for arm/virt. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- MAINTAINERS | 1 + hw/i386/pc.c | 90 ++++--------------------------- hw/virtio/virtio-md-pci.c | 63 ++++++++++++++++++++++ include/hw/virtio/virtio-md-pci.h | 6 +++ stubs/meson.build | 1 + stubs/virtio-md-pci.c | 24 +++++++++ 6 files changed, 106 insertions(+), 79 deletions(-) create mode 100644 stubs/virtio-md-pci.c diff --git a/MAINTAINERS b/MAINTAINERS index bb4626faf7..12e59b6b27 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2234,6 +2234,7 @@ M: David Hildenbrand S: Supported F: hw/virtio/virtio-md-pci.c F: include/hw/virtio/virtio-md-pci.h +F: stubs/virtio-md-pci.c =20 virtio-mem M: David Hildenbrand diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f01d7de5ad..c74a4014f0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -88,13 +88,11 @@ #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h" #include "hw/virtio/virtio-iommu.h" -#include "hw/virtio/virtio-pmem-pci.h" -#include "hw/virtio/virtio-mem-pci.h" +#include "hw/virtio/virtio-md-pci.h" #include "hw/i386/kvm/xen_overlay.h" #include "hw/i386/kvm/xen_evtchn.h" #include "hw/i386/kvm/xen_gnttab.h" #include "hw/i386/kvm/xen_xenstore.h" -#include "hw/mem/memory-device.h" #include "sysemu/replay.h" #include "target/i386/cpu.h" #include "e820_memory_layout.h" @@ -1500,68 +1498,6 @@ static void pc_memory_unplug(HotplugHandler *hotplug= _dev, error_propagate(errp, local_err); } =20 -static void pc_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); - Error *local_err =3D NULL; - - if (!hotplug_dev2 && dev->hotplugged) { - /* - * Without a bus hotplug handler, we cannot control the plug/unplug - * order. We should never reach this point when hotplugging on x86, - * however, better add a safety net. - */ - error_setg(errp, "hotplug of virtio based memory devices not suppo= rted" - " on this bus."); - return; - } - /* - * First, see if we can plug this memory device at all. If that - * succeeds, branch of to the actual hotplug handler. - */ - memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL, - &local_err); - if (!local_err && hotplug_dev2) { - hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err); - } - error_propagate(errp, local_err); -} - -static void pc_virtio_md_pci_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); - Error *local_err =3D NULL; - - /* - * Plug the memory device first and then branch off to the actual - * hotplug handler. If that one fails, we can easily undo the memory - * device bits. - */ - memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); - if (hotplug_dev2) { - hotplug_handler_plug(hotplug_dev2, dev, &local_err); - if (local_err) { - memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); - } - } - error_propagate(errp, local_err); -} - -static void pc_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - /* We don't support hot unplug of virtio based memory devices */ - error_setg(errp, "virtio based memory devices cannot be unplugged."); -} - -static void pc_virtio_md_pci_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - /* We don't support hot unplug of virtio based memory devices */ -} - static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1569,9 +1505,8 @@ static void pc_machine_device_pre_plug_cb(HotplugHand= ler *hotplug_dev, pc_memory_pre_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { x86_cpu_pre_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - pc_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_pre_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), e= rrp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { /* Declare the APIC range as the reserved MSI region */ char *resv_prop_str =3D g_strdup_printf("0xfee00000:0xfeefffff:%d", @@ -1603,9 +1538,8 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, pc_memory_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { x86_cpu_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - pc_virtio_md_pci_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), errp); } } =20 @@ -1616,9 +1550,9 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, pc_memory_unplug_request(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { x86_cpu_unplug_request_cb(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - pc_virtio_md_pci_unplug_request(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_unplug_request(VIRTIO_MD_PCI(dev), MACHINE(hotplug_d= ev), + errp); } else { error_setg(errp, "acpi: device unplug request for not supported de= vice" " type: %s", object_get_typename(OBJECT(dev))); @@ -1632,9 +1566,8 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, pc_memory_unplug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { x86_cpu_unplug_cb(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - pc_virtio_md_pci_unplug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_unplug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), err= p); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -1646,8 +1579,7 @@ static HotplugHandler *pc_get_hotplug_handler(Machine= State *machine, { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_CPU) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE)) { return HOTPLUG_HANDLER(machine); diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index 6b02ff908e..e849c3131d 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -13,6 +13,69 @@ #include "qemu/osdep.h" #include "hw/virtio/virtio-md-pci.h" #include "hw/mem/memory-device.h" +#include "qapi/error.h" + +void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp) +{ + DeviceState *dev =3D DEVICE(vmd); + HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); + Error *local_err =3D NULL; + + if (!bus_handler && dev->hotplugged) { + /* + * Without a bus hotplug handler, we cannot control the plug/unplug + * order. We should never reach this point when hotplugging on x86, + * however, better add a safety net. + */ + error_setg(errp, "hotplug of virtio based memory devices not suppo= rted" + " on this bus."); + return; + } + /* + * First, see if we can plug this memory device at all. If that + * succeeds, branch of to the actual hotplug handler. + */ + memory_device_pre_plug(md, ms, NULL, &local_err); + if (!local_err && bus_handler) { + hotplug_handler_pre_plug(bus_handler, dev, &local_err); + } + error_propagate(errp, local_err); +} + +void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) +{ + DeviceState *dev =3D DEVICE(vmd); + HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); + Error *local_err =3D NULL; + + /* + * Plug the memory device first and then branch off to the actual + * hotplug handler. If that one fails, we can easily undo the memory + * device bits. + */ + memory_device_plug(md, ms); + if (bus_handler) { + hotplug_handler_plug(bus_handler, dev, &local_err); + if (local_err) { + memory_device_unplug(md, ms); + } + } + error_propagate(errp, local_err); +} + +void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, MachineState *ms, + Error **errp) +{ + /* We don't support hot unplug of virtio based memory devices */ + error_setg(errp, "virtio based memory devices cannot be unplugged."); +} + +void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) +{ + /* We don't support hot unplug of virtio based memory devices */ +} =20 static const TypeInfo virtio_md_pci_info =3D { .name =3D TYPE_VIRTIO_MD_PCI, diff --git a/include/hw/virtio/virtio-md-pci.h b/include/hw/virtio/virtio-m= d-pci.h index a241b54fcd..f9fa857aec 100644 --- a/include/hw/virtio/virtio-md-pci.h +++ b/include/hw/virtio/virtio-md-pci.h @@ -32,4 +32,10 @@ struct VirtIOMDPCI { VirtIOPCIProxy parent_obj; }; =20 +void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp); +void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp); +void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, MachineState *ms, + Error **errp); +void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp= ); + #endif diff --git a/stubs/meson.build b/stubs/meson.build index a56645e2f7..ef6e39a64d 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -60,6 +60,7 @@ if have_system stub_ss.add(files('semihost.c')) stub_ss.add(files('usb-dev-stub.c')) stub_ss.add(files('xen-hw-stub.c')) + stub_ss.add(files('virtio-md-pci.c')) else stub_ss.add(files('qdev.c')) endif diff --git a/stubs/virtio-md-pci.c b/stubs/virtio-md-pci.c new file mode 100644 index 0000000000..ce5bba0c9d --- /dev/null +++ b/stubs/virtio-md-pci.c @@ -0,0 +1,24 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/virtio/virtio-md-pci.h" + +void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp) +{ + error_setg(errp, "virtio based memory devices not supported"); +} + +void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) +{ + error_setg(errp, "virtio based memory devices not supported"); +} + +void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, MachineState *ms, + Error **errp) +{ + error_setg(errp, "virtio based memory devices not supported"); +} + +void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) +{ + error_setg(errp, "virtio based memory devices not supported"); +} --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089789; cv=none; d=zohomail.com; s=zohoarc; b=gN+uR77jTh0M84HKz1uRrgq9sZEn1t1ALXJCr08PhGxuFoGa++xN2QsYcv4lOSQJ3z8iOoZkjv1xk0q1nXFOFu6Y+Y/tsHc2KNXXaAYBrlvpzWh/C8MKHw/zxozShKYmnZZfu0oJJ0YRXSuk2rpxJZoirmWdWfh4CPg+6nvjPhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089789; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=unXQKIVOpw/IzP/fdmWUw3PBos1JK3kUxSiK24Zd92I=; b=NP4rPMEfScolCqn893LZXDR4WhUAd2VrbAP+VWjuzk5MVtTuHk8niklMvhO5S9lHqYv28PkdQr7D7H4/GUWFpDXb4yH5wJVjHZF+RlLR3taUVqhjuKYRbn+Qiq/ahU7lbWL3RWVzrC0P4na5t4CxvTA7lzsHLNaT2QrNPecLC7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689089789190347.7593300822782; Tue, 11 Jul 2023 08:36:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOh-00082O-IH; Tue, 11 Jul 2023 11:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOa-0007vf-Eb for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOW-0005qs-Aj for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-mOm_SoqJPfq41s7bogAn3g-1; Tue, 11 Jul 2023 11:35:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 285001066564; Tue, 11 Jul 2023 15:34:57 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8FCFC09A09; Tue, 11 Jul 2023 15:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=unXQKIVOpw/IzP/fdmWUw3PBos1JK3kUxSiK24Zd92I=; b=QAZnD1IqvMP7jQ/d4SlgK/PRYf1hFigRIYjrfPL0x7oPDRZ2TJ0Soa/gg1me+snsrX9ONL +YfsrCaqSUah+Q3/XggWCUJAeQVSHjKou5AjiUaGWfKy34Sbze2E3PYX1mmnTgpSXAderO oxdJLUtqt/sWE7rO3ZCZn5vQkAXruxw= X-MC-Unique: mOm_SoqJPfq41s7bogAn3g-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 3/7] arm/virt: Use virtio-md-pci (un)plug functions Date: Tue, 11 Jul 2023 17:34:41 +0200 Message-ID: <20230711153445.514112-4-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089791418100003 Content-Type: text/plain; charset="utf-8" Let's use our new helper functions. Note that virtio-pmem-pci is not enabled for arm and, therefore, not compiled in. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- hw/arm/virt.c | 81 ++++++++------------------------------------------- 1 file changed, 12 insertions(+), 69 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8a4c663735..4ae1996d37 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -73,11 +73,10 @@ #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" #include "target/arm/internals.h" -#include "hw/mem/memory-device.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" #include "hw/acpi/generic_event_device.h" -#include "hw/virtio/virtio-mem-pci.h" +#include "hw/virtio/virtio-md-pci.h" #include "hw/virtio/virtio-iommu.h" #include "hw/char/pl011.h" #include "qemu/guest-random.h" @@ -2740,64 +2739,6 @@ static void virt_memory_plug(HotplugHandler *hotplug= _dev, dev, &error_abort); } =20 -static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); - Error *local_err =3D NULL; - - if (!hotplug_dev2 && dev->hotplugged) { - /* - * Without a bus hotplug handler, we cannot control the plug/unplug - * order. We should never reach this point when hotplugging on ARM. - * However, it's nice to add a safety net, similar to what we have - * on x86. - */ - error_setg(errp, "hotplug of virtio based memory devices not suppo= rted" - " on this bus."); - return; - } - /* - * First, see if we can plug this memory device at all. If that - * succeeds, branch of to the actual hotplug handler. - */ - memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL, - &local_err); - if (!local_err && hotplug_dev2) { - hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err); - } - error_propagate(errp, local_err); -} - -static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) -{ - HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); - Error *local_err =3D NULL; - - /* - * Plug the memory device first and then branch off to the actual - * hotplug handler. If that one fails, we can easily undo the memory - * device bits. - */ - memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); - if (hotplug_dev2) { - hotplug_handler_plug(hotplug_dev2, dev, &local_err); - if (local_err) { - memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); - } - } - error_propagate(errp, local_err); -} - -static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **er= rp) -{ - /* We don't support hot unplug of virtio based memory devices */ - error_setg(errp, "virtio based memory devices cannot be unplugged."); -} - - static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -2805,8 +2746,8 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_memory_pre_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_pre_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), e= rrp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { hwaddr db_start =3D 0, db_end =3D 0; char *resv_prop_str; @@ -2855,12 +2796,11 @@ static void virt_machine_device_plug_cb(HotplugHand= ler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_memory_plug(hotplug_dev, dev, errp); - } - - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - virt_virtio_md_pci_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), errp); } =20 if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { @@ -2915,8 +2855,9 @@ static void virt_machine_device_unplug_request_cb(Hot= plugHandler *hotplug_dev, { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_dimm_unplug_request(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { - virt_virtio_md_pci_unplug_request(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_unplug_request(VIRTIO_MD_PCI(dev), MACHINE(hotplug_d= ev), + errp); } else { error_setg(errp, "device unplug request for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -2928,6 +2869,8 @@ static void virt_machine_device_unplug_cb(HotplugHand= ler *hotplug_dev, { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_dimm_unplug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { + virtio_md_pci_unplug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), err= p); } else { error_setg(errp, "virt: device unplug for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -2941,7 +2884,7 @@ static HotplugHandler *virt_machine_get_hotplug_handl= er(MachineState *machine, =20 if (device_is_dynamic_sysbus(mc, dev) || object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { return HOTPLUG_HANDLER(machine); } --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089807; cv=none; d=zohomail.com; s=zohoarc; b=LObVnGN2okNySREkrh26o1e3f8L2zWlfS2AVbnLkA7aGycYLbbVNfqm+clB9jM42MFvFVk1Fv40MPJl7KXPDhKQS/MGqFwLeMLzWdddxPA85yzw2aGJr3PdjkJE+Eh+kojUKZn3l4/GqMjCx9UmE9+WYxuEo5dtFH4iKlR3coWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089807; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YuSCIQO9rXBFSfOOQlk2HmFXz7anBKMb7iNXVP+qRqU=; b=ndO9fOWGTtkoAnss6NujFa3+UtQXZhKu355GyRUHw0A/tH+IgbrlQJqZnSMpwjZ6EgRUyVcoSaqetNvVTu3/6HJGRKkZPXew/Hw01EKYIk7n7hVpZhn8FAlGFjmdbGxCYcnusc4SH+gWhYP3Uu+QduHL7jgKzUnq1891Km2GJZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689089807109814.1823470071434; Tue, 11 Jul 2023 08:36:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOd-0007y3-JX; Tue, 11 Jul 2023 11:35:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOP-0007rS-T1 for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOL-0005n9-U2 for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:08 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-1A2A0k3dNAynIhHkTdXDcA-1; Tue, 11 Jul 2023 11:35:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB6391C08786; Tue, 11 Jul 2023 15:34:59 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EEC1C09A09; Tue, 11 Jul 2023 15:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YuSCIQO9rXBFSfOOQlk2HmFXz7anBKMb7iNXVP+qRqU=; b=I24Q76mpYT6WLaziHNLn2/Y0i/P2DUo+B4fQkSip0Yqn/fV/kDWT3t5Qgb97fxbal95pxn a20Xo+pl8tl8tr8oaULZZMAy5qd+0YR2CR4AKVl++UnhrIs84jrmps6GJ91c7QCgFX/Pdc zeelupVe1V7YE6sm6tT8yzFfPpy8GVM= X-MC-Unique: 1A2A0k3dNAynIhHkTdXDcA-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 4/7] virtio-md-pci: Handle unplug of virtio based memory devices Date: Tue, 11 Jul 2023 17:34:42 +0200 Message-ID: <20230711153445.514112-5-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089808426100001 Content-Type: text/plain; charset="utf-8" While we fence unplug requests from the outside, the VM can still trigger unplug of virtio based memory devices, for example, in Linux doing on a virtio-mem-pci device: # echo 0 > /sys/bus/pci/slots/3/power While doing that is not really expected to work without harming the guest OS (e.g., removing a virtio-mem device while it still provides memory), let's make sure that we properly handle it on the QEMU side. We'll add support for unplugging of virtio-mem devices in some configurations next. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-md-pci.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index e849c3131d..a22a259e2d 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -14,6 +14,7 @@ #include "hw/virtio/virtio-md-pci.h" #include "hw/mem/memory-device.h" #include "qapi/error.h" +#include "qemu/error-report.h" =20 void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp) { @@ -74,7 +75,27 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Mach= ineState *ms, =20 void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { - /* We don't support hot unplug of virtio based memory devices */ + DeviceState *dev =3D DEVICE(vmd); + HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); + Error *local_err =3D NULL; + + /* Unplug the memory device while it is still realized. */ + memory_device_unplug(md, ms); + + if (bus_handler) { + hotplug_handler_unplug(bus_handler, dev, &local_err); + if (local_err) { + /* Not expected to fail ... but still try to recover. */ + memory_device_plug(md, ms); + error_propagate(errp, local_err); + return; + } + } else { + /* Very unexpected, but let's just try to do the right thing. */ + warn_report("Unexpected unplug of virtio based memory device"); + qdev_unrealize(dev); + } } =20 static const TypeInfo virtio_md_pci_info =3D { --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089815; cv=none; d=zohomail.com; s=zohoarc; b=OvyxfsdSVBKb6Mg4sVuiLZvfBIMcnNX6EAhNyLdlfEbSfxZrQ27V74E/9POq9KU7FfoVkt38PxNPWlYbLyb75QgLPzxsZtvU1oDCK4w2guaSXJ8/a/pWqOjn5BgXTUZhr7P4D4EgVRHVGjqr85erxiQ2cbVbi/SLKTjK+xSm03w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089815; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2uLwmFuTr/wAV/uBvTQzX96h8o4ZK3oUljwgdfMzvkU=; b=T9PilKXZsYG2yXyKtaxfnZ6t1OE8ndAu1Q4RX/+xeumU+L1vmWDAg33OVYK2qPzL3OHNkPvl39JezlKUfe5aUWLpoG1Tjc9w5e5T1rWsvvPf2hMvk8GqeG2XWoms6XgJe02TCJCsUvFD7eJ/gT7i2+O4ffPEDjoHzBVC38TtN/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689089815807675.826918634407; Tue, 11 Jul 2023 08:36:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOb-0007vQ-0K; Tue, 11 Jul 2023 11:35:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOQ-0007rT-HT for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFON-0005oL-5g for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-3Xp0wFMfPK2rPDz1P6Lddw-1; Tue, 11 Jul 2023 11:35:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 935E41043AC9; Tue, 11 Jul 2023 15:35:02 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A359C478DE; Tue, 11 Jul 2023 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2uLwmFuTr/wAV/uBvTQzX96h8o4ZK3oUljwgdfMzvkU=; b=S2EZBFGICorZ+ZOoBrVO7iM+XdFck/rGn30yTGruSTacVISv5JhfOwyTzuqZyF88X/Q+p5 CHwpxxvSuDxEgW9Ct/LI9CGwY8vj1BZlZIzlRjFEqAXPd9qk7Zekq2C7Tdgg78OGe2b0yT O1wlXaQsV+LHndN3DeAJn7tICo9QCnk= X-MC-Unique: 3Xp0wFMfPK2rPDz1P6Lddw-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 5/7] virtio-md-pci: Support unplug requests for compatible devices Date: Tue, 11 Jul 2023 17:34:43 +0200 Message-ID: <20230711153445.514112-6-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089816860100003 Content-Type: text/plain; charset="utf-8" Let's support unplug requests for virtio-md-pci devices that provide a unplug_request_check() callback. We'll wire that up for virtio-mem-pci next. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-md-pci.c | 38 +++++++++++++++++++++++++++++-- include/hw/virtio/virtio-md-pci.h | 3 +++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index a22a259e2d..62bfb7920b 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -69,8 +69,42 @@ void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *= ms, Error **errp) void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { - /* We don't support hot unplug of virtio based memory devices */ - error_setg(errp, "virtio based memory devices cannot be unplugged."); + VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_GET_CLASS(vmd); + DeviceState *dev =3D DEVICE(vmd); + HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + HotplugHandlerClass *hdc; + Error *local_err =3D NULL; + + if (!vmdc->unplug_request_check) { + error_setg(errp, "this virtio based memory devices cannot be unplu= gged"); + return; + } + + if (!bus_handler) { + error_setg(errp, "hotunplug of virtio based memory devices not" + "supported on this bus"); + return; + } + + vmdc->unplug_request_check(vmd, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + /* + * Forward the async request or turn it into a sync request (handling = it + * like qdev_unplug()). + */ + hdc =3D HOTPLUG_HANDLER_GET_CLASS(bus_handler); + if (hdc->unplug_request) { + hotplug_handler_unplug_request(bus_handler, dev, &local_err); + } else { + virtio_md_pci_unplug(vmd, ms, &local_err); + if (!local_err) { + object_unparent(OBJECT(dev)); + } + } } =20 void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) diff --git a/include/hw/virtio/virtio-md-pci.h b/include/hw/virtio/virtio-m= d-pci.h index f9fa857aec..5912e16674 100644 --- a/include/hw/virtio/virtio-md-pci.h +++ b/include/hw/virtio/virtio-md-pci.h @@ -26,6 +26,9 @@ OBJECT_DECLARE_TYPE(VirtIOMDPCI, VirtIOMDPCIClass, VIRTIO= _MD_PCI) struct VirtIOMDPCIClass { /* private */ VirtioPCIClass parent; + + /* public */ + void (*unplug_request_check)(VirtIOMDPCI *vmd, Error **errp); }; =20 struct VirtIOMDPCI { --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089771; cv=none; d=zohomail.com; s=zohoarc; b=ct9Le4huXcBrcrVpLIo2kjRCyMLV/Jke81jCK+XUcQynsyb2VTDLLxakn0Bgkw0d9IOVi1ne5Lcq4OKPN6FuRmNNlCG44wAEOtzZwMXyFm/OMHu8ZIdCFuKQmosFjLloWeFeRzRr8XxpYaJFkqu+W8pcnPJcC+OQ6PQPzGO6+uU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089771; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sWm/aBOMSzPH7fHXQPW3X3aDhTY8xljtSTnrC1sDgKo=; b=jXr79tYucmMQHCG+BIIlpeTYxrOB2kN1nlWoHogjAVmpLxlukSP/FMSJ2Pm2FCmfsKG+AWdCRcbm7KMYe6MGJQLhIlUrcc1Us3WJM/BRuRhLKOnvXrUkFzjOofdeSMtZvAC+ZWn7oZPxpObuwSit6PAGLPjASmtxMjq992dlFYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16890897712911004.9031258749438; Tue, 11 Jul 2023 08:36:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFOf-0007zZ-JU; Tue, 11 Jul 2023 11:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOS-0007sh-1v for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFOQ-0005ps-Kj for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:35:11 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-gyDkk9roO4-FPoJ5yF2kcg-1; Tue, 11 Jul 2023 11:35:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9227A382C980; Tue, 11 Jul 2023 15:35:05 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFFF4C54FB3; Tue, 11 Jul 2023 15:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sWm/aBOMSzPH7fHXQPW3X3aDhTY8xljtSTnrC1sDgKo=; b=WrNJt/Y25N4wtRw9L0BXBOrSacNDvCJNJrp19+ZPCQgIiyFKhOTGX0DL+QGykUH1vxPBaR NtWJiY7SHs5mGJg9rd1MzuWuNJ/IGVG+n+RS2Fwzvd4n1BpVgDxrkNoPBYLrqqFp1i+G5a OjS7i0DwKVxN0vFQ4B5AoFNi6/5hduc= X-MC-Unique: gyDkk9roO4-FPoJ5yF2kcg-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 6/7] virtio-mem: Prepare for device unplug support Date: Tue, 11 Jul 2023 17:34:44 +0200 Message-ID: <20230711153445.514112-7-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089773322100003 Content-Type: text/plain; charset="utf-8" In many cases, blindly unplugging a virtio-mem device is problematic. We can only safely remove a device once: * The guest is not expecting to be able to read unplugged memory (unplugged-inaccessible =3D=3D on) * The virtio-mem device does not have memory plugged (size =3D=3D 0) * The virtio-mem device does not have outstanding requests to the VM to plug memory (requested-size =3D=3D 0) So let's add a callback to the virtio-mem device class to check for that. We'll wire-up virtio-mem-pci next. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 25 +++++++++++++++++++++++++ include/hw/virtio/virtio-mem.h | 1 + 2 files changed, 26 insertions(+) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index ec0ae32589..27b3aac87c 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -1483,6 +1483,30 @@ static void virtio_mem_rdm_unregister_listener(RamDi= scardManager *rdm, QLIST_REMOVE(rdl, next); } =20 +static void virtio_mem_unplug_request_check(VirtIOMEM *vmem, Error **errp) +{ + if (vmem->unplugged_inaccessible =3D=3D ON_OFF_AUTO_OFF) { + /* + * We could allow it with a usable region size of 0, but let's just + * not care about that legacy setting. + */ + error_setg(errp, "virtio-mem device cannot get unplugged while" + " '" VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP "' !=3D 'on= '"); + return; + } + + if (vmem->size) { + error_setg(errp, "virtio-mem device cannot get unplugged while" + " '" VIRTIO_MEM_SIZE_PROP "' !=3D '0'"); + return; + } + if (vmem->requested_size) { + error_setg(errp, "virtio-mem device cannot get unplugged while" + " '" VIRTIO_MEM_REQUESTED_SIZE_PROP "' !=3D '0'"); + return; + } +} + static void virtio_mem_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -1505,6 +1529,7 @@ static void virtio_mem_class_init(ObjectClass *klass,= void *data) vmc->get_memory_region =3D virtio_mem_get_memory_region; vmc->add_size_change_notifier =3D virtio_mem_add_size_change_notifier; vmc->remove_size_change_notifier =3D virtio_mem_remove_size_change_not= ifier; + vmc->unplug_request_check =3D virtio_mem_unplug_request_check; =20 rdmc->get_min_granularity =3D virtio_mem_rdm_get_min_granularity; rdmc->is_populated =3D virtio_mem_rdm_is_populated; diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h index f15e561785..ab0fe2b4f2 100644 --- a/include/hw/virtio/virtio-mem.h +++ b/include/hw/virtio/virtio-mem.h @@ -98,6 +98,7 @@ struct VirtIOMEMClass { MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp); void (*add_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier); void (*remove_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifie= r); + void (*unplug_request_check)(VirtIOMEM *vmem, Error **errp); }; =20 #endif --=20 2.41.0 From nobody Sat May 18 13:36:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689089945; cv=none; d=zohomail.com; s=zohoarc; b=OosbaZ4E4249NnaDlWMlq5YR25neqUADf2F6qhvvQIKHjbzhG8/yjf7ZaYpywK9MsJkITO37gj9xKwaMGg30LO7nUW7o29JZKPL2ffDNyAEm7sa+oI2+NChla+1JbT8/8Vc/GiwQvL5ae1H/XISKrZn9Yp3yM/LcZMsxjfEmoyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689089945; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fi7JfruppMfky0aOjE2GJMkpq4aLQborK4itS9FQ3VQ=; b=nyC4K+8xWmg6k6JL41WnYN4KdjDR6g1ewsNfCjZ8NrOV3ceN6KS6UxDH606/VCVCIcizhJKUCqkF0z1asIc4d3/52cj4nmO7c824OAlWq6JY3kGh6JVB64ME987X+4VpwZGqtaVGRqUA0T/YH8iED7kQJ2l1XZXFIeyYaXBpuGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689089945086505.9728936799835; Tue, 11 Jul 2023 08:39:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFS0-0005fu-1Y; Tue, 11 Jul 2023 11:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFRy-0005fI-MP for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:38:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFRx-00071D-6L for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:38:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-Y1486YujMdiPyXoyhC5OvQ-1; Tue, 11 Jul 2023 11:35:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 658B5185A794; Tue, 11 Jul 2023 15:35:08 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.194.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAEFDC51488; Tue, 11 Jul 2023 15:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689089926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fi7JfruppMfky0aOjE2GJMkpq4aLQborK4itS9FQ3VQ=; b=F9d7uyHR9sfYjGduBKk3h1uFKsMU77GbLRXD7Quq5+amaG41X0PF2Eecfww3ROKINZLBsP JNaAnClLGzq9sXiMO3EqAS0/+qXm9yWLM/4Sjw4+WZpE/W3mfmVvsEEYvV0XVbmX+SpDp1 xFbcBEhYITNXYXLWSXzKrIWhJIOjCJQ= X-MC-Unique: Y1486YujMdiPyXoyhC5OvQ-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Igor Mammedov , qemu-arm@nongnu.org, Gavin Shan , Mario Casquero Subject: [PATCH v4 7/7] virtio-mem-pci: Device unplug support Date: Tue, 11 Jul 2023 17:34:45 +0200 Message-ID: <20230711153445.514112-8-david@redhat.com> In-Reply-To: <20230711153445.514112-1-david@redhat.com> References: <20230711153445.514112-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689089946798100003 Content-Type: text/plain; charset="utf-8" Let's support device unplug by forwarding the unplug_request_check() callback to the virtio-mem device. Further, disallow changing the requested-size once an unplug request is pending. Disallowing requested-size changes handles corner cases such as (1) pausing the VM (2) requesting device unplug and (3) adjusting the requested size. If the VM would plug memory (due to the requested size change) before processing the unplug request, we would be in trouble. Tested-by: Mario Casquero Signed-off-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-mem-pci.c | 49 +++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index 2ef0f07630..c4597e029e 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -93,12 +93,53 @@ static void virtio_mem_pci_size_change_notify(Notifier = *notifier, void *data) g_free(qom_path); } =20 +static void virtio_mem_pci_unplug_request_check(VirtIOMDPCI *vmd, Error **= errp) +{ + VirtIOMEMPCI *pci_mem =3D VIRTIO_MEM_PCI(vmd); + VirtIOMEM *vmem =3D &pci_mem->vdev; + VirtIOMEMClass *vpc =3D VIRTIO_MEM_GET_CLASS(vmem); + + vpc->unplug_request_check(vmem, errp); +} + +static void virtio_mem_pci_get_requested_size(Object *obj, Visitor *v, + const char *name, void *opaq= ue, + Error **errp) +{ + VirtIOMEMPCI *pci_mem =3D VIRTIO_MEM_PCI(obj); + + object_property_get(OBJECT(&pci_mem->vdev), name, v, errp); +} + +static void virtio_mem_pci_set_requested_size(Object *obj, Visitor *v, + const char *name, void *opaq= ue, + Error **errp) +{ + VirtIOMEMPCI *pci_mem =3D VIRTIO_MEM_PCI(obj); + DeviceState *dev =3D DEVICE(obj); + + /* + * If we passed virtio_mem_pci_unplug_request_check(), making sure that + * the requested size is 0, don't allow modifying the requested size + * anymore, otherwise the VM might end up hotplugging memory before + * handling the unplug request. + */ + if (dev->pending_deleted_event) { + error_setg(errp, "'%s' cannot be changed if the device is in the" + " process of unplug", name); + return; + } + + object_property_set(OBJECT(&pci_mem->vdev), name, v, errp); +} + static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); MemoryDeviceClass *mdc =3D MEMORY_DEVICE_CLASS(klass); + VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_CLASS(klass); =20 k->realize =3D virtio_mem_pci_realize; set_bit(DEVICE_CATEGORY_MISC, dc->categories); @@ -111,6 +152,8 @@ static void virtio_mem_pci_class_init(ObjectClass *klas= s, void *data) mdc->get_memory_region =3D virtio_mem_pci_get_memory_region; mdc->fill_device_info =3D virtio_mem_pci_fill_device_info; mdc->get_min_alignment =3D virtio_mem_pci_get_min_alignment; + + vmdc->unplug_request_check =3D virtio_mem_pci_unplug_request_check; } =20 static void virtio_mem_pci_instance_init(Object *obj) @@ -135,9 +178,9 @@ static void virtio_mem_pci_instance_init(Object *obj) OBJECT(&dev->vdev), VIRTIO_MEM_BLOCK_SIZE_PR= OP); object_property_add_alias(obj, VIRTIO_MEM_SIZE_PROP, OBJECT(&dev->vdev= ), VIRTIO_MEM_SIZE_PROP); - object_property_add_alias(obj, VIRTIO_MEM_REQUESTED_SIZE_PROP, - OBJECT(&dev->vdev), - VIRTIO_MEM_REQUESTED_SIZE_PROP); + object_property_add(obj, VIRTIO_MEM_REQUESTED_SIZE_PROP, "size", + virtio_mem_pci_get_requested_size, + virtio_mem_pci_set_requested_size, NULL, NULL); } =20 static const VirtioPCIDeviceTypeInfo virtio_mem_pci_info =3D { --=20 2.41.0