Libvirt
by Gk Gk
Hi All,
I am trying to collect memory, disk and network stats for a VM on kvm host.
It seems that the statistics are not matching what the OS inside the VM is
reporting. Why is this discrepancy ?
Is this a known bug of libvirt ? Also I heard that libvirt shows cumulative
figures for these measures ever since the VM was created. Also I tested by
creating a new vm and comparing the stats without a reboot . Even in this
case, the stats dont agree. Can someone help me here please ?
Thanks
Kumar
1 year, 1 month
Attach a GPS in preboot mode
by lnj.sam@gmail.com
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:
|root@host:~# journalctl -kf||
||# GPS in MTP storage mode (default when reset)||
||...||
||janv. 23 23:02:51 host kernel: usb 2-4: New USB device found,
idVendor=091e, idProduct=48db, bcdDevice= 0.01||
||janv. 23 23:02:51 host kernel: usb 2-4: New USB device strings: Mfr=1,
Product=2, SerialNumber=5||
||...||
||# GPS in mass storage mode||
||...||
||janv. 23 23:01:29 host kernel: usb 2-4: New USB device found,
idVendor=091e, idProduct=28db, bcdDevice= 5.09||
||janv. 23 23:01:29 host kernel: usb 2-4: New USB device strings: Mfr=0,
Product=0, SerialNumber=5||
||...||
||# GPS in preboot mode||
||...||
||janv. 23 23:09:05 host kernel: usb 2-4: New USB device found,
idVendor=091e, idProduct=0003, bcdDevice= 0.01||
||janv. 23 23:09:05 host kernel: usb 2-4: New USB device strings: Mfr=0,
Product=0, SerialNumber=0||
||janv. 23 23:09:13 host kernel: garmin_gps ttyUSB0: Garmin GPS usb/tty
converter now disconnected from ttyUSB0|
...
We see that *idVendor*, *idProduct*, *bcdDevice*, *Mfr*, *Product* and
*SerialNumber* vary according to the modes.We also see that the GPS is
seen as a *ttyUSB0* serial device.
I managed to attach the GPS in preboot mode, thanks to a script which
waits for the GPS to be detected in this mode (not detailed here so as
not to overload, but I can publish it if necessary) and which attaches
to a VM in running (*successfully tested on Debian 11 **and**Windows 7
guests*).
Here is the code that generates the XML before attaching it :
|...||
||echo "<serial type='dev'> \||
|| <source path='"$( \||
|| ls -1 /dev/tty* | grep -Ev "tty(|S?[0-9]+)$" \||
|| )"'/> \||
|| <target type='usb-serial'> \||
|| <vendor id='0x"$( \||
|| echo 091e \||
|| )"'/> \||
|| <product id='0x"$( \||
|| echo 28db \||
|| )"'/> \||
|| </target> \||
|| </serial>" > serial_device.xml||
||virsh attach-device vm-bullseye --file serial_device.xml &||
||...|
But once attached, this is what I see in the XML configuration of my VM
(from *virt-manager*) :
|<serial type="dev">||
|| <source path="/dev/ttyUSB1"/>||
|| <target type="usb-serial" port="1">||
|| <model name="usb-serial"/>||
|| </target>||
|| <alias name="serial1"/>||
|| <address type="usb" bus="0" port="4"/>||
||</serial>|
We see that libvirt has removed the *vendor/product id* from the XML.
Also here is what I get from a *Debian 11 guest* :
|root@vm-bullseye:~# journalctl -k -f||
||...||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: new full-speed USB
device number 2 using uhci_hcd||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: New USB device found,
idVendor=0403, idProduct=6001, bcdDevice= 4.00||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: New USB device strings:
Mfr=1, Product=2, SerialNumber=4||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: Product: QEMU USB SERIAL||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: Manufacturer: QEMU||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: SerialNumber:
1-0000:00:05.7-4||
||janv. 23 21:26:22 vm-bullseye kernel: usbcore: registered new
interface driver usbserial_generic||
||janv. 23 21:26:22 vm-bullseye kernel: usbserial: USB Serial support
registered for generic||
||janv. 23 21:26:22 vm-bullseye kernel: usbcore: registered new
interface driver ftdi_sio||
||janv. 23 21:26:22 vm-bullseye kernel: usbserial: USB Serial support
registered for FTDI USB Serial Device||
||janv. 23 21:26:22 vm-bullseye kernel: ftdi_sio 3-2:1.0: FTDI USB
Serial Device converter detected||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: Detected FT232BM||
||janv. 23 21:26:22 vm-bullseye kernel: usb 3-2: FTDI USB Serial Device
converter now attached to ttyUSB0||
||janv. 23 21:26:25 vm-bullseye kernel: usb 3-2: USB disconnect, device
number 2||
||janv. 23 21:26:25 vm-bullseye kernel: ftdi_sio ttyUSB0: FTDI USB
Serial Device converter now disconnected from ttyUSB0||
||janv. 23 21:26:25 vm-bullseye kernel: ftdi_sio 3-2:1.0: device
disconnected||
||...|
The guest sees the GPS well but
idVendor=*0403*, idProduct=*6001*, bcdDevice=4.00, Mfr=1, Product=2,
SerialNumber=4
... do not correspond to anything, and tools that expect GPS in preboot
mode do not see it.
My questions :
Q1 : Is it possible ?
Q2 : Am I doing it the right way ?
Q3 : Is there a method to pass such a device directly (pass-through) ?
Thank you in advance for the time you are going to devote to me :)
With Adelphity,
lnj
1 year, 9 months
WinServer2016 guest no mouse in VirtManager
by John McInnes
Hi! I recently converted several Windows Server VMs from HyperV to libvirt/KVM. The host is running openSUSE Leap 15.3. I used virt-v2v and I installed virtio drivers on all of them and it all went well - except for one VM. The mouse does not work for this VM in VirtualMachineManager. There is no cursor and no response. There are no issues showing in Windows Device Manager. The mouse shows up as a PS/2 mouse. Interestingly if I RDP into this VM using Microsoft Remote Desktop the mouse works fine. Any ideas?
----
John McInnes
jmcinnes /\T svt.org
1 year, 9 months
libvirt error - "cannot set CPU affinity"
by Dipanjan Das
Hello,
I am getting the following error message when trying to run a VM with
the emulatorpin cpuset set to a value -
"cannot set CPU affinity on process 78: Invalid argument".
Note that removing the emulatorpin leads to the VM running successfully.
The core that I am setting for the emulatorpin cpuset is present on the
system and is not in the isolcpus set of the host.
Any suggestions on what could be the problem? Any pointers to how to debug
the issue would help greatly too.
Some further details if they help - I am using kubevirt (KubeVirt.io
<http://kubevirt.io/>) which uses libvirt to manage VM instances in a
kubernetes environment. The libvirt version being used is 8.0.0.
Thanks,
Dipanjan Das
1 year, 9 months
USB Device Redirection | Change Access For Mount
by Stefanie Leisestreichler
Hi.
I am using kvm/qemu to redirect my mobile phone in a Virtual Machine
(via virt-viewer). The mount works automatically but unfortunately the
permission to access the files (i.e. photos) is limited to the mounting
user only. I want to grant access to other users also.
How can I archive this?
Thanks,
Steffi
1 year, 10 months
Libvirt dnsmasq oddity
by Charles Curley
I seem to have hit an oddity in how dnsmasq operates for libvirt.
I have two host machines each with several guests. One of those is also
the local samba server. Guests on the non-samba server can resolve the
samba server's host name correctly, so far without fail.
Guests on the samba server sometimes get the correct IP address for the
samba server, and other times get an IP address for the samba server of
127.0.1.1. That is the IP address provided in the host's /etc/hosts.
Similarly for amanda and hosts.
I have a workaround of hard coding the IP address in the fstab entry,
but that's tacky. Is there a better way to handle this?
One possible way: non-virtual machines use a bind9 server. dnsmasq has
an option, --no-hosts, to inhibit reading the hostnames in /etc/hosts.
How do I feed that to dnsmasq?
Thank you.
root@hawk:~# cat /etc/debian_version
11.6
root@hawk:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
root@hawk:~# pre libvirt dnsmasq qemu
dnsmasq-base 2.85-1 amd64
gir1.2-libvirt-glib-1.0 3.0.0-1 amd64
ipxe-qemu 1.0.0+git-20190125.36a4c85-5.1 all
libvirt0 7.0.0-3 amd64
libvirt-clients 7.0.0-3 amd64
libvirt-daemon 7.0.0-3 amd64
libvirt-daemon-config-network 7.0.0-3 all
libvirt-daemon-config-nwfilter 7.0.0-3 all
libvirt-daemon-driver-lxc 7.0.0-3 amd64
libvirt-daemon-driver-qemu 7.0.0-3 amd64
libvirt-daemon-driver-vbox 7.0.0-3 amd64
libvirt-daemon-driver-xen 7.0.0-3 amd64
libvirt-daemon-system 7.0.0-3 amd64
libvirt-daemon-system-systemd 7.0.0-3 all
libvirt-glib-1.0-0 3.0.0-1 amd64
python3-libvirt 7.0.0-2 amd64
qemu 1:5.2+dfsg-11+deb11u2 amd64
qemu-system-common 1:5.2+dfsg-11+deb11u2 amd64
qemu-system-data 1:5.2+dfsg-11+deb11u2 all
qemu-system-gui 1:5.2+dfsg-11+deb11u2 amd64
qemu-system-x86 1:5.2+dfsg-11+deb11u2 amd64
qemu-utils 1:5.2+dfsg-11+deb11u2 amd64
root@hawk:~#
--
Does anybody read signatures any more?
https://charlescurley.com
https://charlescurley.com/blog/
1 year, 10 months
question about virtio related options: ats=on and iommu=on
by Yalan Zhang
Hi,
I have a question about the virtio related options, could someone please
help to confirm?
In my understanding, the ats='on' should depend on the "iommu=on", but I'm
not sure about it.
Please check the details below.
Thank you!
Details:
1. set vm with intel iommu device, and enable iommu for virtio filesystem
device:
# virsh dumpxml rhel --xpath //iommu
<iommu model="intel">
<driver intremap="on" caching_mode="on" iotlb="on"/>
</iommu>
Set iommu="on" ats="on" for virtio filesystem device:
# virsh dumpxml rhel --xpath //filesystem
<filesystem type="mount" accessmode="passthrough">
<driver type="virtiofs" queue="512" iommu="on" ats="on"/>
<binary path="/usr/libexec/virtiofsd" xattr="on">
<cache mode="none"/>
</binary>
<source dir="/path1"/>
<target dir="mount_tag1"/>
<address type="pci" domain="0x0000" bus="0x04" slot="0x00"
function="0x0"/>
</filesystem>
2. failed to start the vm since "iommu_platform=true is not supported by
the device"
# virsh start rhel
error: Failed to start domain 'rhel'
error: internal error: qemu unexpectedly closed the monitor:
2023-01-09T03:48:03.198629Z qemu-kvm: -device
{"driver":"vhost-user-fs-pci","iommu_platform":true,"ats":true,"id":"fs0","chardev":"chr-vu-fs0","queue-size":512,"tag":"mount_tag1","bus":"pci.4","addr":"0x0"}:
iommu_platform=true is not supported by the device
3. update the xml to be with only ats="on", vm can start successfully,
which is not expected.
# virsh dumpxml rhel --xpath //filesystem
<filesystem type="mount" accessmode="passthrough">
<driver type="virtiofs" queue="512" ats="on"/>
<binary path="/usr/libexec/virtiofsd" xattr="on">
<cache mode="none"/>
</binary>
<source dir="/path1"/>
<target dir="mount_tag1"/>
<alias name="fs0"/>
<address type="pci" domain="0x0000" bus="0x04" slot="0x00"
function="0x0"/>
</filesystem>
the qemu cmd line:
-chardev
socket,id=chr-vu-fs0,path=/var/lib/libvirt/qemu/domain-5-rhel/fs0-fs.sock \
-device
'{"driver":"vhost-user-fs-pci","ats":true,"id":"fs0","chardev":"chr-vu-fs0","queue-size":512,"tag":"mount_tag1","bus":"pci.4","addr":"0x0"}'
Refer to libvirt.org:
QEMU's virtio devices have some attributes related to the virtio transport
under the driver element: The iommu attribute enables the use of emulated
IOMMU by the device.
The attribute ats controls the Address Translation Service support for PCIe
devices. This is needed to make use of IOTLB support (see IOMMU devices).
Possible values are on or off.
In my understanding, the ats='on' should depend on the iommu='on', so if
the device does not support iommu, it should not support ats, eigher.
I'm not sure if the understanding is correct.
Could someone please help to confirm it?
Thank you!
Yalan
1 year, 10 months
Public IPv6 Bridges
by André Malm
I'm having trouble getting IPv6 to work for my KVM/qemu guests.
I have two bridges setup, one routed (external, non libvirt) bridge for
public dedicated ipv4 + ipv6 which works for both protocols.
Then I have a libvirt nat bridge (with the routed bridge as parent) with
a nated ipv4 (that works) and I also want a public ipv6. I'm able to
transmit udp packets out but I never get any response.
Looking at tcpdump there are incoming neighbor solicitations that get
unanswered and don't get forwarded to the guest.
Do I need to set something special up for this to work? Ubuntu 22.04 /
Libvirt 8.0.0
The routed bridge (pubBr) has ipv6 2001:x:x:7d8e:: - My nat bridge
config below:
<network>
<name>natbr</name>
<bridge name="natbr" />
<forward mode='nat' dev='pubBr'>
<nat>
<port start='8000' end='30000'/>
</nat>
</forward>
<ip address="10.1.1.1" netmask="255.255.0.0">
<dhcp>
<range start='10.1.1.2' end='10.1.1.255'/>
</dhcp>
</ip>
<ip family="ipv6" address="2001:x:x:7d8e::1" prefix="64">
<dhcp>
<host name="test" ip="2001:x:x:7d8e:a01:2ff::"/>
</dhcp>
</ip>
</network>
Thanks!
1 year, 10 months
libvirt_connect_get_nic_models
by Simon Fairweather
Hi
Can you confirm that I source get an array of these when running this api
call, currently I just get a return of false
root@computenode:/mnt/testpool# qemu -nic model=help
Supported NIC models:
e1000
e1000-82544gc
e1000-82545em
e1000e
i82550
i82551
i82557a
i82557b
i82557c
i82558a
i82558b
i82559a
i82559b
i82559c
i82559er
i82562
i82801
ne2k_pci
pcnet
rtl8139
tulip
virtio-net-pci
virtio-net-pci-non-transitional
virtio-net-pci-transitional
vmxnet3
function domain_get_nic_models($arch = 'x86_64') {
$tmp = libvirt_connect_get_nic_models($this->conn, $arch) ;
return ($tmp) ? $tmp : $this->_set_last_error();
}
1 year, 10 months