Add bluetooth to virt-manager [SOLVED]

Desktop Environments and Multimedia
Post Reply
Message
Author
User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Add bluetooth to virt-manager [SOLVED]

#1 Post by Scorpion »

I created a virtual machine with android.
I added the PCI devices of the network card that has the bluetooth.
I can' t use the virtual machine with those devices:

Code: Select all

Error starting domain: unsupported configuration: host doesn't support passthrough of host PCI devices

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 66, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/domain.py", line 1400, in startup
    self._backend.create()
  File "/usr/lib/python3/dist-packages/libvirt.py", line 1080, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: unsupported configuration: host doesn't support passthrough of host PCI devices
How can I add the bluetooth?
I also have a bluetooth usb key, how can I add a usb port?
Last edited by Scorpion on 2020-07-26 15:16, edited 1 time in total.

User avatar
pylkko
Posts: 1801
Joined: 2014-11-06 19:02

Re: Add bluetooth to virt-manager

#2 Post by pylkko »

what motherboard/processor?

did you check bios/uefi settings?

User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Re: Add bluetooth to virt-manager

#3 Post by Scorpion »

Of the virtual machine? Of the ones of the real computer?

CwF
Posts: 1124
Joined: 2018-06-20 15:16
Has thanked: 1 time
Been thanked: 4 times

Re: Add bluetooth to virt-manager

#4 Post by CwF »

You can set up the host to pass devices by configuring those pci id's for vfio. The term is vfio and is googleable. That's a page of instruction. You can use this to pass the pcie card or the motherboard usb port group.

With a usb dongle you can soft-pass it easier. The viewer window provided by vmm has 'Redirect USB Device' right in the menu, click around a bit... A virt-viewer window has the same but nicer interface. It gives a dialog of all the host usb devices, click the right one!
- And you start the VM without, and attach it after it's running.

User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Re: Add bluetooth to virt-manager

#5 Post by Scorpion »

How can I check if the bluetooth usb drive is working? On debian since my netcard has bluetooth I am not sure, but the system see it:

Code: Select all

lsusb
[...]
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
[...]
I was able to redirect a data usb drive on the virtual machine, and the bluettooth dongle but I was not able to use/check the last one, android VM.

And for the netcard bluetooth:

Code: Select all

lspci
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)
00:1c.5 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #6 (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation C220 Series Chipset Family H81 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
01:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 3GB] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GP106 High Definition Audio Controller (rev a1)
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 11)
Should I redirect the last 2?

CwF
Posts: 1124
Joined: 2018-06-20 15:16
Has thanked: 1 time
Been thanked: 4 times

Re: Add bluetooth to virt-manager

#6 Post by CwF »

I'm easily confused, you jumble factors together. Please always note PCI-e slot device vs usb device, and where the listing is from - host or guest.

Any slot device needs to be under vfio control on the host. You cannot simply pick it in vmm's add hardware dialog and pass it to a guest if the device is not under vfio control - vmm does not show this detail.

On the host this will show what pci(e) devices are available to pass

Code: Select all

# dmesg | grep vfio
For usb devices there is variation. It is often helpful to have to host ignorant of the device. This means the host should NOT have drivers or firmware, or have any software loaded. While for a usb this should never be the case, sometimes it is... USB devices with multifuntion may list as multiple devices, all need to be passed together. That is true for vfio pass also and additionally be in a clean iommmu group. In both scenerios sometimes enumeration within the guest needs fixed to regroup the devices.

for your devices
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 11)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
...please post the CROPPED output of

Code: Select all

# for iommu_group in $(find /sys/kernel/iommu_groups/ -maxdepth 1 -mindepth 1 -type d);do echo "IOMMU group $(basename "$iommu_group")"; for device in $(\ls -1 "$iommu_group"/devices/); do if [[ -e "$iommu_group"/devices/"$device"/reset ]]; then echo -n "[RESET]"; fi; echo -n $'\t';lspci -nns "$device"; done; done
This will help determine what is possible, and if and how far you need to back up...
After the device is in an android guest, I don't know! I haven't played with androidx86 for a few years.

User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Re: Add bluetooth to virt-manager

#7 Post by Scorpion »

On the host:

Code: Select all

dmesg | grep vfio
No output.

On the host:

Code: Select all

for iommu_group in $(find /sys/kernel/iommu_groups/ -maxdepth 1 -mindepth 1 -type d);do echo "IOMMU group $(basename "$iommu_group")"; for device in $(\ls -1 "$iommu_group"/devices/); do if [[ -e "$iommu_group"/devices/"$device"/reset ]]; then echo -n "[RESET]"; fi; echo -n $'\t';lspci -nns "$device"; done; done
Again no output.

The previously post codes are all from the host (debian 10).

The VM is android-x86_64-8.1-rc1.

CwF
Posts: 1124
Joined: 2018-06-20 15:16
Has thanked: 1 time
Been thanked: 4 times

Re: Add bluetooth to virt-manager

#8 Post by CwF »

No output indicates your host is not set up. Soft passing usb is your only option at this point.
The term is vfio and is googleable. That's a page of instruction...
...determine what is possible, and if and how far you need to back up...
You have some homework to do! You need to verify the platform is vt-d capable, turn on iommu, create modprobe and vfio.conf files, regen the initramfs etc, etc. I have commented on these here in these forums, search...

Nothing in the virtual machine manager add hardware 'PCI Host Device' dialog is available for use until you reconfigure. It's pretty easy, but there are details that vary. Feel free to ask for clarifications...Good Luck.

User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Re: Add bluetooth to virt-manager

#9 Post by Scorpion »

But why does the data usb drive work and the bluetooth one doesn' t?
It would be easier, and can android VM support my netcard?

In the BIOS I already had the IOMMU activated, in advanced-->virtualization. But in chipset I saw VT'd(?) not avaible.

Code: Select all

inxi --cpu
CPU:       Topology: Dual Core model: Intel Pentium G3450 bits: 64 type: MCP L2 cache: 3072 KiB 
           Speed: 1132 MHz min/max: 800/3400 MHz Core speeds (MHz): 1: 835 2: 858 
Cannot I redirect a PCI device with my CPU?
"kvm-ok" states that is fine:

Code: Select all

kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

https://scottlinux.com/2017/05/10/how-t ... ora-linux/
Edit the file /etc/default/grub and add intel_iommu=on to the existing GRUB_CMDLINE_LINUX line.

Note: I have a lot going on here for mine, such as a fix for a weird usb power issue of my motherboard, enabling nested virtualization for kvm and more. Disregard those things and only add intel_iommu=on for this task!
Do I need to edit grub?

Code: Select all

virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : WARN (Enable 'cpuacct' in kernel Kconfig file or mount/enable cgroup controller in your system)
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for device assignment IOMMU support                         : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)
   LXC: Checking for Linux >= 2.6.26                                         : PASS
   LXC: Checking for namespace ipc                                           : PASS
   LXC: Checking for namespace mnt                                           : PASS
   LXC: Checking for namespace pid                                           : PASS
   LXC: Checking for namespace uts                                           : PASS
   LXC: Checking for namespace net                                           : PASS
   LXC: Checking for namespace user                                          : PASS
   LXC: Checking for cgroup 'cpu' controller support                         : PASS
   LXC: Checking for cgroup 'cpuacct' controller support                     : FAIL (Enable 'cpuacct' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking for cgroup 'cpuset' controller support                      : PASS
   LXC: Checking for cgroup 'memory' controller support                      : PASS
   LXC: Checking for cgroup 'devices' controller support                     : PASS
   LXC: Checking for cgroup 'freezer' controller support                     : PASS
   LXC: Checking for cgroup 'blkio' controller support                       : PASS
   LXC: Checking if device /sys/fs/fuse/connections exists                   : PASS
So maybe is this the problem: "Enable 'cpuacct' in kernel Kconfig file or mount/enable cgroup controller in your system".

I found in the (debian) forum this http://forums.debian.net/viewtopic.php? ... mu#p721885.
Should I create this file /etc/modprobe.d/vfio.conf:

Code: Select all

cat /etc/modprobe.d/vfio.conf

options vfio-pci ids=?????

CwF
Posts: 1124
Joined: 2018-06-20 15:16
Has thanked: 1 time
Been thanked: 4 times

Re: Add bluetooth to virt-manager

#10 Post by CwF »

But why does the data usb drive work and the bluetooth one doesn' t?
...Cannot I redirect a PCI device with my CPU?
According to Intel, not with that cpu, the G3450 does not support vt-d. A simplistic difference is the pci-e slot is wired to the cpu, the usb port is not. Why the usb bt adapter doesn't work, I don't know for sure. I would usually pass the usb chip as listed earlier, likely #2, but in this example that is the same as switching the pci root port and requires vt-d. When you pass the entire usb hub, any device is only dependent on the guest.
It would be easier, and can android VM support my netcard?
good question!

If soft passing usb does not work then your option is to upgrade the cpu to an 'i' or 'e3' series supporting vt-d.

CwF
Posts: 1124
Joined: 2018-06-20 15:16
Has thanked: 1 time
Been thanked: 4 times

Re: Add bluetooth to virt-manager

#11 Post by CwF »

Coincidence.
With a primary purpose of looking at connman in bullseye for some reason I needed to give it something to play with and didn't really worry it's in a vm. Just went on hooking things up to check it out.
Oh ya, that vfio bluetooth thread...

So into the host I plug

Code: Select all

Bus 004 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle
this host, buster, does know what to do, and operates the dongle fine.
The virt-viewer menu list 'USB Device' as option 3, interesting - not so good.
It is the one! the dongle passed trouble free to the bullseye vm and worked fine.
The dongle passed back to the host, no issue.

Then I got to thinking I've deduced to this question before, without an answer. Does soft passing USB use vt-d?
I can't know. So I suggest above soft-pass will work without, though maybe I'm not sure!

..and of course, who knows what android can do with it.

User avatar
Scorpion
Posts: 283
Joined: 2018-10-17 11:38

Re: Add bluetooth to virt-manager

#12 Post by Scorpion »

I have a VM with ubuntu server I redirected the BT dongle with the virt-manager GUI.
It worked successfully with my phone, I sent a file as a test but I cannot see my smart band with BLE (Bluetooth Low Energy). On the host I can see it.

My BT dongle should not be too old https://www.trust.com/en/product/18187- ... -0-adapter.

Android wasn' t able to use it, I suppose that it can' t use the netcard.

Post Reply