Move shared directory creation out of vm generating function

This commit is contained in:
Mikhail Klementev 2020-01-03 22:10:13 +00:00
parent f1fd2e1505
commit 57e15fa0a0
No known key found for this signature in database
GPG Key ID: BE44DA8C062D87DC

View File

@ -165,8 +165,8 @@ func isRunning(l *libvirt.Libvirt, name string) bool {
return err == nil return err == nil
} }
func generateAppVM(l *libvirt.Libvirt, appvmPath, name string, verbose, func generateAppVM(l *libvirt.Libvirt, name, appvmPath, sharedDir string,
online bool) (err error) { verbose, online bool) (err error) {
err = os.Chdir(appvmPath) err = os.Chdir(appvmPath)
if err != nil { if err != nil {
@ -178,9 +178,6 @@ func generateAppVM(l *libvirt.Libvirt, appvmPath, name string, verbose,
return return
} }
sharedDir := fmt.Sprintf(os.Getenv("HOME") + "/appvm/" + name)
os.MkdirAll(sharedDir, 0700)
xml := generateXML(name, online, realpath, reginfo, qcow2, sharedDir) xml := generateXML(name, online, realpath, reginfo, qcow2, sharedDir)
_, err = l.DomainCreateXML(xml, libvirt.DomainStartValidate) _, err = l.DomainCreateXML(xml, libvirt.DomainStartValidate)
return return
@ -255,7 +252,11 @@ func start(l *libvirt.Libvirt, name string, verbose, online bool,
if !verbose { if !verbose {
go stupidProgressBar() go stupidProgressBar()
} }
err = generateAppVM(l, appvmPath, name, verbose, online)
sharedDir := fmt.Sprintf(os.Getenv("HOME") + "/appvm/" + name)
os.MkdirAll(sharedDir, 0700)
err = generateAppVM(l, name, appvmPath, sharedDir, verbose, online)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }