Browse Source

Merge "Avoid crashing while getting libvirt capabilities with unknown arch names"

tags/19.0.0.0rc1
Zuul 2 months ago
parent
commit
c8f7246343
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

@@ -16075,6 +16075,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
16075 16075
             guest.domtype = ['kvm']
16076 16076
             caps.guests.append(guest)
16077 16077
 
16078
+            # Include one that is not known to nova to make sure it
16079
+            # does not trip us up.
16080
+            guest = vconfig.LibvirtConfigGuest()
16081
+            guest.ostype = 'hvm'
16082
+            guest.arch = 'itanic'
16083
+            guest.domtype = ['kvm']
16084
+            caps.guests.append(guest)
16085
+
16078 16086
             return caps
16079 16087
 
16080 16088
         self.stub_out('nova.virt.libvirt.host.Host.get_capabilities',

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

@@ -5939,11 +5939,17 @@ class LibvirtDriver(driver.ComputeDriver):
5939 5939
             for dt in g.domtype:
5940 5940
                 if dt != CONF.libvirt.virt_type:
5941 5941
                     continue
5942
-                instance_cap = (
5943
-                    fields.Architecture.canonicalize(g.arch),
5944
-                    fields.HVType.canonicalize(dt),
5945
-                    fields.VMMode.canonicalize(g.ostype))
5946
-                instance_caps.append(instance_cap)
5942
+                try:
5943
+                    instance_cap = (
5944
+                        fields.Architecture.canonicalize(g.arch),
5945
+                        fields.HVType.canonicalize(dt),
5946
+                        fields.VMMode.canonicalize(g.ostype))
5947
+                    instance_caps.append(instance_cap)
5948
+                except exception.InvalidArchitectureName:
5949
+                    # NOTE(danms): Libvirt is exposing a guest arch that nova
5950
+                    # does not even know about. Avoid aborting here and
5951
+                    # continue to process the rest.
5952
+                    pass
5947 5953
 
5948 5954
         return instance_caps
5949 5955
 

Loading…
Cancel
Save