Hi administrator,
I am a cloud compute developer. I need some help from you about libvirt.
I have a work to modify a image file which is saved by virDomainSave() or virDomainSaveFlags(). So virDomainSaveImageGetXMLDesc() and virDomainSaveImageDefineXML() are APIs I choosed to do.
Because I found a sentence: A save file can be inspected or modified slightly with virDomainSaveImageGetXMLDesc() and virDomainSaveImageDefineXML().
But an error is happened when I do like that.  libvirt: QEMU Driver error: operation failed: new xml too large to fit in file.
I found that if I increase strlen(xml_old) to strlen(xml_new).
if (strlen(xml_new) - strlen(xml_old) <= 29) {
this is right;
}
but if (strlen(xml_new) - strlen(xml_old) >= 50) {
this is error;
}
But I don't choose to find an accurate number.  I think this value will be affected by some factors.
For example: memory alignment, range safety or other rules.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                           strlen(xml_old)                                                  +  free space  +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                             strlen(xml_new)                                                                     +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I really want to know how long free space I can use. Can you convert slightly to a precise number?
Thank you for taking so long to read my Email.
Looking forward to your reply.
ps:
OS: CentOS7.4
libvirt: 4.5.0
hypervisor: KVM
Sincerely, 
Vincent Wu