mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 09:13:29 +00:00
qemu: fix qemu leak when failed to start container
do cleanup inside startVM() if start vm get error Fixes: #1426 Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
c89eb81dec
commit
096fa046f8
@ -108,7 +108,7 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
|
||||
}
|
||||
}()
|
||||
|
||||
if err := s.getAndStoreGuestDetails(); err != nil {
|
||||
if err = s.getAndStoreGuestDetails(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -908,7 +908,7 @@ func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error) {
|
||||
}
|
||||
|
||||
// startVM starts the VM.
|
||||
func (s *Sandbox) startVM() error {
|
||||
func (s *Sandbox) startVM() (err error) {
|
||||
span, ctx := s.trace("startVM")
|
||||
defer span.Finish()
|
||||
|
||||
@ -939,6 +939,12 @@ func (s *Sandbox) startVM() error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
s.hypervisor.stopSandbox()
|
||||
}
|
||||
}()
|
||||
|
||||
// In case of vm factory, network interfaces are hotplugged
|
||||
// after vm is started.
|
||||
if s.factory != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user