Skip to content

Conversation

@phip1611
Copy link
Member

@phip1611 phip1611 commented Nov 27, 2025

This is my solution for #7524 which we discussed in todays Cloud Hypervisor office hour. I think it improves certain things:

TL;DR improvements

  • more fearless refactorings: cargo test|check|clippy now run on the whole workspace by default (without explicit --all/--workspace)
  • main Cargo.toml is not so overwhelming anymore
  • We got rid of a lot of repetitions in CI files (no more -D warnings all the time)
  • cleaned up technical debt of unused build.rs scripts

More info in ticket or commit message.

Steps

  • add new workspace member cloud-hypervisor
  • move ./src to new workspace member
  • move ./tests to new workspace member
  • move relevant parts from Cargo.toml to new workspace member

@phip1611
Copy link
Member Author

From today's cloud hypervisor office meeting: Yes, it is a great improvement, we want to go that way (Rob)

@phip1611 phip1611 force-pushed the workspace branch 2 times, most recently from 4d0b9d2 to 544c9ab Compare November 27, 2025 18:48
@phip1611 phip1611 marked this pull request as ready for review November 27, 2025 18:48
@phip1611 phip1611 requested a review from a team as a code owner November 27, 2025 18:48
@phip1611 phip1611 force-pushed the workspace branch 5 times, most recently from 378de4b to 0259156 Compare November 28, 2025 08:05
@phip1611
Copy link
Member Author

phip1611 commented Nov 28, 2025

ping @RuoqingHe - I needed to take special care for the riscv job: bc4a2bd

@phip1611 phip1611 force-pushed the workspace branch 4 times, most recently from 796c055 to bc4a2bd Compare November 28, 2025 08:15
@phip1611 phip1611 self-assigned this Dec 2, 2025
Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

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

Like the direction. :)

@phip1611 phip1611 force-pushed the workspace branch 5 times, most recently from 7615b35 to cc3bd62 Compare December 5, 2025 12:00
let target_cmd_path = format!("{target_artifact_dir}/{cmd}");

let full_path = workspace_root.join(&target_cmd_path);
String::from(full_path.to_str().unwrap())
Copy link
Member

@alyssais alyssais Dec 5, 2025

Choose a reason for hiding this comment

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

Just a thought, not a blocker at all: I wonder if we could use e.g. env!("CARGO_BIN_EXE_cloud-hypervisor") and get rid of this function. It should at least work for the code in tests/, but I'm not sure if it would be set when the test_infra crate is built, so if not it would require the two other users of this function to be adjusted to take an executable path as a parameter passed by code in tests/.

This will also prevent some useless rebuilds. Using `--verbose` we can
observe that the build.rs causes frequent useless rebuilds - having
less is a good thing. They come from the dependency of `build.rs` to
the local git repository.

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
TL;DR: cargo clippy|check|... now runs on whole workspace by default.

## Steps

- add new workspace member `cloud-hypervisor`
- move `./src` to new workspace member
- move `./tests` to new workspace member
- move relevant parts from Cargo.toml to new workspace member
- kept necessary parts in main Cargo.toml, such as profile
  configurations

## About

The main Cargo.toml historically mixes workspace and crate definitions
for cloud-hypervisor and ch-remote. This makes it hard to read and
requires `--workspace` to run cargo clippy or cargo test on all
workspace members, which is counter-intuitive.

This patch separates the workspace from the crate definition in the main
Cargo.toml file. After this, cargo clippy, cargo test, etc., work on the
whole workspace naturally, giving a smoother developer experience. The
Cargo.toml without a package definition is also called a virtual
workspace or virtual manifest by Cargo [0].

Backporting is not a concern: CHV no longer backports, but the affected
files are rarely modified anyway.

[0] https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
Unrelated but necessary to also always format code for all
architectures and all features.

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
It is no longer needed to add `--all` (which is an alias for
`--workspace`). The documentation says "Commands run in the workspace
root will run against all workspace members by default" [0].

We however still need `--tests` as this activates the building of
tests in `<crate>/tests` directories.

[0] https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
`cargo rustc` is incompatible with virtual manifests, so the CI needs to
 use cargo build instead. However, passing `RUSTFLAGS="-D warnings"` via
 the environment would propagate to all dependencies, and some of them
 currently fail to build under ``-D warnings` due to issues like [0]:

```
error: creating a mutable reference to mutable static
  --> src/temp.rs:97:5
   |
97 |     DIRS.pop()
   |     ^^^^^^^^^^ mutable reference to mutable static
```

To resolve this, apply ``-D warnings` only to the `cargo clippy`
commands (which apply to our workspace only) and avoid enforcing it for
the entire cargo build.

[0]: https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/19962283528/job/57245376263?pr=7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 8, 2025
This is the first commit of the cherry-pick from [0].

[0] cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 8, 2025
This is the last commit of the cherry-pick from [1].

`cargo rustc` is incompatible with virtual manifests, so the CI needs to
 use cargo build instead. However, passing `RUSTFLAGS="-D warnings"` via
 the environment would propagate to all dependencies, and some of them
 currently fail to build under ``-D warnings` due to issues like [0]:

```
error: creating a mutable reference to mutable static
  --> src/temp.rs:97:5
   |
97 |     DIRS.pop()
   |     ^^^^^^^^^^ mutable reference to mutable static
```

To resolve this, apply ``-D warnings` only to the `cargo clippy`
commands (which apply to our workspace only) and avoid enforcing it for
the entire cargo build.

[0]: https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/19962283528/job/57245376263?pr=7525
[1]: cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
@rbradford rbradford added this pull request to the merge queue Dec 9, 2025
Merged via the queue into cloud-hypervisor:main with commit 0be7d1b Dec 9, 2025
48 of 49 checks passed
@phip1611 phip1611 deleted the workspace branch December 9, 2025 19:22
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 17, 2025
This is the first commit of the cherry-pick from [0].

[0] cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 17, 2025
This is the last commit of the cherry-pick from [1].

`cargo rustc` is incompatible with virtual manifests, so the CI needs to
 use cargo build instead. However, passing `RUSTFLAGS="-D warnings"` via
 the environment would propagate to all dependencies, and some of them
 currently fail to build under ``-D warnings` due to issues like [0]:

```
error: creating a mutable reference to mutable static
  --> src/temp.rs:97:5
   |
97 |     DIRS.pop()
   |     ^^^^^^^^^^ mutable reference to mutable static
```

To resolve this, apply ``-D warnings` only to the `cargo clippy`
commands (which apply to our workspace only) and avoid enforcing it for
the entire cargo build.

[0]: https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/19962283528/job/57245376263?pr=7525
[1]: cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 17, 2025
This is the first commit of the cherry-pick from [0].

[0] cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/cloud-hypervisor that referenced this pull request Dec 17, 2025
This is the last commit of the cherry-pick from [1].

`cargo rustc` is incompatible with virtual manifests, so the CI needs to
 use cargo build instead. However, passing `RUSTFLAGS="-D warnings"` via
 the environment would propagate to all dependencies, and some of them
 currently fail to build under ``-D warnings` due to issues like [0]:

```
error: creating a mutable reference to mutable static
  --> src/temp.rs:97:5
   |
97 |     DIRS.pop()
   |     ^^^^^^^^^^ mutable reference to mutable static
```

To resolve this, apply ``-D warnings` only to the `cargo clippy`
commands (which apply to our workspace only) and avoid enforcing it for
the entire cargo build.

[0]: https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/19962283528/job/57245376263?pr=7525
[1]: cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Dec 17, 2025
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50. As our v49-based CHV version backported these changes
already, we need to adapt the Nix build of CHV.

[0] cloud-hypervisor/cloud-hypervisor#7525
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Dec 17, 2025
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50. As our v49-based CHV version backported these changes
already, we need to adapt the Nix build of CHV.

[0] cloud-hypervisor/cloud-hypervisor#7525

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50. Since we updated our Cloud Hypervisor to v50 [1], we
need to adjust that here.

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 pushed a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 6, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 7, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded our Cloud Hypervisor patchset
to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
phip1611 added a commit to phip1611/libvirt-tests that referenced this pull request Jan 7, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded our Cloud Hypervisor patchset
to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
github-merge-queue bot pushed a commit to cyberus-technology/libvirt-tests that referenced this pull request Jan 7, 2026
Since PR #7525 (Dec 2025)[0], Cloud Hypervisor uses a virtual Cargo manifest and
the main package was moved to the `./cloud-hypervisor` subdirectory. This change
is effective since v50, which we just upgraded our Cloud Hypervisor patchset
to [1].

[0] cloud-hypervisor/cloud-hypervisor#7525
[1] cyberus-technology/cloud-hypervisor#60

Signed-off-by: Philipp Schuster <[email protected]>
On-behalf-of: SAP [email protected]
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.

3 participants