Skip to content

Scaphandre does not work on VMs with more than one logical host CPU #133

@armaniv

Description

@armaniv

Bug description

Scaphandre does not work on Qemu/KVM virtual machines with more than one logical host CPU assigned.

To Reproduce

  1. Create a VM and allocate to it two or more logical host CPUs.
  2. Follow the procedure described in the documentation under the Qemu exporter section.
  3. Run, for example:
    sudo docker run -v /var/scaphandre:/var/scaphandre -v /proc:/proc -ti hubblo/scaphandre --vm json -t 15

Expected behavior

Scaphandre measures and shows metrics in JSON format.

Environment

  • Linux distribution version - Ubuntu 20.04.3 LTS
  • Kernel version - 5.11.0-38-generic
  • KVM verision - QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.18)

Additional context

  • The command sudo docker run -e RUST_BACKTRACE=1 -v /var/scaphandre:/var/scaphandre -v /proc:/proc -ti hubblo/scaphandre --vm json -t 15 outputs:
thread 'main' panicked at 'Trick: if you are running on a vm, do not forget to use --vm parameter invoking scaphandre at the command line', src/sensors/mod.rs:263:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::option::expect_failed
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1226
   3: scaphandre::sensors::Topology::add_cpu_cores
   4: <scaphandre::sensors::powercap_rapl::PowercapRAPLSensor as scaphandre::sensors::Sensor>::generate_topology
   5: <scaphandre::sensors::powercap_rapl::PowercapRAPLSensor as scaphandre::sensors::Sensor>::get_topology
   6: scaphandre::exporters::json::JSONExporter::runner
   7: scaphandre::run
   8: scaphandre::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace
  • The command sudo docker run -e RUST_BACKTRACE=full -v /var/scaphandre:/var/scaphandre -v /proc:/proc -ti hubblo/scaphandre --vm json -t 15 outputs:
thread 'main' panicked at 'Trick: if you are running on a vm, do not forget to use --vm parameter invoking scaphandre at the command line', src/sensors/mod.rs:263:18
stack backtrace:
   0:     0x55a129f5bc70 - std::backtrace_rs::backtrace::libunwind::trace::h72c2fb8038f1bbee
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x55a129f5bc70 - std::backtrace_rs::backtrace::trace_unsynchronized::h1e3b084883f1e78c
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x55a129f5bc70 - std::sys_common::backtrace::_print_fmt::h3bf6a7ebf7f0394a
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:79
   3:     0x55a129f5bc70 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2e8cb764b7fe02e7
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:58
   4:     0x55a129f7ec4c - core::fmt::write::h7a1184eaee6a8644
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
   5:     0x55a129f55442 - std::io::Write::write_fmt::haeeb374d93a67eac
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/io/mod.rs:1516
   6:     0x55a129f5e11d - std::sys_common::backtrace::_print::h1d14a7f6ad632dc8
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:61
   7:     0x55a129f5e11d - std::sys_common::backtrace::print::h301abac8bb2e3e81
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:48
   8:     0x55a129f5e11d - std::panicking::default_hook::{{closure}}::hde0cb80358a6920a
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:208
   9:     0x55a129f5ddc8 - std::panicking::default_hook::h9b1a691049a0ec8f
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:227
  10:     0x55a129f5e801 - std::panicking::rust_panic_with_hook::h2bdec87b60580584
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:577
  11:     0x55a129f5e3a9 - std::panicking::begin_panic_handler::{{closure}}::h101ca09d9df5db47
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
  12:     0x55a129f5c0dc - std::sys_common::backtrace::__rust_end_short_backtrace::h3bb85654c20113ca
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
  13:     0x55a129f5e369 - rust_begin_unwind
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
  14:     0x55a129f7c871 - core::panicking::panic_fmt::h48c31e1e3d550146
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
  15:     0x55a129f7c603 - core::option::expect_failed::hf3f43f1792267e24
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1226
  16:     0x55a129a1a897 - scaphandre::sensors::Topology::add_cpu_cores::h63e5518e58e301c8
  17:     0x55a1299b00bd - <scaphandre::sensors::powercap_rapl::PowercapRAPLSensor as scaphandre::sensors::Sensor>::generate_topology::h5bc10914f1385482
  18:     0x55a1299b04fa - <scaphandre::sensors::powercap_rapl::PowercapRAPLSensor as scaphandre::sensors::Sensor>::get_topology::h06a9dd8e7d085121
  19:     0x55a129a2ae9b - scaphandre::exporters::json::JSONExporter::runner::h7f5a768af8fc512d
  20:     0x55a12996b6b9 - scaphandre::run::ha4ed5db2b42f3873
  21:     0x55a1299582f7 - scaphandre::main::hb3cd48c47ec910bd
  22:     0x55a1299567d3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3c9a2d2e7724640c
  23:     0x55a1299567e9 - std::rt::lang_start::{{closure}}::h829cbaf531010019
  24:     0x55a129f5ed17 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::he179d32a5d10d957
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:259
  25:     0x55a129f5ed17 - std::panicking::try::do_call::hcb3d5e7be089b2b4
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381
  26:     0x55a129f5ed17 - std::panicking::try::h7ac93b0cd56fb701
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345
  27:     0x55a129f5ed17 - std::panic::catch_unwind::h7b40e396c93a4fcd
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:382
  28:     0x55a129f5ed17 - std::rt::lang_start_internal::h142b9cc66267fea1
                               at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/rt.rs:51
  29:     0x55a1299584a2 - main
  30:     0x7fcd55035cb2 - __libc_start_main
  31:     0x55a12995617a - _start
  32:                0x0 - <unknown>

  • The execution of the previous command in a Qemu/KVM virtual machine (ore the same VM resized) with one logical host CPU assigned works as expected.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Previous releases

Relationships

None yet

Development

No branches or pull requests

Issue actions