Bug 1047234

Summary: virsh command numatune accept integer as mode type.
Product: Red Hat Enterprise Linux 7 Reporter: Hao Liu <hliu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, dyuan, hliu, jeder, jmiao, mzhan, pkrempa, zsong
Target Milestone: rc   
Target Release: 7.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.1.1-18.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:49:25 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 Hao Liu 2013-12-30 02:19:29 UTC
Description of problem:
virsh command numatune accept integer as mode type.

Version-Release number of selected component (if applicable):
libvirt-1.1.1-16.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
With a shut-off vm test-vm,

1. Change NUMA mode using numatune and an integer <N> as mode type.
# virsh numatune test-vm --mode <N>

2. Check NUMA mode <mode>
# virsh numatune test-vm
numa_mode      : <mode>
numa_nodeset   : 

Actual Result:
<N> = 0: <mode> = strict
<N> = 1: <mode> = preferred
<N> = 2: <mode> = interleave
else: <mode> = (null)

Expected Result:
error: Invalid mode: <N>

Comment 2 Peter Krempa 2014-01-06 15:21:56 UTC
Fixed upstream with:

commit 6e7490c734a538983f9c5ae680cdb36edbaffe65
Author: Peter Krempa <pkrempa>
Date:   Mon Jan 6 14:26:14 2014 +0100

    qemu: range check numa memory placement mode
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1047234
    
    Add a range check for supported numa memory placement modes provided by
    the user before setting them in the domain definition. Without the check
    the user is able to provide a (yet) unknown mode which is then stored in
    the domain definition. This potentially causes a NULL dereference when
    the defintion is formatted into the XML.
    
    To reproduce run:
     virsh numatune DOMNAME --mode 6 --nodeset 0
    
    The XML will then contain:
      <numatune>
          <memory mode='(null)' nodeset='0'/>
      </numatune>
    
    With this fix, the command fails:
     error: Unable to change numa parameters
     error: invalid argument: unsupported numa_mode: '6'

commit 8b573a6b0d1ee9d99862104f28fee8bc7f949a9d
Author: Peter Krempa <pkrempa>
Date:   Mon Jan 6 14:11:42 2014 +0100

    qemu: Clean up qemuDomainSetNumaParameters
    
    Add whitespace to separate logical code blocks, reformat error messages
    and clean up code flow.
    
    This patch changes error handling in some cases where the the loop would
    be continued to jump to cleanup instead and error out rather than modify
    the domain any further.

Comment 5 Hao Liu 2014-01-13 02:08:01 UTC
This fix is VERIFIED on libvirt-1.1.1-18.el7.x86_64:

Verifying steps:
# virsh numatune test-vm
numa_mode      : strict
numa_nodeset   :


# virsh numatune test-vm --mode 0


# virsh numatune test-vm
numa_mode      : strict
numa_nodeset   : 


# virsh numatune test-vm --mode 1


# virsh numatune test-vm
numa_mode      : preferred
numa_nodeset   : 


# virsh numatune test-vm --mode 2


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   : 


# virsh numatune test-vm --mode 3
error: Unable to change numa parameters
error: invalid argument: unsupported numa_mode: '3'


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   : 


# virsh numatune test-vm --mode -1
error: Unable to change numa parameters
error: invalid argument: unsupported numa_mode: '-1'


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   : 

numatune on longer permit unsupported numa modes. so it's VERIFIED.

Comment 6 zhengqin 2014-02-20 06:22:15 UTC
Could reproduce it with above steps for libvirt-1.1.1-16.el7.x86_64.

Have fixed and verified libvirt-1.1.1-23.el7.x86_64:
# virsh numatune test-vm
numa_mode      : strict
numa_nodeset   :


# virsh numatune test-vm --mode 0


# virsh numatune test-vm
numa_mode      : strict
numa_nodeset   : 


# virsh numatune test-vm --mode 1


# virsh numatune test-vm
numa_mode      : preferred
numa_nodeset   : 


# virsh numatune test-vm --mode 2


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   : 


# virsh numatune test-vm --mode 3
error: Unable to change numa parameters
error: invalid argument: unsupported numa_mode: '3'


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   : 


# virsh numatune test-vm --mode -1
error: Unable to change numa parameters
error: invalid argument: unsupported numa_mode: '-1'


# virsh numatune test-vm
numa_mode      : interleave
numa_nodeset   :

Comment 7 Ludek Smid 2014-06-13 12:49:25 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.