1use crate::config::DeviceVtl;
7use guid::Guid;
8use mesh::CancelContext;
9use mesh::MeshPayload;
10use mesh::error::RemoteError;
11use mesh::payload::message::ProtobufMessage;
12use mesh::rpc::FailableRpc;
13use mesh::rpc::Rpc;
14use std::fs::File;
15use vm_resource::Resource;
16use vm_resource::kind::PciDeviceHandleKind;
17use vm_resource::kind::VmbusDeviceHandleKind;
18
19#[derive(MeshPayload)]
20pub enum VmRpc {
21 Save(FailableRpc<(), ProtobufMessage>),
22 Resume(Rpc<(), bool>),
23 Pause(Rpc<(), bool>),
24 ClearHalt(Rpc<(), bool>),
25 Reset(FailableRpc<(), ()>),
26 Nmi(Rpc<u32, ()>),
27 AddVmbusDevice(FailableRpc<(DeviceVtl, Resource<VmbusDeviceHandleKind>), ()>),
28 ConnectHvsock(FailableRpc<(CancelContext, Guid, DeviceVtl), unix_socket::UnixStream>),
29 AddHvsockListener(FailableRpc<(DeviceVtl, Guid, unix_socket::UnixListener), ()>),
30 RemoveHvsockListener(FailableRpc<(DeviceVtl, Guid), ()>),
31 PulseSaveRestore(Rpc<(), Result<(), PulseSaveRestoreError>>),
32 StartReloadIgvm(FailableRpc<File, ()>),
33 CompleteReloadIgvm(FailableRpc<bool, ()>),
34 ReadMemory(FailableRpc<(u64, usize), Vec<u8>>),
35 WriteMemory(FailableRpc<(u64, Vec<u8>), ()>),
36 UpdateCliParams(FailableRpc<String, ()>),
39 AddPcieDevice(FailableRpc<(String, Resource<PciDeviceHandleKind>), ()>),
42 RemovePcieDevice(FailableRpc<String, ()>),
44 EjectPcieDevice(FailableRpc<(String, std::time::Duration), ()>),
46 AddVpciDevice(FailableRpc<(Guid, Resource<PciDeviceHandleKind>), ()>),
48 RemoveVpciDevice(FailableRpc<Guid, ()>),
50 DumpState(FailableRpc<File, ()>),
57}
58
59#[derive(Debug, MeshPayload, thiserror::Error)]
60pub enum PulseSaveRestoreError {
61 #[error("reset not supported")]
62 ResetNotSupported,
63 #[error("pulse save+restore failed")]
64 Other(#[source] RemoteError),
65}
66
67impl From<anyhow::Error> for PulseSaveRestoreError {
68 fn from(err: anyhow::Error) -> Self {
69 Self::Other(RemoteError::new(err))
70 }
71}