<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Thank you Peter and sorry for the delay !<br>
    <p>You put me in the correct direction and the problem is now
      resolved :)</p>
    I wrongly assumed that attaching the device to the guest in "preboot
    mode" should be only made in the "serial" way because I supposed
    that we can not attach the device as a "hostdev" before the host
    really detect the device as a USB device listed by "lsusb" which can
    take a moment.<br>
    <br>
    But simply attach with "hostdev" with the idVendor/idProduct given
    in "preboot mode" did the trick :<br>
    <br>
        echo    "<hostdev mode='subsystem' type='usb'
    managed='yes'> \<br>
                    <source> \<br>
                        <vendor id='0x091e'/> \<br>
                        <product id='0x0003'/> \<br>
                    </source> \<br>
                </hostdev>" > serial_device.xml<br>
    <p>From the host (here Debian 11) when I plug the GPS, I see this :</p>
    <p>root@host:~# journalctl -kf<br>
      ...<br>
      févr. 04 13:11:46 host kernel: usb 2-11: new high-speed USB device
      number 34 using xhci_hcd<br>
      févr. 04 13:11:46 host kernel: usb 2-11: New USB device found,
      idVendor=091e, idProduct=0003, bcdDevice= 0.01<br>
      févr. 04 13:11:46 host kernel: usb 2-11: New USB device strings:
      Mfr=0, Product=0, SerialNumber=0<br>
      févr. 04 13:11:46 host kernel: garmin_gps 2-11:1.0: Garmin GPS
      usb/tty converter detected<br>
      févr. 04 13:11:46 host kernel: usb 2-11: Garmin GPS usb/tty
      converter now attached to ttyUSB0<br>
      févr. 04 13:11:54 host kernel: usb 2-11: USB disconnect, device
      number 34<br>
      févr. 04 13:11:54 host kernel: garmin_gps ttyUSB0: Garmin GPS
      usb/tty converter now disconnected from ttyUSB0<br>
      févr. 04 13:11:54 host kernel: garmin_gps 2-11:1.0: device
      disconnected<br>
      ...<br>
      <br>
      From a guest (here Debian 11 too) when the script attach the GPS,
      I see this :<br>
      <br>
      root@guest:~# journalctl -kf<br>
      ...<br>
      févr. 04 13:25:58 guest kernel: usb 2-6: new high-speed USB device
      number 8 using ehci-pci<br>
      févr. 04 13:25:58 guest kernel: usb 2-6: New USB device found,
      idVendor=091e, idProduct=0003, bcdDevice= 0.01<br>
      févr. 04 13:25:58 guest kernel: usb 2-6: New USB device strings:
      Mfr=0, Product=0, SerialNumber=0<br>
      févr. 04 13:25:58 guest kernel: garmin_gps 2-6:1.0: Garmin GPS
      usb/tty converter detected<br>
      févr. 04 13:25:58 guest kernel: usb 2-6: Garmin GPS usb/tty
      converter now attached to ttyUSB0<br>
      févr. 04 13:26:03 guest kernel: usb 2-6: USB disconnect, device
      number 8<br>
      févr. 04 13:26:03 guest kernel: garmin_gps ttyUSB0: Garmin GPS
      usb/tty converter now disconnected from ttyUSB0<br>
      févr. 04 13:26:03 guest kernel: garmin_gps 2-6:1.0: device
      disconnected<br>
      ...<br>
    </p>
    <p>So the device is correctly transferred, and it is confirmed as
      the "preboot tools" detect the device in a "Windows 7"<b> </b>guest</p>
    I want to add that, as far as I know we can not use the
    "virt-manager" GUI to do the same, for two reasons :<br>
    - the USB host device window do not refresh itself when the items
    are added or removed<br>
    - the delay to attach this device is pretty short (5 to 8 seconds)
    and just after, from the guest we must trigger the tools which can
    manage the device in "preboot mode" (typically a flash tool)<br>
    <br>
    <p>That is why the solution I found, is to automate this with a
      script which detects the kernel events and automatically attach
      the devices.</p>
    <p><br>
    </p>
    <p>The host versions :<br>
      root@host:~# cat /etc/os-release | grep -E "^(NAME|VERSION)=" | tr
      '\n' ' ' ; uname -a ; kvm --version | grep version ; libvirtd
      --version ; virt-manager --version<br>
      NAME="Debian GNU/Linux" VERSION="11 (bullseye)"<br>
      Linux host 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03)
      x86_64 GNU/Linux<br>
      QEMU emulator version 5.2.0 (Debian 1:5.2+dfsg-11)<br>
      libvirtd (libvirt) 7.0.0<br>
      3.2.0</p>
    <p><br>
    </p>
    <p>As I want to post the complete method I used, I will certainly
      make a feedback in this thread later ;)  <br>
    </p>
    <div class="moz-cite-prefix">Le 25/01/2023 à 15:24, Peter Krempa a
      écrit :<br>
    </div>
    <blockquote type="cite" cite="mid:Y9E7pEPdle1Qcc13@angien.pipo.sk">
      <pre class="moz-quote-pre" wrap="">On Tue, Jan 24, 2023 at 00:10:46 +0100, <a class="moz-txt-link-abbreviated" href="mailto:lnj.sam@gmail.com">lnj.sam@gmail.com</a> wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">Hello everyone and best wishes for 2023 :)

I have an old *Garmin Drive Smart 50 GPS* and I want to be able to attach it
when it is in preboot mode to a VM hosted by a *Debian 11 host*.

>From what I understand, the preboot mode allows us to flash a firmware
before the GPS actually starts (used among other things when the GPS is soft
bricked).

When I connect the GPS to the host it gives:
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
[...]

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">My questions :

Q1 : Is it possible ?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
It shpi;d be/

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
Q2 : Am I doing it the right way ?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
I don't think so. You are using a serial device emulated which is then
connected to the host side USB-tty device.

A better way is simply to use USB-assignment/passthrough and have the
guest OS handle also the USB side

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
Q3 : Is there a method to pass such a device directly (pass-through) ?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
To pass a USB device use the following XML: 

    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x1a86'/>
        <product id='0x55d4'/>
      </source>
      <address type='usb' bus='0' port='4'/>
    </hostdev>

Obviously tweak vendor/product.

Alternatively when you are using virt-manager GUI there's a menu to pass
any device, or by default when you have a VM window active and plug in a
USB device it's passed to the VM. (It can be disabled though).

</pre>
    </blockquote>
  </body>
</html>