From 2e075383340ff4acca80a63bf66ed549562b6c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 09:21:04 +0200 Subject: [PATCH] clh: Expose VmAddNetPut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VmAddNetPut is the API provided by the Cloud Hypervisor client (auto generated) code to hotplug a new network device to the VM. Let's expose it now as it'll be used as part this series, mostly to guide the reviewer through the process of what we have to do, as later on, spoiler alert, it'll end up being removed. Signed-off-by: Fabiano FidĂȘncio --- src/runtime/virtcontainers/clh.go | 6 ++++++ src/runtime/virtcontainers/clh_test.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index a47c688f4..6a7cf6122 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -99,6 +99,8 @@ type clhClient interface { VmAddDiskPut(ctx context.Context, diskConfig chclient.DiskConfig) (chclient.PciDeviceInfo, *http.Response, error) // Remove a device from the VM VmRemoveDevicePut(ctx context.Context, vmRemoveDevice chclient.VmRemoveDevice) (*http.Response, error) + // Add a new net device to the VM + VmAddNetPut(ctx context.Context, netConfig chclient.NetConfig) (chclient.PciDeviceInfo, *http.Response, error) } type clhClientApi struct { @@ -142,6 +144,10 @@ func (c *clhClientApi) VmRemoveDevicePut(ctx context.Context, vmRemoveDevice chc return c.ApiInternal.VmRemoveDevicePut(ctx).VmRemoveDevice(vmRemoveDevice).Execute() } +func (c *clhClientApi) VmAddNetPut(ctx context.Context, netConfig chclient.NetConfig) (chclient.PciDeviceInfo, *http.Response, error) { + return c.ApiInternal.VmAddNetPut(ctx).NetConfig(netConfig).Execute() +} + // // Cloud hypervisor state // diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index 79e35210b..23c54b342 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -117,6 +117,11 @@ func (c *clhClientMock) VmRemoveDevicePut(ctx context.Context, vmRemoveDevice ch return nil, nil } +//nolint:golint +func (c *clhClientMock) VmAddNetPut(ctx context.Context, netConfig chclient.NetConfig) (chclient.PciDeviceInfo, *http.Response, error) { + return chclient.PciDeviceInfo{}, nil, nil +} + func TestCloudHypervisorAddVSock(t *testing.T) { assert := assert.New(t) clh := cloudHypervisor{}