Skip to content

Commit 5e56d92

Browse files
committed
fix comments and tests
Signed-off-by: Jerome Gravel-Niquet <[email protected]>
1 parent 1a2312a commit 5e56d92

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

firecracker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,16 @@ func (f *Client) PutGuestDriveByID(ctx context.Context, driveID string, drive *m
183183
return f.client.Operations.PutGuestDriveByID(params)
184184
}
185185

186-
// PutGuestVsockOpt is a functional option to be used for the
186+
// PutGuestVsockByIDOpt is a functional option to be used for the
187187
// PutGuestVsockByID API in setting any additional optional fields.
188188
type PutGuestVsockByIDOpt func(*ops.PutGuestVsockByIDParams)
189189

190-
// PutGuestVsock is a wrapper for the swagger generated client to make
190+
// PutGuestVsockByID is a wrapper for the swagger generated client to make
191191
// calling of the API easier.
192192
func (f *Client) PutGuestVsockByID(ctx context.Context, vsock *models.Vsock, opts ...PutGuestVsockByIDOpt) (*ops.PutGuestVsockByIDNoContent, error) {
193193
params := ops.NewPutGuestVsockByIDParams()
194194
params.SetContext(ctx)
195-
params.SetID(*vsock.VsockID)
195+
params.ID = *vsock.VsockID
196196
params.SetBody(vsock)
197197
for _, opt := range opts {
198198
opt(params)

handlers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,9 @@ func TestHandlers(t *testing.T) {
592592
{
593593
Handler: AddVsocksHandler,
594594
Client: fctesting.MockClient{
595-
PutGuestVsockByIDFn: func(params *ops.PutGuestVsockByIDParams) (*ops.PutGuestVsockByIDCreated, *ops.PutGuestVsockByIDNoContent, error) {
595+
PutGuestVsockByIDFn: func(params *ops.PutGuestVsockByIDParams) (*ops.PutGuestVsockByIDNoContent, error) {
596596
called = AddVsocksHandler.Name
597-
return &ops.PutGuestVsockByIDCreated{}, &ops.PutGuestVsockByIDNoContent{}, nil
597+
return &ops.PutGuestVsockByIDNoContent{}, nil
598598
},
599599
},
600600
Config: Config{

machine.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ type RateLimiterSet struct {
222222
// VsockDevice represents a vsock connection between the host and the guest
223223
// microVM.
224224
type VsockDevice struct {
225+
// ID defines the vsock's device ID for firecracker.
226+
ID string
225227
// Path defines the filesystem path of the vsock device on the host.
226228
Path string
227229
// CID defines the 32-bit Context Identifier for the vsock device. See
@@ -398,8 +400,8 @@ func (m *Machine) createNetworkInterfaces(ctx context.Context, ifaces ...Network
398400
}
399401

400402
func (m *Machine) addVsocks(ctx context.Context, vsocks ...VsockDevice) error {
401-
for i, dev := range m.Cfg.VsockDevices {
402-
if err := m.addVsock(ctx, fmt.Sprintf("%d", i), dev); err != nil {
403+
for _, dev := range m.Cfg.VsockDevices {
404+
if err := m.addVsock(ctx, dev); err != nil {
403405
return err
404406
}
405407
}
@@ -729,11 +731,11 @@ func (m *Machine) attachDrive(ctx context.Context, dev models.Drive) error {
729731
}
730732

731733
// addVsock adds a vsock to the instance
732-
func (m *Machine) addVsock(ctx context.Context, id string, dev VsockDevice) error {
734+
func (m *Machine) addVsock(ctx context.Context, dev VsockDevice) error {
733735
vsockCfg := models.Vsock{
734736
GuestCid: Int64(int64(dev.CID)),
735737
UdsPath: &dev.Path,
736-
VsockID: &id,
738+
VsockID: &dev.ID,
737739
}
738740

739741
resp, err := m.client.PutGuestVsockByID(ctx, &vsockCfg)

machine_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ func testAttachSecondaryDrive(ctx context.Context, t *testing.T, m *Machine) {
562562

563563
func testAttachVsock(ctx context.Context, t *testing.T, m *Machine) {
564564
dev := VsockDevice{
565+
ID: "1",
565566
CID: 3,
566567
Path: "foo",
567568
}

0 commit comments

Comments
 (0)