Skip to content

Commit b102a23

Browse files
authored
Merge pull request #433 from olibearo/populate-createvm-response
Populate response for CreateVM in Runtime shim
2 parents 31fa27b + 505cdc7 commit b102a23

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

runtime/service.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ func (s *service) StartShim(shimCtx context.Context, containerID, containerdBina
336336
if err != nil {
337337
return "", errors.Wrap(err, "failed to generate UUID for VMID")
338338
}
339-
340339
s.vmID = uuid.String()
341340

342341
// This request is handled by a short-lived shim process to find its control socket.
@@ -457,7 +456,6 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe
457456
err = s.createVM(ctxWithTimeout, request)
458457
createRan = true
459458
})
460-
461459
if !createRan {
462460
return nil, status.Error(codes.AlreadyExists, "shim cannot create VM more than once")
463461
}
@@ -485,9 +483,14 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe
485483
// let all the other methods know that the VM is ready for tasks
486484
close(s.vmReady)
487485

486+
resp.VMID = s.vmID
487+
resp.MetricsFifoPath = s.machineConfig.MetricsFifo
488+
resp.LogFifoPath = s.machineConfig.LogFifo
489+
resp.SocketPath = s.shimDir.FirecrackerSockPath()
488490
if c, ok := s.jailer.(cgroupPather); ok {
489491
resp.CgroupPath = c.CgroupPath()
490492
}
493+
491494
return &resp, nil
492495
}
493496

runtime/service_integ_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,14 +1849,16 @@ func TestCreateVM_Isolated(t *testing.T) {
18491849
t.Run(subtest.name, func(t *testing.T) {
18501850
request.VMID = testNameToVMID(t.Name())
18511851

1852-
_, err = fcClient.CreateVM(ctx, &request)
1852+
resp, err := fcClient.CreateVM(ctx, &request)
18531853
validate(t, err)
1854-
18551854
if err != nil {
18561855
// No VM to stop.
18571856
return
18581857
}
18591858

1859+
// Ensure the response fields are populated correctly
1860+
assert.Equal(t, request.VMID, resp.VMID)
1861+
18601862
_, err = fcClient.StopVM(ctx, &proto.StopVMRequest{VMID: request.VMID})
18611863
require.Equal(t, status.Code(err), codes.OK)
18621864
})

0 commit comments

Comments
 (0)