machine: Re-enable USBs check for wsl machine set

Re-enable USBs check in wsl `SetProviderAttrs` function to prevent the
user trying to set USB settings which isn't supported.

Additionally removes a TODO in wsl's `CreateVM` function to check if the
`opts.USBs` length is greater than 0. This check is done in a more
generic way higher up the stack.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
Jake Correnti
2024-02-13 15:33:00 -05:00
parent 0e9d867555
commit 3de467d9f8

View File

@ -34,12 +34,6 @@ func (w WSLStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConf
defer callbackFuncs.CleanIfErr(&err)
go callbackFuncs.CleanOnSignal()
mc.WSLHypervisor = new(vmconfigs.WSLConfig)
// TODO
// USB opts are unsupported in WSL. Need to account for that here
// or up the stack
// if len(opts.USBs) > 0 {
// return nil, fmt.Errorf("USB host passthrough is not supported for WSL machines")
// }
if cont, err := checkAndInstallWSL(opts.ReExec); !cont {
appendOutputIfError(opts.ReExec, err)
@ -159,10 +153,9 @@ func (w WSLStubber) SetProviderAttrs(mc *vmconfigs.MachineConfig, opts define.Se
return errors.New("changing memory not supported for WSL machines")
}
// TODO USB still needs to be plumbed for all providers
// if USBs != nil {
// setErrors = append(setErrors, errors.New("changing USBs not supported for WSL machines"))
// }
if opts.USBs != nil {
return errors.New("changing USBs not supported for WSL machines")
}
if opts.DiskSize != nil {
return errors.New("changing disk size not supported for WSL machines")