From f4368e5cdf286d065742e0da1977a3e48c091123 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 13 Dec 2011 16:48:05 -0500 Subject: avoid error and trace on dom.vcpus() in lxc This fixes bug 903943. If you used lxc, you'd eventually see stack traces in nova-compute due to use of dom.vcpus(). Change-Id: I8ff4e973d33eef3df116feb237b2febc8e6a59b5 --- nova/virt/libvirt/connection.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index bbd45ee13..864707f20 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -1384,7 +1384,13 @@ class LibvirtConnection(driver.ComputeDriver): total = 0 for dom_id in self._conn.listDomainsID(): dom = self._conn.lookupByID(dom_id) - total += len(dom.vcpus()[1]) + vcpus = dom.vcpus() + if vcpus is None: + # dom.vcpus is not implemented for lxc, but returning 0 for + # a used count is hardly useful for something measuring usage + total += 1 + else: + total += len(vcpus[1]) return total def get_memory_mb_used(self): -- cgit