From 84374314a29345f0cbd47febe2ab7d529e13246a Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Mon, 20 Dec 2021 13:44:20 +0000 Subject: [PATCH] Use per-VM qcow2, remove it after the start --- appvm.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appvm.go b/appvm.go index c4f1ba2..19f88b2 100644 --- a/appvm.go +++ b/appvm.go @@ -161,7 +161,7 @@ func generateVM(path, name string, verbose bool) (realpath, reginfo, qcow2 strin syscall.Unlink("result") - qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2" + qcow2 = os.Getenv("HOME") + "/appvm/." + name + ".fake.qcow2" if _, e := os.Stat(qcow2); os.IsNotExist(e) { system.System("qemu-img", "create", "-f", "qcow2", qcow2, "40M") } @@ -177,7 +177,7 @@ func isRunning(l *libvirt.Libvirt, name string) bool { func generateAppVM(l *libvirt.Libvirt, nixName, vmName, appvmPath, sharedDir string, - verbose bool, network networkModel, gui bool) (err error) { + verbose bool, network networkModel, gui bool) (qcow2 string, err error) { realpath, reginfo, qcow2, err := generateVM(appvmPath, nixName, verbose) if err != nil { @@ -270,8 +270,9 @@ func start(l *libvirt.Libvirt, name string, verbose bool, network networkModel, go stupidProgressBar() } - err := generateAppVM(l, name, vmName, appvmPath, sharedDir, + qcow2, err := generateAppVM(l, name, vmName, appvmPath, sharedDir, verbose, network, gui) + defer os.Remove(qcow2) if err != nil { log.Fatal(err) }