Bug 273421

Summary: [5.2] virt-install hangs up when 32 NICs or more are specified as --network option
Product: Red Hat Enterprise Linux 5 Reporter: Flavio Leitner <fleitner>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 5.1CC: herrold, tao, xen-maint
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0291 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-21 16:47:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 246258    

Description Flavio Leitner 2007-08-31 23:41:59 UTC
Description of problem:

The virt-install command hungs up in a endless busy loop when specified 32 NICs
parameters or more as --network option.

Relevant code parts:
src/xml.c
 407 virBufferVSprintf(virBufferPtr buf, const char *format, ...)
 408 {
...
 415     size = buf->size - buf->use - 1;
...
 418     while (((count = vsnprintf(&buf->content[buf->use], size, format,
 419                                locarg)) < 0) || (count >= size - 1)) {
...
 424         if (virBufferGrow(buf, 1000) < 0) {
 425             return (-1);
 426         }
 427         size = buf->size - buf->use - 1;
...
 429     }


 281 virBufferGrow(virBufferPtr buf, unsigned int len)
 282 {
...
 291     size = buf->use + len + 1000;
...
 293     newbuf = (char *) realloc(buf->content, size);
...
 299     buf->size = size;
...
 301 }

When a number of parameter NICs is bigger enough to vsnprintf have to truncate,
it will return the number of bytes which would have been written to the final
string. In line 291 it does:

size = buf->use + 1000 + 1000.

It is _constant_ regardless of count, then the condition on line 491 
(count >= size - 1) is always true entering on busy loop.

Example: initial buffer size = 1000 and vsnprintf() returns 2600, the line 491
is true and calls virBufferGrow(,1000), then the size now is:
size = few used bytes(300) + 1000 + 1000 = 2300, so It runs the loop again and
the count still is 2600, calls virBufferGrow(1000) which ends up on the same
size as in previous loop entering in busy loop.


Version-Release number of selected component (if applicable):
libvirt-0.2.3-9.el5

How reproducible:
Always

Steps to Reproduce:
1. Run:
# virt-install --name=test --ram=350 --file=/dev/sda5 --paravirt \
   --location=ftp://10.131.236.20/rhel5.1b_ia64< /a> --vnc --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge --network=bridge \
   --network=bridge --network=bridge --network=bridge

  
Actual results:
virt-install enter on endless busy loop

Expected results:
virt-install configure and install a vm with 32 or NICs.

Additional info:
Patch to fix this issue is available at:
https://www.redhat.com/archives/libvir-list/2007-August/msg00213.html

Comment 1 Daniel Veillard 2007-09-24 10:24:50 UTC
Yes we should fix this, too late for 5.1, but definitely for 5.2,

Daniel

Comment 2 RHEL Program Management 2007-10-16 03:42:54 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 3 Daniel Veillard 2007-10-16 09:04:40 UTC
This has been fixed upstream and was part of the two lat release:

Thu Aug 30 15:11:44 CEST 2007 Daniel Veillard <veillard>

        * src/buf.c: applied patch from Masayuki Sunou fixing a loop
          due to an error in growing buffers.

This definitely should get devel_ack+,

Daniel

Comment 5 Daniel Veillard 2007-12-11 15:10:58 UTC
libvirt-0.3.3-1.el5 has been built in dist-5E-qu-candidate with the fix
 
Daniel


Comment 9 errata-xmlrpc 2008-05-21 16:47:36 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0291.html