1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

network: check negative values in bridge queues

We already are checking for negative value, reporting an error, but
using wrong function and the check only succeeds when a value that
cannot be converted to number successfully is encountered. This patch
provides just a minor change in call of the right version
of function virStrToLong.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1138539
This commit is contained in:
Erik Skultety 2014-09-16 10:06:50 +02:00 committed by Martin Kletzander
parent e3c626a61d
commit e6fc664618
3 changed files with 34 additions and 1 deletions

View File

@ -7377,7 +7377,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (queues) {
unsigned int q;
if (virStrToLong_ui(queues, NULL, 10, &q) < 0) {
if (virStrToLong_uip(queues, NULL, 10, &q) < 0) {
virReportError(VIR_ERR_XML_DETAIL,
_("'queues' attribute must be positive number: %s"),
queues);

View File

@ -0,0 +1,32 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='file' device='disk'>
<source file='/dev/HostVG/QEMUGuest1'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<interface type='user'>
<mac address='52:54:00:e5:48:58'/>
<model type='virtio'/>
<driver name='vhost' queues='-5'/>
</interface>
<memballoon model='virtio'/>
</devices>
</domain>

View File

@ -954,6 +954,7 @@ mymain(void)
DO_TEST_FAILURE("misc-enable-s4", NONE);
DO_TEST("misc-no-reboot", NONE);
DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID);
DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
DO_TEST("net-vhostuser", QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV);
DO_TEST("net-user", NONE);
DO_TEST("net-virtio", NONE);