nova/nova/tests
Stephen Finucane ac05bc3b38 Handle multiple 'vcpusched' elements during live migrate
When live migrating a pinned instance, we recalculate pinning
information for the destination host and then update the instance's XML
before spawning the instance there. As part of the pinning information
recalculation, we must also recalculate information for realtime cores,
which are configured using the '<vcpusched>' element. The
'nova.virt.libvirt.migration._update_numa_xml' function, which handles
this updating, was assuming there would only be one of these elements.
This is a reasonably sane assumption since this is all we create in the
'nova.virt.libvirt.LibvirtDriver._get_guest_numa_config' function used
to generate the initial instance XML. However, a look at logs show that
at least some (all?) versions of libvirt actually rewrite the XML we're
providing them. Compare what is returned from '_get_guest_xml':

  DEBUG nova.virt.libvirt.driver [...] [instance: ...] End _get_guest_xml xml=<domain type="kvm">
    ...
    <cputune>
      <shares>4096</shares>
      ...
      <vcpusched vcpus="2-3" scheduler="fifo" priority="1"/>
    </cputune>
    ...
  </domain>
   {{(pid=12600) _get_guest_xml /opt/stack/nova/nova/virt/libvirt/driver.py:6331}}

to what is seen when we enter '_update_numa_xml' (or via 'virsh dumpxml'
at any point after instance creation):

  DEBUG nova.virt.libvirt.migration [-] _update_numa_xml input xml=<domain type="kvm">
    ...
    <cputune>
      <shares>4096</shares>
      ...
      <vcpusched vcpus="2" scheduler="fifo" priority="1"/>
      <vcpusched vcpus="3" scheduler="fifo" priority="1"/>
    </cputune
    ...
  </domain>
   {{(pid=12600) _update_numa_xml /opt/stack/nova/nova/virt/libvirt/migration.py:97}

The solution is simple: rather than trying to modify the existing XML,
simply scrap it and rebuild the elements from scratch. We should
probably do this for all elements, but that can/should be tackled
separately.

Change-Id: Ic01603a91f6099f1068af0e955f3e1056021d673
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-Bug: #1889257
(cherry picked from commit b6aef1ec4f)
2020-07-29 18:00:43 +01:00
..
functional objects: Update keypairs when saving an instance 2020-07-23 09:46:14 +00:00
unit Handle multiple 'vcpusched' elements during live migrate 2020-07-29 18:00:43 +01:00
__init__.py
fixtures.py Repro bug 1845530: versioned discovery is authed 2020-04-03 21:24:28 +00:00
json_ref.py Transform instance.exists notification 2018-06-05 12:51:30 +00:00