[lxc-devel] [lxd/master] lxd/vm/qemu: Fixes nvram creation on ubuntu 18.04

tomponline on Github lxc-bot at linuxcontainers.org
Wed Nov 13 13:16:42 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 428 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191113/bc01d406/attachment.bin>
-------------- next part --------------
From c1d5b9b6234b999e1ad9dcaf7a5a36ebf3bbf28e Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 13 Nov 2019 13:15:56 +0000
Subject: [PATCH] lxd/vm/qemu: Fixes nvram creation on ubuntu 18.04

- Also removes temporary config drive folder after iso creation

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/vm_qemu.go | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go
index 2a87f9c893..51a97da7be 100644
--- a/lxd/vm_qemu.go
+++ b/lxd/vm_qemu.go
@@ -427,9 +427,14 @@ func (vm *vmQemu) Start(stateful bool) error {
 		vm.VolatileSet(map[string]string{"volatile.vm.uuid": vmUUID})
 	}
 
-	// Generate an empty nvram file.
+	// Copy OVMF firmware to nvram file.
 	if !shared.PathExists(vm.getNvramPath()) {
-		err = shared.FileCopy("/usr/share/OVMF/OVMF_VARS.ms.fd", vm.getNvramPath())
+		srcOvmfFile := "/usr/share/OVMF/OVMF_VARS.ms.fd"
+		if !shared.PathExists(srcOvmfFile) {
+			srcOvmfFile = "/usr/share/OVMF/OVMF_VARS.fd"
+		}
+
+		err = shared.FileCopy(srcOvmfFile, vm.getNvramPath())
 		if err != nil {
 			return err
 		}
@@ -619,7 +624,7 @@ func (vm *vmQemu) getNvramPath() string {
 }
 
 func (vm *vmQemu) generateConfigDrive() (string, error) {
-	configDrivePath := filepath.Join(vm.Path(), "config")
+	configDrivePath := filepath.Join(vm.Path(), "configdrv")
 
 	// Create config drive dir.
 	err := os.MkdirAll(configDrivePath, 0100)
@@ -640,7 +645,7 @@ runcmd:
 		logger.Warnf("lxd-agent not found, skipping its inclusion in the VM config drive: %v", err)
 	} else {
 		// Install agent into config drive dir if found.
-		_, err = shared.RunCommand("cp", path, configDrivePath+"/lxd-agent")
+		err = shared.FileCopy(path, configDrivePath+"/lxd-agent")
 		if err != nil {
 			return "", err
 		}
@@ -747,6 +752,9 @@ WantedBy=multi-user.target
 		return "", err
 	}
 
+	// Remove the config drive folder.
+	os.RemoveAll(configDrivePath)
+
 	return isoPath, nil
 }
 


More information about the lxc-devel mailing list