Skip to content

Commit 9da525a

Browse files
committed
chore: bump rust edition
1 parent faa8dc1 commit 9da525a

File tree

19 files changed

+639
-714
lines changed

19 files changed

+639
-714
lines changed

Cargo.lock

+456-623
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ members = [
1414
anyhow = "1.0.76"
1515
fossable = "0.1.2"
1616
hex = "0.4.3"
17-
rand = "0.8.5"
17+
rand = "0.9.0"
1818
regex = "1.10.2"
1919
serde = { version = "1.0.192", features = ["derive"] }
2020
sha2 = "0.10.8"
2121
strum = { version = "0.27.1", features = ["derive"] }
2222
tracing = "0.1.40"
2323
zstd = "0.13.0"
24+
reqwest = "0.12.15"

goldboot-image/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[package]
22
authors = ["Tyler Cook"]
33
description = "Defines the goldboot image format"
4-
edition = "2021"
4+
edition = "2024"
55
homepage = "https://goldboot.fossable.org"
66
license = "AGPL-3.0-only"
77
name = "goldboot-image"
88
repository = "https://github.com/fossable/goldboot"
9-
rust-version = "1.74"
9+
rust-version = "1.85"
1010
version = "0.0.5"
1111

1212
[dependencies]
1313
aes-gcm = { version = "0.10.3", features = ["std"] }
1414
anyhow = { workspace = true }
15-
binrw = "0.13.1"
15+
binrw = "0.14.1"
1616
flate2 = "1.0.28"
1717
hex = { workspace = true }
1818
rand = { workspace = true }

goldboot-image/src/lib.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
//!
22
33
use crate::qcow::Qcow3;
4-
use aes_gcm::KeyInit;
5-
use aes_gcm::{aead::Aead, Aes256Gcm, Key, Nonce};
6-
use anyhow::bail;
7-
use anyhow::Result;
4+
use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce, aead::Aead};
5+
use anyhow::{Result, bail};
86
use binrw::{BinRead, BinReaderExt, BinWrite};
97
use rand::Rng;
108
use regex::Regex;
119
use serde::{Deserialize, Serialize};
1210
use sha2::{Digest, Sha256};
13-
use std::ffi::CStr;
14-
use std::path::PathBuf;
1511
use std::{
12+
ffi::CStr,
1613
fs::File,
1714
io::{BufReader, Cursor, Read, Seek, SeekFrom, Write},
18-
path::Path,
15+
path::{Path, PathBuf},
1916
time::{SystemTime, UNIX_EPOCH},
2017
};
2118
use strum::{Display, EnumIter};
@@ -639,16 +636,16 @@ impl ImageBuilder {
639636

640637
// Prepare cipher and RNG if the image header should be encrypted
641638
let header_cipher = new_key(self.password.clone().unwrap_or("".to_string()));
642-
let mut rng = rand::thread_rng();
639+
let mut rng = rand::rng();
643640

644641
// Prepare directory
645642
let mut directory = Directory {
646-
protected_nonce: rng.gen::<[u8; 12]>(),
643+
protected_nonce: rng.random::<[u8; 12]>(),
647644
protected_size: 0,
648-
config_nonce: rng.gen::<[u8; 12]>(),
645+
config_nonce: rng.random::<[u8; 12]>(),
649646
config_offset: 0,
650647
config_size: 0,
651-
digest_table_nonce: rng.gen::<[u8; 12]>(),
648+
digest_table_nonce: rng.random::<[u8; 12]>(),
652649
digest_table_offset: 0,
653650
digest_table_size: 0,
654651
};
@@ -658,7 +655,7 @@ impl ImageBuilder {
658655
version: 1,
659656
arch: ImageArch::Amd64, // TODO
660657
size,
661-
directory_nonce: rng.gen::<[u8; 12]>(),
658+
directory_nonce: rng.random::<[u8; 12]>(),
662659
directory_offset: 0,
663660
directory_size: 0,
664661
timestamp: SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs(),
@@ -684,15 +681,15 @@ impl ImageBuilder {
684681
} else {
685682
ClusterEncryptionType::None
686683
},
687-
cluster_key: rng.gen::<[u8; 32]>(),
684+
cluster_key: rng.random::<[u8; 32]>(),
688685
nonce_count: 0,
689686
nonce_table: vec![],
690687
};
691688

692689
if self.password.is_some() {
693690
protected_header.nonce_count = protected_header.cluster_count;
694691
protected_header.nonce_table = (0..protected_header.cluster_count)
695-
.map(|_| rng.gen::<[u8; 12]>())
692+
.map(|_| rng.random::<[u8; 12]>())
696693
.collect();
697694
}
698695

@@ -815,13 +812,15 @@ impl ImageBuilder {
815812
cluster_count += 1;
816813
}
817814
block_offset += source.header.cluster_size();
818-
// self.progress(source.header.cluster_size(), source.header.size);
815+
// self.progress(source.header.cluster_size(),
816+
// source.header.size);
819817
}
820818
} else {
821819
block_offset +=
822820
source.header.cluster_size() * source.header.l2_entries_per_cluster();
823821
// self.progress(
824-
// source.header.cluster_size() * source.header.l2_entries_per_cluster(),
822+
// source.header.cluster_size() *
823+
// source.header.l2_entries_per_cluster(),
825824
// source.header.size,
826825
// );
827826
}
@@ -891,12 +890,13 @@ mod tests {
891890
#[test]
892891
fn convert_random_data() -> Result<()> {
893892
let tmp = tempfile::tempdir()?;
893+
let rng = rand::rng();
894894

895895
// Generate file of random size and contents
896-
let size = rand::thread_rng().gen_range(512..=1000);
896+
let size = rng.gen_range(512..=1000);
897897
let mut raw: Vec<u8> = Vec::new();
898898
for _ in 0..size {
899-
raw.push(rand::thread_rng().gen());
899+
raw.push(rng.random());
900900
}
901901

902902
// Write out for qemu-img

goldboot-image/src/qcow/header.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ pub struct QcowHeader {
4444
_refcount_table_clusters: u32,
4545

4646
/// Number of snapshots contained in the image
47-
_nb_snapshots: u32,
47+
pub nb_snapshots: u32,
4848

4949
/// Offset into the image file at which the snapshot table
5050
/// starts. Must be aligned to a cluster boundary.
51-
_snapshots_offset: u64,
51+
pub snapshots_offset: u64,
5252

5353
/// Bitmask of incompatible features. An implementation must fail to open an
5454
/// image if an unknown bit is set.

goldboot-image/src/qcow/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use anyhow::bail;
2-
use anyhow::Result;
1+
use anyhow::{bail, Result};
32
use binrw::{io::SeekFrom, BinRead, BinReaderExt};
3+
use snapshot::Snapshot;
44
use std::{
55
fs::File,
66
io::BufReader,
@@ -15,13 +15,19 @@ pub use header::*;
1515
pub mod levels;
1616
use levels::*;
1717

18+
mod snapshot;
19+
1820
/// Represents a (stripped down) qcow3 file on disk.
1921
#[derive(BinRead, Debug)]
2022
#[brw(big)]
2123
pub struct Qcow3 {
2224
/// The image header
2325
pub header: QcowHeader,
2426

27+
/// List of snapshots present within this qcow
28+
#[br(seek_before = SeekFrom::Start(header.snapshots_offset), count = header.nb_snapshots)]
29+
pub snapshots: Vec<Snapshot>,
30+
2531
/// The "active" L1 table
2632
#[br(seek_before = SeekFrom::Start(header.l1_table_offset), count = header.l1_size)]
2733
pub l1_table: Vec<L1Entry>,

goldboot-image/src/qcow/snapshot.rs

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
use super::levels::L1Entry;
2+
use binrw::{BinRead, binread, io::SeekFrom};
3+
4+
/// An entry in the snapshot table representing the system state at a moment in
5+
/// time
6+
#[binread]
7+
#[derive(Debug)]
8+
pub struct Snapshot {
9+
/// Offset into the image file at which the L1 table for the
10+
/// snapshot starts. Must be aligned to a cluster boundary.
11+
#[br(temp)]
12+
l1_table_offset: u64,
13+
14+
/// Number of entries in the L1 table of the snapshots
15+
#[br(temp)]
16+
l1_entry_count: u32,
17+
18+
/// Table of L1 entries in the screenshot
19+
#[br(restore_position, seek_before = SeekFrom::Start(l1_table_offset), count = l1_entry_count)]
20+
pub l1_table: Vec<L1Entry>,
21+
22+
/// Length of the unique ID string describing the snapshot
23+
#[br(temp)]
24+
unique_id_len: u16,
25+
26+
/// Length of the name of the snapshot
27+
#[br(temp)]
28+
name_len: u16,
29+
30+
/// Time at which the snapshot was taken since the Epoch
31+
pub time: SnapshotTime,
32+
33+
/// Time that the guest was running until the snapshot was taken in
34+
/// nanoseconds
35+
pub guest_runtime: u64,
36+
37+
/// Size of the VM state in bytes. 0 if no VM state is saved.
38+
///
39+
/// If there is VM state, it starts at the first cluster
40+
/// described by first L1 table entry that doesn't describe a
41+
/// regular guest cluster (i.e. VM state is stored like guest
42+
/// disk content, except that it is stored at offsets that are
43+
/// larger than the virtual disk presented to the guest)
44+
pub vm_state_size: u32,
45+
46+
#[br(temp)]
47+
extra_data_size: u32,
48+
49+
/// Optional extra snapshot data that comes from format updates
50+
#[br(pad_size_to = extra_data_size)]
51+
#[br(args(extra_data_size))]
52+
pub extra_data: SnapshotExtraData,
53+
54+
/// A unique identifier for the snapshot (example value: "1")
55+
#[br(count = unique_id_len, try_map = String::from_utf8)]
56+
pub unique_id: String,
57+
58+
/// Name of the snapshot
59+
#[br(count = name_len, try_map = String::from_utf8)]
60+
pub name: String,
61+
}
62+
63+
/// Optional extra snapshot data that comes from format updates
64+
///
65+
/// **Note:** Version 3 snapshots must have both vm_state_size and
66+
/// virtual_disk_size present.
67+
#[derive(BinRead, Debug)]
68+
#[br(import(size: u32))]
69+
pub struct SnapshotExtraData {
70+
/// Size of the VM state in bytes. 0 if no VM state is saved. If this field
71+
/// is present, the 32-bit value in Snapshot.vm_state_size is ignored.
72+
#[br(if(size >= 8))]
73+
pub vm_state_size: u64,
74+
75+
/// Virtual disk size of the snapshot in bytes
76+
#[br(if(size >= 16))]
77+
pub virtual_disk_size: Option<u64>,
78+
79+
/// icount value which corresponds to the record/replay instruction count
80+
/// when the snapshot was taken. Set to -1 if icount was disabled
81+
#[br(if(size >= 24))]
82+
pub instruction_count: Option<i64>,
83+
}
84+
85+
/// Represents the time a snapshot was taken in the form of seconds,
86+
/// nanoseconds. The nanoseconds represent the sub-second time of the snapshot.
87+
#[derive(BinRead, Debug)]
88+
pub struct SnapshotTime {
89+
/// Seconds since the unix epoch
90+
pub secs: u32,
91+
92+
/// Subsecond portion of time in nanoseconds
93+
pub nanosecs: u32,
94+
}

goldboot-linux/Cargo.toml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
[package]
22
authors = ["Tyler Cook"]
33
description = "A command-line application for building goldboot images"
4-
edition = "2021"
4+
edition = "2024"
55
homepage = "https://goldboot.org"
66
license = "AGPL-3.0-only"
77
name = "goldboot-linux"
88
repository = "https://github.com/fossable/goldboot"
9-
rust-version = "1.74"
9+
rust-version = "1.85"
1010
version = "0.0.3"
1111

1212
[dependencies]
1313
block-utils = { version = "0.11.1" }
1414
built = { version = "0.7", features = ["chrono", "semver"] }
1515
clap = { version = "4.4.7", features = ["derive", "string"] }
16-
gdk4 = { version = "0.8.1" }
17-
gdk-pixbuf = { version = "0.19.2" }
18-
glib-macros = { version = "0.19.2" }
19-
glib = { version = "0.19.2" }
20-
goldboot-image = { path="../goldboot-image", version = "0.0.5" }
21-
goldboot = { path="../goldboot", version = "0.0.10" }
22-
gtk4 = { version = "0.8.1", features = ["v4_12"] }
16+
gdk4 = { version = "0.9.6" }
17+
gdk-pixbuf = { version = "0.20.9" }
18+
glib-macros = { version = "0.20.7" }
19+
glib = { version = "0.20.9" }
20+
goldboot-image = { path = "../goldboot-image", version = "0.0.5" }
21+
goldboot = { path = "../goldboot", version = "0.0.10" }
22+
gtk4 = { version = "0.9.6", features = ["v4_12"] }
2323
tracing = "0.1.40"
2424
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
2525
ubyte = "0.10.4"

goldboot-macros/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
authors = ["Tyler Cook"]
33
description = "Supporting macros for goldboot"
4-
edition = "2021"
4+
edition = "2024"
55
license = "AGPL-3.0-only"
66
name = "goldboot-macros"
7-
rust-version = "1.74"
7+
rust-version = "1.85"
88
version = "0.0.3"
99
repository = "https://github.com/fossable/goldboot"
1010

goldboot-macros/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn impl_prompt(ast: &syn::DeriveInput) -> TokenStream {
2323
_ => panic!(),
2424
};
2525

26-
let gen = quote! {
26+
let syntax = quote! {
2727
impl Prompt for #name {
2828
fn prompt(
2929
&mut self,
@@ -34,7 +34,7 @@ fn impl_prompt(ast: &syn::DeriveInput) -> TokenStream {
3434
}
3535
}
3636
};
37-
gen.into()
37+
syntax.into()
3838
}
3939

4040
// TODO probably need a macro for ImageMold and Fabricator

goldboot-registry/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
name = "goldboot-registry"
33
description = "A web service for hosting goldboot images"
44
version = "0.0.5"
5-
edition = "2021"
5+
edition = "2024"
66
license = "AGPL-3.0-only"
77
authors = ["Tyler Cook"]
88
readme = "README.md"
99
homepage = "https://goldboot.org"
1010
repository = "https://github.com/fossable/goldboot"
11-
rust-version = "1.74"
11+
rust-version = "1.85"
1212

1313
[dependencies]
1414
anyhow = "1.0.76"
15-
axum = "0.7.4"
15+
axum = "0.8.3"
1616
clap = { version = "4.4.7", features = ["derive", "string"] }
17-
goldboot-image = { path="../goldboot-image", version = "0.0.5" }
18-
goldboot = { path="../goldboot", version = "0.0.10" }
19-
reqwest = { version = "0.11.22", features = ["stream"] }
20-
tftpd = { version = "0.2.12", optional = true }
17+
goldboot-image = { path = "../goldboot-image", version = "0.0.5" }
18+
goldboot = { path = "../goldboot", version = "0.0.10" }
19+
reqwest = { workspace = true, features = ["stream"] }
20+
tftpd = { version = "0.3.3", optional = true }
2121
tokio = { version = "1.34.0", features = ["full"] }
2222
tracing = "0.1.40"
2323
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

goldboot-uefi/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "goldboot-uefi"
33
version = "0.1.0"
4-
edition = "2021"
5-
rust-version = "1.74"
4+
edition = "2024"
5+
rust-version = "1.85"
66

77
[dependencies]

0 commit comments

Comments
 (0)