From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6yOI-0006FM-RD for qemu-devel@nongnu.org; Mon, 01 Oct 2018 09:37:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6yOE-0008RW-KI for qemu-devel@nongnu.org; Mon, 01 Oct 2018 09:37:38 -0400 Date: Mon, 1 Oct 2018 15:37:18 +0200 From: Igor Mammedov Message-ID: <20181001153718.4ed97bd3@redhat.com> In-Reply-To: <20180926094219.20322-20-david@redhat.com> References: <20180926094219.20322-1-david@redhat.com> <20180926094219.20322-20-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 19/24] virtio-pmem: prototype List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Hildenbrand Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Dr . David Alan Gilbert" , "Michael S . Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Eric Blake , Markus Armbruster , Pankaj Gupta , Luiz Capitulino , Xiao Guangrong , David Gibson , Alexander Graf On Wed, 26 Sep 2018 11:42:14 +0200 David Hildenbrand wrote: > From: Pankaj Gupta > > This is the current protoype of virtio-pmem. Support will require > machine changes for the architectures that will support it, so it will > not yet be compiled. > > Signed-off-by: Pankaj Gupta > [ MemoryDevice/MemoryRegion changes, cleanups, addr property "memaddr", > split up patches ] > Signed-off-by: David Hildenbrand not an actual review, but a small nit/no/ below [...] > + > +static const char *virtio_pmem_md_get_device_id(const MemoryDeviceState *md) > +{ > + Object *obj = OBJECT(md); > + > + /* always return the ID of the proxy device the user configured */ > + if (obj->parent && object_dynamic_cast(obj->parent, TYPE_DEVICE)) { > + const DeviceState *parent_dev = DEVICE(obj->parent); > + > + return parent_dev->id; It's layer violation, child device shouldn't ever access it's parent fields, in general it's not acceptable practice. To workaround parent could set a property for a child with this id to use, but I'm not sure if it would work in this case. Anyways you might not need this callback at all if proxy would implement memory-device interface as mentioned in another comment. > + } > + return NULL; > +} > + [...]