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