From patchwork Fri Mar 19 11:58:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 48144 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 DC20FB7C33 for ; Fri, 19 Mar 2010 23:16:08 +1100 (EST) Received: from localhost ([127.0.0.1]:49717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nsax8-0002NG-37 for incoming@patchwork.ozlabs.org; Fri, 19 Mar 2010 08:05:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nsat2-00015d-RK for qemu-devel@nongnu.org; Fri, 19 Mar 2010 08:01:08 -0400 Received: from [199.232.76.173] (port=35576 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nsat2-00014x-6h for qemu-devel@nongnu.org; Fri, 19 Mar 2010 08:01:08 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nsasw-0004hh-Ty for qemu-devel@nongnu.org; Fri, 19 Mar 2010 08:01:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5719) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nsasv-0004hE-8c for qemu-devel@nongnu.org; Fri, 19 Mar 2010 08:01:01 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2JC0Lat005509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Mar 2010 08:00:21 -0400 Received: from localhost (vpn-235-201.phx2.redhat.com [10.3.235.201]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2JC0JKd023400; Fri, 19 Mar 2010 08:00:20 -0400 From: Amit Shah To: qemu-devel@nongnu.org Date: Fri, 19 Mar 2010 17:28:39 +0530 Message-Id: <1268999926-29560-3-git-send-email-amit.shah@redhat.com> In-Reply-To: <1268999926-29560-2-git-send-email-amit.shah@redhat.com> References: <1268999926-29560-1-git-send-email-amit.shah@redhat.com> <1268999926-29560-2-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , quintela@redhat.com, mst@redhat.com, kraxel@redhat.com, virtualization@lists.linux-foundation.org Subject: [Qemu-devel] [PATCH 2/9] virtio-serial-bus: save/load: Ensure nr_ports on src and dest are same. 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 The number of ports on the source as well as the destination machines should match. If they don't, it means some ports that got hotplugged on the source aren't instantiated on the destination. Or that ports that were hot-unplugged on the source are created on the destination. Signed-off-by: Amit Shah Reported-by: Juan Quintela --- hw/virtio-serial-bus.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 36985a1..f43d1fc 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -401,7 +401,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) { VirtIOSerial *s = opaque; VirtIOSerialPort *port; - uint32_t max_nr_ports, nr_active_ports; + uint32_t max_nr_ports, nr_active_ports, nr_ports; unsigned int i; if (version_id > 2) { @@ -418,7 +418,21 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) /* The config space */ qemu_get_be16s(f, &s->config.cols); qemu_get_be16s(f, &s->config.rows); - s->config.nr_ports = qemu_get_be32(f); + nr_ports = qemu_get_be32(f); + + if (nr_ports != s->config.nr_ports) { + /* + * Source hot-plugged/unplugged ports and we don't have all of + * them here. + * + * Note: This condition cannot check for all hotplug/unplug + * events: eg, if one port was hot-plugged and one was + * unplugged, the nr_ports remains the same but the port id's + * would have changed and we won't catch it here. A later + * check for !find_port_by_id() will confirm if this happened. + */ + return -EINVAL; + } /* Items in struct VirtIOSerial */