Can enable autostart of VMs

This commit is contained in:
2023-10-28 17:30:27 +02:00
parent 9a15fb4f60
commit 335aec788e
10 changed files with 304 additions and 56 deletions

View File

@ -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(())
}
}