Bug 1210545

Summary: libvirtd crashed when define/edit a vm with a vcpus='0, ^0' in <vcpusched>
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.2CC: dyuan, honzhang, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.15-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:28:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luyao Huang 2015-04-10 03:13:46 UTC
description of problem:
libvirtd crashed when define/edit a vm with a vcpus='0,^0' in <vcpusched>

Version-Release number of selected component (if applicable):
libvirt-1.2.14-1.el7.x86_64
qemu-kvm-rhev-2.2.0-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.# virsh edit test3
...
<vcpusched vcpus='0,^0' scheduler='fifo' priority='1'/>
...
error: End of file while reading data: Input/output error
Failed. Try again? [y,n,i,f,?]:
error: internal error: client socket is closed

Actual results:
libvirtd crashed when define/edit a vm with a vcpus='0,^0' in <vcpusched>

Expected results:
fix it

infomation:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f2821f74700 (LWP 24491)]
virBitmapIsAllClear (bitmap=0x0) at util/virbitmap.c:649
649            for (i = 0; i < bitmap->map_len; i++)
(gdb) bt
#0  virBitmapIsAllClear (bitmap=0x0) at util/virbitmap.c:649
#1  0x00007f28322f1245 in virDomainThreadSchedParse (node=0x7f28000047f0, minid=minid@entry=0, maxid=3, name=name@entry=0x7f28325190a8 "vcpus", sp=0x7f28000113b0) at conf/domain_conf.c:13464
#2  0x00007f283238aec8 in virDomainDefParseXML (xml=xml@entry=0x7f2800003410, root=root@entry=0x7f2800003770, ctxt=ctxt@entry=0x7f2800003570, caps=caps@entry=0x7f28101e1c90, xmlopt=xmlopt@entry=0x7f281024ae50,
    expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=258) at conf/domain_conf.c:14059
#3  0x00007f2832390ddb in virDomainDefParseNode (xml=xml@entry=0x7f2800003410, root=0x7f2800003770, caps=caps@entry=0x7f28101e1c90, xmlopt=xmlopt@entry=0x7f281024ae50,
    expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=258) at conf/domain_conf.c:15588
#4  0x00007f2832390f02 in virDomainDefParse (
    xmlStr=xmlStr@entry=0x7f28000009f0 "<domain type='kvm'>\n  <name>test3</name>\n  <uuid>7347d748-f7ce-448f-8d49-3d29c9bcac30</uuid>\n  <maxMemory slots='16' unit='KiB'>1524288</maxMemory>\n  <memory unit='KiB'>1024000</memory>\n  <currentMemo"..., filename=filename@entry=0x0, caps=caps@entry=0x7f28101e1c90, xmlopt=0x7f281024ae50, expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=258)
    at conf/domain_conf.c:15530
#5  0x00007f2832390f53 in virDomainDefParseString (
    xmlStr=xmlStr@entry=0x7f28000009f0 "<domain type='kvm'>\n  <name>test3</name>\n  <uuid>7347d748-f7ce-448f-8d49-3d29c9bcac30</uuid>\n  <maxMemory slots='16' unit='KiB'>1524288</maxMemory>\n  <memory unit='KiB'>1024000</memory>\n  <currentMemo"..., caps=caps@entry=0x7f28101e1c90, xmlopt=<optimized out>, expectedVirtTypes=expectedVirtTypes@entry=15, flags=flags@entry=258) at conf/domain_conf.c:15546
#6  0x00007f2819d8e8de in qemuDomainDefineXMLFlags (conn=0x7f280c0009a0,
    xml=0x7f28000009f0 "<domain type='kvm'>\n  <name>test3</name>\n  <uuid>7347d748-f7ce-448f-8d49-3d29c9bcac30</uuid>\n  <maxMemory slots='16' unit='KiB'>1524288</maxMemory>\n  <memory unit='KiB'>1024000</memory>\n  <currentMemo"..., flags=<optimized out>) at qemu/qemu_driver.c:7385
#7  0x00007f28323ebc9c in virDomainDefineXMLFlags (conn=0x7f280c0009a0,
    xml=0x7f28000009f0 "<domain type='kvm'>\n  <name>test3</name>\n  <uuid>7347d748-f7ce-448f-8d49-3d29c9bcac30</uuid>\n  <maxMemory slots='16' unit='KiB'>1524288</maxMemory>\n  <memory unit='KiB'>1024000</memory>\n  <currentMemo"..., flags=1) at libvirt-domain.c:6515
#8  0x00007f2832e78aaa in remoteDispatchDomainDefineXMLFlags (server=0x7f28349ccef0, msg=0x7f28349e60f0, ret=0x7f28000009c0, args=0x7f28000008e0, rerr=0x7f2821f73c70, client=0x7f28349e7800)
    at remote_dispatch.h:3755
#9  remoteDispatchDomainDefineXMLFlagsHelper (server=0x7f28349ccef0, client=0x7f28349e7800, msg=0x7f28349e60f0, rerr=0x7f2821f73c70, args=0x7f28000008e0, ret=0x7f28000009c0) at remote_dispatch.h:3733
#10 0x00007f2832453152 in virNetServerProgramDispatchCall (msg=0x7f28349e60f0, client=0x7f28349e7800, server=0x7f28349ccef0, prog=0x7f28349e1920) at rpc/virnetserverprogram.c:437
#11 virNetServerProgramDispatch (prog=0x7f28349e1920, server=server@entry=0x7f28349ccef0, client=0x7f28349e7800, msg=0x7f28349e60f0) at rpc/virnetserverprogram.c:307
#12 0x00007f2832eabefd in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>, srv=0x7f28349ccef0) at rpc/virnetserver.c:172
#13 virNetServerHandleJob (jobOpaque=<optimized out>, opaque=0x7f28349ccef0) at rpc/virnetserver.c:193
#14 0x00007f283234f615 in virThreadPoolWorker (opaque=opaque@entry=0x7f28349ad660) at util/virthreadpool.c:145
#15 0x00007f283234eb38 in virThreadHelper (data=<optimized out>) at util/virthread.c:206
#16 0x00007f282f787df5 in start_thread (arg=0x7f2821f74700) at pthread_create.c:308
#17 0x00007f282f4ae1ad in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Additional info:

Patch propose in upstream (i didn't write this bugzilla link in patch, because i wrote the patch before file a bug):

http://www.redhat.com/archives/libvir-list/2015-April/msg00319.html

Comment 1 Erik Skultety 2015-04-16 11:43:58 UTC
Fixed upstream:

commit b77ce18a28bc8b5d6a88ecdde084259b4697b049
Author: Erik Skultety <eskultet>
Date:   Fri Apr 10 11:11:21 2015 +0200

    virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls
    
    This patch adds checks for empty bitmaps right after the calls of
    virBitmapParse. These only include spots where set API's are called and
    where domain's XML is parsed.
    Also, it partially reverts commit 983f5a which added a check for
    invalid nodeset "0,^0" into virBitmapParse function. This change broke
    the logic, as an empty bitmap should not cause an error.

v1.2.14-116-gb77ce18

Comment 3 Luyao Huang 2015-07-07 08:05:35 UTC
Verify this bug with libvirt-1.2.17-1.el7.x86_64:

1. add a line in guest xml like this:

<vcpusched vcpus='0,^0' scheduler='fifo' priority='1'/>

# virsh edit r6
error: unsupported configuration: Invalid value of 'vcpus': 0,^0
Failed. Try again? [y,n,i,f,?]: 

2. also test with iothreadsched:

 <iothreadsched iothreads='0,^0' scheduler='batch'/>


# virsh edit r6
error: unsupported configuration: Invalid value of 'iothreads': 0,^0
Failed. Try again? [y,n,i,f,?]:

Comment 5 errata-xmlrpc 2015-11-19 06:28:01 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html