python - 为什么 libvirt virdomain guest os 可能会忽略重新启动或关闭的请求?
问题描述
来自 libvirt-domain 的 virdomain 类的重启功能:
def reboot(self, flags=0):
"""Reboot a domain, the domain object is still usable thereafter, but
the domain OS is being stopped for a restart.
Note that the guest OS may ignore the request.
Additionally, the hypervisor may check and support the domain
'on_reboot' XML setting resulting in a domain that shuts down instead
of rebooting.
If @flags is set to zero, then the hypervisor will choose the
method of shutdown it considers best. To have greater control
pass one or more of the virDomainRebootFlagValues. The order
in which the hypervisor tries each shutdown method is undefined,
and a hypervisor is not required to support all methods.
To use guest agent (VIR_DOMAIN_REBOOT_GUEST_AGENT) the domain XML
must have <channel> configured.
Due to implementation limitations in some drivers (the qemu driver,
for instance) it is not advised to migrate or save a guest that is
rebooting as a result of this API. Migrating such a guest can lead
to a plain shutdown on the destination. """
ret = libvirtmod.virDomainReboot(self._o, flags)
if ret == -1: raise libvirtError ('virDomainReboot() failed', dom=self)
return ret
并且我的 qemu/kvm vm 不响应重新启动或关闭的请求,而它响应重置请求。我想知道为什么以及我能做什么。谢谢~
解决方案
您没有提到您正在使用哪个管理程序,所以我将在我的回答中假设 QEMU/KVM。
有两种方法shutdown
,reboot
可以工作。
libvirt/QEMU 采用的默认方法是注入 ACPI 电源按钮事件。大多数来宾操作系统的构建使得某些东西会看到 ACPI 事件并开始正常关闭,但情况并非总是如此。对于重新启动,libvirt 将执行相同的 ACPI 电源按钮注入,但是当客户机完成其关闭序列时,它将被重置以再次启动。
第二种可选方法是在来宾操作系统中安装 QEMU 来宾代理。然后你可以告诉 virsh 使用来宾代理来触发关机/重启。但是,如果您安装了 virtio 驱动程序包,则来宾代理仅适用于某些操作系统、现代 Linux 和 windows。
Avirsh reset
完全不同 - 这只是立即重置虚拟 CPU,导致来宾立即重新启动,而没有正常关闭过程。
推荐阅读
- node.js - MongoDB Atlas 首次连接时无法连接到服务器
- powershell - PowerShell 如何自动重启服务?
- javascript - 从 vue 导入的模拟 javascript 函数
- ios - Scenekit:子节点未正确添加到父节点
- python - best_state 在 pytorch 训练期间随模型而变化
- matrix - 逆向工程数字模式
- c++ - 减少多虚拟继承中对象(浪费)的大小
- jquery - 将函数文本返回到字符串
- python - 使用 seaborn clustermap 在层次聚类中提取聚类行
- elasticsearch - 是否可以使用 elasticsearch-dsl (python) 应用前/后标签?