From nobody Wed May 22 00:33:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1607447345; cv=none; d=zohomail.com; s=zohoarc; b=YN4hjXCR9NJLq22vrBjeV/vXVQIhStTD3O0jteR5eMMKg5JowSJ7IH4OvQtdAeOlHtCMajOwJ+uq9Anj/tZ4qMIKfepikETs7nzvIm8POwfpIVJyZy7FMHcIMER9GPbxUOux3VY/mpv+5RzgDaexLwoK7awgEaSEbZ5Y4GHWgEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607447345; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wuDaBLBKSNDnZmjEVJ3ifOWBEnuNh7fStX/OzA5OCbU=; b=A+T8ZqA3joM15bYzER48wcnNJtweQzUU2eGZxds+OU2+PTOhZJ8xX9/WI2F0okmBGeXcbfLCMBITtRO96sb/Kfu6rQlIhO7/EE84SudH8e8JbACmSvgemMilS7QRBgwdOIy7YKl5aQc3pXrZdOiY7OVhYXeN3XHmlbgIIyIaqH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607447345777132.55976217284456; Tue, 8 Dec 2020 09:09:05 -0800 (PST) Received: from localhost ([::1]:40416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmgU4-00089F-8o for importer@patchew.org; Tue, 08 Dec 2020 12:09:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmg82-0000lH-8i for qemu-devel@nongnu.org; Tue, 08 Dec 2020 11:46:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kmg80-00071j-1j for qemu-devel@nongnu.org; Tue, 08 Dec 2020 11:46:18 -0500 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-477-yFfBOUMFMje9-lhMR6GZnQ-1; Tue, 08 Dec 2020 11:46:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB6D9107AD29; Tue, 8 Dec 2020 16:46:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CB8560BE2; Tue, 8 Dec 2020 16:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607445973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wuDaBLBKSNDnZmjEVJ3ifOWBEnuNh7fStX/OzA5OCbU=; b=bF4e0oeqsNLV0NEMmdW27l6+NHbOL9KG7/sHo0WX9Rlx2Ksfv++PKIPd6dyTpZuWLW/lLn pASB4AWhpOZjCSauDQl0pMPzsEGd/P4ISvRvRF5PdvP/I5Z1t9Gfwb1x2vHQUJY7UJ6qzV u96f6/pkAg2IBw3uIMAvFmuLvqo2KLw= X-MC-Unique: yFfBOUMFMje9-lhMR6GZnQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v2] ppc/spapr: cleanup -machine pseries,nvdimm=X handling Date: Tue, 8 Dec 2020 11:46:06 -0500 Message-Id: <20201208164606.4109134-1-imammedo@redhat.com> In-Reply-To: <20201208110532.4099624-1-imammedo@redhat.com> References: <20201208110532.4099624-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Cc: pbonzini@redhat.com, danielhb413@gmail.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Since NVDIMM support was introduced on pseries machine, it ignored machine's nvdimm=3Don|off option and effectively was always enabled on machines that support NVDIMM. Later on commit (28f5a716212 ppc/spapr_nvdimm: do not enable support with 'nvdimm=3Doff') makes QEMU error out in case user explicitly set 'nvdimm=3Doff' on CLI by peeking at machine_opts. However that's a workaround and leaves 'nvdimms_state->is_enabled' in inconsistent state (false) when it should be set true by default. Instead of using on machine_opts, set default to true for pseries machine in initfn time. If user sets manually 'nvdimm=3Doff' it will overwrite default value to false and QEMU will error as expected without need to peek into machine_opts. That way pseries will have, nvdimm enabled by default and will honor user provided 'nvdimm=3Don|off'. Signed-off-by: Igor Mammedov Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- CC: danielhb413@gmail.com CC: david@gibson.dropbear.id.au CC: pbonzini@redhat.com v2: - simplify a bit more by using spapr_instance_init() to set default value instead of doing it in generic machine code PS: Patch should be applied on top of: [PATCH 08/15] machine: introduce MachineInitPhase --- hw/ppc/spapr.c | 13 +++++++++++++ hw/ppc/spapr_nvdimm.c | 14 +------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b7e0894019..803a6f52a2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3267,6 +3267,19 @@ static void spapr_instance_init(Object *obj) { SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + MachineState *ms =3D MACHINE(spapr); + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + + /* + * NVDIMM support went live in 5.1 without considering that, in + * other archs, the user needs to enable NVDIMM support with the + * 'nvdimm' machine option and the default behavior is NVDIMM + * support disabled. It is too late to roll back to the standard + * behavior without breaking 5.1 guests. + */ + if (mc->nvdimm_supported) { + ms->nvdimms_state->is_enabled =3D true; + } =20 spapr->htab_fd =3D -1; spapr->use_hotplug_event_source =3D true; diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index a833a63b5e..66cd3dc13f 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -27,10 +27,8 @@ #include "hw/ppc/spapr_nvdimm.h" #include "hw/mem/nvdimm.h" #include "qemu/nvdimm-utils.h" -#include "qemu/option.h" #include "hw/ppc/fdt.h" #include "qemu/range.h" -#include "sysemu/sysemu.h" #include "hw/ppc/spapr_numa.h" =20 bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, @@ -38,7 +36,6 @@ bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, N= VDIMMDevice *nvdimm, { const MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); const MachineState *ms =3D MACHINE(hotplug_dev); - const char *nvdimm_opt =3D qemu_opt_get(qemu_get_machine_opts(), "nvdi= mm"); g_autofree char *uuidstr =3D NULL; QemuUUID uuid; int ret; @@ -48,16 +45,7 @@ bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, = NVDIMMDevice *nvdimm, return false; } =20 - /* - * NVDIMM support went live in 5.1 without considering that, in - * other archs, the user needs to enable NVDIMM support with the - * 'nvdimm' machine option and the default behavior is NVDIMM - * support disabled. It is too late to roll back to the standard - * behavior without breaking 5.1 guests. What we can do is to - * ensure that, if the user sets nvdimm=3Doff, we error out - * regardless of being 5.1 or newer. - */ - if (!ms->nvdimms_state->is_enabled && nvdimm_opt) { + if (!ms->nvdimms_state->is_enabled) { error_setg(errp, "nvdimm device found but 'nvdimm=3Doff' was set"); return false; } --=20 2.27.0