From cf2a4896b24776e395fde4478f270641cb5d07a4 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Tue, 12 Mar 2024 18:28:06 +0200 Subject: [PATCH] minor cleanup Signed-off-by: Arik Hadas --- pkg/controller/plan/kubevirt.go | 2 +- virt-v2v/cold/entrypoint.go | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 62dbed6a8..d4a322126 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -941,7 +941,7 @@ func (r *KubeVirt) UpdateVmByConvertedConfig(vm *plan.VMStatus, pod *core.Pod, s return } - r.Log.Info("setting the vm firmware to ", firmware, "vmId", vm.ID) + r.Log.Info("setting vm firmware", "vmId", vm.ID, "firmware", firmware) vm.Firmware = firmware diff --git a/virt-v2v/cold/entrypoint.go b/virt-v2v/cold/entrypoint.go index 93cd5d7a9..626ea9a7a 100644 --- a/virt-v2v/cold/entrypoint.go +++ b/virt-v2v/cold/entrypoint.go @@ -223,6 +223,7 @@ func executeVirtV2v(source string, args []string) (err error) { if match := UEFI_RE.FindSubmatch(line); match != nil { fmt.Println("UEFI firmware detected") firmware = "efi" + break } } @@ -325,26 +326,19 @@ func addFirmwareToXml(filePath string) (err error) { defer tempFile.Close() scanner := bufio.NewScanner(file) - domainFound := false for scanner.Scan() { line := scanner.Text() - if strings.Contains(line, "") { - domainFound = true - } - _, err = tempFile.WriteString(line + "\n") if err != nil { return } - if domainFound { - _, err = tempFile.WriteString(newFirmwareData + "\n") - if err != nil { + if strings.Contains(line, "") { + if _, err = tempFile.WriteString(newFirmwareData + "\n"); err != nil { return } - domainFound = false } } @@ -352,8 +346,7 @@ func addFirmwareToXml(filePath string) (err error) { return } - err = os.Rename(tempFilePath, filePath) - if err != nil { + if err = os.Rename(tempFilePath, filePath); err != nil { return }