[Kimchi-devel] [PATCH 2/6 - V2] [Memory HotPlug] Add maxMemory and numa configuration to guest xml

Aline Manera alinefm at linux.vnet.ibm.com
Mon Jun 1 19:44:09 UTC 2015



On 01/06/2015 16:33, Rodrigo Trujillo wrote:
>
>
> On 06/01/2015 09:24 AM, Aline Manera wrote:
>>
>>
>> On 28/05/2015 10:59, Rodrigo Trujillo wrote:
>>> In order to support memory hotplug, guest must have maxMemory and NUMA
>>> configured in the xml.
>>> For maxMemory, this patch changes xml generation at guest creation
>>> time, adding maxMemory equals to host total memory and memory slots as
>>> the integer number of GiB that fit inside maxMemory (by design users
>>> will be allowed to add only memory chunks of 1GB).
>>> For NUMA, this patch adds the simplest configuration possible, creating
>>> only one node with all vcpus and memory set in the template.
>>>
>>> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>>> ---
>>>   src/kimchi/model/vms.py  |  8 ++++++++
>>>   src/kimchi/vmtemplate.py | 29 +++++++++++++++++++----------
>>>   2 files changed, 27 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
>>> index f0182b9..dc7f91f 100644
>>> --- a/src/kimchi/model/vms.py
>>> +++ b/src/kimchi/model/vms.py
>>> @@ -94,6 +94,14 @@ class VMsModel(object):
>>>           if pool_uri:
>>>               vm_overrides['storagepool'] = pool_uri
>>>               vm_overrides['fc_host_support'] = 
>>> self.caps.fc_host_support
>>> +
>>
>>> +        # Setting maxMemory and slots parameter values
>>> +        # getInfo memory value comes in MiB, so dividing by 1024 
>>> integer,
>>> +        # gives the interger maximum number of slots to use in 
>>> chunks of
>>> +        # 1 GB
>>> +        vm_overrides['max_memory'] = self.conn.get().getInfo()[1] * 
>>> 1024
>>> +        vm_overrides['slots'] = self.conn.get().getInfo()[1] / 1024
>>> +
>>
>> As those values are the same to every guest and will never change (at 
>> least by now) I suggest insert it to the 'defaults' in the osinfo.py
> Yes, I can move to there. Just a doubt, is osinfo instantiated once ? 
> Because I coded in VM create function to catch the case where the host 
> had its memory increased on-the-fly.
>

The 'defaults' in osinfo is a dict. The dict is built on server start up.
To make it "refreshable" you will need to change the osinfo.lookup() 
which is called on every Template creation.

>
>>
>>>           t = TemplateModel.get_template(t_name, self.objstore, 
>>> self.conn,
>>>                                          vm_overrides)
>>>
>>> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
>>> index e047228..a20098d 100644
>>> --- a/src/kimchi/vmtemplate.py
>>> +++ b/src/kimchi/vmtemplate.py
>>> @@ -270,17 +270,25 @@ class VMTemplate(object):
>>>           return input_output
>>>
>>>       def _get_cpu_xml(self):
>>
>>> -
>>> +        # NUMA configuration. Necessary for memory hotplug
>>> +        cpus = self.info.get('cpus') - 1
>>
>> Just curious about the count above. What is it for?
>
> I am getting the total number of CPUS to set below in the NUMA node. 
> We are going to have only one node, so, all cpus must be
> set in that node, such as "cpus=0-3", if guest has 4 cpus ; or 
> "cpus=0" if the guest has 1 cpu.  Actually I am setting the "cpu ID",
> starting from zero to X-1.
>

Thanks for the explanation.

>>
>>> +        xml = E.cpu(E.numa(E.cell(
>>> +            id='0',
>>> +            cpus='0-' + str(cpus) if cpus > 0 else '0',
>>> +            memory=str(self.info.get('memory') << 10),
>>> +            unit='KiB')))
>>> +
>>> +        # Include CPU topology, if provided
>>>           cpu_info = self.info.get('cpu_info')
>>> -        if cpu_info is None:
>>> -            return ""
>>> -        cpu_topo = cpu_info.get('topology')
>>> -        if cpu_topo is None:
>>> -            return ""
>>> -        return etree.tostring(E.cpu(E.topology(
>>> -            sockets=str(cpu_topo['sockets']),
>>> -            cores=str(cpu_topo['cores']),
>>> -            threads=str(cpu_topo['threads']))))
>>> +        if cpu_info is not None:
>>> +            cpu_topo = cpu_info.get('topology')
>>> +            if cpu_topo is not None:
>>> +                xml.insert(0, E.topology(
>>> +                    sockets=str(cpu_topo['sockets']),
>>> +                    cores=str(cpu_topo['cores']),
>>> +                    threads=str(cpu_topo['threads'])))
>>> +
>>> +        return etree.tostring(xml)
>>>
>>>       def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
>>>           params = dict(self.info)
>>> @@ -313,6 +321,7 @@ class VMTemplate(object):
>>>             %(qemu-stream-cmdline)s
>>>             <name>%(name)s</name>
>>>             <uuid>%(uuid)s</uuid>
>>> +          <maxMemory slots='%(slots)s' 
>>> unit='KiB'>%(max_memory)s</maxMemory>
>>>             <memory unit='MiB'>%(memory)s</memory>
>>>             <vcpu>%(cpus)s</vcpu>
>>>             %(cpu_info)s
>>
>> _______________________________________________
>> 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