From patchwork Tue Jun 24 17:19:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 363569 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 E2293140087 for ; Wed, 25 Jun 2014 03:20:54 +1000 (EST) Received: from localhost ([::1]:33037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUOr-00023G-1x for incoming@patchwork.ozlabs.org; Tue, 24 Jun 2014 13:20:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUO2-0000bz-IU for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzUNu-0002WV-Da for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:20:02 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:50127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzUNu-0002WO-4E for qemu-devel@nongnu.org; Tue, 24 Jun 2014 13:19:54 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jun 2014 18:19:52 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Jun 2014 18:19:52 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id CBB0A17D8047 for ; Tue, 24 Jun 2014 18:21:18 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5OHJpXZ25231550 for ; Tue, 24 Jun 2014 17:19:51 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 s5OHJoPb024078 for ; Tue, 24 Jun 2014 11:19:51 -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 s5OHJo4J024075; Tue, 24 Jun 2014 11:19:50 -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 38B33210FFE; Tue, 24 Jun 2014 19:19:49 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 24 Jun 2014 19:19:48 +0200 Message-ID: <20140624171930.17522.56076.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-3548-0000-0000-000000440383 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.112 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 06/22] virtio-serial: 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/char/virtio-serial-bus.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9f1df84..3989722 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -521,14 +521,17 @@ static void vser_reset(VirtIODevice *vdev) static void virtio_serial_save(QEMUFile *f, void *opaque) { - VirtIOSerial *s = VIRTIO_SERIAL(opaque); + /* The virtio device */ + virtio_save(VIRTIO_DEVICE(opaque), f); +} + +static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f) +{ + VirtIOSerial *s = VIRTIO_SERIAL(vdev); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int i, max_nr_ports; - /* The virtio device */ - virtio_save(VIRTIO_DEVICE(s), f); - /* The config space */ qemu_put_be16s(f, &s->config.cols); qemu_put_be16s(f, &s->config.rows); @@ -666,21 +669,22 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id, static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) { - VirtIOSerial *s = VIRTIO_SERIAL(opaque); - uint32_t max_nr_ports, nr_active_ports, ports_map; - unsigned int i; - int ret; - uint32_t tmp; - if (version_id > 3) { return -EINVAL; } /* The virtio device */ - ret = virtio_load(VIRTIO_DEVICE(s), f, version_id); - if (ret) { - return ret; - } + return virtio_load(VIRTIO_DEVICE(opaque), f, version_id); +} + +static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f, + int version_id) +{ + VirtIOSerial *s = VIRTIO_SERIAL(vdev); + uint32_t max_nr_ports, nr_active_ports, ports_map; + unsigned int i; + int ret; + uint32_t tmp; if (version_id < 2) { return 0; @@ -1023,6 +1027,8 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; + vdc->save = virtio_serial_save_device; + vdc->load = virtio_serial_load_device; } static const TypeInfo virtio_device_info = {