From nobody Sun Dec 22 06:46:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734622939691738.000788862681; Thu, 19 Dec 2024 07:42:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9991E1797; Thu, 19 Dec 2024 10:42:18 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E7B30171D; Thu, 19 Dec 2024 10:40:02 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CCD26170A; Thu, 19 Dec 2024 10:39:57 -0500 (EST) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 375681717 for ; Thu, 19 Dec 2024 10:39:46 -0500 (EST) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-385f07cd1a4so633505f8f.1 for ; Thu, 19 Dec 2024 07:39:46 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c828ba0sm1802220f8f.14.2024.12.19.07.39.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Dec 2024 07:39:44 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734622785; x=1735227585; darn=lists.libvirt.org; 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=ISSyZu80+Z0LOt9qrMxsW+Lah1hE0o+0ErPwOcAlXN4=; b=OWkZPlRxbaW08NKyC/I3aUgBMSx3XY/dmddTq4t9ojqKbnfZWEccpHroo/oVmwODYQ 3fmUyfhEd5rGL5UBwfru4CO5rs5jtiK9c3/VGOfmWF8hhESWgGwCr4/D11pz6Xa1SxyX 5rr92yCV4k8pCALrgmABGSap4q7XFQixv+cq14PQP/dv2t2GDvyc8m7eHtR81pIpoW8q c2Q7Mbcrv2jl9xiLrSJEXRXCGiXIp9mMZKgouUCyg3nlfCZxooE33Irq8ImP5+ImYIpc 3wC+JFfMBUd1O/19aaCnVR+kXKB21ez/x1aV27Ci7VFeLMJRFhyr0h8XFS8qoVQWuj6Z Ns4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734622785; x=1735227585; 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=ISSyZu80+Z0LOt9qrMxsW+Lah1hE0o+0ErPwOcAlXN4=; b=B7m/qGfK0VpheaxdKo9yhK49aBGpfUTUxu59GUbrTbUNA/pbkYRdBoWc9yHsQfQT6t yMByPVqHNhMD6c59lV9Ic159i6dQ9iIu9canF3rUjjNf20yaiQF4XObRxF7hWmL2c68w ztlLsRxbJHZl4IyS9JTQsCSHREjqlOLRv4RC9YcO8IlvjB5Jumh7/zVhmtMrPYH2MTX5 fbvBy69HiNYZXjHnf4Fl07MIoEe6SaIVCm+emQHNB/zczmQqth97W6aOSBe5Ew5T+NyT SC4rIv7Ky7ek7Q9t2Tj957nCLP9IwreGreTMbLDQE2fvRz8FlK3dCZcs/hUKhwQtadYD eLlA== X-Forwarded-Encrypted: i=1; AJvYcCVvp4QtbsPFmaC/B82c6ulzZOvaXMO92HP1pOhxslQ2v62fRz2EV2jqgPRiamb/Pb5KZ9ZO4w==@lists.libvirt.org X-Gm-Message-State: AOJu0YzZYUq1uvUI4Vr7pfgqSdCe/SJltEGFC9cyElt8D+niPHt7GyjU rW60LV/qtG9T8Q9vCOJC+fdM0H6+mNTlKSOzKYKmjtsxzjZ/e79o1K9eRTRLOHA= X-Gm-Gg: ASbGnctcuMjd5sHmtcbZWu3SqELRnuThsb9HRaWJZdC8Fn+AppvqB3o+r3KLzuT2I6x inXeEnoeHldS7qjDvQizkjAdExOjk/Tu4QNdct6wA5D5qaWYsGSBSV3Vgt5eHbGb3pBbzIYvbDG z6KXUdf6S+5nJMl+G1FGHhuB5EvG/fJXOWzTFVs1YMabw/YQRjCSljkzW8SqMX4v7QZk6klLfB5 tWUrgUajqjJcrKiDdQqOqfZB35KIgBrNyOppq3inAvsrQklG2xM+gMEIsDi6hkcTMIVRfP6pyG1 jjuH X-Google-Smtp-Source: AGHT+IGsBFx3gRdGZ8dbbmXiiGC5S8eUniiw7NRzNAZmFthEqd6n6t7RPGfaSDyl3FduFf+EbjAdGg== X-Received: by 2002:a5d:47c8:0:b0:382:3754:38fa with SMTP id ffacd0b85a97d-388e4d96c35mr8177590f8f.51.1734622785043; Thu, 19 Dec 2024 07:39:45 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 08/10] hw/misc/vmcoreinfo: Implement 'vmcore-info' object Date: Thu, 19 Dec 2024 16:38:55 +0100 Message-ID: <20241219153857.57450-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241219153857.57450-1-philmd@linaro.org> References: <20241219153857.57450-1-philmd@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NWU75OD4BJHMLMYUWBN3MUNCX7KQUNGT X-Message-ID-Hash: NWU75OD4BJHMLMYUWBN3MUNCX7KQUNGT X-MailFrom: philmd@linaro.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: Ani Sinha , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , devel@lists.libvirt.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1734622941749116600 Content-Type: text/plain; charset="utf-8" 'vmcore-info' object allow to transition from '-device' to 'object', following the deprecation process. No need to modify VMCoreInfoState since DeviceState already inherits from Object state. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/misc/vmcoreinfo.h | 4 ++- hw/misc/vmcoreinfo.c | 48 +++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h index 122c69686b0..d4cce42cee6 100644 --- a/include/hw/misc/vmcoreinfo.h +++ b/include/hw/misc/vmcoreinfo.h @@ -16,8 +16,10 @@ #include "standard-headers/linux/qemu_fw_cfg.h" #include "qom/object.h" =20 +#define TYPE_VMCOREINFO "vmcore-info" +OBJECT_DECLARE_SIMPLE_TYPE(VMCoreInfoState, VMCOREINFO) + #define TYPE_VMCOREINFO_DEVICE "vmcoreinfo" -typedef struct VMCoreInfoState VMCoreInfoState; DECLARE_INSTANCE_CHECKER(VMCoreInfoState, VMCOREINFO_DEVICE, TYPE_VMCOREINFO_DEVICE) =20 diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index a0511ea0da4..e2258e08fb1 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -12,11 +12,11 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" -#include "qemu/module.h" #include "sysemu/reset.h" #include "hw/nvram/fw_cfg.h" #include "migration/vmstate.h" #include "hw/misc/vmcoreinfo.h" +#include "qom/object_interfaces.h" =20 static const VMStateDescription vmstate_vmcoreinfo =3D { .name =3D "vmcoreinfo", @@ -32,6 +32,11 @@ static const VMStateDescription vmstate_vmcoreinfo =3D { }, }; =20 +static char *vmcoreinfo_get_vmstate_id(VMStateIf *vmif) +{ + return g_strdup(TYPE_VMCOREINFO); +} + static void fw_cfg_vmci_write(void *opaque, off_t offset, size_t len) { VMCoreInfoState *s =3D opaque; @@ -88,6 +93,32 @@ static void vmcoreinfo_device_realize(DeviceState *dev, = Error **errp) vmcoreinfo_realize(VMCOREINFO_DEVICE(dev), errp); } =20 +static bool vmcoreinfo_can_be_deleted(UserCreatable *uc) +{ + return false; +} + +static void vmcoreinfo_complete(UserCreatable *uc, Error **errp) +{ + if (vmstate_register_any(VMSTATE_IF(uc), &vmstate_vmcoreinfo, uc) < 0)= { + error_setg(errp, "%s: Failed to register vmstate", TYPE_VMCOREINFO= ); + } + + vmcoreinfo_realize(VMCOREINFO(uc), errp); +} + +static void vmcoreinfo_class_init(ObjectClass *oc, void *data) +{ + UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(oc); + VMStateIfClass *vc =3D VMSTATE_IF_CLASS(oc); + ResettableClass *rc =3D RESETTABLE_CLASS(oc); + + ucc->complete =3D vmcoreinfo_complete; + ucc->can_be_deleted =3D vmcoreinfo_can_be_deleted; + vc->get_id =3D vmcoreinfo_get_vmstate_id; + rc->phases.hold =3D vmcoreinfo_reset_hold; +} + static void vmcoreinfo_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -106,6 +137,18 @@ static const TypeInfo vmcoreinfo_types[] =3D { .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(VMCoreInfoState), .class_init =3D vmcoreinfo_device_class_init, + }, + { + .name =3D TYPE_VMCOREINFO, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(VMCoreInfoState), + .class_init =3D vmcoreinfo_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_RESETTABLE_INTERFACE }, + { TYPE_USER_CREATABLE }, + { TYPE_VMSTATE_IF }, + { } + } } }; =20 @@ -116,6 +159,9 @@ VMCoreInfoState *vmcoreinfo_find(void) Object *obj; =20 obj =3D object_resolve_path_type("", TYPE_VMCOREINFO_DEVICE, NULL); + if (!obj) { + obj =3D object_resolve_path_type("", TYPE_VMCOREINFO, NULL); + } =20 return obj ? (VMCoreInfoState *)obj : NULL; } --=20 2.47.1