From patchwork Mon Jul 26 14:01:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 59917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A63B2B70A6 for ; Tue, 27 Jul 2010 00:08:02 +1000 (EST) Received: from localhost ([127.0.0.1]:35364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdOLX-0005hJ-5y for incoming@patchwork.ozlabs.org; Mon, 26 Jul 2010 10:07:59 -0400 Received: from [140.186.70.92] (port=49921 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdOFI-0002Nj-IQ for qemu-devel@nongnu.org; Mon, 26 Jul 2010 10:01:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdOF8-0005Py-P9 for qemu-devel@nongnu.org; Mon, 26 Jul 2010 10:01:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22639) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdOF8-0005Pc-Hw for qemu-devel@nongnu.org; Mon, 26 Jul 2010 10:01:22 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6QE1KLe021157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Jul 2010 10:01:21 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6QE1FeT021114; Mon, 26 Jul 2010 10:01:19 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Mon, 26 Jul 2010 16:01:13 +0200 Message-Id: <1280152877-29037-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1280152877-29037-1-git-send-email-kwolf@redhat.com> References: <1280152877-29037-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/7] virtio-blk: Create exit function to unregister savevm X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Williamson Otherwise we can't migrate after we've removed a virtio block device. Signed-off-by: Alex Williamson Signed-off-by: Kevin Wolf --- hw/virtio-blk.c | 8 ++++++++ hw/virtio-pci.c | 1 + hw/virtio.h | 1 + 3 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index f50069d..490cd41 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -28,6 +28,7 @@ typedef struct VirtIOBlock BlockConf *conf; unsigned short sector_mask; char sn[BLOCK_SERIAL_STRLEN]; + DeviceState *qdev; } VirtIOBlock; static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) @@ -522,9 +523,16 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); + s->qdev = dev; register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_removable(s->bs, 0); return &s->vdev; } + +void virtio_blk_exit(VirtIODevice *vdev) +{ + VirtIOBlock *s = to_virtio_blk(vdev); + unregister_savevm(s->qdev, "virtio-blk", s); +} diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 31a711e..17c3d15 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -569,6 +569,7 @@ static int virtio_blk_exit_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + virtio_blk_exit(proxy->vdev); blockdev_mark_auto_del(proxy->block.bs); return virtio_exit_pci(pci_dev); } diff --git a/hw/virtio.h b/hw/virtio.h index e4306cd..30e472a 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -194,6 +194,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf); void virtio_net_exit(VirtIODevice *vdev); +void virtio_blk_exit(VirtIODevice *vdev); #define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \ DEFINE_PROP_BIT("indirect_desc", _state, _field, \