Skip to content

Commit 31baf03

Browse files
feat: add usbredir
Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
1 parent 83e1079 commit 31baf03

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,7 @@ func (b *KVVM) SetMetadata(metadata metav1.ObjectMeta) {
650650
func (b *KVVM) SetUpdateVolumesStrategy(strategy *virtv1.UpdateVolumesStrategy) {
651651
b.Resource.Spec.UpdateVolumesStrategy = strategy
652652
}
653+
654+
func (b *KVVM) SetClientPassthroughDevices() {
655+
b.Resource.Spec.Template.Spec.Domain.Devices.ClientPassthrough = &virtv1.ClientPassthroughDevices{}
656+
}

images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func ApplyVirtualMachineSpec(
111111
return err
112112
}
113113

114+
kvvm.SetClientPassthroughDevices()
114115
kvvm.SetMetadata(vm.ObjectMeta)
115116
setNetwork(kvvm, networkSpec)
116117
kvvm.SetTablet("default-0")

src/cli/internal/cmd/usbredir/usbredir.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func NewCommand() *cobra.Command {
4242
cmd.SetUsageTemplate(templates.UsageTemplate())
4343
usbRedir.AddFlags(cmd.Flags())
4444

45+
_ = cmd.MarkFlagRequired("device")
46+
_ = cmd.MarkFlagRequired("bus")
47+
4548
return cmd
4649
}
4750

@@ -51,8 +54,8 @@ type USBRedir struct {
5154
}
5255

5356
func (c *USBRedir) AddFlags(fs *pflag.FlagSet) {
54-
fs.StringVarP(&c.device, "device", "d", "", "The device you want to redirect.")
55-
fs.StringVarP(&c.bus, "bus", "b", "", "The bus of the device you want to redirect.")
57+
fs.StringVarP(&c.device, "device", "d", "", "(required) The device you want to redirect.")
58+
fs.StringVarP(&c.bus, "bus", "b", "", "(required) The bus of the device you want to redirect.")
5659
}
5760

5861
func (c *USBRedir) Validate() error {

0 commit comments

Comments
 (0)