Virt-manager: Difference between revisions

imported>Softmoth
Provide instructions for getting the QEMU guest agent working under libvirt
Phobos (talk | contribs)
mNo edit summary
 
(14 intermediate revisions by 11 users not shown)
Line 1: Line 1:
== Requisites ==
[https://virt-manager.org/ Virt-manager] (a.k.a. Virtual Machine Manager) is a GUI application for managing local and remote virtual machines through [[libvirt]]. It primarily targets KVM VMs, but also manages Xen and LXC (Linux Containers).
Even though Virt-manager (using the KVM hypervisor) is able to take advantage of virtualisation capabilities without any UEFI/BIOS configuration, best performances demand that host have Vt-x and Vt-d (Intel) or AMD-V and AMD-Vi (AMD) enabled. These settings can usually be found under the UEFI/BIOS settings.


== Installation ==
== Prequisites ==
Though Virt-manager (using the KVM hypervisor) is able to take advantage of virtualisation capabilities without any UEFI/BIOS configuration, best performance demands that the host have Vt-x and Vt-d (Intel) or AMD-V and AMD-Vi (AMD) enabled.


=== NixOS ===
These settings can usually be found under the UEFI/BIOS settings.
Before 23.11:
<syntaxhighlight lang="nix">
virtualisation.libvirtd.enable = true;
programs.dconf.enable = true; # virt-manager requires dconf to remember settings
environment.systemPackages = with pkgs; [ virt-manager ];
</syntaxhighlight>


After 23.11:
== Installation ==
<syntaxhighlight lang="nix">
In your configuration file add:
virtualisation.libvirtd.enable = true;
{{File|3=virtualisation.libvirtd.enable = true;
programs.virt-manager.enable = true;
programs.virt-manager.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}}{{Note|<br/><br /><code>authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'</code>
</syntaxhighlight>
See [https://github.com/NixOS/nixpkgs/pull/261474 relevant merge request]


To resolve, add your user to the libvirtd group:


You will get a warning when you open it for the first time:
{{File|3={
  users.users.<myuser>.extraGroups = [ "libvirtd" ];
}|name=/etc/nixos/configuration.nix|lang=nix}}|leading=After rebuild, you may get the following error:}}


<code>Could not detect a default hypervisor. Make sure the appropriate QEMU/KVM virtualization packages are installed to manage virtualization on this host.
=== Networking ===
To use the default libvirt network, you will need to install the <code>dnsmasq</code> package. This is required for DNS and DCHP functionality within the network:


A virtualization connection can be manually added via File->Add Connection</code>
{{File|3=environment.systemPackages = with pkgs; [
  dnsmasq
];|name=/etc/nixos/configuration.nix|lang=nix}}


To resolve:
The default network starts off inactive, you must enable it before it is accessible. This can be done by running the following command: <syntaxhighlight lang="console"># virsh net-start default</syntaxhighlight>And if you would like to enable it automatically at boot:<syntaxhighlight lang="console">
# virsh net-autostart default
</syntaxhighlight>By default, this will enable a virtual network bridge under the name <code>virbr0</code>.


<pre>
=== Display ===
File (in the menu bar) -> Add connection
The default video may not allow different resolutions and is limited. It is recommended to use Virtio instead.


HyperVisor = QEMU/KVM
For information on how to use Virtio with your VM's, [https://wiki.libvirt.org/Virtio.html you can read up on Virtio on the libvirt wiki].
Autoconnect = checkmark


Connect
=== Shared folders ===
</pre>
To be able to share a folder with a guest, you will need 'virtiofsd'. The recommended way to solve this problem is now to add <code>pkgs.virtiofsd</code> to <code>virtualisation.libvirtd.qemu.vhostUserPackages</code>:


The same can also be achieved declaratively by setting the corresponding dconf settings with home-manager. If you want to do this instead of the imperative configuration described above, add the following snippet to your home-manager configuration:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
dconf.settings = {
virtualisation.libvirtd = {
   "org/virt-manager/virt-manager/connections" = {
   enable = true;
    autoconnect = ["qemu:///system"];
  qemu.vhostUserPackages = with pkgs; [ virtiofsd ];
    uris = ["qemu:///system"];
  };
};
};
</syntaxhighlight>
</syntaxhighlight>


You may get the following error:
===Windows Guest===
 
See [https://github.com/virtio-win/virtio-win-guest-tools-installer Virtio-win guest tools] for additional drivers for both paravirtual and emulated hardware
<code>authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'</code>
 
To resolve, add the user to the <code>libvirtd</code> group:
 
<syntaxhighlight lang="nix">
{
  users.users.<myuser>.extraGroups = [ "libvirtd" ];
}
</syntaxhighlight>
 
=== Networking ===
The default network starts off as being inactive, you must enable it before it is accessible.
This can be done by running the following command: <code>virsh net-start default</code>.  
 
By default this will enable the <code>virbr0</code> virtual network bridge.


===Guest Agent===
===Guest Agent===
Line 71: Line 52:
{
{
   services.qemuGuest.enable = true;
   services.qemuGuest.enable = true;
  services.spice-vdagentd.enable = true;  # enable copy and paste between host and guest
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 76: Line 58:
The host must [https://wiki.libvirt.org/Qemu_guest_agent.html#setting-qemu-ga-up provide the needed virtio serial port] under the special name <code>org.qemu.guest_agent.0</code>.
The host must [https://wiki.libvirt.org/Qemu_guest_agent.html#setting-qemu-ga-up provide the needed virtio serial port] under the special name <code>org.qemu.guest_agent.0</code>.


=== Wayland ===
In order to run on Wayland, virt-manager must be ran under XWayland with `$ GDK_BACKEND=x11 virt-manager` or a gdk cursor must be set. An example of setting a gdk cursor with home-manager is as follows:
  home.pointerCursor = {
    gtk.enable = true;
    package = pkgs.vanilla-dmz;
    name = "Vanilla-DMZ";
  };
[[Category:Virtualization]]
[[Category:Virtualization]]