Skip to content

nvx-rs: run cannot restore a snapshot whose boot console was attached to the terminal #1254

Closed

Description

Summary

nvx-rs run --restore-snapshot DIR passes no --virtio-console, but OpenVMM restores a snapshot whose boot console was attached to the terminal, with --virtio-console console, only when the restore passes --virtio-console console again. So nvx-rs run cannot restore such a snapshot. It should read the snapshot's manifest, and pass --virtio-console console when the snapshot's boot console was on the terminal.

This came up in the review of #1245 (part of #549), whose cold boots of nvx-rs run pass --virtio-console console. The gap predates it, since nvx-rs run has never passed a console option to a restore, but #1248 makes it pressing: once OpenVMM's byte channel takes no host input, no restore of nvx-rs run takes the terminal's input.

Root cause

In OpenVMM, at eda13d80a, the pin of dev and of #1245, and still at 4713c539a:

  • --virtio-console console records the boot console's attachment, console:microvm-virtio0, in the snapshot's machine contract, with reconnect policy require-inherited-attachment and identity kind provider (console.rs#L296-L306). A restore of that attachment takes the restore's own --virtio-console, and without one fails with snapshot requires --virtio-console console as a replacement attachment (console.rs#L545-L547), as OpenVMM's inherited_attachment_requires_matching_replacement test checks (console.rs#L1024-L1045).
  • A restore cannot pass the option to every snapshot either. A snapshot without a boot console refuses it, with a restore-time virtio-console cannot be added to a snapshot without one (console.rs#L636-L642), and one captured with --virtio-console none, as templates are, restores without it (console.rs#L548-L553) and refuses console, which does not match its attachment.

In nvx-rs, at #1245's head, 2d12a8780:

  • run adds --virtio-console console to a cold boot only, and a restore's command passes no console option (run.rs#L394-L422).
  • The fake OpenVMM refuses --virtio-console on the restore of a run (fake_openvmm.rs#L1146-L1154), so no test restores a snapshot that needs the option.

Impact

Fix

  • On --restore-snapshot DIR, read DIR/manifest.bin, and pass --virtio-console console if its machine contract holds the attachment console:microvm-virtio0 with reconnect policy require-inherited-attachment, and no console option otherwise. TemplateManifest cannot read it as it is: it refuses every manifest that is not a template's capture (manifest.rs#L653-L669), and decodes an attachment only to check its form (manifest.rs#L1282-L1309). A decoder of the contract's attachments could serve both.
  • Decide what --dry-run, and a manifest that cannot be read, do: run reads nothing of the snapshot today, and leaves its checks to OpenVMM.
  • Make the fake OpenVMM apply OpenVMM's rule: require --virtio-console console of the restore of a snapshot whose boot console was on the terminal, and refuse it of any other. Test both restores of nvx-rs run, and their command lines in tests/cli.
  • Cover it end to end: a test-microvm scenario that captures a snapshot with the boot console on the terminal, restores it through nvx-rs run, and types into the guest's shell.
  • Update what Run, Usage, nvx-rs's README, and the module documentation of run.rs and of the fake OpenVMM say of a restore's console.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions