Bug 1161461

Summary: forbid to set memory to ZERO
Product: Red Hat Enterprise Linux 7 Reporter: Jincheng Miao <jmiao>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, honzhang, lhuang, mzhan, rbalakri, rmohr
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.14-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:55:19 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 Jincheng Miao 2014-11-07 07:58:11 UTC
Description of problem:
forbid to set memory to ZERO in order to avoid some strange error message.

version:
libvirt-1.2.8-5.el7.x86_64
qemu-kvm-1.5.3-77.el7.x86_64

How reproducible:
100%

Step to reproduce:
1. set memory to zero
# virsh edit r7
...
  <memory unit='KiB'>0</memory>
  <currentMemory unit='KiB'>0</currentMemory>
  <vcpu placement='static'>6</vcpu>
...

2. start guest
# virsh start r7
error: Failed to start domain r7
error: internal error: unable to execute QEMU command 'balloon': Parameter 'target' expects a size

3. if there is a auto placement vcpu
  <memory unit='KiB'>0</memory>
  <currentMemory unit='KiB'>0</currentMemory>
  <vcpu placement='static'>6</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>

# virsh start r7
error: Failed to start domain r7
error: invalid argument: Failed to parse bitmap ''

Expect result:
memory value should not be set to ZERO, that is meanless.
libvirtd should forbid this.

Comment 3 Peter Krempa 2015-03-16 14:38:27 UTC
Fixed upstream as a part of:

commit 4bca6192f20802773012d935145811fb4ba4a4d4
Author: Peter Krempa <pkrempa>
Date:   Wed Mar 4 11:04:27 2015 +0100

    conf: Make specifying <memory> optional
    
    Now that the size of guest's memory can be inferred from the NUMA
    configuration (if present) make it optional to specify <memory>
    explicitly.
    
    To make sure that memory is specified add a check that some form of
    memory size was specified. One side effect of this change is that it is
    no longer possible to specify 0KiB as memory size for the VM, but I
    don't think it would be any useful to do so. (I can imagine embedded
    systems without memory, just registers, but that's far from what libvirt
    is usually doing).
    
    Forbidding 0 memory for guests also fixes a few corner cases where 0 was
    not interpreted correctly and caused failures. (Arguments for numad when
    using automatic placement, size of the balloon). This fixes problems
    described in https://bugzilla.redhat.com/show_bug.cgi?id=1161461
    
    Test case changes are added to verify that the schema change and code
    behave correctly.

Comment 6 Luyao Huang 2015-07-07 08:30:31 UTC
Verify this bug with libvirt-1.2.17-1.el7.x86_64:

1. edit a guest and set memory is 0:

  <memory unit='KiB'>0</memory>
  <currentMemory unit='KiB'>11111110</currentMemory>


# virsh edit test4
error: XML error: Memory size must be specified via <memory> or in the <numa> configuration
Failed. Try again? [y,n,i,f,?]: 

2. edit a guest and set current memory is 0:

  <memory unit='KiB'>10240000</memory>
  <currentMemory unit='KiB'>0</currentMemory>

# virsh edit test4
Domain test4 XML configuration edited.

# virsh dumpxml test4

  <memory unit='KiB'>10240000</memory>
  <currentMemory unit='KiB'>10240000</currentMemory>


3. edit a guest and set memory is 0 and with numa settings:

  <memory unit='KiB'>0</memory>
  <currentMemory unit='KiB'>0</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB' memAccess='shared'/>
    </numa>
  </cpu>

# virsh edit test4
Domain test4 XML configuration edited.

# virsh dumpxml test4
...
  <memory unit='KiB'>1024000</memory>
  <currentMemory unit='KiB'>1024000</currentMemory>
  <vcpu placement='auto'>4</vcpu>
...
  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB' memAccess='shared'/>
    </numa>
  </cpu>
...

Comment 8 errata-xmlrpc 2015-11-19 05:55:19 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