From 7f3d542eb5b94eab4229ae89fca4614a5b0d6900 Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Tue, 17 Oct 2023 10:47:19 -0500 Subject: [PATCH] Do not overwrite ovmf vars if they exist The VM may have made ovmf vars changes. We do not want to clobber those. Signed-off-by: Serge Hallyn --- pkg/api/qconfig.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/api/qconfig.go b/pkg/api/qconfig.go index fab79f7..6e307c8 100644 --- a/pkg/api/qconfig.go +++ b/pkg/api/qconfig.go @@ -389,13 +389,12 @@ func ConfigureUEFIVars(c *qcli.Config, srcCode, srcVars, runDir string, secureBo } dest = filepath.Join(runDir, qcli.UEFIVarsFileName) log.Infof("Importing UEFI Vars from '%s' to '%q'", src, dest) - // FIXME: should we skip re-import of srcVars, the imported Vars may have - // had changes that a new import would clobber, warning for now - if PathExists(dest) { - log.Warnf("Already imported UEFI Vars file %q to %q, overwriting...", src, dest) - } - if err := CopyFileBits(src, dest); err != nil { - return fmt.Errorf("Failed to import UEFI Vars from '%s' to '%q': %s", src, dest, err) + if !PathExists(dest) { + if err := CopyFileBits(src, dest); err != nil { + return fmt.Errorf("Failed to import UEFI Vars from '%s' to '%q': %s", src, dest, err) + } + } else { + log.Infof("Already imported UEFI Vars file %q to %q. Not overwriting.", src, dest) } uefiDev.Vars = dest