title: Libvirt: Change network interface of running domain
body: <p>The Virt-Manager is capable of modifying network interfaces of running domains, for example changing the connected network.</p>
  
  <p>I want to script this in python with the libvirt-API. </p>
  
  <pre><code>import libvirt
  conn = libvirt.open('qemu:///system')
  deb = conn.lookupByName('Testdebian')
  xml = deb.XMLDesc()
  xml = replace('old-network-name', 'new-network-name')
  deb.undefine()
  deb = conn.defineXML(xml)
  </code></pre>
  
  <p>But that doesn't work. The network isn't changed. Can someone give me a tipp how to modify a running domain with libvirt? I couldn't find anything about that in the docs. But it must be possible as the Virt-Manager can do it.</p>
  
  <p>Thanks for any help.</p>
  
  <p>Edit: I managed to perform the network change via virsh:</p>
  
  <pre><code>virsh update-device 16 Testdebian.xml
  </code></pre>
  
  <p>Testdebian.xml must contain the interface device only, not the whole domain-XML.</p>
  
  <p>But how can I do this via the libvirt-API? There seems to be no method to perform update-device through the API....</p>