[lxc-devel] [lxd/master] VM: Mount VM config vol before generating NVRAM file

tomponline on Github lxc-bot at linuxcontainers.org
Tue Jan 28 11:08:55 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 493 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200128/6ea1674e/attachment.bin>
-------------- next part --------------
From b2ce63726ab4b5354ed22ba1ed8c99a234031795 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Tue, 28 Jan 2020 11:07:46 +0000
Subject: [PATCH] lxd/instance/drivers/driver/qemu: Mount VM config vol before
 generating NVRAM file

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/instance/drivers/driver_qemu.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index fb13696a57..4ebdc409bf 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -837,6 +837,16 @@ func (vm *qemu) Start(stateful bool) error {
 }
 
 func (vm *qemu) setupNvram() error {
+	// Mount the instance's config volume.
+	ourMount, err := vm.mount()
+	if err != nil {
+		return err
+	}
+
+	if ourMount {
+		defer vm.unmount()
+	}
+
 	srcOvmfFile := filepath.Join(vm.ovmfPath(), "OVMF_VARS.fd")
 	if vm.expandedConfig["security.secureboot"] == "" || shared.IsTrue(vm.expandedConfig["security.secureboot"]) {
 		srcOvmfFile = filepath.Join(vm.ovmfPath(), "OVMF_VARS.ms.fd")
@@ -847,7 +857,7 @@ func (vm *qemu) setupNvram() error {
 	}
 
 	os.Remove(vm.getNvramPath())
-	err := shared.FileCopy(srcOvmfFile, vm.getNvramPath())
+	err = shared.FileCopy(srcOvmfFile, vm.getNvramPath())
 	if err != nil {
 		return err
 	}


More information about the lxc-devel mailing list