Handle of multiple identical devices
Hi @victortoso , This issue is similar to #29 (closed), but since error is slightly different, I'm opening a new issue. When trying to redirect 2 identical devices, 1st device is always redirected correctly
ubuntu@r1s01-r32:~$ sudo -E /var/lib/rancher/rke2/bin/kubectl virt usbredir 0bda:0811 -n kubevirt testvmlinux
{"component":"","level":"info","msg":"port_arg: 'localhost:39841'","pos":"usbredir.go:158","timestamp":"2023-07-13T13:00:23.242569Z"}
{"component":"","level":"info","msg":"args: '[--device 0bda:0811 --to localhost:39841]'","pos":"usbredir.go:159","timestamp":"2023-07-13T13:00:23.242745Z"}
{"component":"","level":"info","msg":"Executing commandline: 'usbredirect [--device 0bda:0811 --to localhost:39841]'","pos":"usbredir.go:160","timestamp":"2023-07-13T13:00:23.242787Z"}
{"component":"","level":"info","msg":"Connected to usbredirect at 288.020011ms","pos":"usbredir.go:127","timestamp":"2023-07-13T13:00:23.530477Z"}
However 1st call for 2nd device ALWAYS returns error
ubuntu@r1s01-r32:~$ sudo -E /var/lib/rancher/rke2/bin/kubectl virt usbredir 0bda:0811 -n kubevirt testvmlinux
{"component":"","level":"info","msg":"port_arg: 'localhost:33795'","pos":"usbredir.go:158","timestamp":"2023-07-13T13:00:29.089192Z"}
{"component":"","level":"info","msg":"args: '[--device 0bda:0811 --to localhost:33795]'","pos":"usbredir.go:159","timestamp":"2023-07-13T13:00:29.089355Z"}
{"component":"","level":"info","msg":"Executing commandline: 'usbredirect [--device 0bda:0811 --to localhost:33795]'","pos":"usbredir.go:160","timestamp":"2023-07-13T13:00:29.089403Z"}
{"component":"","level":"error","msg":"Failed to execut usbredirect due signal: aborted (core dumped), output: \n(usbredirect:240163): usbredirect-WARNING **: 13:00:29.375: Error starting usbredirhost\nusbredirect: ../../libusb/os/threads_posix.h:58: usbi_mutex_destroy: Assertion `pthread_mutex_destroy(mutex) == 0' failed.\n","pos":"usbredir.go:165","timestamp":"2023-07-13T13:00:29.530939Z"}
Error encountered: signal: aborted (core dumped)
After which 2nd and all following calls are working as intended
ubuntu@r1s01-r32:~$ sudo -E /var/lib/rancher/rke2/bin/kubectl virt usbredir 0bda:0811 -n kubevirt testvmlinux
{"component":"","level":"info","msg":"port_arg: 'localhost:38351'","pos":"usbredir.go:158","timestamp":"2023-07-13T13:01:52.900029Z"}
{"component":"","level":"info","msg":"args: '[--device 0bda:0811 --to localhost:38351]'","pos":"usbredir.go:159","timestamp":"2023-07-13T13:01:52.900222Z"}
{"component":"","level":"info","msg":"Executing commandline: 'usbredirect [--device 0bda:0811 --to localhost:38351]'","pos":"usbredir.go:160","timestamp":"2023-07-13T13:01:52.900273Z"}
{"component":"","level":"info","msg":"Connected to usbredirect at 285.146502ms","pos":"usbredir.go:127","timestamp":"2023-07-13T13:01:53.185087Z"}
Environment: Ubuntu 22.04, kubevirt 1.0.0, virtctl 1.0.0, usbredirect 0.11.0-2build1