Skip to content

openvmm: a console write error drops microVM output a snapshot should keep #1370

Closed

Description

@tangruize

When a write to the host side of a microVM's portb console fails with an error other than BrokenPipe (for example ConnectionReset), MicrovmPortb drops all the guest output it has buffered. This also happens during a snapshot's console flush and the device's stop, so the snapshot saves an empty buffer and the restored VM never writes those bytes. The controller then logs "failed to flush microVM console output before snapshot; undelivered bytes stay in the snapshot" (openvmm/openvmm_entry/src/vm_controller/microvm.rs), and the device's stop comment says remaining bytes are saved and retried after restore. Only the host-side endpoint can cause this, and only console output is lost; guest state is not affected.

Reproduction

Have the guest write bytes to the portb data port, make the endpoint's write fail with ConnectionReset or Other, and send a snapshot flush (or stop the device). The saved state should hold the bytes. Instead its tx_buffer is empty, the restored portb never writes those bytes, and the controller logs that they stay in the snapshot. With no connected endpoint, a BrokenPipe error or a zero-length write, the bytes are kept.

Cause

MicrovmPortb::poll_tx keeps the buffered output on BrokenPipe and clears it on any other error:

// vm/devices/chipset/src/microvm.rs
Poll::Ready(Err(error)) if error.kind() == ErrorKind::BrokenPipe => {
    // ...
    return Poll::Ready(Err(error));
}
Poll::Ready(Err(error)) => {
    tracelimit::error_ratelimited!(
        // ...
        "microVM portb output failed; dropping buffered bytes"
    );
    self.tx_buffer.clear();

save serializes only what is left in tx_buffer.

Fix

No patch is attached; the retention policy needs a decision:

  • Keep the bytes on every error, and retry them later. A permanently failed endpoint then fills the 1 MiB buffer, after which new guest output is dropped, as for any full buffer; guest writes never block.
  • Keep the bytes only while a snapshot flush or stop is in progress, and drop them on errors at other times.
  • Keep today's behaviour, and correct the controller's warning and the stop comment to name the cases that keep the bytes: no endpoint, BrokenPipe, or a zero-length write.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions