diff --git a/.gitignore b/.gitignore index 8e0fd9e..092ab87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea *.iml .vscode/ -vermin.exe \ No newline at end of file +vermin.exe +vermin \ No newline at end of file diff --git a/hypervisor/virtualbox/virtualbox.go b/hypervisor/virtualbox/virtualbox.go index 04a98c2..88e78fa 100644 --- a/hypervisor/virtualbox/virtualbox.go +++ b/hypervisor/virtualbox/virtualbox.go @@ -38,25 +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), - } - - for i, arg := range importArgs { - 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 }