客户:
我在 Debian 工作站上安装了一个软件包spice-client-gtk
,该软件包连接到远程服务器,即在 QEMU-KVM 上运行虚拟机的虚拟机管理程序。spice-client-gtk
未安装在虚拟机管理程序本身上。
虚拟机:
我virt-manager
双击每个虚拟机,然后在主菜单中导航到ViewDetails.然后我选择了一个名为 的属性Display [Spice|VNC]
并将部分设置Type
为Spice server
。我还选择了左侧的另一个属性,Video [QXL|Virtio|VGA]
并将其设置Model
为QXL
。然后我单击Add Hardware,选择一个属性Channel
并将部分设置Name
为 ,com.redhat.spice.0
并将部分设置Device Type
为Spice agent (spicevmc)
。
在我安装的 Windows 虚拟机上Spice 访客工具重新启动虚拟机后,我可以在工作站和 Windows 虚拟机之间进行复制和粘贴。
在 Debian 虚拟机上,我安装了一个软件包spice-vdagent
并重新启动,但复制和粘贴不起作用。
我执行systemctl
检查服务,发现 onlyspice-vdagentd.socket
是唯一运行的服务。然后我检查了所有服务的状态:
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> systemctl status spice-vdagentd.service
● spice-vdagentd.service - Agent daemon for Spice guests
Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
Active: inactive (dead)
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> systemctl status spice-vdagent.service
● spice-vdagentd.service - Agent daemon for Spice guests
Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
Active: inactive (dead)
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> systemctl status spice-vdagentd.socket
● spice-vdagentd.socket - Activation socket for spice guest agent daemon
Loaded: loaded (/lib/systemd/system/spice-vdagentd.socket; enabled; vendor preset: enabled)
Active: active (listening) since Fri 2021-01-08 08:57:50 CET; 4min 59s ago
Listen: /var/run/spice-vdagentd/spice-vdagent-sock (Stream)
CGroup: /system.slice/spice-vdagentd.socket
Jan 08 08:57:50 localhost systemd[1]: Listening on Activation socket for spice guest agent daemon.
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> ls /lib/systemd/system/ | grep spice
-rw-r--r-- 1 root root 335 Oct 3 2018 spice-vdagentd.service
-rw-r--r-- 1 root root 280 Oct 3 2018 spice-vdagentd.socket
lrwxrwxrwx 1 root root 22 Oct 3 2018 spice-vdagent.service -> spice-vdagentd.service
请注意,服务spice-vdagent.service
是指向spice-vdagentd.service
.
现在我检查了服务的定义文件systemd
:
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> cat /lib/systemd/system/spice-vdagentd.service
[Unit]
Description=Agent daemon for Spice guests
Requires=spice-vdagentd.socket
[Service]
Type=forking
EnvironmentFile=-/etc/default/spice-vdagentd
ExecStart=/usr/sbin/spice-vdagentd $SPICE_VDAGENTD_EXTRA_ARGS
PIDFile=/var/run/spice-vdagentd/spice-vdagentd.pid
PrivateTmp=true
Restart=on-failure
[Install]
Also=spice-vdagentd.socket
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> cat /lib/systemd/system/spice-vdagentd.socket
[Unit]
Description=Activation socket for spice guest agent daemon
# only start the socket if the virtio port device exists
Requisite=dev-virtio\x2dports-com.redhat.spice.0.device
[Socket]
ListenStream=/var/run/spice-vdagentd/spice-vdagent-sock
[Install]
WantedBy=sockets.target
笔记:
配置参数的根文件夹前面
EnvironmentFile
有一个减号( ):-
EnvironmentFile=-/etc/default/spice-vdagentd
正如 @Zaroth 在他的回答中指出的那样,这不是一个错误。
我还决定创建一个/etc/default/spice-vdagentd
默认情况下不存在的。然后在里面我添加了一行,明确设置 Spice 通道,如手册页:
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> touch /etc/default/spice-vdagentd
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> echo "SPICE_VDAGENTD_EXTRA_ARGS = -s "/dev/virtio-ports/com.redhat.spice.0"
请注意,Spice chanell/dev/virtio-ports/com.redhat.spice.0
已经存在于 Debian 虚拟机上,因为我之前将其设置在virt-manager
.
我尝试重新启动 Debian 虚拟机,但仍然...复制和粘贴不起作用。
添加:
@Zaroth 建议手动启动并启用该服务spice-vdagentd.service
。我这样做了,然后检查了这两个服务的状态:
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> systemctl status spice-vdagentd.socket
● spice-vdagentd.socket - Activation socket for spice guest agent daemon
Loaded: loaded (/lib/systemd/system/spice-vdagentd.socket; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-01-08 10:08:06 CET; 2min 28s ago
Listen: /var/run/spice-vdagentd/spice-vdagent-sock (Stream)
Tasks: 0 (limit: 1149)
Memory: 0B
CGroup: /system.slice/spice-vdagentd.socket
Jan 08 10:08:06 localhost systemd[1]: Listening on Activation socket for spice guest agent daemon.
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> sudo systemctl status spice-vdagentd.service
● spice-vdagentd.service - Agent daemon for Spice guests
Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
Active: active (running) since Fri 2021-01-08 10:09:02 CET; 1min 38s ago
Process: 1263 ExecStart=/usr/sbin/spice-vdagentd $SPICE_VDAGENTD_EXTRA_ARGS (code=exited, status=0/SUCCESS)
Main PID: 1264 (spice-vdagentd)
Tasks: 1 (limit: 1149)
Memory: 520.0K
CGroup: /system.slice/spice-vdagentd.service
└─1264 /usr/sbin/spice-vdagentd -s /dev/virtio-ports/com.redhat.spice.0
Jan 08 10:09:02 localhost systemd[1]: Starting Agent daemon for Spice guests...
Jan 08 10:09:02 localhost systemd[1]: spice-vdagentd.service: Can't open PID file /run/spice-vdagentd/spice-vdagentd.pid
Jan 08 10:09:02 localhost systemd[1]: Started Agent daemon for Spice guests.
服务状态spice-vdagentd.service
报告称它无法打开 PID 文件,但我仔细检查后,每次我手动启动spice-vdagentd.service
.这里是:
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
└─> ls -l /run/spice-vdagentd/spice-vdagentd.pid
-rw-r--r-- 1 root root 5 Jan 8 10:19 /run/spice-vdagentd/spice-vdagentd.pid
这很奇怪,因为一切看起来都应该是这样,但spice-vdagentd.service
即使启用也不会启动。如何解决这个问题?
答案1
in 路径前面的减号EnvironmentFile
不是错误。这只是意味着该文件是可选的:
传递的参数应该是绝对文件名或通配符表达式,可以选择以“-”为前缀,这表示如果文件不存在,则不会读取该文件,并且不会记录错误或警告消息。
至于您的问题,让我们从基础开始。您没有在任何地方声明您实际上启用和/或启动了该服务。你尝试过简单吗systemctl enable spice-vdagentd.service && systemctl start spice-vdagentd.service
?会不会启动失败?如果是的话,journald 中的错误是什么?