From fe8567f6ad0055f38141f473071b30f3fe8df728 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Tue, 21 Jun 2016 12:00:45 -0400 Subject: [PATCH] qemu: support setting host-side IP addresses/routes For type='ethernet' interfaces only. (This patch had been pushed earlier in commit 0b4645a7e061abc8a4be71fe89865cf248ce6e56, but was reverted in commit 84d47a3cce71175bc1d8af596f835f66f38a190c because it had been accidentally pushed during the freeze for release 2.0.0) --- src/qemu/qemu_interface.c | 6 ++- .../qemuxml2argv-net-eth-hostip.args | 23 ++++++++++ .../qemuxml2argv-net-eth-hostip.xml | 39 ++++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-net-eth-hostip.xml | 44 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-eth-hostip.xml diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index b48ae50464..e637d21fb7 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -196,8 +196,12 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net) break; } - case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_ETHERNET: + if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0) + goto cleanup; + break; + + case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_VHOSTUSER: case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_CLIENT: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.args new file mode 100644 index 0000000000..b96c933ff1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.args @@ -0,0 +1,23 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \ +-net tap,fd=3,vlan=0,name=hostnet0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.xml new file mode 100644 index 0000000000..6d08e82fb1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-hostip.xml @@ -0,0 +1,39 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + +
+ + + + + + + + + + +