«

麒麟v10-sp1-20210319 设置自启动qemu-guest-agent.service报错

指尖二进制 • 1 年前 • 1230 次点击 • KYLIN


麒麟v10 设置自启动qemu-guest-agent.service报错

[root@localhost ~]# systemctl enable /usr/lib/systemd/system/qemu-guest-agent.service 
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
? A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
? A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
? A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
? In case of template units, the unit is meant to be enabled with some
  instance name specified.

解决方法:
编辑文件 /usr/lib/systemd/system/qemu-guest-agent.service 在结尾增加install单元节点后再重新执行命令即可正常。

[Install]
WantedBy=multi-user.target

增加后完整内容如下:

[root@localhost ~]# cat /usr/lib/systemd/system/qemu-guest-agent.service
[Unit]
Description=QEMU Guest Agent
BindTo=dev-virtio\x2dports-org.qemu.guest_agent.0.device
After=dev-virtio\x2dports-org.qemu.guest_agent.0.device

[Service]
ExecStart=-/usr/bin/qemu-ga
Restart=always
RestartSec=0

[Install]
WantedBy=multi-user.target

测试开机启动

[root@localhost ~]# systemctl enable /usr/lib/systemd/system/qemu-guest-agent.service 
Created symlink /etc/systemd/system/multi-user.target.wants/qemu-guest-agent.service → /usr/lib/systemd/system/qemu-guest-agent.service.
[root@localhost ~]# systemctl is-enabled qemu-guest-agent.service
enabled
还没收到回复