[libvirt] virsh nodecpustats --cpu <invalid cpu no> is not failing error

Bug #1868528 reported by bugproxy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
The Ubuntu-power-systems project
Fix Released
High
Canonical Server
libvirt (Ubuntu)
Fix Released
High
Ubuntu on IBM Power Systems Bug Triage

Bug Description

== Comment: #0 - Satheesh Rajendran <email address hidden> - 2020-02-12 01:42:11 ==
---Problem Description---
virsh nodecpustats --cpu <invalid cpu no> is not failing error

Contact Information = <email address hidden>

---uname output---
5.4.0-13-generic

Machine Type = power9 ppc64le DD2.3

---Debugger---
A debugger is not configured

---Steps to Reproduce---
 1. Execute virsh nodecpustats with a invalid cpu number, ideally it should fail with error msg rather it returns nothing and commands succeeds.

# lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 160
On-line CPU(s) list: 0-159
Thread(s) per core: 4
Core(s) per socket: 20
Socket(s): 2
NUMA node(s): 2
Model: 2.3 (pvr 004e 1203)
Model name: POWER9, altivec supported
Frequency boost: enabled
CPU max MHz: 3800.0000
CPU min MHz: 2300.0000
L1d cache: 1.3 MiB
L1i cache: 1.3 MiB
L2 cache: 10 MiB
L3 cache: 200 MiB
NUMA node0 CPU(s): 0-79
NUMA node8 CPU(s): 80-159
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Mitigation; RFI Flush, L1D private per thread
Vulnerability Mds: Not affected
Vulnerability Meltdown: Mitigation; RFI Flush, L1D private per thread
Vulnerability Spec store bypass: Mitigation; Kernel entry/exit barrier (eieio)
Vulnerability Spectre v1: Mitigation; __user pointer sanitization, ori31 speculation barrier enabled
Vulnerability Spectre v2: Mitigation; Software count cache flush (hardware accelerated), Software link stack flush
Vulnerability Tsx async abort: Not affected

the system has total 160 cpus, any cpu number beyond should return error.

Actual:
# virsh nodecpustats --cpu 2000

# echo $?
0

Expected:
# virsh nodecpustats --cpu 2000
error: Unable to get node cpu stats
error: Invalid cpuNum in virHostCPUGetStatsLinux

Userspace tool common name: ii libvirt0:ppc64el 6.0.0-0ubuntu2 ppc64el library for interfacing with different virtualization systems

The userspace tool has the following bit modes: both

Userspace rpm: ii libvirt0:ppc64el 6.0.0-0ubuntu2 ppc64el library for interfacing with different virtualization systems

Userspace tool obtained from project website: na

*Additional Instructions for <email address hidden>:
-Post a private note with access information to the machine that the bug is occuring on.
-Attach ltrace and strace of userspace application.

== Comment: #3 - Satheesh Rajendran <email address hidden> - 2020-02-12 04:07:48 ==

== Comment: #8 - Mauro Rodrigues <email address hidden> - 2020-02-14 06:54:20 ==

== Comment: #9 - Mauro Rodrigues <email address hidden> - 2020-02-14 06:55:38 ==
It does happen upstream. Seeteena would you please test the attached patch?

Thing is that, even though virHostCPUGetStatsLinux was logging the invalid cpuNum error, it wasn't returning a failure (see the message below), so the upper layers correctly couldn't report as such.

2020-02-14 12:44:03.524+0000: 46611: error : virHostCPUGetStatsLinux:833 : Invalid cpuNum in virHostCPUGetStatsLinux

Another thing that bothers me, but considere I'm new to libvirt/qemu/kvm so it might just be my own incorrect understanding of it, is the fact that when we use "LIBVIRT_DEBUG=1 virsh cmd" we are just logging the command, not libvirt (ie libvirtd) execution.. The above message could be seen in libvirtd logs, but not from the command execution with LIBVIRT_DEBUG=1. So for me it's a bit misleading, but again it might just be my own mistake understanding this.

I recommend to always attach libvirtd logs as well in future issues.

== Comment: #13 - Mauro Rodrigues <email address hidden> - 2020-02-25 06:50:24 ==
FYI The patch, including a unit test, was sent to the libvirt mail list last friday. No feedback so far, unfortunately (which I think is fairly usual at libvirt ml).

https://www.redhat.com/archives/libvir-list/2020-February/msg00757.html

... which reads:
"util: virhostcpu: Fail when fetching CPU Stats for invalid cpu"

Related branches

Revision history for this message
bugproxy (bugproxy) wrote : libvirt debug log

Default Comment by Bridge

tags: added: architecture-ppc64le bugnameltc-183869 severity-high targetmilestone-inin---
Revision history for this message
bugproxy (bugproxy) wrote : fix for invalid cpu nodecpustats

Default Comment by Bridge

Changed in ubuntu:
assignee: nobody → Ubuntu on IBM Power Systems Bug Triage (ubuntu-power-triage)
affects: ubuntu → libvirt (Ubuntu)
Frank Heimes (fheimes)
Changed in ubuntu-power-systems:
status: New → Triaged
assignee: nobody → Canonical Server Team (canonical-server)
importance: Undecided → High
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fail:
root@f:~# virsh nodecpustats --cpu 47

root@f:~# echo $?
0

While older releases worked:
$ virsh nodecpustats --cpu 47
error: Unable to get node cpu stats
error: Invalid cpuNum in virHostCPUGetStatsLinux

Confirmed the issue, will create a test build with the upstream submission and try it ...

Changed in libvirt (Ubuntu):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2020-03-23 09:34 EDT-------
(In reply to comment #19)
> PPA: https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/3986
> MP:
> https://code.launchpad.net/~paelzer/ubuntu/+source/libvirt/+git/libvirt/
> +merge/380942

Tested above PPA and found the reported issue is fixed.

~# uname -a
Linux xyz 5.4.0-18-generic #22-Ubuntu SMP Sat Mar 7 18:06:34 UTC 2020 ppc64le ppc64le ppc64le GNU/Linux

# dpkg -l|grep libvirt
ii libvirt-clients 6.0.0-0ubuntu6~ppa2 ppc64el Programs for the libvirt library
ii libvirt-daemon 6.0.0-0ubuntu6~ppa2 ppc64el Virtualization daemon
ii libvirt-daemon-driver-qemu 6.0.0-0ubuntu6~ppa2 ppc64el Virtualization daemon QEMU connection driver
ii libvirt-daemon-driver-storage-rbd 6.0.0-0ubuntu6~ppa2 ppc64el Virtualization daemon RBD storage driver
ii libvirt-daemon-system 6.0.0-0ubuntu6~ppa2 ppc64el Libvirt daemon configuration files
ii libvirt-daemon-system-systemd 6.0.0-0ubuntu6~ppa2 ppc64el Libvirt daemon configuration files (systemd)
ii libvirt-dev:ppc64el 6.0.0-0ubuntu6~ppa2 ppc64el development files for the libvirt library
ii libvirt-glib-1.0-0:ppc64el 3.0.0-1 ppc64el libvirt GLib and GObject mapping library
ii libvirt0:ppc64el 6.0.0-0ubuntu6~ppa2 ppc64el library for interfacing with different virtualization systems
ii python3-libvirt 6.0.0-0ubuntu3 ppc64el libvirt Python 3 bindings

# virsh nodecpustats --cpu 2000
error: Unable to get node cpu stats
error: Invalid cpuNum in virHostCPUGetStatsLinux

# echo $?
1

Regards,
-Satheesh

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

With the build from the PPA it works fine now.
I just need to make sure the other changes are good as well before an upload.

root@f-dcap-after-cap:~# virsh nodecpustats --cpu 47
error: Unable to get node cpu stats
error: Invalid cpuNum in virHostCPUGetStatsLinux

root@f-dcap-after-cap:~# echo $?
1

Changed in libvirt (Ubuntu):
status: Triaged → Fix Committed
Frank Heimes (fheimes)
Changed in ubuntu-power-systems:
status: Triaged → Fix Committed
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

FYI I also replied on the upstream ML to add my test/review tags to get this going there.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2020-03-24 09:49 EDT-------
Christian, thanks for your review and testing, it indeed helped to get things moving in the mail list. The patch is merged upstream:

https://libvirt.org/git/?p=libvirt.git;a=commit;h=75a4ec42f70b5324f95d7ffbbfbf7457620735e4

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

FYI Regression test is fine on this build, but waiting a bit to give it a chance to be upstream committed

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libvirt - 6.0.0-0ubuntu6

---------------
libvirt (6.0.0-0ubuntu6) focal; urgency=medium

  * d/p/ubuntu/lp-1867460-*: fix domcapabilities before capabilities
    and binary autodetection in general (LP: #1867460)
  * d/p/stable/lp-1868539-*: stabilize libvirt by backporting upstream
    fixes (LP: #1868539)
  * d/p/ubuntu/lp-1853200*: add cpu models without hle/rtm features to have
    modern types on kernels with recent security fixes (LP: #1853200)
  * d/p/ubuntu/lp-1868528-*: Fail when fetching CPU Status for invalid CPU
    (LP: #1868528)

 -- Christian Ehrhardt <email address hidden> Fri, 20 Mar 2020 10:34:19 +0100

Changed in libvirt (Ubuntu):
status: Fix Committed → Fix Released
Frank Heimes (fheimes)
Changed in ubuntu-power-systems:
status: Fix Committed → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2020-05-11 15:09 EDT-------
Based on the previous comments, closing this one.

tags: added: targetmilestone-inin2004
removed: targetmilestone-inin---
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.