From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn3xc-0003vX-No for qemu-devel@nongnu.org; Fri, 16 Oct 2015 08:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn3xY-000574-Ns for qemu-devel@nongnu.org; Fri, 16 Oct 2015 08:18:12 -0400 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:36383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn3xY-000570-Hz for qemu-devel@nongnu.org; Fri, 16 Oct 2015 08:18:08 -0400 Received: by wicgb1 with SMTP id gb1so6976310wic.1 for ; Fri, 16 Oct 2015 05:18:08 -0700 (PDT) Date: Fri, 16 Oct 2015 14:18:05 +0200 From: Stefan Hajnoczi Message-ID: <20151016121805.GI10205@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] Virtio device "exit" function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Johnson Cc: QEMU Developers On Wed, Sep 23, 2015 at 04:32:00PM +0000, Chris Johnson wrote: > I am working on adding a virtio device to support a PCIe card (PCIe > pass-through wasn't an option). I need to do some cleanup when a VM that is > using this device is shutdown. It doesn't seem like the device_unrealize > function runs on shutdown unlike the device_realize function that runs when > the VM is started. I've been tracing through other virtio device code to try > and figure out what "exit" type functions will run for other devices when a > VM is shutdown but haven't had any luck with that yet. > > When does a virtio device's unrealize function run? > > What function, if any, runs for a virtio device when a VM is shutdown? When QEMU terminates in vl.c:main(), devices are not unrealized. The unrealize code is only invoked on hot unplug (e.g. PCI card removed via 'device_del' command). What are you trying to do in the unrealize function? Stefan