From patchwork Mon Jul 10 22:26:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 701082 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410525wrs; Mon, 10 Jul 2023 15:31:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUnb6mVJsnWAB78V1eOydA4AkRDyPDjzCTQrLCkYu3mKOYR3hndTW8IUfnifSMtodQF4uT X-Received: by 2002:a37:2c81:0:b0:765:ab6e:53fb with SMTP id s123-20020a372c81000000b00765ab6e53fbmr11262075qkh.40.1689028310538; Mon, 10 Jul 2023 15:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028310; cv=none; d=google.com; s=arc-20160816; b=HN3H8YW9JhCqzl8VfuQpKaapDvqSUji1LetvGZxtgeTy449XrORHA3/75WV4YkplrB KLRYdBdgv2A/iJjPCPUxTdx14IFrDTHM0c8rA+g4nt2bTJlMGfjrq0ib0qL9oQMi/Lhf cYF6aujgULc8i8gcPpqt89TQMoNISDKMv/zP0s7RU7anUWYX4hjULP9wEiKF/P0gXDqt u55qc92CcJfFjAR/ndIDN/frDwgtQ/cvDQABg40ifqKBOyq1k2Qo5zSh9x8inwWjD7fp zoP2Zd2USJ3VAqmhur1mx9A8G4t8cUFtvz9AnFW1yX1NPE3+HytIjzBSISdaCbgUnwJR E2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; fh=hcwln6fraUM3+9Hj3KHhLVXh6W//hTqT+Pt2BsvEI7E=; b=cvGzfZrGPIJaIfqlgRoHu/x0dmQ6VETXDFFtFzSSIwNg3irDLuINyC2ZDShVs53vq2 rGt5X/wZj1L6aoOO7RQcBr9Ig8lOe5SyV5CNO47AXN1VUIekBJzO6zenD+KWdDUUGxdN 7smca6k9B41KJLklwj2+aSIxDmiWFusLkVX+/xSczv7BdXE+USWQKlUoZ93uIKm12eZv xo8NbeVXD4SqLG0Vw2b/BH8r93uUvHP44Ws15v8Tvjs9VFsqgs5trohS0ZgNKWYhSUFp jhl14Q+8mszO05oyRd9O9et4XVKi/d9io3Hgbc1R6pYw6AU7EQdaxjruPBBFsHS6rlAC Gy2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hEPjb8/C"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u9-20020a05620a430900b00767117b9c26si274350qko.210.2023.07.10.15.31.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hEPjb8/C"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzOf-0005i2-1P; Mon, 10 Jul 2023 18:30:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIzOX-0005P9-5y for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:14 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzOU-0002S3-VF for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:12 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fc03aa6e04so30160835e9.2 for ; Mon, 10 Jul 2023 15:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028209; x=1691620209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; b=hEPjb8/CeLGyUKZlGSHWX5jprjvTOLtpLi1Rx/Fm7B7nmowdwglGrAjnds3GHSwGJB 57LFuXMVNxE2UBSUSW+SrTKaSnxHjLhRfrza6BWXzSsxcU4KnWYwF9jJceVYGd1uunrU vbNV21XiCdY8i6bptyG/u4qAw4xX3lJQNf+XvR789NBeL5ZlGc4KOEFe0udM/9x/DYX6 4uQeRDLtefcURQIvNP7ZKy1AkTfr28H2damXICgVyQujdS3B6cCw0bU5A0HU3BxMX4tu S7snt7e+Wy+W17RSk0y052HrA5RoeEWXsOR8r0dKhxwWojeZRpj+pAcrQ7ECPYVUMbBW opkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028209; x=1691620209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; b=duacImi+k/DWFKetvkfAyEWPhPRzdK3c7SnYXkqHOHP9Jt1AVfEj/K/jUMEHzFgo7i cZs43o64MO8Bl/McMnt941wA0KEJbAKeRNfSO6UZFZzD0QlpWxJKONSxHPW62htb2ft2 tPkdGj2cWEI9p7dWz3OK7m1sjnFSu2MatsfmiiVhNGRW8CoJX0ZKyDcRRTIhdyYIkbLr T63Xub66ZPcXZABDJfvEFpJaqi67y1H8i9ueW2iNHzfRNAEZpLKY4qHVv1sJwOAw1pDs SZhrcnO14lBMHw22VBjMynSMyxhmcBH1S4cxLWrRBG6GF+LjRy9sV0RtgkCJjlIeysRX 03dg== X-Gm-Message-State: ABy/qLbipor7SmRbhe5zQap8RXvUhGXETRfTGSZYO69t6GZ0h8Pgq+Oa HCg6AJbvvDUG50F2x4Uat5OEYLu4p+hwNi3ksXzQNw== X-Received: by 2002:a1c:7910:0:b0:3fa:962e:e8f4 with SMTP id l16-20020a1c7910000000b003fa962ee8f4mr3827286wme.26.1689028209177; Mon, 10 Jul 2023 15:30:09 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c378400b003fbfc61d36asm929811wmr.5.2023.07.10.15.30.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:30:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow Subject: [PULL 44/44] hw/ide/piix: Move registration of VMStateDescription to DeviceClass Date: Tue, 11 Jul 2023 00:26:11 +0200 Message-Id: <20230710222611.50978-45-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Bernhard Beschow The modern, declarative way to set up VM state handling is to assign to DeviceClass::vmsd attribute. There shouldn't be any change in behavior since dc->vmsd causes vmstate_register_with_alias_id() to be called on the instance during the instance init phase. vmstate_register() was also called during the instance init phase which forwards to vmstate_register_with_alias_id() internally. Checking the migration schema before and after this patch confirms: before: > qemu-system-x86_64 -S > qemu > migrate -d exec:cat>before.mig after: > qemu-system-x86_64 -S > qemu > migrate -d exec:cat>after.mig > analyze-migration.py -d desc -f before.mig > before.json > analyze-migration.py -d desc -f after.mig > after.json > diff before.json after.json -> empty Signed-off-by: Bernhard Beschow Message-Id: <20230531211043.41724-8-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/piix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 47e0b474c3..151f206046 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -28,7 +28,6 @@ */ #include "qemu/osdep.h" -#include "migration/vmstate.h" #include "qapi/error.h" #include "hw/pci/pci.h" #include "hw/ide/piix.h" @@ -159,8 +158,6 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); - vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); - for (unsigned i = 0; i < 2; i++) { if (!pci_piix_init_bus(d, i, errp)) { return; @@ -186,6 +183,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->reset = piix_ide_reset; + dc->vmsd = &vmstate_ide_pci; k->realize = pci_piix_ide_realize; k->exit = pci_piix_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_INTEL; @@ -208,6 +206,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->reset = piix_ide_reset; + dc->vmsd = &vmstate_ide_pci; k->realize = pci_piix_ide_realize; k->exit = pci_piix_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_INTEL;