From patchwork Tue Jun 24 17:20:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 363570 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 38612140087 for ; Wed, 25 Jun 2014 03:21:30 +1000 (EST) Received: from localhost ([::1]:33046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUPQ-0003Jb-Bm for incoming@patchwork.ozlabs.org; Tue, 24 Jun 2014 13:21:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUON-0001Q0-FC for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:20:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzUOF-0002se-Ae for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:20:23 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:36175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUOF-0002sR-39 for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:20:15 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jun 2014 18:20:14 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Jun 2014 18:20:12 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 999B01B08040 for ; Tue, 24 Jun 2014 18:20:43 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5OHKBOj36110420 for ; Tue, 24 Jun 2014 17:20:11 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 s5OHKAMF024563 for ; Tue, 24 Jun 2014 11:20:11 -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 s5OHKAjk024560; Tue, 24 Jun 2014 11:20:10 -0600 Received: from bahia.local (icon-9-164-148-109.megacenter.de.ibm.com [9.164.148.109]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 661DF210FFE; Tue, 24 Jun 2014 19:20:09 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 24 Jun 2014 19:20:08 +0200 Message-ID: <20140624171955.17522.90755.stgit@bahia.local> In-Reply-To: <20140624151955.17522.62537.stgit@bahia.local> References: <20140624151955.17522.62537.stgit@bahia.local> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14062417-2966-0000-0000-0000004D10F3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.109 Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Juan Quintela , Rusty Russell , Alexander Graf , "Michael S. Tsirkin" , aneesh.kumar@linux.vnet.ibm.com, Anthony Liguori , Amit Shah , Paolo Bonzini , Andreas =?utf-8?q?F=C3=A4rber?= Subject: [Qemu-devel] [PATCH v9 07/22] virtio-balloon: 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 Reviewed-by: Alexander Graf --- hw/virtio/virtio-balloon.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 165592e..e0ed5ee 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -325,10 +325,12 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target) static void virtio_balloon_save(QEMUFile *f, void *opaque) { - VirtIOBalloon *s = VIRTIO_BALLOON(opaque); - VirtIODevice *vdev = VIRTIO_DEVICE(s); + virtio_save(VIRTIO_DEVICE(opaque), f); +} - virtio_save(vdev, f); +static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f) +{ + VirtIOBalloon *s = VIRTIO_BALLOON(vdev); qemu_put_be32(f, s->num_pages); qemu_put_be32(f, s->actual); @@ -336,17 +338,16 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque) static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id) { - VirtIOBalloon *s = VIRTIO_BALLOON(opaque); - VirtIODevice *vdev = VIRTIO_DEVICE(s); - int ret; - if (version_id != 1) return -EINVAL; - ret = virtio_load(vdev, f, version_id); - if (ret) { - return ret; - } + return virtio_load(VIRTIO_DEVICE(opaque), f, version_id); +} + +static int virtio_balloon_load_device(VirtIODevice *vdev, QEMUFile *f, + int version_id) +{ + VirtIOBalloon *s = VIRTIO_BALLOON(vdev); s->num_pages = qemu_get_be32(f); s->actual = qemu_get_be32(f); @@ -416,6 +417,8 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data) vdc->get_config = virtio_balloon_get_config; vdc->set_config = virtio_balloon_set_config; vdc->get_features = virtio_balloon_get_features; + vdc->save = virtio_balloon_save_device; + vdc->load = virtio_balloon_load_device; } static const TypeInfo virtio_balloon_info = {