VirtualBox

source: vbox/trunk/src/VBox/Main/include/NvramStoreImpl.h

Last change on this file was 108620, checked in by vboxsync, 6 weeks ago

Main/NvramStore: Changeset r164311 modified the implementation of
NvramStore::getNonVolatileStorageFile() to return failure if no NVRAM
file however the API documents that this attribute may not exist. This
change breaks IMachine::moveTo() if the VM has a snapshot since
snapshots don't have an NVRAM file. Thus restore the behaviour of
getNonVolatileStorageFile() to its previous incarnation where the caller
is required to check for the attribute's existence upon successful
invocation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: NvramStoreImpl.h 108620 2025-03-19 19:29:06Z vboxsync $ */
2/** @file
3 * VirtualBox COM NVRAM store class implementation
4 */
5
6/*
7 * Copyright (C) 2021-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_NvramStoreImpl_h
29#define MAIN_INCLUDED_NvramStoreImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "NvramStoreWrap.h"
35#include "SecretKeyStore.h"
36#include <VBox/vmm/pdmdrv.h>
37#include <VBox/VBoxCryptoIf.h>
38
39
40#ifdef VBOX_COM_INPROC
41class Console;
42struct DRVMAINNVRAMSTORE;
43#else
44class GuestOSType;
45
46namespace settings
47{
48 struct NvramSettings;
49}
50#endif
51
52class ATL_NO_VTABLE NvramStore :
53 public NvramStoreWrap
54{
55public:
56
57 DECLARE_COMMON_CLASS_METHODS(NvramStore)
58
59 HRESULT FinalConstruct();
60 void FinalRelease();
61
62 // public initializer/uninitializer for internal purposes only
63#ifdef VBOX_COM_INPROC
64 HRESULT init(Console *aParent, const com::Utf8Str &strNonVolatileStorageFile);
65#else
66 HRESULT init(Machine *parent);
67 HRESULT init(Machine *parent, NvramStore *that);
68 HRESULT initCopy(Machine *parent, NvramStore *that);
69#endif
70 void uninit();
71
72 // public methods for internal purposes only
73#ifndef VBOX_COM_INPROC
74 HRESULT i_loadSettings(const settings::NvramSettings &data);
75 HRESULT i_saveSettings(settings::NvramSettings &data);
76#endif
77
78#ifdef VBOX_COM_INPROC
79 static const PDMDRVREG DrvReg;
80#else
81 void i_rollback();
82 void i_commit();
83 void i_copyFrom(NvramStore *aThat);
84 HRESULT i_applyDefaults(GuestOSType *aOSType);
85#endif
86
87 com::Utf8Str i_getNonVolatileStorageFile();
88 void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
89
90 int i_loadStore(const char *pszPath);
91 int i_saveStore(void);
92
93#ifndef VBOX_COM_INPROC
94 HRESULT i_retainUefiVarStore(PRTVFS phVfs, bool fReadonly);
95 HRESULT i_releaseUefiVarStore(RTVFS hVfs);
96#endif
97
98#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
99 HRESULT i_updateEncryptionSettings(const com::Utf8Str &strKeyId,
100 const com::Utf8Str &strKeyStore);
101 HRESULT i_getEncryptionSettings(com::Utf8Str &strKeyId,
102 com::Utf8Str &strKeyStore);
103
104 int i_addPassword(const Utf8Str &strKeyId, const Utf8Str &strPassword);
105 int i_removePassword(const Utf8Str &strKeyId);
106 int i_removeAllPasswords();
107#endif
108
109private:
110
111 int initImpl(void);
112
113 // Wrapped NVRAM store properties
114 HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
115 HRESULT getUefiVariableStore(ComPtr<IUefiVariableStore> &aUefiVarStore);
116 HRESULT getKeyId(com::Utf8Str &aKeyId);
117 HRESULT getKeyStore(com::Utf8Str &aKeyStore);
118
119 // Wrapped NVRAM store members
120 HRESULT initUefiVariableStore(ULONG aSize);
121
122 int i_loadStoreFromTar(RTVFSFSSTREAM hVfsFssTar);
123 int i_loadStoreFromDir(RTVFSDIR hVfsDir, const char *pszNamespace);
124 int i_saveStoreAsTar(const char *pszPath);
125 int i_saveStoreAsDir(const char *pszPath);
126
127 int i_retainCryptoIf(PCVBOXCRYPTOIF *ppCryptoIf);
128 int i_releaseCryptoIf(PCVBOXCRYPTOIF pCryptoIf);
129
130#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
131 int i_setupEncryptionOrDecryption(RTVFSIOSTREAM hVfsIosInOut, bool fEncrypt,
132 PCVBOXCRYPTOIF *ppCryptoIf, SecretKey **ppKey,
133 PRTVFSIOSTREAM phVfsIos);
134 void i_releaseEncryptionOrDecryptionResources(RTVFSIOSTREAM hVfsIos, PCVBOXCRYPTOIF pCryptoIf,
135 SecretKey *pKey);
136#endif
137
138#ifdef VBOX_COM_INPROC
139 static DECLCALLBACK(int) i_SsmSaveExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
140 static int i_SsmSaveExecInner(struct DRVMAINNVRAMSTORE *pThis, PCPDMDRVHLPR3 pHlp, PSSMHANDLE pSSM,
141 void **ppvData, size_t *pcbDataMax) RT_NOEXCEPT;
142 static DECLCALLBACK(int) i_SsmLoadExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
143 static int i_SsmLoadExecInner(struct DRVMAINNVRAMSTORE *pThis, PCPDMDRVHLPR3 pHlp, PSSMHANDLE pSSM,
144 uint32_t cEntries, void **ppvData, size_t *pcbDataMax) RT_NOEXCEPT;
145
146 static DECLCALLBACK(int) i_nvramStoreQuerySize(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
147 uint64_t *pcb);
148 static DECLCALLBACK(int) i_nvramStoreReadAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
149 void *pvBuf, size_t cbRead);
150 static DECLCALLBACK(int) i_nvramStoreWriteAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
151 const void *pvBuf, size_t cbWrite);
152 static DECLCALLBACK(int) i_nvramStoreDelete(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath);
153 static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
154 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
155 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
156#endif
157
158 struct Data; // opaque data struct, defined in NvramStoreImpl.cpp
159 Data *m;
160};
161
162#endif /* !MAIN_INCLUDED_NvramStoreImpl_h */
163/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette