Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carmark/8c3f05ff5103155e579c to your computer and use it in GitHub Desktop.
Save carmark/8c3f05ff5103155e579c to your computer and use it in GitHub Desktop.
lei@ubuntu:/root/ws/src/hyper$ git diff
diff --git a/qemu/context.go b/qemu/context.go
index 2a1c096..9e64cfc 100644
--- a/qemu/context.go
+++ b/qemu/context.go
@@ -65,7 +65,7 @@ type VmContext struct {
timer *time.Timer
process *os.Process
lock *sync.Mutex //protect update of context
- wg *sync.WaitGroup
+ wg *sync.WaitGroup
}
type stateHandler func(ctx *VmContext, event QemuEvent)
@@ -98,7 +98,7 @@ func initContext(id string, hub chan QemuEvent, client chan *types.QemuResponse,
}
defer func() {
if err != nil {
- os.RemoveAll(homeDir)
+ os.Remove(homeDir)
}
}()
@@ -224,7 +224,7 @@ func (ctx *VmContext) Close() {
close(ctx.qmp)
close(ctx.vm)
close(ctx.wdt)
- os.RemoveAll(ctx.shareDir)
+ os.Remove(ctx.shareDir)
ctx.handler = nil
ctx.current = "None"
}
@@ -298,7 +298,7 @@ func (ctx *VmContext) QemuArguments() []string {
// InitDeviceContext will init device info in context
func (ctx *VmContext) InitDeviceContext(spec *pod.UserPod, wg *sync.WaitGroup,
- cInfo []*ContainerInfo, vInfo []*VolumeInfo) {
+ cInfo []*ContainerInfo, vInfo []*VolumeInfo) {
ctx.lock.Lock()
defer ctx.lock.Unlock()
diff --git a/qemu/drive.go b/qemu/drive.go
index 393622f..cf41baa 100644
--- a/qemu/drive.go
+++ b/qemu/drive.go
@@ -2,6 +2,7 @@ package qemu
import (
"fmt"
+ "os"
"os/exec"
"path"
"strings"
@@ -71,6 +72,9 @@ func UmountVolume(shareDir, volPath string, name string, hub chan QemuEvent) {
success = true
}
}
+ if success == true {
+ os.Remove(mount)
+ }
// After umount that device, we need to delete it
hub <- &VolumeUnmounted{Name: name, Success: success}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment