0

Let's say, that I have a virtual machine named test with following configuration:

$ virsh dumpxml test
<domain type='kvm' id='42'>
  <name>test</name>
  <uuid>4b72f3be-41f5-41ec-8149-647ab73d92f7</uuid>
  /* output removed for brevity */
    <interface type='bridge'>
      <mac address='52:54:00:fb:3f:85'/>
      <source bridge='br1'/>
      <target dev='vnet23'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='52:54:00:94:7d:c8'/>
      <source bridge='br2'/>
      <target dev='vnet24'/>
      <model type='virtio'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>
  /* output removed for brevity */
  </devices>
</domain>

$

Now I edit the configuration with virsh edit test and associate the vnet24 with br3 instead of br2. Is it possible to apply those changes without restarting the virtual machine? Obviously, one option is to set this manually with ip or brctl utility, but maybe it's somehow possible with virsh as well?

1 Answer 1

2
+200

If you have a file update.xml

<interface type='bridge'>
  <mac address='52:54:00:94:7d:c8'/>
  <source bridge='br3'/>
  <target dev='vnet24'/>
  <model type='virtio'/>
  <alias name='net2'/>
</interface>

You can do

sudo virsh update-device test update.xml --persistent

Notice that I omitted <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> from update.xml because if I don't for some reason I can't add --persistent flag. --persistent flag equals --live (to apply to a running domain) --config (to affect next startup)

Source: https://www.libvirt.org/manpages/virsh.html#update-device

Also interesting attach-interface command which lets you add a new interface on the fly (https://www.libvirt.org/manpages/virsh.html#attach-interface)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .