From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBKGx-0007hV-4u for qemu-devel@nongnu.org; Wed, 25 Apr 2018 09:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBKGu-0005dC-0s for qemu-devel@nongnu.org; Wed, 25 Apr 2018 09:15:47 -0400 From: David Hildenbrand References: <20180420123456.22196-1-david@redhat.com> <20180423143147.6b4df2ac@redhat.com> <459116211.21924603.1524497545197.JavaMail.zimbra@redhat.com> <20180424160011.47475594@redhat.com> <20180425141535.5000bcb8@redhat.com> <50c25d28-4cac-1e68-c149-e7a5ba8b0f40@redhat.com> Message-ID: <04f968d4-cc3d-1b7b-3d70-f75014ba2742@redhat.com> Date: Wed, 25 Apr 2018 15:15:32 +0200 MIME-Version: 1.0 In-Reply-To: <50c25d28-4cac-1e68-c149-e7a5ba8b0f40@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 0/3] pc-dimm: factor out MemoryDevice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: Pankaj Gupta , Eduardo Habkost , "Michael S . Tsirkin" , qemu-devel@nongnu.org, Markus Armbruster , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , David Gibson >>> So this happens before any hotplug handler is called. Everything works >>> just fine. What you don't like about this is the qdev_get_machine(). I >>> also don't like it but in the short term I don't see any problem with >>> it. It is resource allocation and not a "device plug" in the typical form. >> >> It's not qdev_get_machine() that's issue, it's layer violation, >> where child device is allocating and mapping resources of one of its parents. > > Quite simple: introduce a function at the machine where the child can > "request" to get an address and "request" to plug/unplug a region. > > Or what would be wrong about that? > To extend on such an idea (looking at virtio_bus_device_plugged() getting called from virtio realize functions) Make the machine implement some new interface "MemoryDeviceManager". >>From virtio-mem/pmem realize, call a function like memory_device_plugged(). Lookup the machine (qdev_get_machine() or walk all the way up until we find one that implements MemoryDeviceManager) and call pre_plugged/plugged/unplugged. We could hide that in a new device class TYPE_VIRTIO_MEMORY_DEVICE. Opinions? Completely nonsense? :) Alternatives? -- Thanks, David / dhildenb