Commit Graph

1850 Commits

Author SHA1 Message Date
Zuul 1bca24aeb0 Merge "Always delete NVRAM files when deleting instances" 2024-04-04 22:14:14 +00:00
Sylvain Bauza d445eaf9dd vgpu: Allow device_addresses to not be set
Sometimes, some GPU may have a long list of PCI addresses (say a SRIOV
GPU) or operators may have a long list of GPUs. In order to help their
lifes, let's allow device_addresses to be optional.

This means that a valid configuration could be :

    [devices]
    enabled_mdev_types = nvidia-35, nvidia-36

    [mdev_nvidia-35]

    [mdev_nvidia-36]

NOTE(sbauza): we have a slight coverage gap for testing what happens
if the groups aren't set, but I'll add it in a next patch

Related-Bug: #2041519
Change-Id: I73762a0295212ee003db2149d6a9cf701023464f
2024-03-05 11:48:25 +01:00
Sylvain Bauza 60851e4464 libvirt: Cap with max_instances GPU types
We want to cap a maximum mdevs we can create.
If some type has enough capacity, then other GPUs won't be used and
existing ResourceProviders would be deleted.

Closes-Bug: #2041519
Change-Id: I069879a333152bb849c248b3dcb56357a11d0324
2024-03-05 11:48:19 +01:00
Lee Yarwood 177c184e40 libvirt: Configure and teardown ephemeral encryption secrets
This adds configuration of the default ephemeral encryption format and
sets default encryption attributes in the driver block device mapping
when needed. This includes generation of a secret passphrase when one
has not been provided.

Co-Authored-By: melanie witt <melwittt@gmail.com>

Related to blueprint ephemeral-encryption-libvirt

Change-Id: I052441076c677c0fe76a8d9421af70b0ffa1d400
2024-02-28 07:56:42 +00:00
Zuul 7fa1859576 Merge "libvirt: Support maxphysaddr." 2024-02-28 06:18:08 +00:00
Nobuhiro MIKI 1038a63387 libvirt: Support maxphysaddr.
With Libvirt v8.7.0+, the <maxphysaddr> sub-element
of the <cpu> element specifies the number of vCPU
physical address bits [1].

[1] https://libvirt.org/news.html#v8-7-0-2022-09-01

New flavor extra_specs and image properties are added to
control the physical address bits of vCPUs in Libvirt guests.
The nova-scheduler requests COMPUTE_ADDRESS_SPACE_* traits
based on them. The traits are already defined in os-traits
v2.10.0. Also numerical comparisons are performed at
both compute capabilities filter and image props filter.

blueprint: libvirt-maxphysaddr-support-caracal
Change-Id: I98968f6ef1621c9fb4f682c119038e26d62ce381
Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
2024-02-27 14:16:25 +09:00
Zuul 326a41b3b3 Merge "Catch ImageNotFound on snapshot failure" 2024-02-26 20:59:58 +00:00
Zuul 9a9ab2128b Merge "Reserve mdevs to return to the source" 2024-02-23 15:46:08 +00:00
Zuul bdd7daffbb Merge "Check if destination can support the src mdev types" 2024-02-23 15:46:01 +00:00
Zuul f15b8b7204 Merge "check both source and dest compute libvirt versions for mdev lv" 2024-02-23 15:40:00 +00:00
Dan Smith 40a56ce05b Catch ImageNotFound on snapshot failure
Right now we're logging this as an unexpected failure, complete with
full traceback. However, this is expected if an image is deleted
mid-snapshot, as is the case in one of our tempest tests.

Change-Id: I6eb76c0500c7940778b7a15ac5202659ef92a82a
2024-02-22 11:21:49 -08:00
Sylvain Bauza 2e1e12cd62 Reserve mdevs to return to the source
The destination lookups at the src mdev types and returns its own
mdevs using the same type. We also reserve them by an internal dict
and we make sure we can cleanup this dict if the live-migration aborts.

Partially-Implements: blueprint libvirt-mdev-live-migrate
Change-Id: I4a7e5292dd3df63943bd9f01803fa933e0466014
2024-02-16 16:05:48 +01:00
Zuul 84a3e254e8 Merge "libvirt: stop enabling hyperv feature reenlightenment" 2024-02-15 13:21:27 +00:00
Zuul f315c5658e Merge "libvirt: Stop unconditionally enabling evmcs" 2024-02-15 10:22:41 +00:00
Sylvain Bauza 489aab934c Check if destination can support the src mdev types
Now that the source knows that both the computes support the right
libvirt version, it passes to the destination the list of mdevs it has
for the instance. By this change, we'll verify if the types of those
mdevs are actually supported by the destination.
On the next change, we'll pass the destination mdevs back to the
source.

Partially-Implements: blueprint libvirt-mdev-live-migrate
Change-Id: Icb52fa5eb0adc0aa6106a90d87149456b39e79c2
2024-02-05 15:10:55 +01:00
Sylvain Bauza baa78326dd check both source and dest compute libvirt versions for mdev lv
Since only qemu 8.1 and libvirt 8.6.0 supports mdev live-migration,
we need to verify the values of the hypervisor for both the source
and the destination.

If one of them are older, the conductor raises an exception that will
eventually fact the API to return an HTTP500.

Change-Id: I17f170143c58401b8b0a5a93e83355b1f7178ab5
Partially-Implements: blueprint libvirt-mdev-live-migrate
2024-01-30 20:45:13 +01:00
Simon Hensel 406d590a36 Always delete NVRAM files when deleting instances
When deleting an instance, always send VIR_DOMAIN_UNDEFINE_NVRAM to
delete the NVRAM file, regardless of whether the image is of type UEFI.
This prevents a bug when rebuilding an instance from an UEFI image to a
non-UEFI image.

Closes-Bug: #1997352

Change-Id: I24648f5b7895bf5d093f222b6c6e364becbb531f
Signed-off-by: Simon Hensel <simon.hensel@inovex.de>
2024-01-23 16:16:17 +01:00
songjie e618e78edc libvirt: stop enabling hyperv feature reenlightenment
The 'reenlightenment' hyperv enlightenment will cause
instances live-migration to fail (KVM currently doesn’t
fully support reenlightenment notifications, see
www.qemu.org/docs/master/system/i386/hyperv.html),
so don't enable it now.

Change-Id: I6821819450bc96e4304125ea3b76a0e462e6e33f
Closes-Bug: #2046549
Related-Bug: #2009280
2023-12-29 09:29:01 +08:00
Zuul 3e108ef13a Merge "Use configuration for single enabled mdev type" 2023-12-20 13:08:31 +00:00
Zuul 5e914c27a0 Merge "Bump hacking version" 2023-12-18 21:20:36 +00:00
Sivasathurappan Radhakrishnan 33fa92b6cb Allow live migrate paused instance when post copy is enabled
Live migration of paused instance fails when VIR_MIGRATE_POSTCOPY
flag is set. In this patch, the flag is unset to permit live migration
of paused instance.

Change-Id: Ib5cbc948cb953e35a22bcbb859976f0afddcb662
Closes-Bug: #1671011
2023-12-18 14:11:16 +00:00
Stephen Finucane 3973fc393c Bump hacking version
This bumps the version of flake8 and resolves some erroneous failures in
f-strings. A number of new E721 (do not compare types) class errors are
picked up, which are all addressed.

Change-Id: I7a1937b107ff3af8d1e5fe23fc32b120ef4697f7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-12-14 10:54:26 +00:00
Zuul 17b7aa3926 Merge "[codespell] fix typos in tests" 2023-12-13 23:46:08 +00:00
Artom Lifshitz 86a35e97d2 libvirt: Stop unconditionally enabling evmcs
In I008841988547573878c4e06e82f0fa55084e51b5 we started enabling a
bunch of libvirt enlightenments for Windows unconditionally. Turns
out, the `evmcs` enlightenment only works on Intel hosts, and we broke
the ability to run Windows guests on AMD machines. Until we become
smarter about conditionally enabling evmcs (with something like traits
for host CPU features), just stop enabling it at all.

Change-Id: I2ff4fdecd9dc69de283f0e52e07df1aeaf0a9048
Closes-bug: 2009280
2023-12-13 09:23:10 -05:00
Zuul 85254256b4 Merge "Detach disks using alias when possible" 2023-12-12 14:54:05 +00:00
Zuul 33ab9c5d0e Merge "[libvirt]Add migration_inbound_addr" 2023-12-05 11:43:35 +00:00
Zuul 8ac050c253 Merge "Packed virtqueue support was added." 2023-11-30 12:12:03 +00:00
Danylo Vodopianov eb8519d811 Packed virtqueue support was added.
1) Extend flavor/image extra spec.
2) New xml parameter for qemu command was added.
3) New request filter added for scheduler.
4) Unit and Functional tests were updated
5) Requirments was updated ( os-traits = 3.0.0 )
6) Releasnote was added

Nova spec: https://review.opendev.org/c/openstack/nova-specs/+/868377

Depends-On: https://review.opendev.org/c/openstack/os-traits/+/876069
Change-Id: I789eeae86947e9a3cbd7d5fcc58d2aabe3b8b84c
2023-11-29 16:06:33 +02:00
Pavlo Shchelokovskyy c28494fd27 Use configuration for single enabled mdev type
Even when having specified a single mdev type,
operator still might want to expose only one
of available mdev-capable PCI devices to users,
or use a custom resource class for it.

NOTE(sbauza): That patch isn't changing the current behaviour (you
can see the tests) but it just removes a weird limitation (that I
wrote, sorry folks !)

Co-Authored-By: Sylvain Bauza <sbauza@redhat.com>

Change-Id: I9f42410e407902b2f562adaa506f14cbc69898d4
2023-11-24 16:06:58 +01:00
Takashi Kajinami 03055de176 Detect maximum number of SEV guests automatically
Libvirt has implemented the capability to expose maximum number of
SEV guests and SEV-ES guests in 8.0.0[1][2]. This allows nova to detect
maximum number of memory encrypted guests using that feature.
The detection is not used if the [libvirt] num_memory_encrypted_guests
option is set to preserve the current behavior.

Note that current nova supports only SEV and does not support SEV-ES,
so this implementation only uses the maximum number of SEV guests.
The maximum number of SEV-ES guests will be used in case we implement
support for SEV-ES.

[1] 34cb8f6fcd
[2] 7826148a72

Implements: blueprint libvirt-detect-sev-max-guests
Change-Id: I502e1713add7e6a1eb11ecce0cc2b5eb6a14527a
2023-11-23 07:58:54 +00:00
Dan Smith 1ed02d57c0 Detach disks using alias when possible
This makes us attempt to first look up a disk device by alias using
the volume_uuid, before falling back to the old method of using the
guest target device name.

Related to blueprint libvirt-dev-alias

Change-Id: I1dfe4ad3df81bc810835af9b09cfc6c06e9a5388
2023-11-15 07:07:19 -08:00
Balazs Gibizer 6bca37e904 [libvirt]Add migration_inbound_addr
For live migration the libvirt driver already supports generating the
migration URL based on the compute host hostname if so configured.
However for the non live move operations the driver always used the IP
address of the compute host based on [DEFAULT]my_ip.

Some deployments rely on DNS to abstract the IP address management. In
these environments it is beneficial if nova allows connection between
compute hosts based on the hostname (or FQDN) of the host instead of
trying to configure [DEFAUL]my_ip to an IP address.

This patch introduces a new config option
[libvirt]migration_inbound_addr that is used to determine the address
for incoming move operations (cold migrate, resize, evacuate). This
config is defaulted to [DEFAULT]my_ip to keep the configuration backward
compatible. However it allows an explicit hostname or FQDN to be
specified, or allows to specify '%s' that is then resolved to the
hostname of compute host.

blueprint: libvirt-migrate-with-hostname-instead-of-ip

Change-Id: I6a80b5620f32770a04c751143c4ad07882e9f812
2023-11-12 10:27:51 +01:00
Sean Mooney 2232ca95f2 [codespell] fix typos in tests
this mainly fixes typos in the tests and
one type in an exception message.
some addtional items are added to the dict based on
our usage of vars in test but we could remove them later
by doing minor test updates. They are intentionally not
fixed in this commit to limit scope creep.

Change-Id: Iacfbb0a5dc8ffb0857219c8d7c7a7d6e188f5980
2023-10-03 11:08:55 +01:00
Zuul 88c73e2931 Merge "Bump MIN_{LIBVIRT,QEMU} for "Bobcat"" 2023-09-01 04:56:37 +00:00
Kashyap Chamarthy b6cf8e6128 Bump MIN_{LIBVIRT,QEMU} for "Bobcat"
The minimum required version of QEMU is now 5.2.0, and of libvirt is
7.0.0.

The below version constants get removed:

  - MIN_LIBVIRT_VIOMMU_AW_BITS
  - MIN_LIBVIRT_VDPA
  - MIN_QEMU_VDPA
  - MIN_LIBVIRT_AARCH64_CPU_COMPARE

Adjust the related unit tests accordingly.

Change-Id: Ie805eb7fa59f9f7728da27fddbd6e968e971a2e4
Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2023-07-24 13:39:42 +02:00
Nobuhiro MIKI 2fd034ec48 libvirt: Add 'COMPUTE_ADDRESS_SPACE_*' traits support
Based on the Libvirt and QEMU versions, two traits,
COMPUTE_ADDRESS_SPACE_PASSTHROUGH and COMPUTE_ADDRESS_SPACE_EMULATED,
are controlled. Since the two are supported from the same version on
the Libvirt and QEMU, Nova handles them in the same way.

Blueprint: libvirt-maxphysaddr-support
Depends-On: https://review.opendev.org/c/openstack/os-traits/+/871226
Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
Change-Id: If6c7169b7b8f43ad15a8992831824fb546e85aab
2023-07-24 17:09:19 +09:00
yatinkarel 3f7cc63d94 Add config option to configure TB cache size
Qemu>=5.0.0 bumped the default tb-cache size to 1GiB(from 32MiB)
and this made it difficult to run multiple guest VMs on systems
running with lower memory. With Libvirt>=8.0.0 it's possible to
configure lower tb-cache size.

Below config option is introduced to allow configure
TB cache size as per environment needs, this only
applies to 'virt_type=qemu':-

[libvirt]tb_cache_size

Also enable this flag in nova-next job.

[1] https://github.com/qemu/qemu/commit/600e17b26
[2] https://gitlab.com/libvirt/libvirt/-/commit/58bf03f85

Closes-Bug: #1949606
Implements: blueprint libvirt-tb-cache-size
Change-Id: I49d2276ff3d3cc5d560a1bd96f13408e798b256a
2023-07-13 19:35:52 +05:30
melanie witt db455548a1 Use force=True for os-brick disconnect during delete
The 'force' parameter of os-brick's disconnect_volume() method allows
callers to ignore flushing errors and ensure that devices are being
removed from the host.

We should use force=True when we are going to delete an instance to
avoid leaving leftover devices connected to the compute host which
could then potentially be reused to map to volumes to an instance that
should not have access to those volumes.

We can use force=True even when disconnecting a volume that will not be
deleted on termination because os-brick will always attempt to flush
and disconnect gracefully before forcefully removing devices.

Closes-Bug: #2004555

Change-Id: I3629b84d3255a8fe9d8a7cea8c6131d7c40899e8
2023-05-10 07:09:05 -07:00
Zuul cb2cdee4c9 Merge "Have host look for CPU controller of cgroupsv2 location." 2023-05-04 10:27:32 +00:00
Jorge San Emeterio 973ff4fc1a Have host look for CPU controller of cgroupsv2 location.
Make the host class look under '/sys/fs/cgroup/cgroup.controllers' for support of the cpu controller. The host will try searching through cgroupsv1 first, just like up until now, and in the case that fails, it will try cgroupsv2 then. The host will not support the feature if both checks fail.

This new check needs to be mocked by all tests that focus on this piece of code, as it touches a system file that requires privileges. For such thing, the CGroupsFixture is defined to easily add suck mocking to all test cases that require so.

I also removed old mocking at test_driver.py in favor of the fixture from above.

Partial-Bug: #2008102
Change-Id: I99b57c27c8a4425389bec2b7f05af660bab85610
2023-05-03 15:03:07 -07:00
Zuul 6b0b009783 Merge "Fix logging in MemEncryption-related checks" 2023-02-28 20:28:08 +00:00
Zuul 5ddb70c55d Merge "libvirt: let CPUs be power managed" 2023-02-18 12:34:08 +00:00
Zuul 5c32d5efe1 Merge "libvirt: Add configuration options to set SPICE compression settings" 2023-02-17 01:45:41 +00:00
Alexey Stupnikov 54faea0196 Fix logging in MemEncryption-related checks
Currently Nova produces ambigous error when volume-backed instance
is started using flavor with hw:mem_encryption extra_specs flag:
ImageMeta doesn't contain name if it represents Cinder volume.

This fix sligtly changes steps to get image_meta.name for
some MemEncryption-related checks where it could make any
difference.

Closes-bug: #2006952
Change-Id: Ia69e7cb18cd862f01ecfdbdc358c87af1ab8fbf6
2023-02-11 12:59:02 +01:00
Sylvain Bauza 96f9518096 libvirt: let CPUs be power managed
Before going further, we need to somehow return the list of CPUs even offline
if they are power managed by Nova.

Co-Authored-By: Sean Mooney <smooney@redhat.com>
Partially-Implements: blueprint libvirt-cpu-state-mgmt
Change-Id: I5dca10acde0eff554ed139587aefaf2f5fad2ca5
2023-02-10 12:16:57 +01:00
Zuul c993d8d311 Merge "Add further workaround features for qemu_monitor_announce_self" 2023-01-31 23:07:43 +00:00
as0 fba851bf3a Add further workaround features for qemu_monitor_announce_self
In some cases on Arista VXLAN fabrics, VMs are inaccessible via network
after live migration, despite garps being observed on the fabric itself.

This patch builds on the feature
``[workarounds]/enable_qemu_monitor_announce_self`` feature as reported
in `bug 1815989 <https://bugs.launchpad.net/nova/+bug/1815989>`

This patch adds the ability to config the number of times the QEMU
announce_self monitor command is called, and add a new configuration option to
specify a delay between calling the announce_self command multiple times,
as in some cases, multiple announce_self monitor commands are required for
the fabric to honor the garp packets and the VM to become accessible via
the network after live migration.

Closes-Bug: #1996995
Change-Id: I2f5bf7c9de621bb1dc7fae5b3374629a4fcc1f46
2023-01-30 15:44:44 +00:00
Zuul ffccf7022e Merge "libvirt: Replace usage of compareCPU() with compareHypervisorCPU()" 2023-01-26 17:50:28 +00:00
Zuul f9dc9f259b Merge "libvirt: At start-up rework compareCPU() usage with a workaround" 2023-01-26 13:48:02 +00:00
Kashyap Chamarthy 468b03e0ee libvirt: Replace usage of compareCPU() with compareHypervisorCPU()
The older libvirt API compareCPU() does not take into account the
capabilities of the "host hypervisor" (KVM, QEMU and the details libvirt
knows about the host) when comparing CPUs.  This is causing unwanted
failures during CPU compatibility checks.  To fix this and other related
problems, libvirt has introduced (in v4.4.0) a newer API,
compareHypervisorCPU(), which _does_ take into account the host
hypervisor's capabilities before comparing CPUs.  This will help fix a
range of problems, such as[1][2].

So let's switch to the newer API, which is largely a drop-in
replacement.

In this patch:

 - Introduce a wrapper method, compare_hypervisor_cpu() for libvirt's
   compareHypervisorCPU() API.

 - Update the _compare_cpu() method to use the wrapper method,
   compare_hypervisor_cpu().

 - Update the unit tests to use the newer API, compareHypervisorCPU().

[1] https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1978064
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2138381

Change-Id: Ib523753f52993cfe72e35e0309e429ca879c125c
Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2023-01-24 11:28:43 +01:00