你可以注册通知,以在qvm进程实例退出时得到通知。这样你就可以采取相应的措施来响应这种终止事件。
一、控制终止
你可以写一个最简单的vdev在qvm进程实例退出时来执行适当的操作。例如,因为guest已经关闭或没有响应。下面的示例来自一个虚构的 vdev qvmterm,该函数仅包含一个控制函数,该函数仅在其 qvm 进程实例终止时才注册以接收回调。
这个vdev控制函数仅在qvm进程实例退出时被调用:
qvmterm_control(vdev_t *vdp, unsigned const ctrl, const char *const arg) {
struct term_state *state = vdp->v_device;
switch (ctrl) {
case VDEV_CTRL_TERMINATE:
// The qvm is terminating.
// Do any cleanup necessary for the vdev: end any worker threads
// it created, close its connections to backend drivers, etc.
// In this example, one worker thread was created by this vdev from
// the vdev_thread_create() function when the guest was configured
// (VDEV_CTRL_GUEST_CONFIGURED message block).
// End the thread.
pthread_ca
订阅专栏 解锁全文
6523



被折叠的 条评论
为什么被折叠?



