From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkeCI-000643-2c for qemu-devel@nongnu.org; Mon, 17 Dec 2012 12:09:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkeCG-0003Dn-VA for qemu-devel@nongnu.org; Mon, 17 Dec 2012 12:09:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkeCG-0003Cd-JT for qemu-devel@nongnu.org; Mon, 17 Dec 2012 12:09:44 -0500 Message-ID: <50CF51D5.9050303@redhat.com> Date: Mon, 17 Dec 2012 18:09:41 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> <1355761490-10073-14-git-send-email-pbonzini@redhat.com> <20121217164838.GA29085@redhat.com> <50CF4E2E.90605@redhat.com> <20121217170808.GA29953@redhat.com> In-Reply-To: <20121217170808.GA29953@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 13/15] virtio-pci: reset all qbuses too when writing to the status field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Il 17/12/2012 18:08, Michael S. Tsirkin ha scritto: >>> I would still prefer this logic to reside in virtio.c instead of being >>> duplicated in each bus. >>> My idea was to simply call qdev_reset_all on the binding from virtio.c >>> but other ideas wellcome. >> >> I think you're confusing "in the common superclass of all virtio >> transports" vs "in the common superclass of all virtio devices". >> virtio.c only implements a common superclass of all virtio devices; in >> fact, there is no common superclass of all virtio transports, and it is >> not possible without multiple inheritance or stuff like traits (you're >> already inheriting from PCIDevice for virtio-*-pci). >> >> Such common superclass, if it existed, would abstract stuff like "write >> zero to the status register" and would call qdev_reset_all. But again, >> we don't have this concept. > > There's some misunderstanding here. > > This is not about classes and stuff. > > Common code should be in a single place so everyone can reuse it through > function calls, not duplicated in all transports. > And yes we do have examples of this if you are asking for examples; > examples are functions like virtio_reset, virtio_set_status, etc. We shouldn't need a virtio_reset at all. It should be invoked automatically by virtue of having a correct, complete description of virtio in terms of qdev buses. In other words, qdev_reset_all _is_ the common code you're seeking. Paolo