From nobody Tue Feb 10 14:32:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499998779758540.0434493858199; Thu, 13 Jul 2017 19:19:39 -0700 (PDT) Received: from localhost ([::1]:35008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVqCg-0006xG-AD for importer@patchew.org; Thu, 13 Jul 2017 22:19:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVq8s-0003Ue-TC for qemu-devel@nongnu.org; Thu, 13 Jul 2017 22:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVq8q-0001EW-OI for qemu-devel@nongnu.org; Thu, 13 Jul 2017 22:15:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVq8q-0001EF-Do for qemu-devel@nongnu.org; Thu, 13 Jul 2017 22:15:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 76DA37CE06 for ; Fri, 14 Jul 2017 02:15:39 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-51.pek2.redhat.com [10.72.12.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1468661F21; Fri, 14 Jul 2017 02:15:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 76DA37CE06 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 76DA37CE06 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 14 Jul 2017 10:15:00 +0800 Message-Id: <20170714021509.23681-12-famz@redhat.com> In-Reply-To: <20170714021509.23681-1-famz@redhat.com> References: <20170714021509.23681-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 14 Jul 2017 02:15:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 11/20] ivshmem: Convert to DEFINE_PROP_LINK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Unlike the usual object_property_add_link() invocations in other devices, ivshmem checks the "is mapped" state of the backend in addition to qdev_prop_allow_set_link_before_realize. To convert it without specializing DEFINE_PROP_LINK which always uses the qdev callback, move the extra check to device realize time. Signed-off-by: Fam Zheng --- hw/misc/ivshmem.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 97beaf6..4b38248 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1009,18 +1009,6 @@ static const TypeInfo ivshmem_common_info =3D { .class_init =3D ivshmem_common_class_init, }; =20 -static void ivshmem_check_memdev_is_busy(const Object *obj, const char *na= me, - Object *val, Error **errp) -{ - if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) { - char *path =3D object_get_canonical_path_component(val); - error_setg(errp, "can't use already busy memdev: %s", path); - g_free(path); - } else { - qdev_prop_allow_set_link_before_realize(obj, name, val, errp); - } -} - static const VMStateDescription ivshmem_plain_vmsd =3D { .name =3D TYPE_IVSHMEM_PLAIN, .version_id =3D 0, @@ -1037,6 +1025,8 @@ static const VMStateDescription ivshmem_plain_vmsd = =3D { =20 static Property ivshmem_plain_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("master", IVShmemState, master, ON_OFF_AUTO_OF= F), + DEFINE_PROP_LINK("memdev", IVShmemState, hostmem, TYPE_MEMORY_BACKEND, + HostMemoryBackend *), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -1044,11 +1034,6 @@ static void ivshmem_plain_init(Object *obj) { IVShmemState *s =3D IVSHMEM_PLAIN(obj); =20 - object_property_add_link(obj, "memdev", TYPE_MEMORY_BACKEND, - (Object **)&s->hostmem, - ivshmem_check_memdev_is_busy, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); s->not_legacy_32bit =3D 1; } =20 @@ -1059,6 +1044,11 @@ static void ivshmem_plain_realize(PCIDevice *dev, Er= ror **errp) if (!s->hostmem) { error_setg(errp, "You must specify a 'memdev'"); return; + } else if (host_memory_backend_is_mapped(s->hostmem)) { + char *path =3D object_get_canonical_path_component(OBJECT(s->hostm= em)); + error_setg(errp, "can't use already busy memdev: %s", path); + g_free(path); + return; } =20 ivshmem_common_realize(dev, errp); --=20 2.9.4