On Sat, 2013-01-26 at 20:45 +0000, David Woodhouse wrote:
> I'm looking at adding support for writeable files to qemu's fw_cfg, and
> this would be necessary to write them.

Got this far on the plane home, which actually manages to save the
NvVars to the fw_cfg file and I see them turn up in the corresponding
file on the host. But that's just a proof of concept and a test for my
qemu-side patch. It actually needs to be in a runtime driver so it can
work even after the OS is running. Probably integrated with the normal
variable handling code? I haven't looked at how to do that properly.

I shall probably now disappear for a few days; if anyone wants to pick
this up that would be great... :)

diff --git a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c 
b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
index 190a564..ddc2166 100644
--- a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
+++ b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
@@ -17,6 +17,8 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/QemuFwCfgLib.h>
 
 
 /**
@@ -448,6 +450,18 @@ SaveNvVarsToFs (
     return Status;
   }
 
+  FIRMWARE_CONFIG_ITEM Item;
+  UINTN ItemSize;
+  Status = QemuFwCfgFindFile ("etc/nvstorage", &Item, &ItemSize);
+  if (!EFI_ERROR(Status)) {
+         DEBUG((EFI_D_INFO, "FsAccess.c: Saving %d bytes to qemu nvstorage at 
item 0x%04x\n", VariableDataSize, (UINT16)Item));
+         QemuFwCfgSelectItem(Item);
+         QemuFwCfgWriteBytes(VariableDataSize, VariableData);
+         QemuFwCfgSelectItem(0);
+         return EFI_SUCCESS;
+  }
+  if (FsHandle == NULL)
+         return EFI_NOT_STARTED;
   //
   // Open the NvVars file for writing.
   //
diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c 
b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
index c89bb4a..f33e436 100644
--- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
+++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
@@ -70,14 +70,7 @@ EFIAPI
 UpdateNvVarsOnFileSystem (
   )
 {
-  if (mNvVarsFileLibFsHandle == NULL) {
-    //
-    // A file system had not been connected to the library.
-    //
-    return EFI_NOT_STARTED;
-  } else {
     return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
-  }
 }
 
 

-- 
dwmw2

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to