Virt-manager: Difference between revisions

imported>Abowen
mNo edit summary
Added an explanation on how to config Virt-manager to be able to share folders with guest VM.
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
The [https://virt-manager.org/ virt-manager] application is a GUI for managing local and remote virtual machines through [[libvirt]]. It primarily targets KVM VMs, but also manages Xen and LXC (linux containers).
== Requisites ==
== Requisites ==
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.
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.
Line 5: Line 7:


=== NixOS ===
=== NixOS ===
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:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
virtualisation.libvirtd.enable = true;
virtualisation.libvirtd.enable = true;
programs.virt-manager.enable = true;
programs.virt-manager.enable = true;
</syntaxhighlight>
See [https://github.com/NixOS/nixpkgs/pull/261474 relevant merge request]
You will get a warning when you open it for the first time:
<code>Could not detect a default hypervisor. Make sure the appropriate QEMU/KVM virtualization packages are installed to manage virtualization on this host.
A virtualization connection can be manually added via File->Add Connection</code>
To resolve:
<pre>
File (in the menu bar) -> Add connection
HyperVisor = QEMU/KVM
Autoconnect = checkmark
Connect
</pre>
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">
dconf.settings = {
  "org/virt-manager/virt-manager/connections" = {
    autoconnect = ["qemu:///system"];
    uris = ["qemu:///system"];
  };
};
</syntaxhighlight>
</syntaxhighlight>


Line 61: Line 27:
=== Networking ===
=== Networking ===
The default network starts off as being inactive, you must enable it before it is accessible.
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:  
This can be done by running the following command (may require sudo):  


<code>virsh net-start default</code>
<code>virsh net-start default</code>
Line 71: Line 37:
By default this will enable the <code>virbr0</code> virtual network bridge.
By default this will enable the <code>virbr0</code> virtual network bridge.


===Display===
=== Display ===
The default Video may not allow different resolutions, `Virtio` will allow for more.
The default Video may not allow different resolutions, `Virtio` will allow for more.
=== Shared folders ===
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>:
<syntaxhighlight lang="nix">
virtualisation.libvirtd = {
  enable = true;
  qemu.vhostUserPackages = with pkgs; [ virtiofsd ];
};
</syntaxhighlight>


===Windows Guest===
===Windows Guest===
Line 83: Line 59:
{
{
   services.qemuGuest.enable = true;
   services.qemuGuest.enable = true;
  services.spice-vdagentd.enable = true;  # enable copy and paste between host and guest
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 88: Line 65:
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]]