[Kimchi-devel] [PATCH][Kimchi 1/2] Issue #838: Extend memory hotplug feature test

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Wed Mar 23 18:12:07 UTC 2016


Oh, just remembered ....
we really NEED NUMA and ACPI tags in the xml, because we are starting 
the guest now to check QEMU support.
If the host supports memory hot plug libvirt is going to complain if 
NUMA tag is not present, which in turns requires ACPI tag.

I will leave this part of the code in V2.

Rodrigo

On 03/23/2016 11:25 AM, Rodrigo Trujillo wrote:
>
>
> On 03/23/2016 09:44 AM, Aline Manera wrote:
>>
>>
>> On 03/22/2016 11:18 AM, Rodrigo Trujillo wrote:
>>> If QEMU version is < 2.1, qemu is not going to start guest which have
>>> maxmemory tag configured in the XML. Kimchi adds this tag by default in
>>> order to allow memory hotplug.
>>> In other words, in order to allow memory hotplug, versions must be
>>> libvirt >= 1.2.14 and qemu >= 2.1. Libvirt was already being tested by
>>> the feature test, but qemu did not. Distros as Red Hat 7 and CentOS
>>> still are in qemu 1.5.
>>> This patch extend the feature test and do not create maxmemory tag in
>>> order to avoid problems in those distros.
>>>
>>> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>>> ---
>>>   i18n.py               |  2 +-
>>>   model/featuretests.py | 20 +++++++++++++-------
>>>   model/vms.py          |  8 ++++++++
>>>   vmtemplate.py         |  7 ++++++-
>>>   4 files changed, 28 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/i18n.py b/i18n.py
>>> index beefeb5..6214687 100644
>>> --- a/i18n.py
>>> +++ b/i18n.py
>>> @@ -99,7 +99,7 @@ messages = {
>>>       "KCHVM0043E": _("Only increase memory is allowed in active VMs"),
>>>       "KCHVM0044E": _("For live memory update, new memory value must 
>>> be equal old memory value plus multiples of 1024 Mib"),
>>>       "KCHVM0045E": _("There are not enough free slots of 1024 Mib 
>>> in the guest."),
>>> -    "KCHVM0046E": _("Host's libvirt version does not support memory 
>>> devices. Libvirt must be >= 1.2.14"),
>>> +    "KCHVM0046E": _("Host's libvirt or qemu version does not 
>>> support memory devices and memory hotplug. Libvirt must be >= 1.2.14 
>>> and QEMU must be >= 2.1."),
>>>       "KCHVM0047E": _("Error attaching memory device. Details: 
>>> %(error)s"),
>>>       "KCHVM0048E": _("Cannot start %(name)s. Virtual machine is 
>>> already running."),
>>>       "KCHVM0049E": _("Cannot power off %(name)s. Virtual machine is 
>>> shut off."),
>>> diff --git a/model/featuretests.py b/model/featuretests.py
>>> index 378335a..ba728e1 100644
>>> --- a/model/featuretests.py
>>> +++ b/model/featuretests.py
>>> @@ -72,6 +72,14 @@ MAXMEM_VM_XML = """
>>>       <type arch='%(arch)s'>hvm</type>
>>>       <boot dev='hd'/>
>>>     </os>
>>
>>> +  <cpu>
>>> +    <numa>
>>> +      <cell id='0' cpus='0' memory='10240' unit='KiB'/>
>>> +    </numa>
>>> +  </cpu>
>>> +  <features>
>>> +    <acpi/>
>>> +  </features>
>>
>> Is it really needed?
>
> I my previous tests it was necessary ... but I retested now and it is 
> not necessary. I will remove
>
>>
>>>   </domain>"""
>>>
>>>   DEV_MEM_XML = """
>>> @@ -209,13 +217,9 @@ class FeatureTests(object):
>>>           A memory device can be hot-plugged or hot-unplugged since 
>>> libvirt
>>>           version 1.2.14.
>>>           '''
>>> -        # Libvirt < 1.2.14 does not support memory devices, so 
>>> firstly, check
>>> -        # its version, then try to attach a device. These steps 
>>> avoid errors
>>> -        # with Libvirt 'test' driver for KVM
>>> -        version = 1000000*1 + 1000*2 + 14
>>> -        if libvirt.getVersion() < version:
>>> -            return False
>>> -
>>> +        # Libvirt < 1.2.14 does not support memory devices, so try 
>>> to attach a
>>> +        # device. Then check if QEMU (>= 2.1) supports memory 
>>> hotplug, starting
>>> +        # the guest These steps avoid errors with Libvirt 'test' 
>>> driver for KVM
>>>           with RollbackContext() as rollback:
>>>               FeatureTests.disable_libvirt_error_logging()
>>> rollback.prependDefer(FeatureTests.enable_libvirt_error_logging)
>>> @@ -230,6 +234,8 @@ class FeatureTests(object):
>>>               try:
>>>                   dom.attachDeviceFlags(DEV_MEM_XML,
>>> libvirt.VIR_DOMAIN_MEM_CONFIG)
>>> +                dom.create()
>>> +                rollback.prependDefer(dom.destroy)
>>>                   return True
>>>               except libvirt.libvirtError:
>>>                   return False
>>> diff --git a/model/vms.py b/model/vms.py
>>> index 03ffdae..557d37a 100644
>>> --- a/model/vms.py
>>> +++ b/model/vms.py
>>> @@ -809,6 +809,14 @@ class VMModel(object):
>>>           return (nonascii_name if nonascii_name is not None else 
>>> vm_name, dom)
>>>
>>>       def _update_memory_config(self, xml, params):
>>> +        # Cannot pass max memory if there is not support to memory 
>>> hotplug
>>> +        # Then set max memory as memory, just to continue with the 
>>> update
>>> +        if not self.caps.mem_hotplug_support:
>>> +            if 'maxmemory' in params['memory']:
>>> +                raise InvalidOperation("KCHVM0046E")
>>> +            else:
>>> +                params['memory']['maxmemory'] = 
>>> params['memory']['current']
>>> +
>>>           root = ET.fromstring(xml)
>>>           # MiB to KiB
>>>           hasMem = 'current' in params['memory']
>>> diff --git a/vmtemplate.py b/vmtemplate.py
>>> index 4bcf324..535efd7 100644
>>> --- a/vmtemplate.py
>>> +++ b/vmtemplate.py
>>> @@ -32,6 +32,7 @@ from wok.exception import MissingParameter, 
>>> OperationFailed
>>>   from wok.plugins.kimchi import imageinfo
>>>   from wok.plugins.kimchi import osinfo
>>>   from wok.plugins.kimchi.isoinfo import IsoImage
>>> +from wok.plugins.kimchi.model.config import CapabilitiesModel
>>>   from wok.plugins.kimchi.utils import check_url_path, 
>>> pool_name_from_uri
>>>   from wok.plugins.kimchi.xmlutils.cpu import get_cpu_xml
>>>   from wok.plugins.kimchi.xmlutils.disk import get_disk_xml
>>> @@ -118,6 +119,8 @@ class VMTemplate(object):
>>>               disk_info['index'] = disk_info.get('index', index)
>>>               self.info['disks'][index] = disk_info
>>
>>> +        self.caps = CapabilitiesModel()
>>> +
>>
>> VMTemplate must be independent of Model. In fact, you don't know 
>> which Model instance is being using.
>> So you should pass the information from Model to VMTemplate as 
>> parameter.
>>
>> Use kwargs argument from to_vm_xml() function.
>>
>> def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
>
> ack !  thanks
>>
>>>       def _get_os_info(self, args, scan):
>>>           distro = version = 'unknown'
>>>
>>> @@ -376,7 +379,9 @@ class VMTemplate(object):
>>>           # Rearrange memory parameters
>>>           params['memory'] = self.info['memory'].get('current')
>>>           params['max_memory'] = ""
>>> -        if memory != maxmemory:
>>> +        # if there is not support to memory hotplug in Libvirt or 
>>> qemu, we
>>> +        # cannot add the tag maxMemory
>>> +        if memory != maxmemory and self.caps.mem_hotplug_support:
>>>               maxmem_xml = "<maxMemory slots='%s' 
>>> unit='MiB'>%s</maxMemory>"
>>>               params['max_memory'] = maxmem_xml % (slots, maxmemory)
>>>
>>
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list