Hello there, I wanted to share a problem I'm having with libvirt, for the case someone here could know how to solve it. I'm using an Ubuntu 18.04 LTS, I have libvirtd already installed and I think I got all the dependencies installed. So, I'm using virsh net-create to create this network: <network> <name>pepito</name> <forward mode='nat'/> <bridge name='virbr2' stp='on' delay='0'/> <ip address='192.168.150.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.150.2' end='192.168.150.254'/> </dhcp> </ip> </network> And then I create a domain with this xml: <domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>ARM</name> <memory unit='KiB'>262144</memory> <currentMemory unit='KiB'>262144</currentMemory> <os> <type arch='armv7l' machine='virt-2.9'>hvm</type> <kernel>~/zImage</kernel> <cmdline>console=ttyAMA0 root=/dev/vda</cmdline> <boot dev='hd'/> </os> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-aarch64</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file=' ~/rootfs.qcow2'/> <target dev='hda' bus='virtio'/> </disk> <controller type='virtio-serial' index='0'> <address type='virtio-mmio'/> </controller> <interface type='network'> <mac address='52:54:00:09:a4:37'/> <model type='virtio'/> <source network='pepito'/> <address type='virtio-mmio'/> </interface> </devices> <qemu:commandline> <qemu:arg value='-device'/> <qemu:arg value='virtio-net-pci'/> <qemu:arg value='-netdev'/> <qemu:arg value='user,id=net1'/> </qemu:commandline> </domain> They both work as I created them in a different computer and everything works. But I'm trying it on my other Ubuntu machine, and once virsh creates the network and the domain, my VM never get an IP from that DHCP range. This is libvirtd log: abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, IP range 192.168.150.2 -- 192.168.150.254, lease time 1h abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, sockets bound exclusively to interface virbr2 abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: reading /etc/resolv.conf abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: using nameserver 127.0.0.53#53 abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read /etc/hosts - 7 addresses abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read /var/lib/libvirt/dnsmasq/pepito.addnhosts - 0 addresses abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: read /var/lib/libvirt/dnsmasq/pepito.hostsfile Does anybody know why it could be that the VM never gets an IP from the range I defined? As I said, exactly the same configuration worked in a different machine, I don't know why it does not work here. Thank you so much!! <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Hi, I've seen this before. First, the simple steps: have you started that network? (virsh start network-name) do you have installed the tools to work with bridges in your OS? can you check if the bridge exist in your OS and if the vm's interface is attached to it? In rhel you use the command brctl to do that, don't know about ubuntu... Best Regards, DR On Thu, Apr 16, 2020 at 7:32 PM Computers Issues < computerslover123@gmail.com> wrote:> Hello there, > > I wanted to share a problem I'm having with libvirt, for the case someone > here could know how to solve it. > > I'm using an Ubuntu 18.04 LTS, I have libvirtd already installed and I > think I got all the dependencies installed. So, I'm using virsh net-create > to create this network: > > <network> > <name>pepito</name> > <forward mode='nat'/> > <bridge name='virbr2' stp='on' delay='0'/> > <ip address='192.168.150.1' netmask='255.255.255.0'> > <dhcp> > <range start='192.168.150.2' end='192.168.150.254'/> > </dhcp> > </ip> > </network> > > And then I create a domain with this xml: > > <domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0 > '> > <name>ARM</name> > <memory unit='KiB'>262144</memory> > <currentMemory unit='KiB'>262144</currentMemory> > <os> > <type arch='armv7l' machine='virt-2.9'>hvm</type> > <kernel>~/zImage</kernel> > <cmdline>console=ttyAMA0 root=/dev/vda</cmdline> > <boot dev='hd'/> > </os> > > <on_poweroff>destroy</on_poweroff> > <on_reboot>restart</on_reboot> > <on_crash>destroy</on_crash> > <devices> > <emulator>/usr/bin/qemu-system-aarch64</emulator> > <disk type='file' device='disk'> > <driver name='qemu' type='qcow2'/> > <source file=' ~/rootfs.qcow2'/> > <target dev='hda' bus='virtio'/> > </disk> > <controller type='virtio-serial' index='0'> > <address type='virtio-mmio'/> > </controller> > <interface type='network'> > <mac address='52:54:00:09:a4:37'/> > <model type='virtio'/> > <source network='pepito'/> > <address type='virtio-mmio'/> > </interface> > </devices> > <qemu:commandline> > <qemu:arg value='-device'/> > <qemu:arg value='virtio-net-pci'/> > <qemu:arg value='-netdev'/> > <qemu:arg value='user,id=net1'/> > </qemu:commandline> > </domain> > > They both work as I created them in a different computer and everything > works. But I'm trying it on my other Ubuntu machine, and once virsh creates > the network and the domain, my VM never get an IP from that DHCP range. > This is libvirtd log: > > abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, IP > range 192.168.150.2 -- 192.168.150.254, lease time 1h > abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, > sockets bound exclusively to interface virbr2 > abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: reading > /etc/resolv.conf > abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: using > nameserver 127.0.0.53#53 > abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read > /etc/hosts - 7 addresses > abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read > /var/lib/libvirt/dnsmasq/pepito.addnhosts - 0 addresses > abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: read > /var/lib/libvirt/dnsmasq/pepito.hostsfile > > > Does anybody know why it could be that the VM never gets an IP from the > range I defined? As I said, exactly the same configuration worked in a > different machine, I don't know why it does not work here. > > Thank you so much!! > > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre > de virus. www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-9208904238504833900_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
Hi! First, thanks for answering. Yes, the network is already started, and I think I have installed the tools needed (as I previously installed qemu, qemu-kvm, libvirt-bin, bridge utils, virt-manager and stuff), so I think I get them. About the bridge, yeah! The vribr2 exists and is created once I use the virsh commands I said in the previous message, And, if I use the brctl show commands, I see that my VM's interface is already attached to the bridge, so that's why I do not understand what can be happening. Thanks! <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> El vie., 17 abr. 2020 a las 3:05, Daniel Romero (<romero.cl@gmail.com>) escribió:> Hi, > > I've seen this before. > > First, the simple steps: > > have you started that network? (virsh start network-name) > do you have installed the tools to work with bridges in your OS? > can you check if the bridge exist in your OS and if the vm's interface is > attached to it? In rhel you use the command brctl to do that, don't know > about ubuntu... > > > Best Regards, > DR > > > On Thu, Apr 16, 2020 at 7:32 PM Computers Issues < > computerslover123@gmail.com> wrote: > >> Hello there, >> >> I wanted to share a problem I'm having with libvirt, for the case someone >> here could know how to solve it. >> >> I'm using an Ubuntu 18.04 LTS, I have libvirtd already installed and I >> think I got all the dependencies installed. So, I'm using virsh net-create >> to create this network: >> >> <network> >> <name>pepito</name> >> <forward mode='nat'/> >> <bridge name='virbr2' stp='on' delay='0'/> >> <ip address='192.168.150.1' netmask='255.255.255.0'> >> <dhcp> >> <range start='192.168.150.2' end='192.168.150.254'/> >> </dhcp> >> </ip> >> </network> >> >> And then I create a domain with this xml: >> >> <domain type='qemu' xmlns:qemu=' >> http://libvirt.org/schemas/domain/qemu/1.0'> >> <name>ARM</name> >> <memory unit='KiB'>262144</memory> >> <currentMemory unit='KiB'>262144</currentMemory> >> <os> >> <type arch='armv7l' machine='virt-2.9'>hvm</type> >> <kernel>~/zImage</kernel> >> <cmdline>console=ttyAMA0 root=/dev/vda</cmdline> >> <boot dev='hd'/> >> </os> >> >> <on_poweroff>destroy</on_poweroff> >> <on_reboot>restart</on_reboot> >> <on_crash>destroy</on_crash> >> <devices> >> <emulator>/usr/bin/qemu-system-aarch64</emulator> >> <disk type='file' device='disk'> >> <driver name='qemu' type='qcow2'/> >> <source file=' ~/rootfs.qcow2'/> >> <target dev='hda' bus='virtio'/> >> </disk> >> <controller type='virtio-serial' index='0'> >> <address type='virtio-mmio'/> >> </controller> >> <interface type='network'> >> <mac address='52:54:00:09:a4:37'/> >> <model type='virtio'/> >> <source network='pepito'/> >> <address type='virtio-mmio'/> >> </interface> >> </devices> >> <qemu:commandline> >> <qemu:arg value='-device'/> >> <qemu:arg value='virtio-net-pci'/> >> <qemu:arg value='-netdev'/> >> <qemu:arg value='user,id=net1'/> >> </qemu:commandline> >> </domain> >> >> They both work as I created them in a different computer and everything >> works. But I'm trying it on my other Ubuntu machine, and once virsh creates >> the network and the domain, my VM never get an IP from that DHCP range. >> This is libvirtd log: >> >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, IP >> range 192.168.150.2 -- 192.168.150.254, lease time 1h >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: DHCP, >> sockets bound exclusively to interface virbr2 >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: reading >> /etc/resolv.conf >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: using >> nameserver 127.0.0.53#53 >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read >> /etc/hosts - 7 addresses >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq[13741]: read >> /var/lib/libvirt/dnsmasq/pepito.addnhosts - 0 addresses >> abr 17 00:48:11 usuario-System-Product-Name dnsmasq-dhcp[13741]: read >> /var/lib/libvirt/dnsmasq/pepito.hostsfile >> >> >> Does anybody know why it could be that the VM never gets an IP from the >> range I defined? As I said, exactly the same configuration worked in a >> different machine, I don't know why it does not work here. >> >> Thank you so much!! >> >> >> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre >> de virus. www.avast.com >> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> <#m_1529389328306967443_m_-9208904238504833900_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >> >
On 4/17/20 1:31 AM, Computers Issues wrote:> Hello there, >There is nothing obviously wrong with XMLs. Couple of things to try: 1) are you sure that the guest actually ask for an IP address? What happens when you 'dhclient eth0' from inside the guest (or whatever the equivalent is)? 2) is dnsmasq running on the host? If so, there should be /var/lib/libvirt/dnsmasq/pepito.conf file, can you share its content? 3) Firewall. A lot of times when something network related doesn't work I shut the firewall down and retry. It helps me rule one possible source out. Michal
Hello! Thanks for your answer. Well, I think it has to ask for an IP as I have the same configuration in a different machine (with the same OS) and it works, there I see the DHCP packets and so on, but not here. And yeah, that pepito.conf file exists, this is its content: ##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE ##OVERWRITTEN AND LOST. Changes to this configuration should be made using: ## virsh net-edit pepito ## or other application using the libvirt API. ## ## dnsmasq conf file created by libvirt strict-order user=libvirt-dnsmasq pid-file=/var/run/libvirt/network/pepito.pid except-interface=lo bind-dynamic interface=virbr2 dhcp-range=192.168.150.2,192.168.150.254 dhcp-no-override dhcp-authoritative dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/pepito.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/pepito.addnhosts El vie., 17 abr. 2020 a las 12:33, Michal Privoznik (<mprivozn@redhat.com>) escribió:> On 4/17/20 1:31 AM, Computers Issues wrote: > > Hello there, > > > > There is nothing obviously wrong with XMLs. Couple of things to try: > > 1) are you sure that the guest actually ask for an IP address? What > happens when you 'dhclient eth0' from inside the guest (or whatever the > equivalent is)? > > 2) is dnsmasq running on the host? If so, there should be > /var/lib/libvirt/dnsmasq/pepito.conf file, can you share its content? > > 3) Firewall. A lot of times when something network related doesn't work > I shut the firewall down and retry. It helps me rule one possible source > out. > > > Michal > >