mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Record the default NIC model in the domain XML
This patch implements the devices post parse callback 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.
This commit is contained in:
parent
ad0d10b2b1
commit
a68d672667
@ -554,7 +554,7 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
|
|||||||
virDomainXMLOptionPtr
|
virDomainXMLOptionPtr
|
||||||
virQEMUDriverCreateXMLConf(void)
|
virQEMUDriverCreateXMLConf(void)
|
||||||
{
|
{
|
||||||
return virDomainXMLOptionNew(NULL,
|
return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
|
||||||
&virQEMUDriverPrivateDataCallbacks,
|
&virQEMUDriverPrivateDataCallbacks,
|
||||||
&virQEMUDriverDomainXMLNamespace);
|
&virQEMUDriverDomainXMLNamespace);
|
||||||
}
|
}
|
||||||
|
@ -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
|
static void
|
||||||
qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
|
qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
|
||||||
{
|
{
|
||||||
|
@ -342,5 +342,6 @@ void qemuDomainCleanupRun(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
|
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
|
||||||
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
|
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
|
||||||
|
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
|
||||||
|
|
||||||
#endif /* __QEMU_DOMAIN_H__ */
|
#endif /* __QEMU_DOMAIN_H__ */
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
<interface type='network'>
|
<interface type='network'>
|
||||||
<mac address='52:54:00:24:a5:9f'/>
|
<mac address='52:54:00:24:a5:9f'/>
|
||||||
<source network='default'/>
|
<source network='default'/>
|
||||||
|
<model type='rtl8139'/>
|
||||||
<bandwidth>
|
<bandwidth>
|
||||||
<inbound average='1000' peak='4000' burst='1024'/>
|
<inbound average='1000' peak='4000' burst='1024'/>
|
||||||
<outbound average='128' peak='256' burst='32768'/>
|
<outbound average='128' peak='256' burst='32768'/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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 \
|
macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\
|
||||||
-serial none -parallel none
|
connect=192.168.0.1:5558,vlan=0 -serial none -parallel none
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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,\
|
macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,ifname=nic02,\
|
||||||
vlan=0 -serial none -parallel none
|
script=/etc/qemu-ifup,vlan=0 -serial none -parallel none
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<mac address='00:11:22:33:44:55'/>
|
<mac address='00:11:22:33:44:55'/>
|
||||||
<script path='/etc/qemu-ifup'/>
|
<script path='/etc/qemu-ifup'/>
|
||||||
<target dev='nic02'/>
|
<target dev='nic02'/>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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,\
|
macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139,name=net0 -net tap,\
|
||||||
vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,vlan=1,model=e1000,\
|
script=/etc/qemu-ifup,vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,\
|
||||||
name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 -serial none \
|
vlan=1,model=e1000,name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 \
|
||||||
-parallel none
|
-serial none -parallel none
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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 \
|
macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,script=/etc/qemu-ifup,\
|
||||||
none -parallel none
|
vlan=0 -serial none -parallel none
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
<interface type='ethernet'>
|
<interface type='ethernet'>
|
||||||
<mac address='00:11:22:33:44:55'/>
|
<mac address='00:11:22:33:44:55'/>
|
||||||
<script path='/etc/qemu-ifup'/>
|
<script path='/etc/qemu-ifup'/>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
<virtualport type='802.1Qbg'>
|
<virtualport type='802.1Qbg'>
|
||||||
<parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
|
<parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
|
||||||
</virtualport>
|
</virtualport>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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 \
|
macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,mcast=192.0.0.1:5558,\
|
||||||
-serial none -parallel none
|
vlan=0 -serial none -parallel none
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
<virtualport type='openvswitch'>
|
<virtualport type='openvswitch'>
|
||||||
<parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' profileid='bob'/>
|
<parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' profileid='bob'/>
|
||||||
</virtualport>
|
</virtualport>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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 \
|
macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\
|
||||||
-serial none -parallel none
|
listen=192.168.0.1:5558,vlan=0 -serial none -parallel none
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
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 \
|
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||||
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\
|
-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
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<controller type='ide' index='0'/>
|
<controller type='ide' index='0'/>
|
||||||
<interface type='user'>
|
<interface type='user'>
|
||||||
<mac address='00:11:22:33:44:55'/>
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<virtualport>
|
<virtualport>
|
||||||
<parameters instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
|
<parameters instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
|
||||||
</virtualport>
|
</virtualport>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<interface type='network'>
|
<interface type='network'>
|
||||||
<mac address='22:11:22:33:44:55'/>
|
<mac address='22:11:22:33:44:55'/>
|
||||||
@ -45,6 +46,7 @@
|
|||||||
<virtualport type='802.1Qbh'>
|
<virtualport type='802.1Qbh'>
|
||||||
<parameters profileid='testhis99'/>
|
<parameters profileid='testhis99'/>
|
||||||
</virtualport>
|
</virtualport>
|
||||||
|
<model type='rtl8139'/>
|
||||||
</interface>
|
</interface>
|
||||||
<memballoon model='virtio'/>
|
<memballoon model='virtio'/>
|
||||||
</devices>
|
</devices>
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
<interface type='ethernet'>
|
<interface type='ethernet'>
|
||||||
<mac address='52:54:00:71:70:89'/>
|
<mac address='52:54:00:71:70:89'/>
|
||||||
<script path='/etc/qemu-ifup'/>
|
<script path='/etc/qemu-ifup'/>
|
||||||
|
<model type='rtl8139'/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
||||||
</interface>
|
</interface>
|
||||||
<serial type='pty'>
|
<serial type='pty'>
|
||||||
|
Loading…
Reference in New Issue
Block a user