mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-05 03:43:00 +00:00
Move shared directory creation out of vm generating function
This commit is contained in:
parent
f1fd2e1505
commit
57e15fa0a0
13
appvm.go
13
appvm.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user