FYI/TIP: You can save some memory by just doing <code>device = vm_xml.VMXML.get_net_dev(vm_name)[0]</code>.

What you have here is fine also.