hypervisor: The SandboxConsole is the VM's console

update naming

Signed-off-by: Manohar Castelino <mcastelino@apple.com>
This commit is contained in:
Manohar Castelino 2021-09-20 16:02:13 -07:00 committed by Eric Ernst
parent 4d47aeef2e
commit 8f78e1cc19
10 changed files with 17 additions and 15 deletions

View File

@ -248,7 +248,7 @@ func (a *Acrn) buildDevices(ctx context.Context, imagePath string) ([]Device, er
return nil, fmt.Errorf("Image Path should not be empty: %s", imagePath) return nil, fmt.Errorf("Image Path should not be empty: %s", imagePath)
} }
_, console, err := a.GetSandboxConsole(ctx, a.id) _, console, err := a.GetVMConsole(ctx, a.id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -630,8 +630,8 @@ func (a *Acrn) AddDevice(ctx context.Context, devInfo interface{}, devType Devic
// getSandboxConsole builds the path of the console where we can read // getSandboxConsole builds the path of the console where we can read
// logs coming from the sandbox. // logs coming from the sandbox.
func (a *Acrn) GetSandboxConsole(ctx context.Context, id string) (string, string, error) { func (a *Acrn) GetVMConsole(ctx context.Context, id string) (string, string, error) {
span, _ := katatrace.Trace(ctx, a.Logger(), "GetSandboxConsole", acrnTracingTags, map[string]string{"sandbox_id": a.id}) span, _ := katatrace.Trace(ctx, a.Logger(), "GetVMConsole", acrnTracingTags, map[string]string{"sandbox_id": a.id})
defer span.End() defer span.End()
consoleURL, err := utils.BuildSocketPath(a.store.RunVMStoragePath(), id, acrnConsoleSocket) consoleURL, err := utils.BuildSocketPath(a.store.RunVMStoragePath(), id, acrnConsoleSocket)

View File

@ -205,7 +205,7 @@ func TestAcrnGetSandboxConsole(t *testing.T) {
sandboxID := "testSandboxID" sandboxID := "testSandboxID"
expected := filepath.Join(a.store.RunVMStoragePath(), sandboxID, consoleSocket) expected := filepath.Join(a.store.RunVMStoragePath(), sandboxID, consoleSocket)
proto, result, err := a.GetSandboxConsole(a.ctx, sandboxID) proto, result, err := a.GetVMConsole(a.ctx, sandboxID)
assert.NoError(err) assert.NoError(err)
assert.Equal(result, expected) assert.Equal(result, expected)
assert.Equal(proto, consoleProtoUnix) assert.Equal(proto, consoleProtoUnix)

View File

@ -425,8 +425,8 @@ func (clh *cloudHypervisor) startSandbox(ctx context.Context, timeout int) error
// getSandboxConsole builds the path of the console where we can read // getSandboxConsole builds the path of the console where we can read
// logs coming from the sandbox. // logs coming from the sandbox.
func (clh *cloudHypervisor) GetSandboxConsole(ctx context.Context, id string) (string, string, error) { func (clh *cloudHypervisor) GetVMConsole(ctx context.Context, id string) (string, string, error) {
clh.Logger().WithField("function", "GetSandboxConsole").WithField("id", id).Info("Get Sandbox Console") clh.Logger().WithField("function", "GetVMConsole").WithField("id", id).Info("Get Sandbox Console")
master, slave, err := console.NewPty() master, slave, err := console.NewPty()
if err != nil { if err != nil {
clh.Logger().WithError(err).Error("Error create pseudo tty") clh.Logger().WithError(err).Error("Error create pseudo tty")

View File

@ -1126,7 +1126,7 @@ func (fc *firecracker) HotplugRemoveDevice(ctx context.Context, devInfo interfac
// getSandboxConsole builds the path of the console where we can read // getSandboxConsole builds the path of the console where we can read
// logs coming from the sandbox. // logs coming from the sandbox.
func (fc *firecracker) GetSandboxConsole(ctx context.Context, id string) (string, string, error) { func (fc *firecracker) GetVMConsole(ctx context.Context, id string) (string, string, error) {
master, slave, err := console.NewPty() master, slave, err := console.NewPty()
if err != nil { if err != nil {
fc.Logger().Debugf("Error create pseudo tty: %v", err) fc.Logger().Debugf("Error create pseudo tty: %v", err)

View File

@ -910,7 +910,7 @@ type hypervisor interface {
HotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType DeviceType) (interface{}, error) HotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType DeviceType) (interface{}, error)
ResizeMemory(ctx context.Context, memMB uint32, memoryBlockSizeMB uint32, probe bool) (uint32, MemoryDevice, error) ResizeMemory(ctx context.Context, memMB uint32, memoryBlockSizeMB uint32, probe bool) (uint32, MemoryDevice, error)
ResizeVCPUs(ctx context.Context, vcpus uint32) (uint32, uint32, error) ResizeVCPUs(ctx context.Context, vcpus uint32) (uint32, uint32, error)
GetSandboxConsole(ctx context.Context, sandboxID string) (string, string, error) GetVMConsole(ctx context.Context, sandboxID string) (string, string, error)
Disconnect(ctx context.Context) Disconnect(ctx context.Context)
Capabilities(ctx context.Context) types.Capabilities Capabilities(ctx context.Context) types.Capabilities
HypervisorConfig() HypervisorConfig HypervisorConfig() HypervisorConfig

View File

@ -91,7 +91,7 @@ func (m *mockHypervisor) HotplugRemoveDevice(ctx context.Context, devInfo interf
return nil, nil return nil, nil
} }
func (m *mockHypervisor) GetSandboxConsole(ctx context.Context, sandboxID string) (string, string, error) { func (m *mockHypervisor) GetVMConsole(ctx context.Context, sandboxID string) (string, string, error) {
return "", "", nil return "", "", nil
} }

View File

@ -67,7 +67,7 @@ func TestMockHypervisorGetSandboxConsole(t *testing.T) {
expected := "" expected := ""
expectedProto := "" expectedProto := ""
proto, result, err := m.GetSandboxConsole(context.Background(), "testSandboxID") proto, result, err := m.GetVMConsole(context.Background(), "testSandboxID")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, result, expected) assert.Equal(t, result, expected)
assert.Equal(t, proto, expectedProto) assert.Equal(t, proto, expectedProto)

View File

@ -388,7 +388,7 @@ func (q *qemu) createQmpSocket() ([]govmmQemu.QMPSocket, error) {
func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu.Device, *govmmQemu.IOThread, error) { func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
var devices []govmmQemu.Device var devices []govmmQemu.Device
_, console, err := q.GetSandboxConsole(ctx, q.id) _, console, err := q.GetVMConsole(ctx, q.id)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -484,6 +484,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
span, ctx := katatrace.Trace(ctx, q.Logger(), "createSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id}) span, ctx := katatrace.Trace(ctx, q.Logger(), "createSandbox", qemuTracingTags, map[string]string{"sandbox_id": q.id})
defer span.End() defer span.End()
// Has Kata Specific logic: See within
if err := q.setup(ctx, id, hypervisorConfig); err != nil { if err := q.setup(ctx, id, hypervisorConfig); err != nil {
return err return err
} }
@ -513,6 +514,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
IOMMUPlatform: q.config.IOMMUPlatform, IOMMUPlatform: q.config.IOMMUPlatform,
} }
// MRC: Kata specific
kernelPath, err := q.config.KernelAssetPath() kernelPath, err := q.config.KernelAssetPath()
if err != nil { if err != nil {
return err return err
@ -2024,8 +2026,8 @@ func (q *qemu) AddDevice(ctx context.Context, devInfo interface{}, devType Devic
// getSandboxConsole builds the path of the console where we can read // getSandboxConsole builds the path of the console where we can read
// logs coming from the sandbox. // logs coming from the sandbox.
func (q *qemu) GetSandboxConsole(ctx context.Context, id string) (string, string, error) { func (q *qemu) GetVMConsole(ctx context.Context, id string) (string, string, error) {
span, _ := katatrace.Trace(ctx, q.Logger(), "GetSandboxConsole", qemuTracingTags, map[string]string{"sandbox_id": q.id}) span, _ := katatrace.Trace(ctx, q.Logger(), "GetVMConsole", qemuTracingTags, map[string]string{"sandbox_id": q.id})
defer span.End() defer span.End()
consoleURL, err := utils.BuildSocketPath(q.store.RunVMStoragePath(), id, consoleSocket) consoleURL, err := utils.BuildSocketPath(q.store.RunVMStoragePath(), id, consoleSocket)

View File

@ -332,7 +332,7 @@ func TestQemuGetSandboxConsole(t *testing.T) {
sandboxID := "testSandboxID" sandboxID := "testSandboxID"
expected := filepath.Join(q.store.RunVMStoragePath(), sandboxID, consoleSocket) expected := filepath.Join(q.store.RunVMStoragePath(), sandboxID, consoleSocket)
proto, result, err := q.GetSandboxConsole(q.ctx, sandboxID) proto, result, err := q.GetVMConsole(q.ctx, sandboxID)
assert.NoError(err) assert.NoError(err)
assert.Equal(result, expected) assert.Equal(result, expected)
assert.Equal(proto, consoleProtoUnix) assert.Equal(proto, consoleProtoUnix)

View File

@ -979,7 +979,7 @@ func newConsoleWatcher(ctx context.Context, s *Sandbox) (*consoleWatcher, error)
cw consoleWatcher cw consoleWatcher
) )
cw.proto, cw.consoleURL, err = s.hypervisor.GetSandboxConsole(ctx, s.id) cw.proto, cw.consoleURL, err = s.hypervisor.GetVMConsole(ctx, s.id)
if err != nil { if err != nil {
return nil, err return nil, err
} }