Skip to content

Report swapinfo - #140

Merged
marmarek merged 1 commit into
QubesOS:mainfrom
ben-grande:share-swap
Aug 20, 2026
Merged

Report swapinfo#140
marmarek merged 1 commit into
QubesOS:mainfrom
ben-grande:share-swap

Conversation

@ben-grande

Copy link
Copy Markdown
Contributor

Allows distinguishing how much memory the qube is using from what is assigned by using "meminfo - swapinfo".

For: QubesOS/qubes-core-admin#827


Tested briefly.

ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 25, 2026
@codecov-commenter

codecov-commenter commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.24%. Comparing base (0dc52ab) to head (4575219).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #140   +/-   ##
=======================================
  Coverage   71.24%   71.24%           
=======================================
  Files           6        6           
  Lines         991      991           
=======================================
  Hits          706      706           
  Misses        285      285           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jun 25, 2026
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 3, 2026
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 6, 2026
Comment thread qmemman/meminfo-writer.c Outdated
Comment on lines +89 to +90
sprintf(used_mem_buf, "%lld", used_mem);
sprintf(used_swap_buf, "%lld", used_swap);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant calls.

Comment thread qmemman/meminfo-writer.c Outdated
syslog(LOG_DAEMON | LOG_ERR, "error writing meminfo to xenstore ?");
exit(1);
}
if (!xs_write(xs, XBT_NULL, "memory/swapinfo", swap, strlen(swap))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: this can be merged only after core-admin part, which sets necessary xenstore access.

Comment thread qmemman/meminfo-writer.c Outdated
char *swap;
} UsedMem;

UsedMem parse(const char *meminfo_buf, const char* dom_current_buf)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW the usual method in C for returning more results is to either return a pointer to a structure (usually dynamically allocated via malloc), or add output parameters (pointers to where function should write result). In case of a simple structure like this, compiler will do the latter for you here, so it can stay this way, but keep in mind it wont be efficient code in more complex cases.

Comment thread qmemman/meminfo-writer.c Outdated
return (UsedMem){ .mem = used_mem_buf, .swap = used_swap_buf };
}
return NULL;
return (UsedMem){ .mem = NULL, .swap = NULL };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report swap change if above threshold despite memory being below its threshold.

Comment thread qmemman/meminfo-writer.c Outdated
if (meminfo_data)
send_to_qmemman(xs, meminfo_data);
UsedMem meminfo_data = parse(meminfo_buf, dom_current_buf);
if (meminfo_data.mem && meminfo_data.mem[0])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 14, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" being used in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 14, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" being used in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 16, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" being used in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 17, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 17, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 21, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 22, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 22, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 22, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 22, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 22, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 23, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 23, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 24, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 24, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 30, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Jul 31, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Aug 1, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Aug 2, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Aug 3, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
ben-grande added a commit to ben-grande/qubes-core-admin that referenced this pull request Aug 6, 2026
Although both values can be lied by the qube, we can distinguish the
"memory types" in client tools.

For: QubesOS/qubes-linux-utils#140
marmarek added a commit to QubesOS/qubes-core-admin that referenced this pull request Aug 6, 2026
* origin/pr/827:
  Avoid reads to xenstore keys that are not written
  Deprecate cpu_usage_raw from Stats event
  Report more CPU information to QubesHost
  Report maxmem and fix get_mem variants
  Hotplug memory for real
  Skip stubdom_xid query if qube is not HVM
  Do not require Xen to get VM stats
  Report amount of swap used
  Broadcast memory correctly
  Report vcpu in stats API

Pull request description:

- online vcpus
- time of each vcpu
- share all vm_info captured with clients (I presume there is no intent to capture private information internally and not broadcast to clients, as the only place where `get_vm_stats()` is called is from `admin.vm.Stats`.

---

Requires:

- QubesOS/qubes-linux-utils#140
@marmarek marmarek added the openqa-pending PR to be tested in the next OpenQA run label Aug 6, 2026
@qubesos-bot

qubesos-bot commented Aug 7, 2026

Copy link
Copy Markdown

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026082013-devel-fedora&flavor=pull-requests

Test run included the following:

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update

Failed tests

No failures!

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/176874#dependencies
Nothing fixed

Unstable tests

Details
  • system_tests_dispvm

    system_tests/Fail (1/5 times with errors)
    • job 191554 Tests qubes.tests.integ.dispvm failed (exit code 1), details report...
    system_tests/Failed (1/5 times with errors)
    • job 191554 # Test died: Some tests failed at qubesos/tests/system_tests.pm lin...
    TC_21_DispVM_Preload/test_015_preload_race_more (1/5 times with errors)
    • job 191554 raise TimeoutError from exc_val... TimeoutError

Performance Tests

Performance degradation:

No issues

Remaining performance tests:

No remaining performance tests

Comment thread qmemman/meminfo-writer.c
Comment on lines +106 to +107
data->mem = ret_mem;
data->swap = ret_swap;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two may be uninitialized at this point. Maybe simply set to NULL at the start?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now ret_mem and ret_swap are being initialized to NULL.

Allows distinguishing how much memory the qube is using from what is
assigned by using "meminfo - swapinfo".

For: QubesOS/qubes-core-admin#827
@marmarek
marmarek merged commit 2506306 into QubesOS:main Aug 20, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openqa-pending PR to be tested in the next OpenQA run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants