From nobody Thu May 16 15:52:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=dupond.be ARC-Seal: i=1; a=rsa-sha256; t=1634044112; cv=none; d=zohomail.com; s=zohoarc; b=Dy/NdJn/tn3l/a1aDuStlsjuuF00hskjtkPqWFIEJUlElMIb4Vw+eq2zGrpF075boF48VVrTuta0nwrJrkQQsdmv8ptVDRWvm1d7PDiEs2OCFAXK5yPTOKdFWSS5BuDIUQ4KMiWuIhL7pdBDKHT+xj67CkjMYD/HpFvvCbYzlLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634044112; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+pgcVuw2N1BaWqmZ3nyW4bFxW+5WXH0AuBb7XSsjHMk=; b=VjNf43YutnGeCkpW0BZNDHe46YtfK1RNN4bWxTwFm84sb4+vnTfMSenXXAXA/4MU7aXiJbxoHkckKqlU965j3zIPcGei7DhGSSReqOiBDE2ceTpBnPIqVaYp2WjLHAjq9RQlCJYaRJ8WVXg9cwDyNF63krqi9DZPyuM6f5CYnqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163404411261940.335021564753674; Tue, 12 Oct 2021 06:08:32 -0700 (PDT) Received: from localhost ([::1]:55350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maHWB-0007cT-K6 for importer@patchew.org; Tue, 12 Oct 2021 09:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maD5q-0006EE-6c for qemu-devel@nongnu.org; Tue, 12 Oct 2021 04:25:03 -0400 Received: from apollo.dupie.be ([2001:bc8:3f2a:101::1]:39334) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maD5l-0007KE-AV for qemu-devel@nongnu.org; Tue, 12 Oct 2021 04:25:00 -0400 Received: from localhost.localdomain (unknown [IPv6:2a02:a03f:fa8f:3301:eba1:a8ad:64a3:d6c8]) by apollo.dupie.be (Postfix) with ESMTPSA id AE0701521027; Tue, 12 Oct 2021 10:24:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dupond.be; s=dkim; t=1634027091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+pgcVuw2N1BaWqmZ3nyW4bFxW+5WXH0AuBb7XSsjHMk=; b=i8CC1BlDMkhnXPwiTq5OQbodh9vVoRmglv03cNUIBW7B2r/xyahAuuqnuGKTWXbtsLB9n5 CddLEbHIOCMRsmrj3pjvsGH16EZiJH1dcW8yiHMN0QRvn/bJ+lpUIzN8oj1XNEeQIuRoH/ xPYo6uyiTkTm+ruDpbX5ZoltHxTj/NXUskXXYKyj2diz3Wl7ipxxbiybcWHTrZWdav9K/w oc0aVsSYURT+VaO0J5AtLRPb+oJAavIUjWzFV6Uiv7yoVtBEetvgnNyOMACJ6aLLoFR1Xc b9+s1Z3+gvnC8AD1K3v+Ml608n64S/Z0RmZdgPw4scZXoF2c0LEVZY4fQhRbOg== From: Jean-Louis Dupond To: qemu-devel@nongnu.org Cc: Jean-Louis Dupond Subject: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs Date: Tue, 12 Oct 2021 10:24:28 +0200 Message-Id: <20211012082428.16222-1-jean-louis@dupond.be> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:bc8:3f2a:101::1; envelope-from=jean-louis@dupond.be; helo=apollo.dupie.be 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 12 Oct 2021 09:07:04 -0400 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @dupond.be) X-ZM-MESSAGEID: 1634044113449100001 Content-Type: text/plain; charset="utf-8" hw_compat modes only take into account their base name. But if a device is created with (non)-transitional, then the compat values are not used, causing migrating issues. This commit adds their (non)-transitional entries with the same settings as the base entry. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=3D1999141 Signed-off-by: Jean-Louis Dupond Acked-by: Jason Wang Acked-by: Jean-Louis Dupond --- include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 4ff19c714b..5726825c2d 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -293,6 +293,30 @@ typedef struct GlobalProperty { bool optional; } GlobalProperty; =20 + +/** + * Helper to add (non)transitional compat properties + */ +static inline void +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop) +{ + GlobalProperty *transitional =3D g_new0(typeof(*transitional), 1); + transitional->driver =3D g_strdup_printf("%s-transitional", prop->driv= er); + transitional->property =3D g_strdup(prop->property); + transitional->value =3D g_strdup(prop->value); + transitional->used =3D prop->used; + transitional->optional =3D prop->optional; + g_ptr_array_add(arr, (void *)transitional); + + GlobalProperty *non_transitional =3D g_new0(typeof(*non_transitional),= 1); + non_transitional->driver =3D g_strdup_printf("%s-non-transitional", pr= op->driver); + non_transitional->property =3D g_strdup(prop->property); + non_transitional->value =3D g_strdup(prop->value); + non_transitional->used =3D prop->used; + non_transitional->optional =3D prop->optional; + g_ptr_array_add(arr, (void *)non_transitional); +} + static inline void compat_props_add(GPtrArray *arr, GlobalProperty props[], size_t nelem) @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr, int i; for (i =3D 0; i < nelem; i++) { g_ptr_array_add(arr, (void *)&props[i]); + if (g_str_equal(props[i].driver, "vhost-user-blk-pci") || + g_str_equal(props[i].driver, "virtio-scsi-pci") || + g_str_equal(props[i].driver, "virtio-blk-pci") || + g_str_equal(props[i].driver, "virtio-balloon-pci") || + g_str_equal(props[i].driver, "virtio-serial-pci") || + g_str_equal(props[i].driver, "virtio-9p-pci") || + g_str_equal(props[i].driver, "virtio-net-pci") || + g_str_equal(props[i].driver, "virtio-rng-pci")) { + compat_props_add_transitional(arr, &props[i]); + } } } =20 --=20 2.33.0