[virt-tools-list] [PATCH v2 1/3] Add support for cpu mode attribute and cpu host-passthrough

Cole Robinson crobinso at redhat.com
Sun Apr 14 17:30:23 UTC 2013


On 04/12/2013 05:38 AM, Guannan Ren wrote:
> On 04/11/2013 01:45 PM, Hu Tao wrote:
>> From: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>
>>
>> With this patch, users can use cpu host-passthrough like this:
>>
>>   virt-install --cpu host-passthrough ...
>>
>> Signed-off-by: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>
>> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
>> ---
>>
>> Cole,
>>
>>     v2 is rebased on top of latest virt-manager. Please review.
>>
>> Regards,
>> Hu Tao
>>
>>  virtinst/CPU.py | 23 ++++++++++++++++++++++-
>>  1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/virtinst/CPU.py b/virtinst/CPU.py
>> index 6ada5bc..c1c47e8 100644
>> --- a/virtinst/CPU.py
>> +++ b/virtinst/CPU.py
>> @@ -81,6 +81,7 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
>>          self._model = None
>>          self._match = None
>>          self._vendor = None
>> +        self._mode = None
>>          self._features = []
>>  
>>          self._sockets = None
>> @@ -130,6 +131,8 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
>>      def _get_model(self):
>>          return self._model
>>      def _set_model(self, val):
>> +        if val:
>> +            self.mode = "custom"
>>          if val and not self.match:
>>              self.match = "exact"
>>          self._model = val
>> @@ -150,6 +153,13 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
>>      vendor = _xml_property(_get_vendor, _set_vendor,
>>                             xpath="./cpu/vendor")
>>  
>> +    def _get_mode(self):
>> +        return self._mode
>> +    def _set_mode(self, val):
>> +        self._mode = val
>> +    mode = _xml_property(_get_mode, _set_mode,
>> +                         xpath="./cpu/@mode")
>> +
>>      # Topology properties
>>      def _get_sockets(self):
>>          return self._sockets
>> @@ -184,6 +194,7 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
>>          if not cpu.model:
>>              raise ValueError(_("No host CPU reported in capabilities"))
>>  
>> +        self.mode = "custom"
> 
> 
>           I am on the same work these days too. The following is my a little
> thoughts about the work
> 
>           For the "Copy host CPU configuration",  host-model could be used
> here instead of custom mode
> 
>           <cpu mode='host-model'/>
>           seehttp://www.libvirt.org/formatdomain.html#elementsCPU
> <http://www.libvirt.org/formatdomain.html#elementsCPU>||
> 
>           If we use it, libvirt will do the copying work for cpu and features
> from caps
> 

Yeah, virt-manager should use it. It isn't entirely simple though: we want to
maintain the old behavior for libvirt that doesn't support host-model. And in
virt-manager, we also need to pass the UPDATE_CPU flag to XMLDesc so that the
UI still lists all the flags that host-model maps too. But to do that we need
to make sure libvirt supports that flag. It's all a tedious mess.

But if you have patches, please post them even if they aren't perfect, I can
help work out the corner cases.

Thanks,
Cole




More information about the virt-tools-list mailing list