From aa5ffd5f681891393c076e5807155f0c9fdaec4a Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 20 Mar 2024 21:32:08 +0530 Subject: [PATCH] reverting to older code and updating the code to include quotes in just pathnames --- hypervisor/virtualbox/virtualbox.go | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/hypervisor/virtualbox/virtualbox.go b/hypervisor/virtualbox/virtualbox.go index b4f1e5d..88e78fa 100644 --- a/hypervisor/virtualbox/virtualbox.go +++ b/hypervisor/virtualbox/virtualbox.go @@ -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 }