From nobody Sun Feb 8 08:22:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644346509; cv=none; d=zohomail.com; s=zohoarc; b=i3+DZdcjNaIdX79QIgjqhuFew80TN8h2FD6tSUm7eY/yk4BD4sLO4Y3lgVtFCJfUUPiTv29WQYC9pX2WL5ShkxiQcpmZ7sq9l/RNB7K8XxCc8dl6Y1KuE9zUjSYP9kKkUJFAypZ68VLURYWqIJkw5QCrIe9544c91yVbSd56d/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644346509; h=Content-Type:Content-Transfer-Encoding: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=+ye7AY3Z3kpbOoCai3QhjqOQkgbQ/AABmlA0y+NQOiQ=; b=dvwFlgX5R9u4nCOGKeB6F2BCr43j7F0wLs0dYo9o2E2vUtwa8wmgxXPiFwr7jqtBxMFc+I3h9Eq2Cosi+GGGhaqnbRIykd//O6GD4vxmZBD30gXfx4jjtcAw4MgmdmTUPVvXPErz8BA46Is8hkvfTerb0Pu/7/CtDoVmaDwofYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1644346509038903.7968047152843; Tue, 8 Feb 2022 10:55:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-257-73Iq2VqvO5aSf4i-uPgYSw-1; Tue, 08 Feb 2022 13:53:25 -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 E377651089; Tue, 8 Feb 2022 18:53:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C23D47D498; Tue, 8 Feb 2022 18:53:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 907724A708; Tue, 8 Feb 2022 18:53:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 217CbFCm003354 for ; Mon, 7 Feb 2022 07:37:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7AA926FB87; Mon, 7 Feb 2022 12:37:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id C89106F95B; Mon, 7 Feb 2022 12:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644346507; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+ye7AY3Z3kpbOoCai3QhjqOQkgbQ/AABmlA0y+NQOiQ=; b=Fr62W/E6eDgXDhx77DJ2UwAlWEc+MxIEGCvIckp4OSgmU3PHgqM/cO/hqWf1PJlH4ekmCH OnsbBCA6rdlw/JHlIGKNuVgs7Sy4KxX+lgr78dEKhUS1r+es7izmAokybmSWPhjPihPlpP PT2EvT4hxHu8vUZqlgX5xT/pyxDEUFU= X-MC-Unique: 73Iq2VqvO5aSf4i-uPgYSw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] include: define constants for resetting NVRAM state Date: Mon, 7 Feb 2022 12:37:08 +0000 Message-Id: <20220207123711.1042287-3-berrange@redhat.com> In-Reply-To: <20220207123711.1042287-1-berrange@redhat.com> References: <20220207123711.1042287-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644346510322100001 When starting a guest with pflash based firmware, we will initialize NVRAM from a template if it does not already exist. In theory if the firmware code file is updated, the existing NVRAM variables should continue to work correctly. It is inevitable that this could break accidentally one day. Or a bug in the firmware might corrupt the NVRAM storage. Or user might make bad changes to the settings that prevent booting. Or the user might have re-configured the XML to point to a different firmware file incompatible with the current variables. In all these cases it would be useful to delete the existing NVRAM and initialize it from the pristine template. To support this introduce a VIR_DOMAIN_START_RESET_NVRAM constant for use with virDomainCreate / virDomainCreateXML, along with a VIR_DOMAIN_SAVE_RESET_NVRAM constant for use with virDomainRestore. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain-snapshot.h | 1 + include/libvirt/libvirt-domain.h | 2 ++ src/libvirt-domain.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/include/libvirt/libvirt-domain-snapshot.h b/include/libvirt/li= bvirt-domain-snapshot.h index 90673ed0fb..d729d1a532 100644 --- a/include/libvirt/libvirt-domain-snapshot.h +++ b/include/libvirt/libvirt-domain-snapshot.h @@ -198,6 +198,7 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING =3D 1 << 0, /* Run after revert */ VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED =3D 1 << 1, /* Pause after revert */ VIR_DOMAIN_SNAPSHOT_REVERT_FORCE =3D 1 << 2, /* Allow risky reverts = */ + VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM =3D 1 << 3, /* Re-initialize NV= RAM from template */ } virDomainSnapshotRevertFlags; =20 /* Revert the domain to a point-in-time snapshot. The diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 374859fdff..8c16598817 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -302,6 +302,7 @@ typedef enum { VIR_DOMAIN_START_BYPASS_CACHE =3D 1 << 2, /* Avoid file system cache p= ollution */ VIR_DOMAIN_START_FORCE_BOOT =3D 1 << 3, /* Boot, discarding any mana= ged save */ VIR_DOMAIN_START_VALIDATE =3D 1 << 4, /* Validate the XML document= against schema */ + VIR_DOMAIN_START_RESET_NVRAM =3D 1 << 5, /* Re-initialize NVRAM from = template */ } virDomainCreateFlags; =20 =20 @@ -1268,6 +1269,7 @@ typedef enum { VIR_DOMAIN_SAVE_BYPASS_CACHE =3D 1 << 0, /* Avoid file system cache po= llution */ VIR_DOMAIN_SAVE_RUNNING =3D 1 << 1, /* Favor running over paused = */ VIR_DOMAIN_SAVE_PAUSED =3D 1 << 2, /* Favor paused over running = */ + VIR_DOMAIN_SAVE_RESET_NVRAM =3D 1 << 3, /* Re-initialize NVRAM from t= emplate */ } virDomainSaveRestoreFlags; =20 int virDomainSave (virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5912551a49..75796affc7 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -154,6 +154,10 @@ virDomainGetConnect(virDomainPtr dom) * block attempts at migration. Hypervisors may also block save-to-file, * or snapshots. * + * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will + * discard any existing NVRAM file and re-initialize NVRAM from the + * pristine template. + * * virDomainFree should be used to free the resources after the * domain object is no longer needed. * @@ -1015,6 +1019,10 @@ virDomainRestore(virConnectPtr conn, const char *fro= m) * @flags will override the default read from the file. These two * flags are mutually exclusive. * + * If @flags includes VIR_DOMAIN_SAVE_RESET_NVRAM, then libvirt will + * discard any existing NVRAM file and re-initialize NVRAM from the + * pristine template. + * * Returns 0 in case of success and -1 in case of failure. */ int @@ -6764,6 +6772,10 @@ virDomainCreate(virDomainPtr domain) * If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save * file for this domain is discarded, and the domain boots from scratch. * + * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will + * discard any existing NVRAM file and re-initialize NVRAM from the + * pristine template. + * * Returns 0 in case of success, -1 in case of error */ int @@ -6836,6 +6848,10 @@ virDomainCreateWithFlags(virDomainPtr domain, unsign= ed int flags) * If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save * file for this domain is discarded, and the domain boots from scratch. * + * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will + * discard any existing NVRAM file and re-initialize NVRAM from the + * pristine template. + * * Returns 0 in case of success, -1 in case of error */ int --=20 2.34.1