Output is never tested, isn't it possible the virst command could return 0 but the XML could be invalid?  Suggest dumping the output into a temporary file and running <code>virt-xml-validate FILE"network" </code> on it.  You can <code>utils.run()</code> this since there is no python-native way to access that tool (AFAIK).