Dan MacDonald wrote on 11/28/2017 01:57 PM:
Hi qemu list
I have a CentOS 6 disk image I created with Packer which I would like
to use with a network manager bridged network interface (virbr0) under
libvirt/KVW/qemu.
I can run the image under qemu/KVM with working bridged networking
using a command such as this:
qemu-system-x86_64 -enable-kvm -cpu host -m 1024 -net nic,model=virtio
-net bridge,br=virbr0,helper=/usr/lib/qemu/qemu-bridge-helper -drive
file=c6test,if=virtio
Despite the two -net options used, only one net interface is present
on the VM and it gets assigned a local IP which I can ping from my
host. This is what I'm hoping to achieve but I have not been able to
so far when importing the image into libvirt using virt-install. I
have been trying many variations upon a command like this:
virt-install -n centos6test -r 1024 --connect qemu:///system
--os-type=linux --cpu host --os-variant=rhel6 --disk
/home/dan/PackerTest/output_centos6test/c6test,device=disk,bus=virtio
--network bridge=virbr0 --vnc --noautoconsole --import
I have also tried defining a bridged network with virsh, like so:
<network>
<name>hostbridge</name>
<forward mode="bridge"/>
<bridge name="virbr0"/>
</network>
Then importing that with `virsh net-define` and setting the network
device to use that virsh network. I've also tried using two net
devices, one bridged and one not etc etc but nothing has worked for me
so far in that none of the interfaces ever get assigned an address
after being imported into libvirt and started with virt-install whilst
everything works fine if I just run the image with the first qemu
command I gave.
I would like to be able to control my VM with virsh but this issue is
stopping me. I'm running Ubuntu 17.10 on the host.
Thanks for your help
Dan
Dan,
You may need to add a second set of this command set:
-net nic,model=virtio
-net bridge,br=virbr0,helper=/usr/lib/qemu/qemu-bridge-helper
On my systems that run the VMs when I want two Ethernet device I have the
following:
-net nic,macaddr=52:54:00:10:01:2E,vlan=0,model=e1000
-net tap,vlan=0,helper=/usr/libexec/qemu-bridge-helper
-net nic,macaddr=52:54:00:10:01:23,vlan=0,model=e1000
-net tap,vlan=0,helper=/usr/libexec/qemu-bridge-helper
I am still running an older version of QEMU since it is doing everything I
need without any problems so the "-net tap" might not be correct for what
you are doing. So I would try the following:
-net nic,model=virtio
-net bridge,br=virbr0,helper=/usr/lib/qemu/qemu-bridge-helper
-net nic,model=virtio
-net bridge,br=virbr0,helper=/usr/lib/qemu/qemu-bridge-helper
when you start the VM (yes, a duplicate of the -net commands).
Depending upon your environment setting the MAC address might be useful as
well. The MAC address prefix of 52:54:00 in the options above were selected
based what was being used in a virtual machine environment that supposedly
does not conflict with physical/real hardware MAC addresses 4 or 5 years
ago. The last 3 octets of the MAC correspond to the last 3 octets of the
intended IPv4 address of the network interface inside of the VM. It helps
prevents any potential conflicts with MACs being generated on the systems
running VMs.
A quick check has indicated the prefix 52:54:00 is used by
"Realtek/Uptech?" so you might want to use a different prefix. A check at
https://code.wireshark.org indicates 00:00:6C, 00:01:01, and 00:05:78 are 3
of around 250 or so private MAC address prefixes (word Private in the list).
But I do believe you need to add the second "-net nic" set of options.
Don