mirror of https://gitee.com/openkylin/libvirt.git
Add QEMU monitor callbacks for basic lifecycle events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add callbacks for reset, shutdown, poweroff and stop events. Add convenience methods for emiting those events
This commit is contained in:
parent
e9f4c94301
commit
89832303d7
|
@ -703,6 +703,66 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
|
|||
}
|
||||
|
||||
|
||||
int qemuMonitorEmitShutdown(qemuMonitorPtr mon)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p", mon);
|
||||
|
||||
qemuMonitorRef(mon);
|
||||
qemuMonitorUnlock(mon);
|
||||
if (mon->cb && mon->cb->domainShutdown)
|
||||
ret = mon->cb->domainShutdown(mon, mon->vm);
|
||||
qemuMonitorLock(mon);
|
||||
qemuMonitorUnref(mon);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qemuMonitorEmitReset(qemuMonitorPtr mon)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p", mon);
|
||||
|
||||
qemuMonitorRef(mon);
|
||||
qemuMonitorUnlock(mon);
|
||||
if (mon->cb && mon->cb->domainReset)
|
||||
ret = mon->cb->domainReset(mon, mon->vm);
|
||||
qemuMonitorLock(mon);
|
||||
qemuMonitorUnref(mon);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p", mon);
|
||||
|
||||
qemuMonitorRef(mon);
|
||||
qemuMonitorUnlock(mon);
|
||||
if (mon->cb && mon->cb->domainPowerdown)
|
||||
ret = mon->cb->domainPowerdown(mon, mon->vm);
|
||||
qemuMonitorLock(mon);
|
||||
qemuMonitorUnref(mon);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qemuMonitorEmitStop(qemuMonitorPtr mon)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p", mon);
|
||||
|
||||
qemuMonitorRef(mon);
|
||||
qemuMonitorUnlock(mon);
|
||||
if (mon->cb && mon->cb->domainStop)
|
||||
ret = mon->cb->domainStop(mon, mon->vm);
|
||||
qemuMonitorLock(mon);
|
||||
qemuMonitorUnref(mon);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
||||
virConnectPtr conn)
|
||||
|
|
|
@ -76,6 +76,15 @@ struct _qemuMonitorCallbacks {
|
|||
const char *path,
|
||||
char **secret,
|
||||
size_t *secretLen);
|
||||
|
||||
int (*domainShutdown)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm);
|
||||
int (*domainReset)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm);
|
||||
int (*domainPowerdown)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm);
|
||||
int (*domainStop)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm);
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,6 +115,10 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
|
|||
char **secret,
|
||||
size_t *secretLen);
|
||||
|
||||
int qemuMonitorEmitShutdown(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitReset(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitStop(qemuMonitorPtr mon);
|
||||
|
||||
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
||||
virConnectPtr conn);
|
||||
|
|
Loading…
Reference in New Issue