diff --git a/pkg/config/config.go b/pkg/config/config.go index 7afc3b0e..cd10e96f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -143,7 +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) { - vm.Devices = append(vm.Devices, dev) + vm.AddDevices(dev) +} + +// AddDevices adds a list of devices to vm. +func (vm *VirtualMachine) AddDevices(dev ...VirtioDevice) { + vm.Devices = append(vm.Devices, dev...) } func (vm *VirtualMachine) AddTimeSyncFromCmdLine(cmdlineOpts string) error { diff --git a/pkg/config/json_test.go b/pkg/config/json_test.go index 49fd9d54..9a23551c 100644 --- a/pkg/config/json_test.go +++ b/pkg/config/json_test.go @@ -79,14 +79,12 @@ var jsonTests = map[string]jsonTest{ dev = VirtioVsockNew(1234, "/virtiovsock", false) vm.AddDevice(dev) // virtio-fs - dev = VirtioFsNew("/virtiofs", "tag") - vm.AddDevice(dev) + fs := VirtioFsNew("/virtiofs", "tag") // USB mass storage - dev = USBMassStorageNew("/usbmassstorage") - vm.AddDevice(dev) + usb := USBMassStorageNew("/usbmassstorage") // rosetta - dev = RosettaShareNew("vz-rosetta") - vm.AddDevice(dev) + rosetta := RosettaShareNew("vz-rosetta") + vm.AddDevices(fs, usb, rosetta) return vm },