mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
hypervisor: stopSandbox is StopVM
Renaming. There is no Sandbox specific logic except tracing. Signed-off-by: Manohar Castelino <mcastelino@apple.com>
This commit is contained in:
parent
f989078cd2
commit
a6385c8fde
@ -482,15 +482,15 @@ func (a *Acrn) waitSandbox(ctx context.Context, timeoutSecs int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stopSandbox will stop the Sandbox's VM.
|
// stopSandbox will stop the Sandbox's VM.
|
||||||
func (a *Acrn) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
func (a *Acrn) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||||
span, _ := katatrace.Trace(ctx, a.Logger(), "stopSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
span, _ := katatrace.Trace(ctx, a.Logger(), "StopVM", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
a.Logger().Info("Stopping acrn VM")
|
a.Logger().Info("Stopping acrn VM")
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Logger().Info("stopSandbox failed")
|
a.Logger().Info("StopVM failed")
|
||||||
} else {
|
} else {
|
||||||
a.Logger().Info("acrn VM stopped")
|
a.Logger().Info("acrn VM stopped")
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ func (clh *cloudHypervisor) startSandbox(ctx context.Context, timeout int) error
|
|||||||
if clh.config.SharedFS == config.VirtioFS {
|
if clh.config.SharedFS == config.VirtioFS {
|
||||||
clh.Logger().WithField("function", "startSandbox").Info("Starting virtiofsd")
|
clh.Logger().WithField("function", "startSandbox").Info("Starting virtiofsd")
|
||||||
pid, err := clh.virtiofsd.Start(ctx, func() {
|
pid, err := clh.virtiofsd.Start(ctx, func() {
|
||||||
clh.stopSandbox(ctx, false)
|
clh.StopVM(ctx, false)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -732,10 +732,10 @@ func (clh *cloudHypervisor) ResumeVM(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stopSandbox will stop the Sandbox's VM.
|
// stopSandbox will stop the Sandbox's VM.
|
||||||
func (clh *cloudHypervisor) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
func (clh *cloudHypervisor) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "stopSandbox", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
span, _ := katatrace.Trace(ctx, clh.Logger(), "StopVM", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
clh.Logger().WithField("function", "stopSandbox").Info("Stop Sandbox")
|
clh.Logger().WithField("function", "StopVM").Info("Stop Sandbox")
|
||||||
return clh.terminate(ctx, waitOnly)
|
return clh.terminate(ctx, waitOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,8 +878,8 @@ func (fc *firecracker) cleanupJail(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stopSandbox will stop the Sandbox's VM.
|
// stopSandbox will stop the Sandbox's VM.
|
||||||
func (fc *firecracker) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
func (fc *firecracker) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "stopSandbox", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
span, _ := katatrace.Trace(ctx, fc.Logger(), "StopVM", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
return fc.fcEnd(ctx, waitOnly)
|
return fc.fcEnd(ctx, waitOnly)
|
||||||
|
@ -901,7 +901,7 @@ type hypervisor interface {
|
|||||||
startSandbox(ctx context.Context, timeout int) error
|
startSandbox(ctx context.Context, timeout int) error
|
||||||
// If wait is set, don't actively stop the sandbox:
|
// If wait is set, don't actively stop the sandbox:
|
||||||
// just perform cleanup.
|
// just perform cleanup.
|
||||||
stopSandbox(ctx context.Context, waitOnly bool) error
|
StopVM(ctx context.Context, waitOnly bool) error
|
||||||
PauseVM(ctx context.Context) error
|
PauseVM(ctx context.Context) error
|
||||||
SaveVM() error
|
SaveVM() error
|
||||||
ResumeVM(ctx context.Context) error
|
ResumeVM(ctx context.Context) error
|
||||||
|
@ -917,7 +917,7 @@ func setupStorages(ctx context.Context, sandbox *Sandbox) []*grpc.Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) stopSandbox(ctx context.Context, sandbox *Sandbox) error {
|
func (k *kataAgent) stopSandbox(ctx context.Context, sandbox *Sandbox) error {
|
||||||
span, ctx := katatrace.Trace(ctx, k.Logger(), "stopSandbox", kataAgentTracingTags)
|
span, ctx := katatrace.Trace(ctx, k.Logger(), "StopVM", kataAgentTracingTags)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
req := &grpc.DestroySandboxRequest{}
|
req := &grpc.DestroySandboxRequest{}
|
||||||
|
@ -50,7 +50,7 @@ func (m *mockHypervisor) startSandbox(ctx context.Context, timeout int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockHypervisor) stopSandbox(ctx context.Context, waitOnly bool) error {
|
func (m *mockHypervisor) StopVM(ctx context.Context, waitOnly bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ func TestMockHypervisorStartSandbox(t *testing.T) {
|
|||||||
func TestMockHypervisorStopSandbox(t *testing.T) {
|
func TestMockHypervisorStopSandbox(t *testing.T) {
|
||||||
var m *mockHypervisor
|
var m *mockHypervisor
|
||||||
|
|
||||||
assert.NoError(t, m.stopSandbox(context.Background(), false))
|
assert.NoError(t, m.StopVM(context.Background(), false))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMockHypervisorAddDevice(t *testing.T) {
|
func TestMockHypervisorAddDevice(t *testing.T) {
|
||||||
|
@ -671,7 +671,7 @@ func (q *qemu) vhostFSSocketPath(id string) (string, error) {
|
|||||||
|
|
||||||
func (q *qemu) setupVirtiofsd(ctx context.Context) (err error) {
|
func (q *qemu) setupVirtiofsd(ctx context.Context) (err error) {
|
||||||
pid, err := q.virtiofsd.Start(ctx, func() {
|
pid, err := q.virtiofsd.Start(ctx, func() {
|
||||||
q.stopSandbox(ctx, false)
|
q.StopVM(ctx, false)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -940,8 +940,8 @@ func (q *qemu) waitSandbox(ctx context.Context, timeout int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stopSandbox will stop the Sandbox's VM.
|
// stopSandbox will stop the Sandbox's VM.
|
||||||
func (q *qemu) stopSandbox(ctx context.Context, waitOnly bool) error {
|
func (q *qemu) StopVM(ctx context.Context, waitOnly bool) error {
|
||||||
span, _ := katatrace.Trace(ctx, q.Logger(), "stopSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
span, _ := katatrace.Trace(ctx, q.Logger(), "StopVM", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
q.Logger().Info("Stopping Sandbox")
|
q.Logger().Info("Stopping Sandbox")
|
||||||
|
@ -1181,7 +1181,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.hypervisor.stopSandbox(ctx, false)
|
s.hypervisor.StopVM(ctx, false)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -1264,7 +1264,7 @@ func (s *Sandbox) stopVM(ctx context.Context) error {
|
|||||||
|
|
||||||
s.Logger().Info("Stopping VM")
|
s.Logger().Info("Stopping VM")
|
||||||
|
|
||||||
return s.hypervisor.stopSandbox(ctx, s.disableVMShutdown)
|
return s.hypervisor.StopVM(ctx, s.disableVMShutdown)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sandbox) addContainer(c *Container) error {
|
func (s *Sandbox) addContainer(c *Container) error {
|
||||||
|
@ -137,7 +137,7 @@ func NewVM(ctx context.Context, config VMConfig) (*VM, error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
virtLog.WithField("vm", id).WithError(err).Info("clean up vm")
|
virtLog.WithField("vm", id).WithError(err).Info("clean up vm")
|
||||||
hypervisor.stopSandbox(ctx, false)
|
hypervisor.StopVM(ctx, false)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ func (v *VM) Disconnect(ctx context.Context) error {
|
|||||||
func (v *VM) Stop(ctx context.Context) error {
|
func (v *VM) Stop(ctx context.Context) error {
|
||||||
v.logger().Info("stop vm")
|
v.logger().Info("stop vm")
|
||||||
|
|
||||||
if err := v.hypervisor.stopSandbox(ctx, false); err != nil {
|
if err := v.hypervisor.StopVM(ctx, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user