Hi Chris,
I aggre with you on the "is a kind of" idea you said in another email.
But here, I don't quite understand the marshal method.
What do you mean by "convert vm instance into VMXML instance" ?
Do you mean class VM should also be a subclass of class LibvirtXMLBase ?
So it is like this:
LibvirtXMLBase(XMLTreeFile)
|
|
+---LibvirtXML(LibvirtXMLBase)
|
|
+---VMXML(LibvirtXMLBase)
|
|
+---VMInterfaceXML(LibvirtXMLBase)
|
|
+---VM(virt_vm.BaseVM, LibvirtXMLBase) # So that we can convert vm
# to vmxml.
|
|
+--- ......
Is this kind of convert like the deep copy in C++ ?
We just create another VMXML instance and copy the counterparts in VM
instance one by one.
Thanks. :)
On 08/31/2012 09:33 PM, Chris Evich wrote:
Yes, any way we can simplify libvirt_vm class by moving XML related
stuff to libvirt_xml classes is good. If we keep a relatively flat class
structure it will help a lot. In the future adding marshal(*) methods
will be much easier. It doesn't preclude the xml classes from containing
or returning one another, where that makes sense.
*marshal: Fancy way of saying 'convert'. For example:
class VMXML(LibvirtXMLBase):
...
@classmethod
marshal(cls, vm):
"""Convert vm instance into VMXML instance"""
...
class VM(virt_vm.BaseVM):
...
@classmethod
marshal(cls, vmxml):
"""Convert vmxml instance into vm instance"""
...
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel