KVM Plugin - Remove USB Device from VM not possible

  • I am using a windows vm and attached actually three usb devices to vm. When I try di remove one usb device from vm an error message is thrown from virsh on command line.


    Failed to remove USB device.

    error: Failed to detach device from /tmp/virsh_usbn4uXED

    error: XML Fehler: Invalid value for attribute 'id' in element 'vendor': '0x'. Expected integer value

    virsh detach-device --domain Server-HP --file '/tmp/virsh_usbn4uXED' --persistent --config


    OMV\Exception: Failed to remove USB device.

    error: Failed to detach device from /tmp/virsh_usbn4uXED

    error: XML Fehler: Invalid value for attribute 'id' in element 'vendor': '0x'. Expected integer value

    virsh detach-device --domain Server-HP --file '/tmp/virsh_usbn4uXED' --persistent --config in /usr/share/openmediavault/engined/rpc/kvm.inc:2543

    Stack trace:

    #0 /usr/share/openmediavault/engined/rpc/kvm.inc(1798): OMVRpcServiceKvm->virshCommand(Array, 'Failed to remov...')

    #1 [internal function]: OMVRpcServiceKvm->removeUsb(Array, Array)

    #2 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)

    #3 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod('removeUsb', Array, Array)

    #4 /usr/sbin/omv-engined(537): OMV\Rpc\Rpc::call('Kvm', 'removeUsb', Array, Array, 1)

    #5 {main}


    Seems some problem on plugin creating command line skript.


    Is it generally possible to remove usb device on running kvm vm? Actually I shutdown VM but removing is still not possible. May be manually removing from vm xml file will be successfull.

    • Offizieller Beitrag

    Is it generally possible to remove usb device on running kvm vm?

    Yes. Did you add the usb device with the plugin? It is evidently parsing the usb device incorrectly. Can you post the VM's xml?

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Yes. Did you add the usb device with the plugin? It is evidently parsing the usb device incorrectly. Can you post the VM's xml?

    Yes actually all three devices are added via kvm plugin gui. As I needed the vm I manually removed from XML File the entry for this usb device and I could start my vm again.


    I will test again and send you the VM xml and try to reproduce the issue.

  • Attached you will find my XML File from the VM. Tested once again and online removal of usb device is not possible. Seems that the constucted xml file has some missing data for the complete pci string for the usb device:


    Code
    <hostdev mode="subsystem" type="usb" managed="yes"><source><vendor id="0x"/><product id="0x"/></source></hostdev>



    Failed to remove USB device.

    error: Failed to detach device from /tmp/virsh_usb6TsZpF

    error: XML Fehler: Invalid value for attribute 'id' in element 'vendor': '0x'. Expected integer value

    virsh detach-device --domain Server-HP --file '/tmp/virsh_usb6TsZpF' --persistent --config --live


    OMV\Exception: Failed to remove USB device.

    error: Failed to detach device from /tmp/virsh_usb6TsZpF

    error: XML Fehler: Invalid value for attribute 'id' in element 'vendor': '0x'. Expected integer value

    virsh detach-device --domain Server-HP --file '/tmp/virsh_usb6TsZpF' --persistent --config --live in /usr/share/openmediavault/engined/rpc/kvm.inc:2543

    Stack trace:

    #0 /usr/share/openmediavault/engined/rpc/kvm.inc(1798): OMVRpcServiceKvm->virshCommand(Array, 'Failed to remov...')

    #1 [internal function]: OMVRpcServiceKvm->removeUsb(Array, Array)

    #2 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)

    #3 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod('removeUsb', Array, Array)

    #4 /usr/sbin/omv-engined(537): OMV\Rpc\Rpc::call('Kvm', 'removeUsb', Array, Array, 1)

    #5 {main}

    • Offizieller Beitrag

    It is failing to parse the vendor id. I'm guessing something is weird with your usb device. What is the output of: sudo lsusb

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

    Bus 001 Device 011: ID 041e:3125 Creative Technology, Ltd Creative Bluetooth Audio W2

    Bus 001 Device 004: ID 0922:0020 Dymo-CoStar Corp. LabelWriter 450

    Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply

    Bus 001 Device 021: ID 05e3:0732 Genesys Logic, Inc. All-in-One Cardreader

    Bus 001 Device 020: ID 05ac:12a8 Apple, Inc. iPhone 5/5C/5S/6/SE

    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    • Offizieller Beitrag

    What do the entries in your dropdown when removing the USB devices look like?

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    Unfortunately, that all looks right. What is the output of: sudo tail /var/log/omv-virsh-command.log

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • That is the error message I wrote already above


    • Offizieller Beitrag

    I will have to try this on my server when I get home. Hopefully I reproduce this.

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    Not sure what broke then. You could use virt-manager or virsh too. The plugin uses virsh but somehow the vendor id is not making it from the dropdown to the virsh call.

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    Removing usb devices should work in 6.1.22 in the repo now.

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Hi, I have the same issue.


    Yesterday I setup a VM with Home Assistant Operating System. So far so good. Now I attached my Home Assistant SkyConnect USB Stick (ZigBee/Thread Connectivity) via the KVM Plugin and it was recognized in the VM.


    But I am absolutely new to Home Assistant. So I worked with Snapshots. After some misconfiguration I went the route to go back to an earlier snapshot of that vm. But I had another issue and decided to delete the vm including its snapshots and recreated the vm with the qcow2 file.


    But now its not possible to add the Home Assistant SkyConnect again. I see messages like the following in a red box:


    Code
    500 - Internal Server Error
    Failed to add USB device. error: Failed to attach device from /tmp/virsh_usbXQcqvY error: Angeforderte Operation ist nicht gültig: Einheit ist bereits in der Domain Konfiguration vorhanden virsh attach-device --domain haos --file '/tmp/virsh_usbXQcqvY' --persistent --config --live



    Code
    root@omv6:~# cat /tmp/virsh_usbXQcqvY
    
    <hostdev mode="subsystem" type="usb" managed="yes"><source><vendor id="0x10c4"/><product id="0xea60"/></source></hostdev>

    It is this devices:


    Code
    lsusb
    ...
    Bus 001 Device 004: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
    ...

    My vm.xml looks as follows:



    What exactly do I have to change or delete in the vm.xml file? The relevant part seems to be this:

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

    Is it as simple as removing the complete part or only parts of it?


    Thanks Hoppel

    ----------------------------------------------------------------------------------
    openmediavault 6 | proxmox kernel | zfs | docker | kvm
    supermicro x11ssh-ctf | xeon E3-1240L-v5 | 64gb ecc | 8x10tb wd red | digital devices max s8
    ---------------------------------------------------------------------------------------------------------------------------------------

  • Hm...


    So I did the following:


    • stop the vm
    • deleted the following part of the vm.xml
    Code
        <hostdev mode='subsystem' type='usb' managed='yes'>
          <source>
            <vendor id='0x10c4'/>
            <product id='0xea60'/>
          </source>
          <address type='usb' bus='0' port='4'/>
        </hostdev>

    --> It doesn't work! Still the same issue:


    Code
    500 - Internal Server Error
    Failed to add USB device. error: Failed to attach device from /tmp/virsh_usbIsJpae error: Angeforderte Operation ist nicht gültig: Einheit ist bereits in der Domain Konfiguration vorhanden virsh attach-device --domain haos --file '/tmp/virsh_usbIsJpae' --persistent --config --live
    Code
    cat /tmp/virsh_usbIsJpae 
    
    <hostdev mode="subsystem" type="usb" managed="yes"><source><vendor id="0x10c4"/><product id="0xea60"/></source></hostdev>


    So, I decided to try the following:

    • stop the vm
    • deleted the snapshots of the vm
    • ls /etc/libvirt/qemu/ the file vm.xml is not there anymore
    • recreated my vm with the same qcow2 file
    • added the usb stick -> YEAH!!!! THIS WORKS!!!! :)
    • started the vm -> Yes, it works!

    Anyway, thanks! ;)

    ----------------------------------------------------------------------------------
    openmediavault 6 | proxmox kernel | zfs | docker | kvm
    supermicro x11ssh-ctf | xeon E3-1240L-v5 | 64gb ecc | 8x10tb wd red | digital devices max s8
    ---------------------------------------------------------------------------------------------------------------------------------------

    • Offizieller Beitrag

    You probably should always delete snapshots when adding hardware.

    omv 7.4.8-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.14 | compose 7.2.5 | k8s 7.3.1-1 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.0.9


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Will check that, when I see this message again. Thanks.


    Merry Christmas!

    ----------------------------------------------------------------------------------
    openmediavault 6 | proxmox kernel | zfs | docker | kvm
    supermicro x11ssh-ctf | xeon E3-1240L-v5 | 64gb ecc | 8x10tb wd red | digital devices max s8
    ---------------------------------------------------------------------------------------------------------------------------------------

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!