summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-15 13:13:56 +0000
committerGerrit Code Review <review@openstack.org>2019-03-15 13:13:56 +0000
commitc8f7246343e4f7ca280c10554e3fc06fd46dfefa (patch)
treea35d1b460dfb7a43be753fff55be575b3bae3b4f
parent5ca858eaa72acd0513e27a4c9518980b769f5d6e (diff)
parent71df650d0a390d2b6b19928db4379e723e9f5cde (diff)
Merge "Avoid crashing while getting libvirt capabilities with unknown arch names"
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py8
-rw-r--r--nova/virt/libvirt/driver.py16
2 files changed, 19 insertions, 5 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index d6af86e..d2cf52f 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -16075,6 +16075,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
16075 guest.domtype = ['kvm'] 16075 guest.domtype = ['kvm']
16076 caps.guests.append(guest) 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 return caps 16086 return caps
16079 16087
16080 self.stub_out('nova.virt.libvirt.host.Host.get_capabilities', 16088 self.stub_out('nova.virt.libvirt.host.Host.get_capabilities',
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 692d883..a23b563 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -5939,11 +5939,17 @@ class LibvirtDriver(driver.ComputeDriver):
5939 for dt in g.domtype: 5939 for dt in g.domtype:
5940 if dt != CONF.libvirt.virt_type: 5940 if dt != CONF.libvirt.virt_type:
5941 continue 5941 continue
5942 instance_cap = ( 5942 try:
5943 fields.Architecture.canonicalize(g.arch), 5943 instance_cap = (
5944 fields.HVType.canonicalize(dt), 5944 fields.Architecture.canonicalize(g.arch),
5945 fields.VMMode.canonicalize(g.ostype)) 5945 fields.HVType.canonicalize(dt),
5946 instance_caps.append(instance_cap) 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 return instance_caps 5954 return instance_caps
5949 5955