mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-27 15:05:24 +00:00
vm-virtio: Add the ability to serialize a Queue
This commit relies on serde to serialize and deserialize the content of a Queue structure. This will be useful information to store when implementing snapshot/restore feature for virtio devices. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
This commit is contained in:
parent
b7faf4fdc1
commit
fd45e94510
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1454,6 +1454,7 @@ dependencies = [
|
|||||||
name = "vm-virtio"
|
name = "vm-virtio"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"devices",
|
"devices",
|
||||||
@ -1463,6 +1464,9 @@ dependencies = [
|
|||||||
"net_gen",
|
"net_gen",
|
||||||
"net_util",
|
"net_util",
|
||||||
"pci",
|
"pci",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"vhost",
|
"vhost",
|
||||||
"virtio-bindings 0.1.0 (git+https://github.com/rust-vmm/virtio-bindings)",
|
"virtio-bindings 0.1.0 (git+https://github.com/rust-vmm/virtio-bindings)",
|
||||||
|
@ -10,6 +10,7 @@ pci_support = ["pci"]
|
|||||||
mmio_support = []
|
mmio_support = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
arc-swap = ">=0.4.4"
|
arc-swap = ">=0.4.4"
|
||||||
byteorder = "1.3.4"
|
byteorder = "1.3.4"
|
||||||
devices = { path = "../devices" }
|
devices = { path = "../devices" }
|
||||||
@ -19,6 +20,9 @@ log = "0.4.8"
|
|||||||
net_gen = { path = "../net_gen" }
|
net_gen = { path = "../net_gen" }
|
||||||
net_util = { path = "../net_util" }
|
net_util = { path = "../net_util" }
|
||||||
pci = { path = "../pci", optional = true }
|
pci = { path = "../pci", optional = true }
|
||||||
|
serde = ">=1.0.27"
|
||||||
|
serde_derive = ">=1.0.27"
|
||||||
|
serde_json = ">=1.0.9"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
virtio-bindings = { git = "https://github.com/rust-vmm/virtio-bindings", version = "0.1", features = ["virtio-v5_0_0"]}
|
virtio-bindings = { git = "https://github.com/rust-vmm/virtio-bindings", version = "0.1", features = ["virtio-v5_0_0"]}
|
||||||
vm-allocator = { path = "../vm-allocator" }
|
vm-allocator = { path = "../vm-allocator" }
|
||||||
|
@ -16,6 +16,10 @@ extern crate epoll;
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
#[cfg(feature = "pci_support")]
|
#[cfg(feature = "pci_support")]
|
||||||
extern crate pci;
|
extern crate pci;
|
||||||
|
extern crate serde;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
extern crate serde_json;
|
||||||
extern crate vhost_rs;
|
extern crate vhost_rs;
|
||||||
extern crate virtio_bindings;
|
extern crate virtio_bindings;
|
||||||
extern crate vm_device;
|
extern crate vm_device;
|
||||||
|
@ -383,11 +383,15 @@ impl<'a, 'b> Iterator for AvailIter<'a, 'b> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(remote = "GuestAddress")]
|
||||||
|
struct GuestAddressDef(pub u64);
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
/// A virtio queue's parameters.
|
/// A virtio queue's parameters.
|
||||||
pub struct Queue {
|
pub struct Queue {
|
||||||
/// The maximal size in elements offered by the device
|
/// The maximal size in elements offered by the device
|
||||||
max_size: u16,
|
pub max_size: u16,
|
||||||
|
|
||||||
/// The queue size in elements the driver selected
|
/// The queue size in elements the driver selected
|
||||||
pub size: u16,
|
pub size: u16,
|
||||||
@ -398,18 +402,22 @@ pub struct Queue {
|
|||||||
/// Interrupt vector index of the queue
|
/// Interrupt vector index of the queue
|
||||||
pub vector: u16,
|
pub vector: u16,
|
||||||
|
|
||||||
|
#[serde(with = "GuestAddressDef")]
|
||||||
/// Guest physical address of the descriptor table
|
/// Guest physical address of the descriptor table
|
||||||
pub desc_table: GuestAddress,
|
pub desc_table: GuestAddress,
|
||||||
|
|
||||||
|
#[serde(with = "GuestAddressDef")]
|
||||||
/// Guest physical address of the available ring
|
/// Guest physical address of the available ring
|
||||||
pub avail_ring: GuestAddress,
|
pub avail_ring: GuestAddress,
|
||||||
|
|
||||||
|
#[serde(with = "GuestAddressDef")]
|
||||||
/// Guest physical address of the used ring
|
/// Guest physical address of the used ring
|
||||||
pub used_ring: GuestAddress,
|
pub used_ring: GuestAddress,
|
||||||
|
|
||||||
pub next_avail: Wrapping<u16>,
|
pub next_avail: Wrapping<u16>,
|
||||||
pub next_used: Wrapping<u16>,
|
pub next_used: Wrapping<u16>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
pub iommu_mapping_cb: Option<Arc<VirtioIommuRemapping>>,
|
pub iommu_mapping_cb: Option<Arc<VirtioIommuRemapping>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user