Libvirt: Difference between revisions

m Move hooks section to config
Pigs (talk | contribs)
Configuration: Add default networking section and pci passthrough section
 
(2 intermediate revisions by one other user not shown)
Line 41: Line 41:
</nowiki>}}
</nowiki>}}


=== Bridge networking ===
=== Networking ===
 
==== Default networking ====
 
To utilize the default libvirt network, you will need to install the {{nixos:package|dnsmasq}} package. This is required for DNS and DCHP functionality within the network.
 
Once the package is installed, enable and start the default network using the following commands:
 
<syntaxhighlight lang="console">
# virsh net-autostart default
# virsh net-start default
</syntaxhighlight>
 
This will configure the default network to start automatically on boot and immediately activate it.
 
==== Bridge networking ====


Create a XML file called <code>virbr0.xml</code> with the definition of the bridge interface
Create a XML file called <code>virbr0.xml</code> with the definition of the bridge interface
Line 150: Line 165:
</nowiki>}}
</nowiki>}}


==== Hooks ====
=== Hooks ===
Libvirt allows the use of hooks to run custom scripts during specific events, such as daemon lifecycle events, domain lifecycle events, and network events. On NixOS, you can configure hooks via the NixOS module to automate the placement of hook scripts in the appropriate directories.
Libvirt allows the use of hooks to run custom scripts during specific events, such as daemon lifecycle events, domain lifecycle events, and network events. On NixOS, you can configure hooks via the NixOS module to automate the placement of hook scripts in the appropriate directories.


Line 177: Line 192:
   };
   };
}
}
</syntaxhighlight>Note that after you added the configuration and switch, you'll have the following command to setup the hooks.<syntaxhighlight lang="bash">
systemctl start libvirtd-config.service
</syntaxhighlight>
</syntaxhighlight>
=== PCI Passthrough ===
For detailed instructions on configuring PCI passthrough with libvirt, refer to the [[PCI passthrough]] page.
== Clients ==
== Clients ==