Please check virttest/libvirt_xml/vm_xml.py, there is a sync() method in VMXML class. It can achieve what you want here.