diff --git a/pkg/config/config.go b/pkg/config/config.go index efd83f20..2f84efbe 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -143,8 +143,12 @@ func (vm *VirtualMachine) VirtioVsockDevices() []*VirtioVsock { // AddDevice adds a dev to vm. This device can be created with one of the // VirtioXXXNew methods. func (vm *VirtualMachine) AddDevice(dev VirtioDevice) error { - vm.Devices = append(vm.Devices, dev) + return vm.AddDevices(dev) +} +// AddDevices adds a list of devices to vm. +func (vm *VirtualMachine) AddDevices(dev ...VirtioDevice) error { + vm.Devices = append(vm.Devices, dev...) return nil } diff --git a/pkg/config/json_test.go b/pkg/config/json_test.go index 64ac0864..9345ebb1 100644 --- a/pkg/config/json_test.go +++ b/pkg/config/json_test.go @@ -97,19 +97,15 @@ var jsonTests = map[string]jsonTest{ err = vm.AddDevice(dev) require.NoError(t, err) // virtio-fs - dev, err = VirtioFsNew("/virtiofs", "tag") - require.NoError(t, err) - err = vm.AddDevice(dev) + fs, err := VirtioFsNew("/virtiofs", "tag") require.NoError(t, err) // USB mass storage - dev, err = USBMassStorageNew("/usbmassstorage") - require.NoError(t, err) - err = vm.AddDevice(dev) + usb, err := USBMassStorageNew("/usbmassstorage") require.NoError(t, err) // rosetta - dev, err = RosettaShareNew("vz-rosetta") + rosetta, err := RosettaShareNew("vz-rosetta") require.NoError(t, err) - err = vm.AddDevice(dev) + err = vm.AddDevices(fs, usb, rosetta) require.NoError(t, err) return vm