Merge pull request #3824 from fidencio/stable-2.3-clh-stop-virtiofsd-if-clh-fails-to-boot-up-the-vm

stable-2.3 | clh: stop virtofsd if clh fails to boot up the vm
This commit is contained in:
Fabiano Fidêncio
2022-03-03 23:25:45 +01:00
committed by GitHub

View File

@@ -405,15 +405,20 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
return err
}
clh.state.VirtiofsdPID = pid
defer func() {
if err != nil {
if shutdownErr := clh.virtiofsd.Stop(ctx); shutdownErr != nil {
clh.Logger().WithError(shutdownErr).Warn("error shutting down VirtiofsDaemon")
}
}
}()
} else {
return errors.New("cloud-hypervisor only supports virtio based file sharing")
}
pid, err := clh.launchClh()
if err != nil {
if shutdownErr := clh.virtiofsd.Stop(ctx); shutdownErr != nil {
clh.Logger().WithError(shutdownErr).Warn("error shutting down Virtiofsd")
}
return fmt.Errorf("failed to launch cloud-hypervisor: %q", err)
}
clh.state.PID = pid