aborche / qemu-guest-agent

QEMU Guest Agent patched for FreeBSD
155 stars 16 forks source link

Incorrect RAM usage on FreeBSD 12.2 / 13.0 #19

Open Onepamopa opened 3 years ago

Onepamopa commented 3 years ago

For some reason Proxmox VE shows ram usage at least 2x (even more) what the actual usage is on FreeBSD 12.2 / 13.0. Guest agent is configured as "VirtIO" (possible option is also "ISA") in PVE.

aborche commented 3 years ago

hm. i think this is not a guest-agent problem

$ virsh dommemstat freebsd12.2-zfs actual 1048576 last_update 0 rss 1108384

can you diff memory usage from proxmox and virsh output ?

Onepamopa commented 3 years ago

virsh: Command not found.

Looks like Proxmox doesn't use virsh (libvirt). Any way of checking directly in guest ?

Looks like Proxmox itself doesn't query memory usage via the agent. I'll open a topic in their forum.

qm agent testvm dommemstat command: value 'dommemstat' does not have a value in the enumeration 'fsfreeze-freeze, fsfreeze-status, fsfreeze-thaw, fstrim, get-fsinfo, get-host-name, get-memory-block-info, get-memory-blocks, get-osinfo, get-time, get-timezone, get-users, get-vcpus, info, network-get-interfaces, ping, shutdown, suspend-disk, suspend-hybrid, suspend-ram'

Onepamopa commented 3 years ago

Looks like I've used the wrong command, but in any case:

qm guest cmd 104 dommemstat command: value 'dommemstat' does not have a value in the enumeration 'fsfreeze-freeze, fsfreeze-status, fsfreeze-thaw, fstrim, get-fsinfo, get-host-name, get-memory-block-info, get-memory-blocks, get-osinfo, get-time, get-timezone, get-users, get-vcpus, info, network-get-interfaces, ping, shutdown, suspend-disk, suspend-hybrid, suspend-ram'

get-memory-block-info and get-memory-blocks both return: "error" : { "class" : "CommandNotFound", "desc" : "The command guest-get-memory-blocks has been disabled for this instance" } "error" : { "class" : "CommandNotFound", "desc" : "The command guest-get-memory-block-info has been disabled for this instance" }

https://forum.proxmox.com/threads/freebsd-guest-wrong-ram-usage.87693/

aborche commented 3 years ago

I need more info about memory usage calc in proxmox. Memory commands in qemu guest agent uses sysfs data and cannot be directly used in BSD. We need workaround for it.

juliokele commented 3 years ago

I need more info about memory usage calc in proxmox. Memory commands in qemu guest agent uses sysfs data and cannot be directly used in BSD. We need workaround for it.

proxmox use qemu-monitor-command "info balloon" for memory usage calc

info balloon command result, Ubuntu 20.04 guest: balloon: actual=2048 max_mem=2048 total_mem=1986 free_mem=197 mem_swapped_in=6311936 mem_swapped_out=23953408 major_page_faults=3095 minor_page_faults=588652947 last_update=1618556301

info balloon command result, FreeBSD 12.2 guest: balloon: actual=3072 max_mem=3072 missing parameters for measure the memory usage: total_mem, free_mem, mem_swapped_in, mem_swapped_out, major_page_faults, minor_page_faults, last_update

aborche commented 3 years ago

huh

I did a deep analysis and got several answers.

All requested info comes from kernel balloon driver/module.

The FreeBSD kernel does not have the features found in the virtio_balloon linux driver.

https://github.com/torvalds/linux/blob/v4.15/drivers/virtio/virtio_balloon.c https://github.com/freebsd/freebsd-src/blob/main/sys/dev/virtio/balloon/virtio_balloon.c

If FreeBSD committers commit their changes, I think all additional information will appear automatically. I think we can make some changes to the FreeBSD kernel, but this is not part of qga.

juliokele commented 3 years ago

Thank you for the research work!

"I think we can make some changes to the FreeBSD kernel" it would be nice if you could...

juliokele commented 3 years ago

huh

I did a deep analysis and got several answers.

All requested info comes from kernel balloon driver/module.

The FreeBSD kernel does not have the features found in the virtio_balloon linux driver.

https://github.com/torvalds/linux/blob/v4.15/drivers/virtio/virtio_balloon.c https://github.com/freebsd/freebsd-src/blob/main/sys/dev/virtio/balloon/virtio_balloon.c

If FreeBSD committers commit their changes, I think all additional information will appear automatically. I think we can make some changes to the FreeBSD kernel, but this is not part of qga.

@aborche Is there any news?

7909linder commented 2 years ago

Hi,

@aborche @juliokele I'm facing the same issue, any update?