Skip to content

Commit

Permalink
Merge pull request clearcontainers#548 from bergwolf/cleanup
Browse files Browse the repository at this point in the history
qemu: create vm directory before launching qemu
  • Loading branch information
Julio Montes committed Aug 3, 2018
2 parents 244917c + bd50761 commit dec385a
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,6 @@ func (q *qemu) createQmpSocket() ([]govmmQemu.QMPSocket, error) {
path: monitorSockPath,
}

err = os.MkdirAll(filepath.Dir(monitorSockPath), dirMode)
if err != nil {
return nil, err
}

return []govmmQemu.QMPSocket{
{
Type: "unix",
Expand Down Expand Up @@ -416,21 +411,6 @@ func (q *qemu) createSandbox() error {
return fmt.Errorf("UUID should not be empty")
}

monitorSockPath, err := q.qmpSocketPath(q.id)
if err != nil {
return err
}

q.qmpMonitorCh = qmpChannel{
ctx: context.Background(),
path: monitorSockPath,
}

err = os.MkdirAll(filepath.Dir(monitorSockPath), dirMode)
if err != nil {
return err
}

qmpSockets, err := q.createQmpSocket()
if err != nil {
return err
Expand Down Expand Up @@ -504,7 +484,21 @@ func (q *qemu) startSandbox() error {
}
}()

strErr, err := govmmQemu.LaunchQemu(q.qemuConfig, newQMPLogger())
vmPath := filepath.Join(RunVMStoragePath, q.id)
err := os.MkdirAll(vmPath, dirMode)
if err != nil {
return err
}
defer func() {
if err != nil {
if err := os.RemoveAll(vmPath); err != nil {
q.Logger().WithError(err).Error("Fail to clean up vm directory")
}
}
}()

var strErr string
strErr, err = govmmQemu.LaunchQemu(q.qemuConfig, newQMPLogger())
if err != nil {
return fmt.Errorf("%s", strErr)
}
Expand Down

0 comments on commit dec385a

Please sign in to comment.