提交 89832303 编写于 作者: D Daniel P. Berrange

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
上级 e9f4c943
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册