Skip to content

main: log VM startup time at process start#7977

Closed
phip1611 wants to merge 2 commits intocloud-hypervisor:mainfrom
phip1611:upstream-print-version-and-date
Closed

main: log VM startup time at process start#7977
phip1611 wants to merge 2 commits intocloud-hypervisor:mainfrom
phip1611:upstream-print-version-and-date

Conversation

@phip1611
Copy link
Copy Markdown
Member

@phip1611 phip1611 commented Apr 8, 2026

main: log VM startup time at process start

About and Motivation

In production, the version string tells operators which binary is
running, but it does not tell them when a specific cloud-hypervisor
process actually started.

That distinction matters when correlating logs across libvirt,
OpenStack, journald, and other host-side components for a single VM
launch. A dedicated startup timestamp gives every process instance an
explicit wall-clock anchor in the log stream.

This adds jiff as a runtime dependency for timestamp formatting. It is
already transitively part of the build and does not increase the binary
size therefore.

@phip1611 phip1611 requested a review from a team as a code owner April 8, 2026 13:25
@phip1611 phip1611 changed the title main: print build version and date on startup main: log build version and current timestamp on startup Apr 8, 2026
@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch from 7e6008f to 87897df Compare April 8, 2026 13:30
@phip1611 phip1611 changed the title main: log build version and current timestamp on startup main: log timestamp next to build version on startup Apr 8, 2026
@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch from 87897df to d8cd351 Compare April 8, 2026 13:32
Comment thread cloud-hypervisor/src/main.rs Outdated
@phip1611 phip1611 changed the title main: log timestamp next to build version on startup main: log build time + startup timestamp at startup Apr 9, 2026
@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch from d8cd351 to 3d97deb Compare April 9, 2026 09:49
Comment thread cloud-hypervisor/src/main.rs Outdated
}

info!("{} starting", env!("BUILD_VERSION"));
info!("Starting Cloud Hypervisor {}", env!("BUILD_VERSION"),);
Copy link
Copy Markdown
Member Author

@phip1611 phip1611 Apr 9, 2026

Choose a reason for hiding this comment

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

FYI: the new wording better aligns with e6b1e51

Comment thread cloud-hypervisor/build.rs Outdated
epoll = { workspace = true }
event_monitor = { path = "../event_monitor" }
hypervisor = { path = "../hypervisor" }
jiff = { workspace = true }
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.

Can we explore alternative and avoid bring new dependency?

Copy link
Copy Markdown
Member Author

@phip1611 phip1611 Apr 9, 2026

Choose a reason for hiding this comment

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

I see your concern - I also thought about this first! I tried - but handling calendar time is inherently complex. jiff is already in the dependency tree and doesn't increase the binary size

@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch 2 times, most recently from 9a62ecd to 95bf49a Compare April 9, 2026 20:56
Comment thread cloud-hypervisor/build.rs Outdated

let epoch = epoch.trim();
if epoch.is_empty() || epoch == "0" {
// In that case, the information is useless to users.
Copy link
Copy Markdown
Member Author

@phip1611 phip1611 Apr 9, 2026

Choose a reason for hiding this comment

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

Open discussion: is there a better option? Something like "unknown"? Printing "1970-01-01" feels weird

@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch 6 times, most recently from 3ba87c9 to 9525d93 Compare April 9, 2026 21:27
@phip1611 phip1611 changed the title main: log build time + startup timestamp at startup main: startup timestamp at startup Apr 10, 2026
@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch from 9525d93 to 14312b2 Compare April 10, 2026 06:37
@phip1611 phip1611 changed the title main: startup timestamp at startup main: log VM startup time at process start Apr 10, 2026
# About and Motivation

In production, the version string tells operators which binary is
running, but it does not tell them when a specific cloud-hypervisor
process actually started.

That distinction matters when correlating logs across libvirt,
OpenStack, journald, and other host-side components for a single VM
launch. A dedicated startup timestamp gives every process instance an
explicit wall-clock anchor in the log stream.

This adds jiff as a runtime dependency for timestamp formatting. It is
already transitively part of the build and does not increase the binary
size therefore.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
Without this:
- `cargo build`
- `CH_EXTRA_VERSION=foo cargo build` (no effect)

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
@phip1611 phip1611 force-pushed the upstream-print-version-and-date branch from 3b6e8f0 to c948cdf Compare April 10, 2026 06:45
@phip1611
Copy link
Copy Markdown
Member Author

phip1611 commented Apr 10, 2026

I'm closing this to reduce PR pressure on the project for now. We might need absolute timestamps (we need to design this first)

@phip1611 phip1611 closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants