On 05/28/2013 09:41 PM, liyangfnst wrote:
>>  
>>      __slots__ = base.LibvirtXMLBase.__slots__ + ('uuid',
>> -                                                 'os_arch_machine_map',)
>> -
>> +                                                 'os_arch_machine_map',
>> +                                                 'cpu_count',
>> +                                                 'arch', 'model',
>> +                                                 'vendor', 'feature_list',)
> 
> Commonly these elements won't show up to users.And in VMXML.__init__(),VMXML.xml's value is so simple that if I add these properties in VMXML, every accessor I wrote must be contain "set_cpu_mode() and new_from_dumpxml()", I think it's duplicate, so I add this new class that VMCPUXML.__init__ contains "set_cpu_mode() and dumpxml()", it's convenient for writing accessors.
> I tried to modified VMXML.__init__(), but it's affect is so large, but add a new class inherit VMXML can be more easy and convenient.

Yes, you are right, we do need another class.  One idea is to make VMXML
property to contain instance of VMCPUXML.  Similar to how NetworkXML
"ip" property works with IPXML class instance.  I think this is a good
pattern to follow since it is used elsewhere and follows the object
relationship model well.

Maybe LibvirtXML class can make use of same VMCPUXML class or base-class
do same for host CPU?  The XML representation looks similar maybe?  I am
just thinking how we can re-use code.  Maybe it won't work.