Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Mar 12, 2024
1 parent ae3f78f commit 2fdf499
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 4 additions & 11 deletions virt-v2v/cold/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -325,35 +326,27 @@ 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, "</os>") {
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, "</os>") {
if _, err = tempFile.WriteString(newFirmwareData + "\n"); err != nil {
return
}
domainFound = false
}
}

if err = scanner.Err(); err != nil {
return
}

err = os.Rename(tempFilePath, filePath)
if err != nil {
if err = os.Rename(tempFilePath, filePath); err != nil {
return
}

Expand Down

0 comments on commit 2fdf499

Please sign in to comment.