Skip to content

Commit

Permalink
Merge pull request #89 from BlackHole1/add-AddDevices
Browse files Browse the repository at this point in the history
feat(config): add AddDevices function
  • Loading branch information
openshift-merge-bot[bot] authored Jan 25, 2024
2 parents bf9afb0 + e336529 commit 979f84f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 5 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 4 additions & 8 deletions pkg/config/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 979f84f

Please sign in to comment.