Skip to content

Commit 49c7338

Browse files
committed
Add dev.Validate() back to FromOptions
1 parent c14438c commit 49c7338

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

cmd/vfkit/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ func newVMConfiguration(opts *cmdline.Options) (*config.VirtualMachine, error) {
104104
return nil, err
105105
}
106106

107-
if err := vmConfig.ValidateDevices(); err != nil {
108-
return nil, err
109-
}
110-
111107
if err := vmConfig.AddIgnitionFileFromCmdLine(opts.IgnitionPath); err != nil {
112108
return nil, fmt.Errorf("failed to add ignition file: %w", err)
113109
}

pkg/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestVirtualMachine_ValidateBlockDevices(t *testing.T) {
6464
vm.Devices = append(vm.Devices, dev)
6565
defer os.Remove(imagePath)
6666

67-
err = vm.ValidateDevices()
67+
err = dev.Validate()
6868
require.Error(t, err)
6969
require.ErrorContains(t, err, "vfkit does not support qcow2 image format")
7070
}

pkg/config/virtio.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (dev *VirtioSerial) FromOptions(options []option) error {
303303
}
304304
}
305305

306-
return nil
306+
return dev.Validate()
307307
}
308308

309309
// VirtioInputNew creates a new input device for the virtual machine.
@@ -348,7 +348,7 @@ func (dev *VirtioInput) FromOptions(options []option) error {
348348
return fmt.Errorf("unknown option for virtio-input devices: %s", option.key)
349349
}
350350
}
351-
return nil
351+
return dev.Validate()
352352
}
353353

354354
// VirtioGPUNew creates a new gpu device for the virtual machine.
@@ -407,7 +407,7 @@ func (dev *VirtioGPU) FromOptions(options []option) error {
407407
dev.Height = defaultVirtioGPUResolutionHeight
408408
}
409409

410-
return nil
410+
return dev.Validate()
411411
}
412412

413413
// VirtioNetNew creates a new network device for the virtual machine. It will
@@ -510,7 +510,7 @@ func (dev *VirtioNet) FromOptions(options []option) error {
510510
}
511511
}
512512

513-
return nil
513+
return dev.Validate()
514514
}
515515

516516
// VirtioRngNew creates a new random number generator device to feed entropy
@@ -588,7 +588,10 @@ func (dev *VirtioBlk) FromOptions(options []option) error {
588588
}
589589
}
590590

591-
return dev.DiskStorageConfig.FromOptions(unhandledOpts)
591+
if err := dev.DiskStorageConfig.FromOptions(unhandledOpts); err != nil {
592+
return err
593+
}
594+
return dev.Validate()
592595
}
593596

594597
func (dev *VirtioBlk) ToCmdLine() ([]string, error) {

0 commit comments

Comments
 (0)