Repository navigation
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 consolerecords the boot console's attachment,console:microvm-virtio0, in the snapshot's machine contract, with reconnect policyrequire-inherited-attachmentand identity kindprovider(console.rs#L296-L306). A restore of that attachment takes the restore's own--virtio-console, and without one fails withsnapshot requires --virtio-console console as a replacement attachment(console.rs#L545-L547), as OpenVMM'sinherited_attachment_requires_matching_replacementtest 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 refusesconsole, which does not match its attachment.
In nvx-rs, at #1245's head, 2d12a8780:
runadds--virtio-console consoleto a cold boot only, and a restore's command passes no console option (run.rs#L394-L422).- The fake OpenVMM refuses
--virtio-consoleon the restore of a run (fake_openvmm.rs#L1146-L1154), so no test restores a snapshot that needs the option.
Impact
nvx-rs runcaptures no snapshot itself: it passes no--snapshot-destination, without which OpenVMM ignores a guest's snapshot request (vm_controller/microvm.rs#L129-L134), and OpenVMM refuses a host save of a microVM (vm_controller.rs#L510-L513). So the cold boots to which nvx-rs: give run's guests and one-shot sandboxes the boot console #1245 gives the boot console produce no such snapshot.- It cannot restore the snapshots that are captured elsewhere with the boot console on the terminal, such as those of a direct OpenVMM launch with
--virtio-console console, which Run recommends for typing into the guest's shell once nvx-rs: give run's guests and one-shot sandboxes the boot console #1245 lands. - Once openvmm: pin the microVM byte channel without host input #1248 lands, OpenVMM's byte channel takes no host input. Every restore that
nvx-rs runcan perform keeps a console on the byte channel, a disconnected boot console, or a listening one, none of which takes the terminal's input.
Fix
- On
--restore-snapshot DIR, readDIR/manifest.bin, and pass--virtio-console consoleif its machine contract holds the attachmentconsole:microvm-virtio0with reconnect policyrequire-inherited-attachment, and no console option otherwise.TemplateManifestcannot 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:runreads nothing of the snapshot today, and leaves its checks to OpenVMM. - Make the fake OpenVMM apply OpenVMM's rule: require
--virtio-console consoleof the restore of a snapshot whose boot console was on the terminal, and refuse it of any other. Test both restores ofnvx-rs run, and their command lines intests/cli. - Cover it end to end: a
test-microvmscenario that captures a snapshot with the boot console on the terminal, restores it throughnvx-rs run, and types into the guest's shell. - Update what Run, Usage,
nvx-rs's README, and the module documentation ofrun.rsand of the fake OpenVMM say of a restore's console.
Activity
nvx-rs: give run's guests and one-shot sandboxes the boot console
nvx-rs: let run restore snapshots whose boot console was on the terminal
test-microvm: restore a terminal boot console through nvx-rs run
nvx-rs: let run restore snapshots whose boot console was on the terminal
test-microvm: restore a terminal boot console through nvx-rs run
nvx-rs: give run's guests and one-shot sandboxes the boot console
nvx-rs: check the boot console of a restore in the fake OpenVMM