Skip to content

Commit 10ab87d

Browse files
rbradfordlikebreath
authored andcommitted
misc: Migrate away from versionize
Replace with serde instead. Fixes: cloud-hypervisor#6370 Signed-off-by: Rob Bradford <[email protected]>
1 parent dad55fc commit 10ab87d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+219
-471
lines changed

Cargo.lock

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

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ zbus = { version = "3.15.2", optional = true }
5353
# List of patched crates
5454
[patch.crates-io]
5555
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.7.0" }
56-
versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_derive", branch = "ch-0.1.6" }
5756

5857
[dev-dependencies]
5958
dirs = "5.0.1"

arch/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ log = "0.4.21"
1919
serde = { version = "1.0.197", features = ["rc", "derive"] }
2020
thiserror = "1.0.58"
2121
uuid = "1.8.0"
22-
versionize = "0.2.0"
23-
versionize_derive = "0.1.6"
2422
vm-memory = { version = "0.14.1", features = ["backend-mmap", "backend-bitmap"] }
2523
vm-migration = { path = "../vm-migration" }
2624
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }

arch/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ use std::fmt;
1818
use std::result;
1919
use std::sync::Arc;
2020
use thiserror::Error;
21-
use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
22-
use versionize_derive::Versionize;
23-
use vm_migration::VersionMapped;
2421

2522
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<vm_memory::bitmap::AtomicBitmap>;
2623
type GuestRegionMmap = vm_memory::GuestRegionMmap<vm_memory::bitmap::AtomicBitmap>;
@@ -58,7 +55,7 @@ pub enum Error {
5855
pub type Result<T> = result::Result<T, Error>;
5956

6057
/// Type for memory region types.
61-
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Versionize)]
58+
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
6259
pub enum RegionType {
6360
/// RAM type
6461
Ram,
@@ -76,8 +73,6 @@ pub enum RegionType {
7673
Reserved,
7774
}
7875

79-
impl VersionMapped for RegionType {}
80-
8176
/// Module for aarch64 related functionality.
8277
#[cfg(target_arch = "aarch64")]
8378
pub mod aarch64;

block/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ io-uring = { version = "0.6.3", optional = true }
1515
libc = "0.2.153"
1616
log = "0.4.21"
1717
remain = "0.2.13"
18+
serde = { version = "1.0.197", features = ["derive"] }
1819
smallvec = "1.13.2"
1920
thiserror = "1.0.58"
2021
uuid = { version = "1.8.0", features = ["v4"] }
21-
versionize = "0.2.0"
22-
versionize_derive = "0.1.6"
2322
virtio-bindings = { version = "0.2.2", features = ["virtio-v5_0_0"] }
2423
virtio-queue = "0.11.0"
2524
vm-memory = { version = "0.14.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }

block/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::vhdx::{Vhdx, VhdxError};
3737
#[cfg(feature = "io_uring")]
3838
use io_uring::{opcode, IoUring, Probe};
3939
use libc::{ioctl, S_IFBLK, S_IFMT};
40+
use serde::{Deserialize, Serialize};
4041
use smallvec::SmallVec;
4142
use std::alloc::{alloc_zeroed, dealloc, Layout};
4243
use std::cmp;
@@ -52,8 +53,6 @@ use std::sync::Arc;
5253
use std::sync::MutexGuard;
5354
use std::time::Instant;
5455
use thiserror::Error;
55-
use versionize::{VersionMap, Versionize, VersionizeResult};
56-
use versionize_derive::Versionize;
5756
use virtio_bindings::virtio_blk::*;
5857
use virtio_queue::DescriptorChain;
5958
use vm_memory::{
@@ -544,7 +543,7 @@ impl Request {
544543
}
545544
}
546545

547-
#[derive(Copy, Clone, Debug, Default, Versionize)]
546+
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
548547
#[repr(C, packed)]
549548
pub struct VirtioBlockConfig {
550549
pub capacity: u64,
@@ -567,7 +566,7 @@ pub struct VirtioBlockConfig {
567566
pub write_zeroes_may_unmap: u8,
568567
pub unused1: [u8; 3],
569568
}
570-
#[derive(Copy, Clone, Debug, Default, Versionize)]
569+
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
571570
#[repr(C, packed)]
572571
pub struct VirtioBlockGeometry {
573572
pub cylinders: u16,

devices/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ hypervisor = { path = "../hypervisor" }
1515
libc = "0.2.153"
1616
log = "0.4.21"
1717
pci = { path = "../pci" }
18+
serde = { version = "1.0.197", features = ["derive"] }
1819
thiserror = "1.0.58"
1920
tpm = { path = "../tpm" }
20-
versionize = "0.2.0"
21-
versionize_derive = "0.1.6"
2221
vm-allocator = { path = "../vm-allocator" }
2322
vm-device = { path = "../vm-device" }
2423
vm-memory = "0.14.1"

devices/src/ioapic.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@
1111

1212
use super::interrupt_controller::{Error, InterruptController};
1313
use byteorder::{ByteOrder, LittleEndian};
14+
use serde::{Deserialize, Serialize};
1415
use std::result;
1516
use std::sync::{Arc, Barrier};
16-
use versionize::{VersionMap, Versionize, VersionizeResult};
17-
use versionize_derive::Versionize;
1817
use vm_device::interrupt::{
1918
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
2019
MsiIrqGroupConfig, MsiIrqSourceConfig,
2120
};
2221
use vm_device::BusDevice;
2322
use vm_memory::GuestAddress;
24-
use vm_migration::{
25-
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
26-
};
23+
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
2724
use vmm_sys_util::eventfd::EventFd;
2825

2926
type Result<T> = result::Result<T, Error>;
@@ -136,15 +133,14 @@ pub struct Ioapic {
136133
interrupt_source_group: Arc<dyn InterruptSourceGroup>,
137134
}
138135

139-
#[derive(Versionize)]
136+
#[derive(Serialize, Deserialize)]
140137
pub struct IoapicState {
141138
id_reg: u32,
142139
reg_sel: u32,
143140
reg_entries: [RedirectionTableEntry; NUM_IOAPIC_PINS],
144141
used_entries: [bool; NUM_IOAPIC_PINS],
145142
apic_address: u64,
146143
}
147-
impl VersionMapped for IoapicState {}
148144

149145
impl BusDevice for Ioapic {
150146
fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) {
@@ -444,7 +440,7 @@ impl Snapshottable for Ioapic {
444440
}
445441

446442
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
447-
Snapshot::new_from_versioned_state(&self.state())
443+
Snapshot::new_from_state(&self.state())
448444
}
449445
}
450446

devices/src/legacy/gpio_pl061.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
//!
99
1010
use crate::{read_le_u32, write_le_u32};
11+
use serde::{Deserialize, Serialize};
1112
use std::result;
1213
use std::sync::{Arc, Barrier};
1314
use std::{fmt, io};
14-
use versionize::{VersionMap, Versionize, VersionizeResult};
15-
use versionize_derive::Versionize;
1615
use vm_device::interrupt::InterruptSourceGroup;
1716
use vm_device::BusDevice;
18-
use vm_migration::{
19-
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
20-
};
17+
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
2118

2219
const OFS_DATA: u64 = 0x400; // Data Register
2320
const GPIODIR: u64 = 0x400; // Direction Register
@@ -89,7 +86,7 @@ pub struct Gpio {
8986
interrupt: Arc<dyn InterruptSourceGroup>,
9087
}
9188

92-
#[derive(Versionize)]
89+
#[derive(Serialize, Deserialize)]
9390
pub struct GpioState {
9491
data: u32,
9592
old_in_data: u32,
@@ -102,8 +99,6 @@ pub struct GpioState {
10299
afsel: u32,
103100
}
104101

105-
impl VersionMapped for GpioState {}
106-
107102
impl Gpio {
108103
/// Constructs an PL061 GPIO device.
109104
pub fn new(
@@ -328,7 +323,7 @@ impl Snapshottable for Gpio {
328323
}
329324

330325
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
331-
Snapshot::new_from_versioned_state(&self.state())
326+
Snapshot::new_from_state(&self.state())
332327
}
333328
}
334329

devices/src/legacy/serial.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
// Use of this source code is governed by a BSD-style license that can be
66
// found in the LICENSE-BSD-3-Clause file.
77

8+
use serde::{Deserialize, Serialize};
89
use std::collections::VecDeque;
910
use std::sync::{Arc, Barrier};
1011
use std::{io, result};
11-
use versionize::{VersionMap, Versionize, VersionizeResult};
12-
use versionize_derive::Versionize;
1312
use vm_device::interrupt::InterruptSourceGroup;
1413
use vm_device::BusDevice;
15-
use vm_migration::{
16-
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
17-
};
14+
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
1815
use vmm_sys_util::errno::Result;
1916

2017
const LOOP_SIZE: usize = 0x40;
@@ -74,7 +71,7 @@ pub struct Serial {
7471
out: Option<Box<dyn io::Write + Send>>,
7572
}
7673

77-
#[derive(Versionize)]
74+
#[derive(Serialize, Deserialize)]
7875
pub struct SerialState {
7976
interrupt_enable: u8,
8077
interrupt_identification: u8,
@@ -86,7 +83,6 @@ pub struct SerialState {
8683
baud_divisor: u16,
8784
in_buffer: Vec<u8>,
8885
}
89-
impl VersionMapped for SerialState {}
9086

9187
impl Serial {
9288
pub fn new(
@@ -334,7 +330,7 @@ impl Snapshottable for Serial {
334330
}
335331

336332
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
337-
Snapshot::new_from_versioned_state(&self.state())
333+
Snapshot::new_from_state(&self.state())
338334
}
339335
}
340336

0 commit comments

Comments
 (0)