mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +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.
|
||||
func (a *Acrn) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "stopSandbox", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
func (a *Acrn) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, a.Logger(), "StopVM", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||
defer span.End()
|
||||
|
||||
a.Logger().Info("Stopping acrn VM")
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
a.Logger().Info("stopSandbox failed")
|
||||
a.Logger().Info("StopVM failed")
|
||||
} else {
|
||||
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 {
|
||||
clh.Logger().WithField("function", "startSandbox").Info("Starting virtiofsd")
|
||||
pid, err := clh.virtiofsd.Start(ctx, func() {
|
||||
clh.stopSandbox(ctx, false)
|
||||
clh.StopVM(ctx, false)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -732,10 +732,10 @@ func (clh *cloudHypervisor) ResumeVM(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (clh *cloudHypervisor) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "stopSandbox", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
func (clh *cloudHypervisor) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, clh.Logger(), "StopVM", clhTracingTags, map[string]string{"sandbox_id": clh.id})
|
||||
defer span.End()
|
||||
clh.Logger().WithField("function", "stopSandbox").Info("Stop Sandbox")
|
||||
clh.Logger().WithField("function", "StopVM").Info("Stop Sandbox")
|
||||
return clh.terminate(ctx, waitOnly)
|
||||
}
|
||||
|
||||
|
@ -878,8 +878,8 @@ func (fc *firecracker) cleanupJail(ctx context.Context) {
|
||||
}
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (fc *firecracker) stopSandbox(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "stopSandbox", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
func (fc *firecracker) StopVM(ctx context.Context, waitOnly bool) (err error) {
|
||||
span, _ := katatrace.Trace(ctx, fc.Logger(), "StopVM", fcTracingTags, map[string]string{"sandbox_id": fc.id})
|
||||
defer span.End()
|
||||
|
||||
return fc.fcEnd(ctx, waitOnly)
|
||||
|
@ -901,7 +901,7 @@ type hypervisor interface {
|
||||
startSandbox(ctx context.Context, timeout int) error
|
||||
// If wait is set, don't actively stop the sandbox:
|
||||
// just perform cleanup.
|
||||
stopSandbox(ctx context.Context, waitOnly bool) error
|
||||
StopVM(ctx context.Context, waitOnly bool) error
|
||||
PauseVM(ctx context.Context) error
|
||||
SaveVM() 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 {
|
||||
span, ctx := katatrace.Trace(ctx, k.Logger(), "stopSandbox", kataAgentTracingTags)
|
||||
span, ctx := katatrace.Trace(ctx, k.Logger(), "StopVM", kataAgentTracingTags)
|
||||
defer span.End()
|
||||
|
||||
req := &grpc.DestroySandboxRequest{}
|
||||
|
@ -50,7 +50,7 @@ func (m *mockHypervisor) startSandbox(ctx context.Context, timeout int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockHypervisor) stopSandbox(ctx context.Context, waitOnly bool) error {
|
||||
func (m *mockHypervisor) StopVM(ctx context.Context, waitOnly bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ func TestMockHypervisorStartSandbox(t *testing.T) {
|
||||
func TestMockHypervisorStopSandbox(t *testing.T) {
|
||||
var m *mockHypervisor
|
||||
|
||||
assert.NoError(t, m.stopSandbox(context.Background(), false))
|
||||
assert.NoError(t, m.StopVM(context.Background(), false))
|
||||
}
|
||||
|
||||
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) {
|
||||
pid, err := q.virtiofsd.Start(ctx, func() {
|
||||
q.stopSandbox(ctx, false)
|
||||
q.StopVM(ctx, false)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -940,8 +940,8 @@ func (q *qemu) waitSandbox(ctx context.Context, timeout int) error {
|
||||
}
|
||||
|
||||
// stopSandbox will stop the Sandbox's VM.
|
||||
func (q *qemu) stopSandbox(ctx context.Context, waitOnly bool) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "stopSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
func (q *qemu) StopVM(ctx context.Context, waitOnly bool) error {
|
||||
span, _ := katatrace.Trace(ctx, q.Logger(), "StopVM", qemuTracingTags, map[string]string{"sandbox_id": q.id})
|
||||
defer span.End()
|
||||
|
||||
q.Logger().Info("Stopping Sandbox")
|
||||
|
@ -1181,7 +1181,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
|
||||
|
||||
defer func() {
|
||||
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")
|
||||
|
||||
return s.hypervisor.stopSandbox(ctx, s.disableVMShutdown)
|
||||
return s.hypervisor.StopVM(ctx, s.disableVMShutdown)
|
||||
}
|
||||
|
||||
func (s *Sandbox) addContainer(c *Container) error {
|
||||
|
@ -137,7 +137,7 @@ func NewVM(ctx context.Context, config VMConfig) (*VM, error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user