Struct vmw_backdoor::EnhancedChan
source · pub struct EnhancedChan<'a> { /* private fields */ }
Expand description
Channel for enhanced-RPC transfers.
This can be acquired via BackdoorGuard::open_enhanced_chan
.
Implementations§
source§impl<'a> EnhancedChan<'a>
impl<'a> EnhancedChan<'a>
sourcepub fn open(guard: &'a mut BackdoorGuard) -> Result<Self, VmwError>
pub fn open(guard: &'a mut BackdoorGuard) -> Result<Self, VmwError>
Open an enhanced-RPC channel.
sourcepub fn close(self) -> Result<(), Self>
pub fn close(self) -> Result<(), Self>
Close the channel.
On error, this returns back the channel.
sourcepub fn get_guestinfo(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, VmwError>
pub fn get_guestinfo(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, VmwError>
Retrieve a guestinfo property.
Examples found in repository?
examples/get-guestinfo.rs (line 23)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let key = match env::args().collect::<Vec<_>>().get(1) {
Some(val) => val.clone(),
None => panic!("missing argument: key name"),
};
let is_vmw = vmw::is_vmware_cpu();
eprintln!("VMware CPU detected: {}.", is_vmw);
if !is_vmw {
panic!("Hypervisor not present");
}
let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
eprintln!("Got backdoor access.");
let mut erpc = backdoor.open_enhanced_chan().unwrap();
eprintln!("Got ERPC channel: {:?}.", erpc);
match erpc.get_guestinfo(key.as_bytes()).unwrap() {
Some(val) => {
eprintln!("Got value for key '{}'.", key);
println!("{}", String::from_utf8_lossy(&val));
}
None => panic!("Guestinfo property not found."),
};
}
sourcepub fn log(&mut self, msg: &str) -> Result<(), VmwError>
pub fn log(&mut self, msg: &str) -> Result<(), VmwError>
Log a message.
Examples found in repository?
examples/log.rs (line 23)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() {
let msg = match env::args().collect::<Vec<_>>().get(1) {
Some(val) => val.clone(),
None => "Hello world (from vmw_backdoor)".to_string(),
};
let is_vmw = vmw::is_vmware_cpu();
eprintln!("VMware CPU detected: {}.", is_vmw);
if !is_vmw {
panic!("Hypervisor not present");
}
let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
eprintln!("Got backdoor access.");
let mut erpc = backdoor.open_enhanced_chan().unwrap();
eprintln!("Got ERPC channel: {:?}.", erpc);
erpc.log(&msg).unwrap();
eprintln!("Sent log message: {}.", msg);
}
sourcepub fn report_agent(&mut self) -> Result<(), VmwError>
pub fn report_agent(&mut self) -> Result<(), VmwError>
Report agent (unmanaged) type.
Examples found in repository?
examples/report-agent.rs (line 17)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let is_vmw = vmw::is_vmware_cpu();
eprintln!("VMware CPU detected: {}.", is_vmw);
if !is_vmw {
panic!("Hypervisor not present");
}
let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
eprintln!("Got backdoor access.");
let mut erpc = backdoor.open_enhanced_chan().unwrap();
eprintln!("Got ERPC channel: {:?}.", erpc);
erpc.report_agent().unwrap();
eprintln!("Reported agent.");
}
Trait Implementations§
source§impl<'a> Debug for EnhancedChan<'a>
impl<'a> Debug for EnhancedChan<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for EnhancedChan<'a>
impl<'a> Send for EnhancedChan<'a>
impl<'a> Sync for EnhancedChan<'a>
impl<'a> Unpin for EnhancedChan<'a>
impl<'a> !UnwindSafe for EnhancedChan<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more