Can enable autostart of VMs
This commit is contained in:
@ -308,3 +308,39 @@ impl Handler<ScreenshotDomainReq> for LibVirtActor {
|
||||
Ok(png_out.into_inner())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<bool>")]
|
||||
pub struct IsDomainAutostart(pub DomainXMLUuid);
|
||||
|
||||
impl Handler<IsDomainAutostart> for LibVirtActor {
|
||||
type Result = anyhow::Result<bool>;
|
||||
|
||||
fn handle(&mut self, msg: IsDomainAutostart, _ctx: &mut Self::Context) -> Self::Result {
|
||||
log::debug!(
|
||||
"Check if autostart is enabled for a domain: {}",
|
||||
msg.0.as_string()
|
||||
);
|
||||
let domain = Domain::lookup_by_uuid_string(&self.m, &msg.0.as_string())?;
|
||||
Ok(domain.get_autostart()?)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<()>")]
|
||||
pub struct SetDomainAutostart(pub DomainXMLUuid, pub bool);
|
||||
|
||||
impl Handler<SetDomainAutostart> for LibVirtActor {
|
||||
type Result = anyhow::Result<()>;
|
||||
|
||||
fn handle(&mut self, msg: SetDomainAutostart, _ctx: &mut Self::Context) -> Self::Result {
|
||||
log::debug!(
|
||||
"Set autostart enabled={} for a domain: {}",
|
||||
msg.1,
|
||||
msg.0.as_string()
|
||||
);
|
||||
let domain = Domain::lookup_by_uuid_string(&self.m, &msg.0.as_string())?;
|
||||
domain.set_autostart(msg.1)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user