qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance

qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance

问题描述

在主机通过qga 在虚拟机执行命令时出现命令无法执行的情况:
error: internal error: unable to execute QEMU agent command ;guest-exec’: The command guest-exec has been disabled for this instance
qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance

解决

因为 qemu-ga 通过命令可以获取guest 虚机较高的权限,为了安全考虑,qemu-ga 配置了一个黑名单,来禁止用户来执行某些qga命令,在黑名单中的命令通过 guest-info 查看时会显示 “enable”: false
qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance
如果想要将要执行的命令从黑名单中去掉,可以编辑qemu-ga 的配置文件 /etc/sysconfig/qemu-ga (这里以CentOS为例) 将配置中 BLACKLIST_RPC 中的命令去掉。
qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance
然后,保存文件,重启qemu-ga 服务:
systemctl restart qemu-guest-agent

也可以通过命令直接 dump 删除配置文件。
qemu-ga 执行命令无法执行: The command guest-exec has been disabled for this instance

参考

https://bugzilla.redhat.com/show_bug.cgi?id=1101556