virtio_console: add virtio console device#2973
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
There was a problem hiding this comment.
Pull request overview
Adds a new virtio-console device implementation (virtio device ID 3) that bridges a guest console (/dev/hvc0) to an existing SerialIo backend, and wires it into OpenVMM’s resource/CLI plumbing. It also extends the virtio queue API to support “peek then consume” descriptor handling and allows VirtioDevice::enable() to report failures.
Changes:
- Introduce new
virtio_consolecrate (device implementation, resolver, spec constants, and integration tests). - Extend
virtioqueue handling with a peek/consume API and refactor shared payload-reading helpers; changeVirtioDevice::enable()to returnanyhow::Result<()>. - Add
--virtio-consoleCLI flag and resource wiring so the device can be instantiated with a serial backend.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/virtio/virtio_resources/src/lib.rs | Adds a VirtioConsoleHandle resource type for configuring the new device. |
| vm/devices/virtio/virtio_console/src/lib.rs | Implements the virtio-console device and its async worker loop using peek/consume queues. |
| vm/devices/virtio/virtio_console/src/resolver.rs | Adds a resolver that instantiates VirtioConsoleDevice from resources. |
| vm/devices/virtio/virtio_console/src/spec.rs | Defines virtio-console device ID, feature bit, and config layout helpers. |
| vm/devices/virtio/virtio_console/src/tests.rs | Adds integration tests for RX/TX, disconnect/reconnect, and disable/re-enable scenarios. |
| vm/devices/virtio/virtio_console/Cargo.toml | Declares the new crate and dependencies. |
| vm/devices/virtio/virtio/src/queue.rs | Adds core support for peeking at available descriptors without advancing indices. |
| vm/devices/virtio/virtio/src/common.rs | Adds PeekedWork + helpers and exposes VirtioQueue::{try_peek,poll_peek,peek}. |
| openvmm/openvmm_resources/src/lib.rs | Registers the new VirtioConsoleResolver. |
| openvmm/openvmm_resources/Cargo.toml | Adds virtio_console dependency. |
| openvmm/openvmm_entry/src/cli_args.rs | Adds --virtio-console CLI flag. |
| openvmm/openvmm_entry/src/lib.rs | Wires CLI flag into VM config construction and adds the virtio-console device resource. |
| Cargo.toml | Adds virtio_console to workspace members/deps. |
| Cargo.lock | Records the new workspace crate in the lockfile. |
You can also share your feedback on Copilot code review. Take the survey.
a44079d to
9d94e34
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new virtio-console device to OpenVMM that bridges a guest virtio console (/dev/hvc0) to the existing SerialIo backend ecosystem, plus the resource plumbing and CLI/docs wiring needed to instantiate it from openvmm_entry.
Changes:
- Introduce
virtio_consolecrate (device implementation, resolver, spec constants, integration tests). - Extend
virtioqueue API with peek/consume support and changeVirtioDevice::enableto returnanyhow::Result<()>. - Wire
--virtio-consoleintoopenvmm_entry, register the resolver, and update the Guide CLI reference.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/virtio/virtio_resources/src/lib.rs | Adds VirtioConsoleHandle resource type for instantiating the device. |
| vm/devices/virtio/virtio_console/src/lib.rs | Implements the virtio-console device and async worker loop. |
| vm/devices/virtio/virtio_console/src/resolver.rs | Adds a resource resolver that constructs the device from a serial backend resource. |
| vm/devices/virtio/virtio_console/src/spec.rs | Defines virtio-console constants and config layout helper. |
| vm/devices/virtio/virtio_console/src/tests.rs | Adds integration-style tests driving real virtio rings in guest memory. |
| vm/devices/virtio/virtio_console/Cargo.toml | New crate manifest and dependencies. |
| vm/devices/virtio/virtio/src/queue/split.rs | Refactors split-queue availability checks to support peek without consuming. |
| vm/devices/virtio/virtio/src/queue.rs | Adds core peek/advance APIs (currently split-focused) and refactors work construction. |
| vm/devices/virtio/virtio/src/common.rs | Adds shared payload read helpers and introduces PeekedWork + VirtioQueue::peek(). |
| openvmm/openvmm_resources/src/lib.rs | Registers the new virtio-console resolver. |
| openvmm/openvmm_resources/Cargo.toml | Adds dependency on virtio_console. |
| openvmm/openvmm_entry/src/lib.rs | Instantiates virtio-console via --virtio-console and adds the device to virtio bus. |
| openvmm/openvmm_entry/src/cli_args.rs | Adds the new --virtio-console CLI flag. |
| Guide/src/reference/openvmm/management/cli.md | Documents --virtio-console alongside other serial options. |
| Cargo.toml | Adds virtio_console to workspace members/deps. |
| Cargo.lock | Locks the new crate and dependency graph updates. |
You can also share your feedback on Copilot code review. Take the survey.
|
Pulled peek changes out to #2992, will rebase once those are in. |
bf01acd to
ab4b54f
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new virtio_console device to bridge a guest virtio-console port (/dev/hvc0) to existing SerialIo backends, with supporting virtio API updates and OpenVMM CLI plumbing.
Changes:
- Introduces
virtio_consolecrate (device implementation, resolver, spec constants, and integration tests). - Extends virtio core APIs (device
enable()now returnsanyhow::Result<()>; adds queue peek/consume API). - Wires a new
--virtio-consoleCLI flag and updates the Guide CLI reference.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/virtio/virtio_resources/src/lib.rs | Adds a VirtioConsoleHandle resource definition for the new device. |
| vm/devices/virtio/virtio_console/src/lib.rs | Implements the virtio-console device + worker loop. |
| vm/devices/virtio/virtio_console/src/resolver.rs | Adds resource resolver to instantiate VirtioConsoleDevice from resources. |
| vm/devices/virtio/virtio_console/src/spec.rs | Defines virtio-console device ID, feature bits, and config layout. |
| vm/devices/virtio/virtio_console/src/tests.rs | Adds integration tests covering RX/TX, large payloads, disconnect/reconnect, and re-enable. |
| vm/devices/virtio/virtio_console/Cargo.toml | New crate manifest for virtio_console. |
| vm/devices/virtio/virtio/src/common.rs | Updates virtio device trait docs (and enable() result signature). |
| openvmm/openvmm_resources/src/lib.rs | Registers the virtio-console resolver. |
| openvmm/openvmm_resources/Cargo.toml | Adds virtio_console dependency. |
| openvmm/openvmm_entry/src/lib.rs | Instantiates virtio-console device when --virtio-console is provided. |
| openvmm/openvmm_entry/src/cli_args.rs | Adds the --virtio-console CLI flag. |
| Guide/src/reference/openvmm/management/cli.md | Documents the new CLI flag and serial backend usage. |
| Cargo.toml | Adds virtio_console to workspace dependencies. |
| Cargo.lock | Adds lockfile entry for virtio_console. |
Comments suppressed due to low confidence (1)
Guide/src/reference/openvmm/management/cli.md:53
- The doc says the
BACKENDargument is the same for all serial devices, but the list below omits options that are accepted bySerialConfigCli(e.g.file=<path>andterm[=<program>][,name=<windowtitle>]). Either expand this list to match the actual accepted values or soften the wording so it doesn’t imply the list is complete.
The `BACKEND` argument is the same for all serial devices:
* `none`: Serial output is dropped.
* `console`: Serial input is read and output is written to the console.
* `stderr`: Serial output is written to stderr.
* `listen=PATH`: A named pipe (on Windows) or Unix socket (on Linux) is set
up to listen on the given path. Serial input and output is relayed to this
pipe/socket.
* `listen=tcp:IP:PORT`: As with `listen=PATH`, but listen for TCP
connections on the given IP address and port. Typically IP will be
127.0.0.1, to restrict connections to the current host.
You can also share your feedback on Copilot code review. Take the survey.
- Assert written > 0 after poll_write to catch AsyncWrite contract violations instead of spinning forever on Ok(0). - Align --virtio-console help text with --com1 (add file overwrite note and full term syntax).
65bb230 to
dda3e20
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new virtio-console device (virtio device ID 3) that bridges a guest console (/dev/hvc0) to an arbitrary SerialIo backend, wiring it into OpenVMM’s resource system and CLI.
Changes:
- Introduces new
virtio_consolecrate with device implementation, resolver, spec constants, and integration tests. - Adds a new
virtio-consoleresource handle invirtio_resourcesand registers the resolver inopenvmm_resources. - Adds
--virtio-console <BACKEND>CLI flag and updates the OpenVMM Guide CLI reference.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/virtio/virtio_resources/src/lib.rs | Adds VirtioConsoleHandle resource definition for virtio-console devices. |
| vm/devices/virtio/virtio_console/src/lib.rs | Implements the virtio-console device and worker logic. |
| vm/devices/virtio/virtio_console/src/spec.rs | Defines virtio-console spec constants and config layout. |
| vm/devices/virtio/virtio_console/src/resolver.rs | Adds resource resolver to instantiate the device from resources. |
| vm/devices/virtio/virtio_console/src/tests.rs | Adds integration tests exercising TX/RX, disconnect/reconnect, and re-enable flows. |
| vm/devices/virtio/virtio_console/Cargo.toml | Declares the new crate and its dependencies. |
| vm/devices/virtio/virtio/src/common.rs | Updates virtio device trait documentation around enable/disable behavior. |
| openvmm/openvmm_resources/src/lib.rs | Registers the virtio-console resolver. |
| openvmm/openvmm_resources/Cargo.toml | Adds virtio_console dependency. |
| openvmm/openvmm_entry/src/cli_args.rs | Adds --virtio-console CLI option. |
| openvmm/openvmm_entry/src/lib.rs | Wires CLI flag into VM config by adding the virtio-console device. |
| Guide/src/reference/openvmm/management/cli.md | Documents the new --virtio-console flag and shared serial backend syntax. |
| Cargo.toml | Adds virtio_console to workspace members/dependencies. |
| Cargo.lock | Adds lockfile entries for the new crate. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Adds a new virtio_console device to bridge a guest virtio console (/dev/hvc0) to an existing SerialIo backend, wiring it into resource resolution and the openvmm_entry CLI.
Changes:
- Introduces the
virtio_consolecrate (device, resolver, spec constants, integration tests). - Registers
virtio-consoleas a virtio resource and resolver, and wires up--virtio-consoleCLI flag. - Updates the Guide CLI reference to document
--virtio-console.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/virtio/virtio_resources/src/lib.rs | Adds a VirtioConsoleHandle resource type for instantiating the device with a serial backend. |
| vm/devices/virtio/virtio_console/src/lib.rs | Implements the virtio-console device and worker loop (TX/RX, disconnect handling). |
| vm/devices/virtio/virtio_console/src/spec.rs | Defines virtio-console device/spec constants and config-space layout helper. |
| vm/devices/virtio/virtio_console/src/resolver.rs | Adds a resource resolver to build the device from a serial backend resource. |
| vm/devices/virtio/virtio_console/src/tests.rs | Adds integration tests that drive real virtio queues against a mock serial backend. |
| vm/devices/virtio/virtio_console/Cargo.toml | Adds the new crate’s dependencies and workspace lints. |
| vm/devices/virtio/virtio/src/common.rs | Updates VirtioDevice docs for enable/disable lifecycle expectations. |
| openvmm/openvmm_resources/src/lib.rs | Registers the virtio-console resolver. |
| openvmm/openvmm_resources/Cargo.toml | Adds virtio_console dependency. |
| openvmm/openvmm_entry/src/lib.rs | Instantiates virtio-console when --virtio-console is provided. |
| openvmm/openvmm_entry/src/cli_args.rs | Adds --virtio-console CLI option. |
| Guide/src/reference/openvmm/management/cli.md | Documents the new --virtio-console flag. |
| Cargo.toml / Cargo.lock | Adds the new crate to the workspace and lockfile. |
You can also share your feedback on Copilot code review. Take the survey.
Add a new virtio console device that bridges a guest serial port (/dev/hvc0) to any SerialIo backend.
The device uses two virtio queues — receiveq (host→guest) and transmitq (guest→host) — and supports the F_SIZE feature for reporting console dimensions. Multiport (F_MULTIPORT) is not supported.
The implementation handles backend disconnect/reconnect: when the SerialIo backend disconnects, TX descriptors are drained without forwarding until the backend reconnects.
Key changes:
virtio: add peek/consume API to VirtioQueue, allowing devices to inspect a descriptor chain before deciding whether to consume it. This complements the existing callback-based API and simplifies the console worker loop.
virtio: add VirtioDevice::enable() return type change from () to anyhow::Result<()>, allowing devices to report enablement failures to the transport layer.
virtio_console: new crate with device implementation, resolver, spec constants, and integration tests (9 tests covering TX, RX, large payloads, disconnect/reconnect, and disable/re-enable).
openvmm_entry: wire up --virtio-console CLI flag to instantiate the device with a serial backend.