Skip to content

Commit 2890b0f

Browse files
committed
fix: bump abi version
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent 5ea4c3c commit 2890b0f

11 files changed

Lines changed: 49 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
3030
the configured level is above `OFF` rather than whether the tracing state was
3131
allocated.
3232
* **Breaking:** Virtqueue rings and pools occupy host-owned scratch before page
33-
tables. Snapshots use ABI 4 and config schema v2. Existing snapshots must be
33+
tables. Snapshots use ABI 5 and config schema v3. Existing snapshots must be
3434
regenerated.
3535
* Host virtqueue access uses checked copies and atomics across mapped scratch.
3636
Snapshot admission checks geometry, canonical ring state, and H2G buffer shape.
@@ -46,7 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4646
* Require guest logs and all host and guest function calls to use virtqueues.
4747
* Keep registered Rust guest return values typed until transport encoding so
4848
external byte results avoid intermediate FlatBuffer copies.
49-
* Store canonical virtqueue rings in versioned OCI transport layers. Config v2
49+
* Store canonical virtqueue rings in versioned OCI transport layers. Config v3
5050
rejects snapshots without transport state.
5151
* Running snapshots checkpoint dirty virtqueues before capture. Ordinary calls
5252
keep their deferred result path.

docs/snapshot-oci-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Four blob kinds per tag:
3232
* **manifest** (`application/vnd.oci.image.manifest.v1+json`). Tiny JSON
3333
pointer record selected via `index.json`. References one config and
3434
two layers by digest.
35-
* **config** (`application/vnd.hyperlight.snapshot.config.v2+json`). The
35+
* **config** (`application/vnd.hyperlight.snapshot.config.v3+json`). The
3636
snapshot descriptor: arch, hypervisor, CPU vendor, ABI version,
3737
resume address and captured registers, memory and transport layout,
3838
registered host functions, and snapshot generation counter. Loaded

docs/snapshot-versioning.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ A snapshot carries four independently evolvable version markers:
2727
(`application/vnd.hyperlight.snapshot.transport.v1`), aliased as
2828
`MT_TRANSPORT_CURRENT`. This is the binary encoding of canonical
2929
virtqueue state stored outside the memory layer.
30-
* **Config schema**, `MT_CONFIG_V2`
31-
(`application/vnd.hyperlight.snapshot.config.v2+json`), aliased as
30+
* **Config schema**, `MT_CONFIG_V3`
31+
(`application/vnd.hyperlight.snapshot.config.v3+json`), aliased as
3232
`MT_CONFIG_CURRENT`. This is the JSON shape of the config blob:
3333
field names, types, required vs optional, the descriptors the loader
3434
needs in order to reconstruct the sandbox (memory sizes, buffer
3535
sizes, `abi_version`, `hyperlight_version`, etc.). Renaming a field,
3636
changing its type, or adding a required field is a schema change and
37-
bumps this constant. Version 2 requires a transport layer.
37+
bumps this constant. Version 3 describes the virtqueue-only memory layout
38+
and requires a transport layer. Config v1 and v2 are incompatible with
39+
the current ABI.
3840

3941
The `OCI_LAYOUT_VERSION` constant is pinned by the OCI image-layout
4042
spec at `1.0.0`.

fuzz/fuzz_targets/virtq_roundtrip.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ fuzz_target!(|data: &[u8]| -> Corpus {
5151
Layout::from_base(BASE_ADDR, NonZeroU16::new(QUEUE_SIZE as u16).unwrap()).unwrap()
5252
};
5353

54-
let pool = SlotPool::new(SlotLayout::new(
55-
BASE_ADDR + ring_bytes as u64,
56-
SLOT_SIZE,
57-
QUEUE_SIZE,
58-
))
59-
.unwrap();
54+
let pool_layout =
55+
SlotLayout::new(BASE_ADDR + ring_bytes as u64, SLOT_SIZE, QUEUE_SIZE).unwrap();
56+
let pool = SlotPool::new(pool_layout).unwrap();
6057

6158
let mut producer = VirtqProducer::new(layout, mem.clone(), NoopNotifier, pool.clone());
6259
let mut consumer = VirtqConsumer::new(layout, mem, NoopNotifier);

src/hyperlight_guest/src/transport/mem.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ mod tests {
295295
let base = backing.as_mut_ptr() as u64;
296296
// SAFETY: Backing remains live until all mapped views are dropped.
297297
let mem = unsafe { GuestMemOps::from_raw_parts(base, 8) };
298-
let pool = SlotPool::new(SlotLayout::new(base, 8, 1)).unwrap();
298+
let layout = SlotLayout::new(base, 8, 1).unwrap();
299+
let pool = SlotPool::new(layout).unwrap();
299300
let allocation = pool.alloc(8).unwrap();
300301
let lease = BufferLease::new(pool.clone(), allocation);
301302

@@ -320,7 +321,8 @@ mod tests {
320321
let base = backing.as_mut_ptr() as u64;
321322
// SAFETY: Backing remains mapped for the accessor's lifetime.
322323
let mem = unsafe { GuestMemOps::from_raw_parts(base, 8) };
323-
let pool = SlotPool::new(SlotLayout::new(base + 8, 8, 1)).unwrap();
324+
let layout = SlotLayout::new(base + 8, 8, 1).unwrap();
325+
let pool = SlotPool::new(layout).unwrap();
324326
let allocation = pool.alloc(8).unwrap();
325327
let lease = BufferLease::new(pool.clone(), allocation);
326328

src/hyperlight_host/src/sandbox/snapshot/file/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl CpuVendor {
153153

154154
/// Top-level Hyperlight snapshot config JSON. Lives at
155155
/// `blobs/sha256/<config-digest>` with media type
156-
/// `application/vnd.hyperlight.snapshot.config.v2+json`.
156+
/// `application/vnd.hyperlight.snapshot.config.v3+json`.
157157
///
158158
/// In OCI terms this is the "image config" blob that the manifest's
159159
/// `config` descriptor points to. It describes the accompanying
@@ -907,7 +907,7 @@ mod schema_pin {
907907
const PINNED_CALL: &str = r#"{
908908
"hyperlight_version": "x.y.z",
909909
"arch": "x86_64",
910-
"abi_version": 4,
910+
"abi_version": 5,
911911
"hypervisor": "mshv",
912912
"cpu_vendor": "intel",
913913
"stack_top_gva": 3735928559,
@@ -1097,7 +1097,7 @@ mod schema_pin {
10971097
const PINNED_CALL: &str = r#"{
10981098
"hyperlight_version": "x.y.z",
10991099
"arch": "aarch64",
1100-
"abi_version": 4,
1100+
"abi_version": 5,
11011101
"hypervisor": "mshv",
11021102
"cpu_vendor": "intel",
11031103
"stack_top_gva": 3735928559,

src/hyperlight_host/src/sandbox/snapshot/file/media_types.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ pub(in crate::sandbox::snapshot) const MT_CONFIG_V1: &str =
88
"application/vnd.hyperlight.snapshot.config.v1+json";
99
pub(in crate::sandbox::snapshot) const MT_CONFIG_V2: &str =
1010
"application/vnd.hyperlight.snapshot.config.v2+json";
11-
pub(in crate::sandbox::snapshot) const MT_CONFIG_CURRENT: &str = MT_CONFIG_V2;
11+
pub(in crate::sandbox::snapshot) const MT_CONFIG_V3: &str =
12+
"application/vnd.hyperlight.snapshot.config.v3+json";
13+
pub(in crate::sandbox::snapshot) const MT_CONFIG_CURRENT: &str = MT_CONFIG_V3;
1214
pub(in crate::sandbox::snapshot) const MT_SNAPSHOT_V1: &str =
1315
"application/vnd.hyperlight.snapshot.memory.v1";
1416
pub(in crate::sandbox::snapshot) const MT_SNAPSHOT_CURRENT: &str = MT_SNAPSHOT_V1;
@@ -19,7 +21,7 @@ pub(in crate::sandbox::snapshot) const MT_TRANSPORT_CURRENT: &str = MT_TRANSPORT
1921
/// ABI version for the snapshot memory blob. Bumped when the
2022
/// host-guest contract for the snapshot bytes changes. See
2123
/// docs/snapshot-versioning.md.
22-
pub(in crate::sandbox::snapshot) const SNAPSHOT_ABI_VERSION: u32 = 4;
24+
pub(in crate::sandbox::snapshot) const SNAPSHOT_ABI_VERSION: u32 = 5;
2325

2426
/// OCI standard annotation key for a manifest's tag inside an image
2527
/// index. Set on the manifest descriptor in `index.json`, not on the

src/hyperlight_host/src/sandbox/snapshot/file/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use self::media_types::{
2727
ANNOTATION_ARCH, ANNOTATION_CPU, ANNOTATION_HYPERVISOR, ANNOTATION_REF_NAME,
2828
};
2929
pub(super) use self::media_types::{
30-
MT_CONFIG_CURRENT, MT_CONFIG_V1, MT_CONFIG_V2, MT_SNAPSHOT_CURRENT, MT_SNAPSHOT_V1,
31-
MT_TRANSPORT_CURRENT, MT_TRANSPORT_V1, SNAPSHOT_ABI_VERSION,
30+
MT_CONFIG_CURRENT, MT_CONFIG_V1, MT_CONFIG_V2, MT_CONFIG_V3, MT_SNAPSHOT_CURRENT,
31+
MT_SNAPSHOT_V1, MT_TRANSPORT_CURRENT, MT_TRANSPORT_V1, SNAPSHOT_ABI_VERSION,
3232
};
3333
use self::reference::{OciDigest, OciReference, OciTag};
3434
use super::{NextAction, Snapshot};
@@ -771,18 +771,19 @@ impl Snapshot {
771771
// Loader dispatch on config media type.
772772
let cfg_media = cfg_desc.media_type().to_string();
773773
match cfg_media.as_str() {
774-
MT_CONFIG_V2 => {}
775-
MT_CONFIG_V1 => {
774+
MT_CONFIG_V3 => {}
775+
MT_CONFIG_V1 | MT_CONFIG_V2 => {
776776
return Err(crate::new_error!(
777-
"snapshot config v1 is incompatible with snapshot ABI {}",
777+
"snapshot config media type {:?} is incompatible with snapshot ABI {}",
778+
cfg_media,
778779
SNAPSHOT_ABI_VERSION
779780
));
780781
}
781782
other => {
782783
return Err(crate::new_error!(
783784
"unexpected config media type {:?} (supported: {:?})",
784785
other,
785-
MT_CONFIG_V2
786+
MT_CONFIG_V3
786787
));
787788
}
788789
}

src/hyperlight_host/src/sandbox/snapshot/file_tests.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,17 +1984,21 @@ fn unknown_config_media_type_rejected() {
19841984
}
19851985

19861986
#[test]
1987-
fn config_v1_rejected() {
1988-
let (_dir, path) = save_for_mutation();
1989-
rewrite_manifest(&path, |m| {
1990-
m["config"]["mediaType"] =
1991-
Value::from("application/vnd.hyperlight.snapshot.config.v1+json");
1992-
});
1993-
let err = unwrap_err_snapshot(Snapshot::checked_load(
1994-
&path,
1995-
OciTag::new("latest").unwrap(),
1996-
));
1997-
assert_err_contains(err, "incompatible with snapshot ABI 4");
1987+
fn legacy_config_versions_rejected() {
1988+
for media_type in [
1989+
"application/vnd.hyperlight.snapshot.config.v1+json",
1990+
"application/vnd.hyperlight.snapshot.config.v2+json",
1991+
] {
1992+
let (_dir, path) = save_for_mutation();
1993+
rewrite_manifest(&path, |m| {
1994+
m["config"]["mediaType"] = Value::from(media_type);
1995+
});
1996+
let err = unwrap_err_snapshot(Snapshot::checked_load(
1997+
&path,
1998+
OciTag::new("latest").unwrap(),
1999+
));
2000+
assert_err_contains(err, "incompatible with snapshot ABI 5");
2001+
}
19982002
}
19992003

20002004
#[test]
@@ -2500,7 +2504,7 @@ fn manifest_uses_correct_config_and_layer_media_types() {
25002504
serde_json::from_slice(&std::fs::read(manifest_path(&path)).unwrap()).unwrap();
25012505
assert_eq!(
25022506
manifest["config"]["mediaType"].as_str().unwrap(),
2503-
"application/vnd.hyperlight.snapshot.config.v2+json"
2507+
"application/vnd.hyperlight.snapshot.config.v3+json"
25042508
);
25052509
assert_eq!(manifest["layers"].as_array().unwrap().len(), 2);
25062510
assert_eq!(
@@ -2516,7 +2520,7 @@ fn manifest_uses_correct_config_and_layer_media_types() {
25162520
// that falls back to `config.mediaType` sees the same value.
25172521
assert_eq!(
25182522
manifest["artifactType"].as_str().unwrap(),
2519-
"application/vnd.hyperlight.snapshot.config.v2+json"
2523+
"application/vnd.hyperlight.snapshot.config.v3+json"
25202524
);
25212525
}
25222526

src/hyperlight_host/src/sandbox/snapshot/tripwires.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use super::file::{
1616
SNAPSHOT_ABI_VERSION,
1717
};
1818

19-
const EXPECTED_ABI_VERSION: u32 = 4;
20-
const EXPECTED_MT_CONFIG: &str = "application/vnd.hyperlight.snapshot.config.v2+json";
19+
const EXPECTED_ABI_VERSION: u32 = 5;
20+
const EXPECTED_MT_CONFIG: &str = "application/vnd.hyperlight.snapshot.config.v3+json";
2121
const EXPECTED_MT_SNAPSHOT: &str = "application/vnd.hyperlight.snapshot.memory.v1";
2222
const EXPECTED_MT_TRANSPORT: &str = "application/vnd.hyperlight.snapshot.transport.v1";
2323
const EXPECTED_OCI_LAYOUT_VERSION: &str = "1.0.0";

0 commit comments

Comments
 (0)