virt-manager/QEMU networking

From Gentoo Wiki
Jump to:navigation Jump to:search
Warning
This page has been nominated for deletion.

The given reason is: Duplicate of Libvirt/QEMU_networking

If you disagree with its deletion, do not remove this notice; discuss your objections on the associated discussion page.

Administrators, please remember to check if anything links here and the page history before deleting.

This notice should remain for a minimum of 1 month after it was placed on the page. If discussion is still ongoing it should remain until a consensus is reached, at which time the page may be deleted or this notice may be removed. (However, if the page has only been edited by the user who nominated it for deletion and/or is in the nominator's user space, then a speedy deletion may be called for.)
This article is a stub. Please help out by expanding it - how to get started.

This article details the setup of networking using a virt-manager GUI frontend tool libvirt library and libvirtd API.

Important
If a QEMU front-end is to be used (other than of libvirt and /usr/bin/virsh), disregard the rest of this wiki page and consult the QEMU front-ends wiki page for the desire front-end in which to do the network configuration.

Packages required

In all probability, bridge-utils is not installed by most Gentoo Installation ISO CD. If not, then run:

root #emerge --ask net-misc/bridge-utils

Check that libvirt package is installed properly, having had started the libvirtd service; and that API communication with libvirt daemon is working.

root #virsh sysinfo
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>Dell Inc.</entry>
    <entry name='version'>A22</entry>
    <entry name='date'>11/29/2018</entry>
    <entry name='release'>4.6</entry>
  </bios>
  <system>
    <entry name='manufacturer'>Dell Inc.</entry>
    <entry name='product'>OptiPlex 3010</entry>
    <entry name='version'>01</entry>
    <entry name='serial'>JRJ0SW1</entry>
    <entry name='uuid'>4c4c4544-0052-4a10-8030-cac04f535731</entry>
    <entry name='sku'>OptiPlex 3010</entry>
    <entry name='family'>Not Specified</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>Dell Inc.</entry>
    <entry name='product'>042P49</entry>
    <entry name='version'>A00</entry>
    <entry name='serial'>/JRJ0SW1/CN701632BD05R5/</entry>
    <entry name='asset'>Not Specified</entry>
    <entry name='location'>Not Specified</entry>
  </baseBoard>
  <chassis>
    <entry name='manufacturer'>Dell Inc.</entry>
    <entry name='version'>Not Specified</entry>
    <entry name='serial'>JRJ0SW1</entry>
    <entry name='asset'>Not Specified</entry>
    <entry name='sku'>To be filled by O.E.M.</entry>
  </chassis>
  <processor>
    <entry name='socket_destination'>CPU 1</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Core i5</entry>
    <entry name='manufacturer'>Intel(R) Corporation</entry>
    <entry name='signature'>Type 0, Family 6, Model 58, Stepping 9</entry>
    <entry name='version'>Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz</entry>
    <entry name='external_clock'>100 MHz</entry>
    <entry name='max_speed'>3200 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>Not Specified</entry>
    <entry name='part_number'>Fill By OEM</entry>
  </processor>
  <memory_device>
    <entry name='size'>8 GB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM1</entry>
    <entry name='bank_locator'>Not Specified</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MT/s</entry>
    <entry name='manufacturer'>8C26</entry>
    <entry name='serial_number'>00000000</entry>
    <entry name='part_number'>TIMETEC-UD3-1600</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8 GB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM2</entry>
    <entry name='bank_locator'>Not Specified</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MT/s</entry>
    <entry name='manufacturer'>8C26</entry>
    <entry name='serial_number'>00000000</entry>
    <entry name='part_number'>TIMETEC-UD3-1600</entry>
  </memory_device>
  <oemStrings>
    <entry>Dell System</entry>
    <entry>1[0585]</entry>
    <entry>3[1.0]
</entry>
    <entry>12[www.dell.com]
</entry>
    <entry>14[1]</entry>
    <entry>15[11]</entry>
  </oemStrings>
</sysinfo>

If virsh appears to hang, then (re-)start the libvirtd daemon:

root #rc-service libvirtd start

# for OpenRC initd

root #systemctl start libvirtd

# for systemd initd

Documentation legend

If the host OS is not a Gentoo OS, consult the corresponding OS guide on network installation and replace the following Gentoo Ethernet device names throughout the document with that OS's device name nomenclature.

  • virbr0 netdev - virtual bridge with NAT
  • enp3s0 netdev - slave to virbr0 - WAN-side

And optionally have the following netdevs/IP-links:

  • enp4s0 netdev - DMZ-side (optional)
  • enp5s0 netdev - Internal LAN-side (optional)
  • virbr1 netdev - closed network
Warning
Ensure that any existing firewall setup does not already use the chain name nat, for libvirt already owns nat chain name.

Assess current network

There are three camps of current network setups:

1. default network connection is provided by libvirt. 2. No interface defined, fresh install 3. multiple IP netdevs/links already configured.

1. Default network connection

Check the libvirtd for any existing network connections; a fresh install of app-emulation/libvirt should leave at least a default network:

root #virsh net-list
 Name        State    Autostart   Persistent
----------------------------------------------
 default     active   yes         yes


2. Fresh install

If a default network connection exist, skip this section and go on to "Multiple IP Links Configured" section.

Missing a default network connection means that app-emulation/libvirt may not have been installed correctly or that default network may have been deleted.

To recreate the default network using libvirt default settings, execute:

root #cp -i /usr/share/libvirt/networks/default.xml /etc/libvirt/qemu/networks/default.xml
root #virsh net-define /usr/share/libvirt/networks/default.xml
Network test defined from /usr/share/libvirt/networks/default.xml

After the virsh net-define command completes, libvirt will auto-assign a new but non-conflicting IP subnet to co-exist with your host's networking setup.

To change the IP address of this host, IP subnet, and DHCP IP range, execute:

root #virsh net-edit default

then save the network XML file.

Test the default network by asking the libvirtd daemon to see this new default file:

root #virsh net-list --all
 Name        State    Autostart   Persistent
----------------------------------------------
 default     inactive   no          yes

Enable the default network so that it starts during boot-up time:

root #virsh net-autostart default
Network test marked as autostarted

Start the default network:

root #virsh net-start default
Network default started

See also

  • Virtualization — the concept and technique that permits running software in an environment separate from a computer operating system.
  • QEMU — a generic, open source hardware emulator and virtualization suite.
  • QEMU/QEMU front-ends — user interface application to the QEMU/libvirt API/library.
  • Libvirt — a virtualization management toolkit.
  • Libvirt/QEMU_networking — details the setup of Gentoo networking by Libvirt for use by guest containers and QEMU-based virtual machines.
  • Libvirt/QEMU_guest — covers libvirt and its creation of a virtual machine (VM) for use under the soft-emulation mode QEMU hypervisor Type-2, notably using virsh command.
  • Virt-manager — desktop user interface for management of virtual machines and containers through the libvirt library
  • Virt-manager/QEMU_guest — QEMU creation of a guest (VM or container)
  • QEMU/Linux guest — describes the setup of a Gentoo Linux guest in QEMU using Gentoo bootable media.