capabilities: Handle missing cpu_map.xml

It shouldn't be a fatal issue. Hit on freebsd where they install
libvirt bits into /usr/local

https://www.redhat.com/archives/virt-tools-list/2015-September/msg00056.html
This commit is contained in:
Cole Robinson 2015-09-16 16:55:37 -04:00
parent 5df6757a0b
commit b15c44923c

View File

@ -19,6 +19,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
import logging
import os
import re
from .cpu import CPU as DomainCPU
@ -55,7 +57,12 @@ class _CPUMapFileValues(XMLBuilder):
_cpu_filename = "/usr/share/libvirt/cpu_map.xml"
def __init__(self, conn):
if os.path.exists(self._cpu_filename):
xml = file(self._cpu_filename).read()
else:
xml = None
logging.debug("CPU map file not found: %s", self._cpu_filename)
XMLBuilder.__init__(self, conn, parsexml=xml)
self._archmap = {}