agent: Only probe running VMs for the current Hypervisor Type

Otherwise we try to probe for LXC VMs on a KVM hypervisor and vise versa.
This commit is contained in:
Wido den Hollander 2013-05-26 11:38:00 +02:00
parent 5b902c7005
commit 322db71eed
2 changed files with 19 additions and 10 deletions

View File

@ -84,6 +84,11 @@ domr.scripts.dir=scripts/network/domr/kvm
# set the hypervisor type, values are: kvm, lxc # set the hypervisor type, values are: kvm, lxc
# hypervisor.type=kvm # hypervisor.type=kvm
# set the hypervisor URI. Usually there is no need for changing this
# For KVM: qemu:///system
# For LXC: lxc:///
# hypervisor.uri=qemu:///system
# settings to enable direct networking in libvirt, should not be used # settings to enable direct networking in libvirt, should not be used
# on hosts that run system vms, values for mode are: private, bridge, vepa # on hosts that run system vms, values for mode are: private, bridge, vepa
# libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver # libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver

View File

@ -3943,18 +3943,22 @@ ServerResource {
final HashMap<String, State> vmStates = new HashMap<String, State>(); final HashMap<String, State> vmStates = new HashMap<String, State>();
Connect conn = null; Connect conn = null;
try { if (_hypervisorType == HypervisorType.LXC) {
conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString()); try {
vmStates.putAll(getAllVms(conn)); conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString());
} catch (LibvirtException e) { vmStates.putAll(getAllVms(conn));
s_logger.debug("Failed to get connection: " + e.getMessage()); } catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
}
} }
try { if (_hypervisorType == HypervisorType.KVM) {
conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); try {
vmStates.putAll(getAllVms(conn)); conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString());
} catch (LibvirtException e) { vmStates.putAll(getAllVms(conn));
s_logger.debug("Failed to get connection: " + e.getMessage()); } catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
}
} }
return vmStates; return vmStates;