bug 11212: disable vlan network when vm fails to start. It is still possible for it leak. For example, if the VM object wasn't constructed and we already failed but those cases are less likely and it's not absolutely necessary to disable vlan.

This commit is contained in:
Alex Huang 2011-08-23 11:22:55 -07:00
parent c50a01fa1f
commit b04e14425d
1 changed files with 15 additions and 1 deletions

View File

@ -881,6 +881,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
try {
VM.Record vmr = vm.getRecord(conn);
List<Network> networks = new ArrayList<Network>();
for (VIF vif : vmr.VIFs) {
try {
VIF.Record rec = vif.getRecord(conn);
networks.add(rec.network);
} catch (Exception e) {
s_logger.warn("Unable to cleanup VIF", e);
}
}
if (vmr.powerState == VmPowerState.RUNNING) {
try {
vm.hardShutdown(conn);
@ -911,6 +920,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
s_logger.warn("Unable to cleanup VIF", e);
}
}
for (Network network : networks) {
if (network.getNameLabel(conn).startsWith("VLAN")) {
disableVlanNetwork(conn, network);
}
}
} catch (Exception e) {
s_logger.warn("VM getRecord failed due to ", e);
}
@ -6368,7 +6382,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
* XsNic represents a network and the host's specific PIF.
*/
protected class XsLocalNetwork {
private Network _n;
private final Network _n;
private Network.Record _nr;
private PIF _p;
private PIF.Record _pr;