Hello, we have been looking for other options to do this, and found
that we can add qemu lines to the vm's xml for libvirt.
What we want libvirt to do can be done with a qemu line like this:
qemu -boot c -net nic,vlan=0,macaddr=02:fd:00:04:01:00,name=eth0
-net tap,vlan=0,ifname=ubuntu-e0,script=no ubuntu.img
Which means that inside the host we connect a new tap device to the
interface ubuntu-e0, and then connect the tap device of the host with
the guest's nic, eth0. This provides connectivity between host and
guest.
The way to do this with libvirt seems with the tag <qemu:commandline>,
which allows us to append some qemu lines. So now the definition file
of the vm for libvirt looks like this:
</domain>
...
<interface type="network" name="eth0"
onboot="yes">
<source network="default"/>
<mac address="02:fd:00:04:01:00"/>
</interface>
...
<qemu:commandline>
<qemu:arg value="-net"/>
<qemu:arg value="nic,macaddr=02:fd:00:04:01:00"/>
<qemu:arg value="-net"/>
<qemu:arg value="tap,ifname=ubuntu-e0,script=no"/>
</qemu:commandline>
</domain>
With this, the guest shows the eth0 interface correctly configured.
However there is no connectivity with the host. If we look at the log
file, we find that some of the qemu options of the xml are missing,
like the name oh the host's interface to be associated with the tap
device ("ifname=ubuntu-e0"):
# tail -f /var/log/libvirt/qemu/ubuntu.log
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.12 -cpu qemu32 -enable-kvm
-m 256 -smp 1 -name ubuntu -uuid fb6e6954-53c6-7982-7b55-04edd406b871
-chardev socket,id=monitor,path=/var/lib/libvirt/qemu/ubuntu.monitor,server,nowait
-monitor chardev:monitor -boot cd -drive
file=/root/.vnx/scenarios/simple_ubuntu/vms/ubuntu/fs/root_cow_fs,if=ide,index=0,boot=on,format=qcow2
-drive
file=/root/.vnx/scenarios/simple_ubuntu/vms/ubuntu/fs/opt_fs.iso,if=ide,media=cdrom,index=1
-net nic,macaddr=02:fd:00:04:01:00,vlan=0,name=nic.0 -net
tap,fd=16,vlan=0,name=tap.0 -net
nic,macaddr=02:fd:00:04:01:01,vlan=1,name=nic.1 -net
tap,fd=17,vlan=1,name=tap.1 -chardev pty,id=serial0 -serial
chardev:serial0 -chardev
socket,id=serial1,path=/root/.vnx/scenarios/simple_ubuntu/vms/ubuntu/ubuntu_socket,server,nowait
-serial chardev:serial1 -parallel none -usb -vnc :1 -vga cirrus
char device redirected to /dev/pts/8
What am i doing wrong? How can i specify the name of the host's interface?
regards,
Jorge
On Wed, Apr 13, 2011 at 14:29, Jorge Somavilla <somavilla(a)dit.upm.es> wrote:
Hi! hopefully someone can give me a hint with this:
I need to create a vm with a point-to-point connection to the host
using a /30 subnet. Right now i have this in the vm's xml for libvirt:
<interface type="network" name="eth0" onboot="yes">
<source network="default"/>
<mac address="02:fd:00:00:01:00"/>
</interface>
Which brings up an interface in the vm that is configured later by a a
daemon, getting to this:
vnx@r2:~$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 02:fd:00:00:01:00
inet addr:10.250.0.2 Bcast:10.250.0.3 Mask:255.255.255.252
While in the host the other interface is created:
root@tau:/home/jorge/workspace/vnx# ifconfig r2-e0
r2-e0 Link encap:Ethernet HWaddr 0a:81:b6:3c:24:15
inet addr:10.250.0.1 Bcast:10.250.0.3 Mask:255.255.255.252
However there is no connectivity between them, probably because of
some mistake in the <interface> tag, perhaps a wrong 'type' attribute,
but i haven't found out yet. I wouldn't want to create a bridge and
connect both interfaces (vm's and host's) to the bridge, but to have
this ptp, if possible. How would i go about doing that?
thanks!
Jorge