I’m not sure anyone has reached a resolution yet. So here it goes for 2020:
I’m trying to run NixOS as a guest OS inside of KVM, I’ve set it up through virt-manager, and after downloading the nixos graphical installation iso from Download | Nix & NixOS here I asked virt-manager to boot it and installed it on the VM using the directions from NixOS Manual. virt-manager was about to recognize my os as nixos-20.03 and seemed to have a default profile for it.
I modified my configuration.nix file to include gnome shell, and add qemuGuest and spice-vdagentd.
The additions I added look like:
systemctl status reports that qemu-guest-agent.service is running, but spice-vdagent has some errors:
● spice-vdagentd.service - spice-vdagent daemon
Loaded: loaded (/nix/store/fn4bc6avww5vzx4lyvs913gpmm5qd1y0-unit-spice-vdagentd.service/spice-vdagentd.service; enabled; vendor preset>
Active: active (running) since Tue 2020-07-14 17:16:40 BST; 1min 18s ago
Process: 683 ExecStartPre=/nix/store/c4vnsvk19p5kmmgqhn1h4nx3f276a2x8-unit-script-spice-vdagentd-pre-start (code=exited, status=0/SUCCE>
Process: 697 ExecStart=/nix/store/s4gp0qjx75mg8n25dd7798l8lx3b85ka-spice-vdagent-0.19.0/bin/spice-vdagentd (code=exited, status=0/SUCCE>
Main PID: 700 (spice-vdagentd)
IP: 0B in, 0B out
Tasks: 1 (limit: 4915)
Memory: 1.5M
CPU: 12ms
CGroup: /system.slice/spice-vdagentd.service
└─700 /nix/store/s4gp0qjx75mg8n25dd7798l8lx3b85ka-spice-vdagent-0.19.0/bin/spice-vdagentd
Jul 14 17:16:40 emurgo systemd[1]: Starting spice-vdagent daemon...
Jul 14 17:16:40 emurgo systemd[1]: Started spice-vdagent daemon.
Jul 14 17:16:41 emurgo spice-vdagentd[700]: Error getting active session: No data available
Jul 14 17:16:41 emurgo spice-vdagentd[700]: Error getting active session: No data available
Jul 14 17:16:41 emurgo spice-vdagentd[700]: Error getting active session: No data available
Jul 14 17:16:41 emurgo spice-vdagentd[700]: Error getting active session: No data available
Jul 14 17:17:26 emurgo spice-vdagentd[700]: Error getting session for pid 1490: No data available
virt-manager also reports that there is a “qemu-ga” channel that’s “connected”. I don’t know what that means. Nevertheless, copy-and-paste between the guest and host OS does not work, and virt-manager reports that “guest agent is not available” when I go to select the auto display scaling option.
I’m also running a similar setup, and wondering how to make this work. I have a NixOS guest in virt-manager, and currently trying to figure out how to get resize-screen-to-window working.
Have you tried stopping the qemu-guest-agent service, and starting the agent manually (you’ll find its location in ps x|grep qemu)? I’m having a similar problem with qemu not being able to connect to the agent (Qemu guest agent on Hetzner Cloud doesn't work) and so far that’s the only solution I’ve found.
It’s just a priority system, and you can think of mkSure and mkForce as ‘named’ priorities that you can use instead of magic numbers like 50. IIRC if you have both mkSure true and mkSure false it just errors out.
I have the spice-vdagent as user systemd service running, but the checkbox “Auto resize VM with window” in virt-manager only became enabled after I executed spice-vdagent on the terminal. Then auto-resize also worked.
After restart I have to execute spice-vdagent again to make it work. It’s not clear what the the service is doing or if it is doing anything.
I’m having the same exact issue. What I found so far is that running spice-vdagent in the foreground mode fixes the clipboard: sudo spice-vdagent -x -d |& tee spice-vdagent.log. It’s only good for debugging purposes, though.
Still investigating what’s breaking when spice is kicked off in the daemon mode.
Quick update. This is probably obvious for anyone who knows how spice-vdagent is structured, but posting anyway.
There are two binaries here that need to run at the same time: spice-vdagentdandspice-vdagent. With the default config that we have in NixOS only the daemon is running.
From the man page:
DESCRIPTION
The spice guest agent for Linux consists of 2 parts, a system wide daemon spice-vdagentd and a X11 session agent spice-vdagent of which there is one per
X11 session.
spice-vdagent gets automatically started in desktop environments which honor /etc/xdg/autostart, and under gdm.
I made a small config change in my setup and looks like it fixed the copy-paste behavior between the vm and and host machine:
Not sure how “clean” this solution is (I just started to look into nixos a couple of days ago), but it works fine for now.
Running the same as the root user, didn’t work. I think the binary needs to be initiated for the user of a given X session.
I added volodk’s client service and it was working when I had the graphics in utm/qemu set to virtio-gpu-gl-pci. However, vscode refuses to work (draws a black window) with that. I had to switch to virtio-ramfb-gl to make vscode happy.
Now that I’ve switched, something (which I assume is spice-vdagent) no longer allows display resizing. I can drag the window border and make it bigger, but osx just shows a black border around the graphics. After ~10s, it resizes to the original size.
If I check the spice-vdagent-client status at startup it shows could not connect to X-server. If I restart the service, the logs show
display: failed to call GetCurrentState from mutter over DBUS
error message: Cannot invoke method; proxy is for the well-known name org.gnome.Mutter.Displayconfig without <...>
No guest output map, using output index as display id
I’m not sure why mutter shows up; I am using plasma6 and AFAIK don’t have any gnome stuff installed.