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
# 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
# on hosts that run system vms, values for mode are: private, bridge, vepa
# 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>();
Connect conn = null;
try {
conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString());
vmStates.putAll(getAllVms(conn));
} catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
if (_hypervisorType == HypervisorType.LXC) {
try {
conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString());
vmStates.putAll(getAllVms(conn));
} catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
}
}
try {
conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString());
vmStates.putAll(getAllVms(conn));
} catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
if (_hypervisorType == HypervisorType.KVM) {
try {
conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString());
vmStates.putAll(getAllVms(conn));
} catch (LibvirtException e) {
s_logger.debug("Failed to get connection: " + e.getMessage());
}
}
return vmStates;