The initial purpose was to fix a regression for detaching device,
(introduced by commit ea7182c29). There was a patch posted to
resolve the problem:
https://www.redhat.com/archives/libvir-list/2011-December/msg00818.html
But as Eric suggested, it's not the ideal way to go, we never known
how many stuffs like <address> will be involved in future. So new API
to invoke the internal parsing functions might be a right way then.
However, things are not that simple (an API without internal driver
support, invoking the parsing functions directly). As the domain conf
is a neccessary argument to parse the device XML. (e.g. for an Input
device). Although we can bypass that by modification on
virDomainDeviceDefParse, it could be trap as we will parse the device
XML in another way which is different with the real parsing. So finally
I choosed to implement the driver support for the new API. There might
be something I didn't take into consideration, (e.g. Do we need some
flags for the XML parsing and formating?). But it can demo the thought
good enough.
On the other hand, I'm wondering if it's deserved to introduce such
an API, comparing it's usage, is it two heavy if we need the internal
drivers support for such an API?
Any thoughts and feedback is welcomed.
[PATCH 1/6] normalize_xml: Define the new API
[PATCH 2/6] normalize_xml: Implement the new API
[PATCH 3/6] normalize_xml: Wire up the remote protocol
[PATCH 4/6] normalize_xml: New internal API to format device XML
[PATCH 5/6] normalize_xml: Implement qemu driver support
[PATCH 6/6] normalize_xml: New virsh command to normalize device XML
Regards,
Osier