Skip to content

Commit

Permalink
reverting to older code and updating the code to include quotes in ju…
Browse files Browse the repository at this point in the history
…st pathnames
  • Loading branch information
akhiljns committed Mar 20, 2024
1 parent 637934f commit aa5ffd5
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions hypervisor/virtualbox/virtualbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,14 @@ func (*virtualbox) Commit(vmName, imageName string) error {
}

func (*virtualbox) Create(imageName, vmName string, cpus int, mem int) error {

imagePath := db.GetImageFilePath(imageName)
importArgs := []string{
"import",
imagePath,
importCmd := vboxManage(
"import", `"`+db.GetImageFilePath(imageName)+`"`,
"--vsys", "0",
"--vmname", vmName,
"--basefolder", db.VMsBaseDir,
"--cpus", strconv.Itoa(cpus),
"--memory", strconv.Itoa(mem),
}

// Wrap each argument in quotes if it contains spaces
for i, arg := range importArgs {
if strings.Contains(arg, " ") {
importArgs[i] = `"` + arg + `"`
}
}

importCmd := vboxManage(importArgs...)

"--basefolder", `"`+db.VMsBaseDir+`"`,
"--cpus", fmt.Sprintf("%d", cpus),
"--memory", fmt.Sprintf("%d", mem),
)
if _, err := importCmd.CallWithProgress(fmt.Sprintf("Creating %s from image %s", vmName, imageName)); err != nil {
return err
}
Expand Down

0 comments on commit aa5ffd5

Please sign in to comment.