mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
Autostart domains using virDomainObjStart
This commit is contained in:
parent
5e3537f88a
commit
e0037c2ee8
@ -626,28 +626,30 @@ qemuAutostartDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq
|
||||
{
|
||||
virDomainObjPtr vm = payload;
|
||||
struct qemuAutostartData *data = opaque;
|
||||
virErrorPtr err;
|
||||
|
||||
virDomainObjLock(vm);
|
||||
if (vm->autostart &&
|
||||
!virDomainObjIsActive(vm)) {
|
||||
int ret;
|
||||
|
||||
virResetLastError();
|
||||
ret = qemudStartVMDaemon(data->conn, data->driver, vm, NULL, -1);
|
||||
if (ret < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
|
||||
if (qemuDomainObjBeginJobWithDriver(data->driver, vm) < 0) {
|
||||
err = virGetLastError();
|
||||
VIR_ERROR(_("Failed to start job on VM '%s': %s"),
|
||||
vm->def->name,
|
||||
err ? err->message : _("unknown error"));
|
||||
} else {
|
||||
virDomainEventPtr event =
|
||||
virDomainEventNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_STARTED,
|
||||
VIR_DOMAIN_EVENT_STARTED_BOOTED);
|
||||
if (event)
|
||||
qemuDomainEventQueue(data->driver, event);
|
||||
if (vm->autostart &&
|
||||
!virDomainObjIsActive(vm) &&
|
||||
qemudDomainObjStart(data->conn, data->driver, vm) < 0) {
|
||||
err = virGetLastError();
|
||||
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
|
||||
vm->def->name,
|
||||
err ? err->message : _("unknown error"));
|
||||
}
|
||||
|
||||
if (qemuDomainObjEndJob(vm) == 0)
|
||||
vm = NULL;
|
||||
}
|
||||
|
||||
if (vm)
|
||||
virDomainObjUnlock(vm);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user