Browse Source

Merge "Avoid crashing while getting libvirt capabilities with unknown arch names" into stable/rocky

tags/18.2.2
Zuul 1 month ago
parent
commit
accbb17592
2 changed files with 19 additions and 5 deletions
  1. 8
    0
      nova/tests/unit/virt/libvirt/test_driver.py
  2. 11
    5
      nova/virt/libvirt/driver.py

+ 8
- 0
nova/tests/unit/virt/libvirt/test_driver.py View File

@@ -16165,6 +16165,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
16165 16165
             guest.domtype = ['kvm']
16166 16166
             caps.guests.append(guest)
16167 16167
 
16168
+            # Include one that is not known to nova to make sure it
16169
+            # does not trip us up.
16170
+            guest = vconfig.LibvirtConfigGuest()
16171
+            guest.ostype = 'hvm'
16172
+            guest.arch = 'itanic'
16173
+            guest.domtype = ['kvm']
16174
+            caps.guests.append(guest)
16175
+
16168 16176
             return caps
16169 16177
 
16170 16178
         self.stubs.Set(host.Host, "get_capabilities",

+ 11
- 5
nova/virt/libvirt/driver.py View File

@@ -5866,11 +5866,17 @@ class LibvirtDriver(driver.ComputeDriver):
5866 5866
             for dt in g.domtype:
5867 5867
                 if dt != CONF.libvirt.virt_type:
5868 5868
                     continue
5869
-                instance_cap = (
5870
-                    fields.Architecture.canonicalize(g.arch),
5871
-                    fields.HVType.canonicalize(dt),
5872
-                    fields.VMMode.canonicalize(g.ostype))
5873
-                instance_caps.append(instance_cap)
5869
+                try:
5870
+                    instance_cap = (
5871
+                        fields.Architecture.canonicalize(g.arch),
5872
+                        fields.HVType.canonicalize(dt),
5873
+                        fields.VMMode.canonicalize(g.ostype))
5874
+                    instance_caps.append(instance_cap)
5875
+                except exception.InvalidArchitectureName:
5876
+                    # NOTE(danms): Libvirt is exposing a guest arch that nova
5877
+                    # does not even know about. Avoid aborting here and
5878
+                    # continue to process the rest.
5879
+                    pass
5874 5880
 
5875 5881
         return instance_caps
5876 5882
 

Loading…
Cancel
Save