On 10/08/2013 08:13 AM, Xu Wang wrote:
These patches are based on commit
04bfeb825e5e155ffa72119253de608ccf3bd72b.
So I may need more work on rebasing.
Most of bugs reported recently are about some tags libvirt-cim doesn't
support will be dropped after resource updated. So a new member was added
into every virt_device and domain structure. And a new structure named
unknown device was added to save those tags new added.
The original implementaion is reading every member of virt_device structure
from xml and save it. But the defect of this is some tags were not a
member of virt_device were dropped. After resource updated, every data
in the virt_device will be used to regenerate new xml. Hence the tags
unsupported above, disappeared.
So I added a member into every virt_device and domain structure, 'others'.
It's a link list and used to save all data read from xml. Another new
structure 'unknown_device' was added to save data except libvirt-cim could
recognize.
The new implementation is, firstly parse_*_device() could read all nodes and
properties from xml and save them into 'others' link list. Then every member
of virt_device will fetch data from others link list and save it. So that
nodes in the 'others' link list could be saved until they are used to re-
generate xml.
After resource updating finished, libvirt-cim will call *_xml() to generate
xml. The new process of generating xml like this, firstly all data in the
members of virt_device will be restored into 'others' link list, then a
function (others_to_xml) will use this link list to generate xml.
Some points I have updated,
1. 'others' link list has to be processed in _get_proc_device() and
_get_mem_device(). They should be copied into new data structure.
2. If resource updating happened, others field should be cleared
because this device has been changed and they are useless.
Besides above some logic may be a little strange or boring. Implemention
like that is just to be compatible with upper layer functions (to make
changes as less as possible). After keep a balance I decided to devide
the whole xml into several parts:
<domain>------------------------others in domain to save unsupported sub-nodes of
domain
-some fields (devices, mem, vcpu...) will be skiped
because
-they have their own parsing functions.
<name>xxx</name>
<uuid>xxx</uuid>
<vcpu>xxx</vcpu>
<mem>xxx</mem>
<devices>
<disk>xxx</disk>------- others in virt_device to save unsupported tags of
this device
<emulator>xxx</emulator>
...----------- unknown_device to save unsupported device except like
<disk>,<emu>,etc.
</devices>
</domain>
Hence, all nodes read from xml will be restored after xml generation.
Short notification, Boris or I will do a detail review (hopefully)
by the end of next week (both being pretty busy right now) as
this is touching some of the areas we're working on for s390
enablement.
But in general I think it's a good idea and like the overall approach.
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294