From patchwork Mon May 19 08:38:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 350152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6BB2814008B for ; Mon, 19 May 2014 18:39:33 +1000 (EST) Received: from localhost ([::1]:46635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJ6Z-00060E-D3 for incoming@patchwork.ozlabs.org; Mon, 19 May 2014 04:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJ5s-0004kv-1Y for qemu-devel@nongnu.org; Mon, 19 May 2014 04:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmJ5i-0006TV-Nt for qemu-devel@nongnu.org; Mon, 19 May 2014 04:38:47 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:38527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmJ5i-0006TP-Ev for qemu-devel@nongnu.org; Mon, 19 May 2014 04:38:38 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 May 2014 09:38:37 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 May 2014 09:38:34 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 942411B0805F for ; Mon, 19 May 2014 09:38:50 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4J8cYUY65142912 for ; Mon, 19 May 2014 08:38:34 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4J8cXu7001057 for ; Mon, 19 May 2014 02:38:33 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s4J8cXPB001042; Mon, 19 May 2014 02:38:33 -0600 Received: from bahia.local (icon-9-167-195-35.megacenter.de.ibm.com [9.167.195.35]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 06802210FFD; Mon, 19 May 2014 10:38:31 +0200 (CEST) To: Kevin Wolf , Anthony Liguori , "Michael S. Tsirkin" , Stefan Hajnoczi , Amit Shah , Paolo Bonzini From: Greg Kurz Date: Mon, 19 May 2014 10:38:31 +0200 Message-ID: <20140519083830.22955.82636.stgit@bahia.local> In-Reply-To: <20140519063132.22955.63563.stgit@bahia.local> References: <20140519063132.22955.63563.stgit@bahia.local> User-Agent: StGit/0.16 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14051908-0342-0000-0000-000008CFFCDE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.111 Cc: Juan Quintela , Fam Zheng , Alexander Graf , Andreas =?utf-8?q?F=C3=A4rber?= , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH RFC 3/8] virtio-blk: implement per-device migration calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Greg Kurz --- hw/block/virtio-blk.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 63d4ccd..a50be54 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -588,12 +588,16 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) static void virtio_blk_save(QEMUFile *f, void *opaque) { - VirtIOBlock *s = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(s); - VirtIOBlockReq *req = s->rq; + VirtIODevice *vdev = VIRTIO_DEVICE(opaque); virtio_save(vdev, f); +} +static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f) +{ + VirtIOBlock *s = VIRTIO_BLK(vdev); + VirtIOBlockReq *req = s->rq; + while (req) { qemu_put_sbyte(f, 1); qemu_put_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); @@ -606,15 +610,17 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBlock *s = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(s); - int ret; if (version_id != 2) return -EINVAL; - ret = virtio_load(vdev, f, version_id); - if (ret) { - return ret; - } + return virtio_load(vdev, f, version_id); +} + +static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f, + int version_id) +{ + VirtIOBlock *s = VIRTIO_BLK(vdev); while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); @@ -773,6 +779,8 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data) vdc->get_features = virtio_blk_get_features; vdc->set_status = virtio_blk_set_status; vdc->reset = virtio_blk_reset; + vdc->save = virtio_blk_save_device; + vdc->load = virtio_blk_load_device; } static const TypeInfo virtio_device_info = {