From patchwork Mon Mar 30 16:47:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 11466035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B70C892A for ; Mon, 30 Mar 2020 16:48:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C4622072E for ; Mon, 30 Mar 2020 16:48:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gxuXeY4B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C4622072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIxaC-0006w4-Gm for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 Mar 2020 12:48:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52937) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIxZQ-0005Zh-N1 for qemu-devel@nongnu.org; Mon, 30 Mar 2020 12:47:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIxZP-0001pz-26 for qemu-devel@nongnu.org; Mon, 30 Mar 2020 12:47:28 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:39538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jIxZO-0001nX-PN for qemu-devel@nongnu.org; Mon, 30 Mar 2020 12:47:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585586845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GH+HsEqN61hy6bX9z7Ta7fs1JcJhCfX13beqwU2GDME=; b=gxuXeY4Bg2uIFEP45qRNwlsLaB1lwG781YAR2Lst1hMe+J5ULBN8p/vt5jCLnJgxWT8I97 Y00CqxgoCRQWNbl3pg+AFkOe0utEVavr7LDsI5wlLMGHcggwvvZPC9qh9dK9AcGp9zAEne WraAl7FOdccNrTDxsz/fuZfzZFwUuGg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-lAuvz1iaP9W89So6KMxsGw-1; Mon, 30 Mar 2020 12:47:21 -0400 X-MC-Unique: lAuvz1iaP9W89So6KMxsGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA36E149C7 for ; Mon, 30 Mar 2020 16:47:20 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-162.ams2.redhat.com [10.36.114.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D0E1100EBB3; Mon, 30 Mar 2020 16:47:14 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, marcandre.lureau@redhat.com, pbonzini@redhat.com, mst@redhat.com Subject: [PATCH] serial: Fix double migration data Date: Mon, 30 Mar 2020 17:47:12 +0100 Message-Id: <20200330164712.198282-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" After c9808d60281 we have both an object representing the serial-isa device and a separate object representing the underlying common serial uart. Both of these have vmsd's associated with them and thus the migration stream ends up with two copies of the migration data - the serial-isa includes the vmstate of the core serial. Besides being wrong, it breaks backwards migration compatibility. Fix this by removing the dc->vmsd from the core device, so it only gets migrated by any parent devices including it. Add a vmstate_serial_mm so that any device that uses serial_mm_init rather than creating a device still gets migrated. (That doesn't fix backwards migration for serial_mm_init users, but does seem to work forwards for ppce500). Fixes: c9808d60281 ('serial: realize the serial device') Buglink: https://bugs.launchpad.net/qemu/+bug/1869426 Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Marc-André Lureau --- hw/char/serial.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 2ab8b69e03..c822a9ae6c 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -1043,7 +1043,6 @@ static void serial_class_init(ObjectClass *klass, void* data) dc->user_creatable = false; dc->realize = serial_realize; dc->unrealize = serial_unrealize; - dc->vmsd = &vmstate_serial; device_class_set_props(dc, serial_properties); } @@ -1113,6 +1112,16 @@ static void serial_mm_realize(DeviceState *dev, Error **errp) sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq); } +static const VMStateDescription vmstate_serial_mm = { + .name = "serial", + .version_id = 3, + .minimum_version_id = 2, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(serial, SerialMM, 0, vmstate_serial, SerialState), + VMSTATE_END_OF_LIST() + } +}; + SerialMM *serial_mm_init(MemoryRegion *address_space, hwaddr base, int regshift, qemu_irq irq, int baudbase, @@ -1162,6 +1171,7 @@ static void serial_mm_class_init(ObjectClass *oc, void *data) device_class_set_props(dc, serial_mm_properties); dc->realize = serial_mm_realize; + dc->vmsd = &vmstate_serial_mm; } static const TypeInfo serial_mm_info = {