This patch implements the devices post parse cllback and uses it to fill
the default qemu network card model into the XML if none is specified.
Libvirt assumes that the network card model for qemu is the "rtl8139".
Record this in the XML using the new callback to avoid user
confusion.
---
src/qemu/qemu_conf.c | 2 +-
src/qemu/qemu_domain.c | 25 ++++++++++++++++++++++
src/qemu/qemu_domain.h | 1 +
.../qemuxml2argv-net-bandwidth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 ++--
.../qemuxml2argv-net-eth-ifname.args | 4 ++--
.../qemuxml2argv-net-eth-ifname.xml | 1 +
.../qemuxml2argv-net-eth-names.args | 8 +++----
tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 ++--
tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 ++--
.../qemuxml2argv-net-openvswitch.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 ++--
tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 ++-
tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 +
.../qemuxml2argv-net-virtio-network-portgroup.xml | 2 ++
.../qemuxml2xmlout-graphics-spice-timeout.xml | 1 +
18 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c709188..7ee60d6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -554,7 +554,7 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr
driver)
virDomainXMLOptionPtr
virQEMUDriverCreateXMLConf(void)
{
- return virDomainXMLOptionNew(NULL,
+ return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
&virQEMUDriverPrivateDataCallbacks,
&virQEMUDriverDomainXMLNamespace);
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a0a66dd..80e70cd 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -662,6 +662,31 @@ virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = {
};
+static int
+qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+ virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virCapsPtr caps ATTRIBUTE_UNUSED,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+ dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+ if (!dev->data.net->model &&
+ !(dev->data.net->model = strdup("rtl8139")))
+ goto no_memory;
+ }
+ return 0;
+
+no_memory:
+ virReportOOMError();
+ return -1;
+}
+
+
+virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
+ .devicesPostParseCallback = qemuDomainDeviceDefPostParse,
+};
+
+
static void
qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
{
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 26d5859..089ced0 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -342,5 +342,6 @@ void qemuDomainCleanupRun(virQEMUDriverPtr driver,
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
+extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
#endif /* __QEMU_DOMAIN_H__ */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
index bf7dde5..885e854 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
@@ -44,6 +44,7 @@
<interface type='network'>
<mac address='52:54:00:24:a5:9f'/>
<source network='default'/>
+ <model type='rtl8139'/>
<bandwidth>
<inbound average='1000' peak='4000' burst='1024'/>
<outbound average='128' peak='256' burst='32768'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-client.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-client.args
index 7974f2e..34fab0a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-client.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-client.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,connect=192.168.0.1:5558,vlan=0 \
--serial none -parallel none
+macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\
+connect=192.168.0.1:5558,vlan=0 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
index cced5d5..6aef307 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=00:11:22:33:44:55,vlan=0 -net tap,ifname=nic02,script=/etc/qemu-ifup,\
-vlan=0 -serial none -parallel none
+macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,ifname=nic02,\
+script=/etc/qemu-ifup,vlan=0 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml
index 04a4ca4..b150371 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml
@@ -25,6 +25,7 @@
<mac address='00:11:22:33:44:55'/>
<script path='/etc/qemu-ifup'/>
<target dev='nic02'/>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
index dc15f63..57761c5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
@@ -1,7 +1,7 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=00:11:22:33:44:55,vlan=0,name=net0 -net tap,script=/etc/qemu-ifup,\
-vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,vlan=1,model=e1000,\
-name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 -serial none \
--parallel none
+macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139,name=net0 -net tap,\
+script=/etc/qemu-ifup,vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,\
+vlan=1,model=e1000,name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 \
+-serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
index a482193..877dac2 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=00:11:22:33:44:55,vlan=0 -net tap,script=/etc/qemu-ifup,vlan=0 -serial \
-none -parallel none
+macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,script=/etc/qemu-ifup,\
+vlan=0 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml
index 87dd65f..eca5da5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml
@@ -24,6 +24,7 @@
<interface type='ethernet'>
<mac address='00:11:22:33:44:55'/>
<script path='/etc/qemu-ifup'/>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml
index 81f70d0..9be0d2d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml
@@ -32,6 +32,7 @@
<virtualport type='802.1Qbg'>
<parameters managerid='11' typeid='1193047'
typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
</virtualport>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args
index fc2091b..ed4f01e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,mcast=192.0.0.1:5558,vlan=0 \
--serial none -parallel none
+macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,mcast=192.0.0.1:5558,\
+vlan=0 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml
index ff09844..9c2c5dc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml
@@ -32,6 +32,7 @@
<virtualport type='openvswitch'>
<parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'
profileid='bob'/>
</virtualport>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-server.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-server.args
index 7c9d735..c92a3ff 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-server.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-server.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,listen=192.168.0.1:5558,vlan=0 \
--serial none -parallel none
+macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\
+listen=192.168.0.1:5558,vlan=0 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
index 7364281..814167b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
@@ -1,4 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
-macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -serial none -parallel none
+macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net user,vlan=0 -serial none \
+-parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml
index 37e5edf..fe3a271 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml
@@ -23,6 +23,7 @@
<controller type='ide' index='0'/>
<interface type='user'>
<mac address='00:11:22:33:44:55'/>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml
b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml
index c84ed3f..0fb9b2c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml
@@ -38,6 +38,7 @@
<virtualport>
<parameters instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'
interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
</virtualport>
+ <model type='rtl8139'/>
</interface>
<interface type='network'>
<mac address='22:11:22:33:44:55'/>
@@ -45,6 +46,7 @@
<virtualport type='802.1Qbh'>
<parameters profileid='testhis99'/>
</virtualport>
+ <model type='rtl8139'/>
</interface>
<memballoon model='virtio'/>
</devices>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
index cd19b64..54b68fa 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
@@ -62,6 +62,7 @@
<interface type='ethernet'>
<mac address='52:54:00:71:70:89'/>
<script path='/etc/qemu-ifup'/>
+ <model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x07' function='0x0'/>
</interface>
<serial type='pty'>
--
1.8.1.5