This was accidentally left out of the patch that added support for
setting a tap device's "peer" address, which rendered the new feature
DOA.
xml2argv and xml2xml tests were added to assure it doesn't disappear
in the future.
---
src/conf/domain_conf.c | 8 +++++-
.../qemuxml2argv-net-eth-peer.args | 20 +++++++++++++
.../qemuxml2argvdata/qemuxml2argv-net-eth-peer.xml | 30 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
.../qemuxml2xmlout-net-eth-peer.xml | 33 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
6 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-eth-peer.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7ee52b..a7ae8ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19657,8 +19657,14 @@ virDomainNetIpsFormat(virBufferPtr buf, virDomainNetIpDefPtr
*ips, size_t nips)
VIR_FREE(ipStr);
if (familyStr)
virBufferAsprintf(buf, " family='%s'", familyStr);
- if (ips[i]->prefix != 0)
+ if (ips[i]->prefix)
virBufferAsprintf(buf, " prefix='%u'", ips[i]->prefix);
+ if (VIR_SOCKET_ADDR_VALID(&ips[i]->peer)) {
+ if (!(ipStr = virSocketAddrFormat(&ips[i]->peer)))
+ return -1;
+ virBufferAsprintf(buf, " peer='%s'", ipStr);
+ VIR_FREE(ipStr);
+ }
virBufferAddLit(buf, "/>\n");
}
return 0;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.args
new file mode 100644
index 0000000..ab6230f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.args
@@ -0,0 +1,20 @@
+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 \
+-device virtio-net-pci,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-peer.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.xml
new file mode 100644
index 0000000..8c22071
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-peer.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='ethernet'>
+ <mac address='00:11:22:33:44:55'/>
+ <ip address='192.168.125.1' family='ipv4' prefix='24'
peer='192.168.125.2'/>
+ <script path='/etc/qemu-ifup'/>
+ <model type='virtio'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b43f03c..eed2da9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -969,6 +969,7 @@ mymain(void)
DO_TEST("net-eth", NONE);
DO_TEST("net-eth-ifname", NONE);
DO_TEST("net-eth-names", NONE);
+ DO_TEST("net-eth-peer", NONE);
DO_TEST("net-client", NONE);
DO_TEST("net-server", NONE);
DO_TEST("net-mcast", NONE);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-eth-peer.xml
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-eth-peer.xml
new file mode 100644
index 0000000..11e56db
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-eth-peer.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='ethernet'>
+ <mac address='00:11:22:33:44:55'/>
+ <ip address='192.168.125.1' family='ipv4' prefix='24'
peer='192.168.125.2'/>
+ <script path='/etc/qemu-ifup'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index f766f4d..5172865 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -454,6 +454,7 @@ mymain(void)
DO_TEST("net-virtio-disable-offloads");
DO_TEST("net-eth");
DO_TEST("net-eth-ifname");
+ DO_TEST("net-eth-peer");
DO_TEST("net-virtio-network-portgroup");
DO_TEST("net-hostdev");
DO_TEST("net-hostdev-vfio");
--
2.5.5