From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq55q-0002LP-DP for qemu-devel@nongnu.org; Mon, 09 Dec 2013 12:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq55l-0002Bj-1a for qemu-devel@nongnu.org; Mon, 09 Dec 2013 12:58:06 -0500 Received: from mail-qc0-x233.google.com ([2607:f8b0:400d:c01::233]:65529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq55k-0002Ao-U7 for qemu-devel@nongnu.org; Mon, 09 Dec 2013 12:58:00 -0500 Received: by mail-qc0-f179.google.com with SMTP id i8so2962671qcq.38 for ; Mon, 09 Dec 2013 09:58:00 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52A604A3.2030208@redhat.com> Date: Mon, 09 Dec 2013 18:57:55 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1385720262-14107-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1385720262-14107-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 00/30] virtio: cleanup, fix hot-unplug, move to realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de Il 29/11/2013 11:17, Paolo Bonzini ha scritto: > This series fixes hot-unplug of virtio devices, which can crash due to > dangling pointer accesses. > > The current implementation supports guest-initiated hot-unplug via the > virtio_bus_destroy_device function, but not hot-unplugging the virtio > device by virtue of unplugging its parent container device. > > The problem is that the callback for the bus implementation to cleanup > is placed in the wrong place; it is in virtio_bus_destroy_device, which > should be called by the bus, instead of being somewhere in device code. > We need to have the callback in device code (for example in dc->exit), > so that we invoke it on every unplug action, no matter who starts it. > > Thus, the series cleans up plugging and unplugging of virtio devices > so that it does not need any help from the bus (patches 2-5). It then > stops the virtio devices' overriding of dc->exit, moving their cleanup > code to the new exit callback in VirtioDeviceClass (patches 6-11). > Finally, patch 12 can make virtio-pci implement the device_unplugged > callback. > > A similar dangling-pointer bug is exposed by this change in virtio-ccw. > Patch 1 avoids this; it is kept at the beginning to ensure bisectability. > > Patches 13-30 are Andreas's conversion of virtio to realize/unrealize, > which has better error propagation as shown by the small testcase fix. Conny, I pushed this to github at git://github.com/bonzini/qemu.git, branch refs/heads/virtio. It would be great if you can give it a test in case I screwed up a rebase. Paolo