CLOUDSTACK-4436: in case of older kvm host, we'd better try serveral times to make sure we passed cmdline parameters to system vms

Conflicts:

	core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
This commit is contained in:
Edison Su 2013-09-25 16:10:57 -07:00
parent 9fa56e28ec
commit dda1133f12
2 changed files with 46 additions and 8 deletions

View File

@ -1215,6 +1215,41 @@ public class VirtualRoutingResource implements Manager {
return "Unable to connect"; return "Unable to connect";
} }
public boolean connect(final String ipAddress, int retry, int sleep) {
for (int i = 0; i <= retry; i++) {
SocketChannel sch = null;
try {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Trying to connect to " + ipAddress);
}
sch = SocketChannel.open();
sch.configureBlocking(true);
final InetSocketAddress addr = new InetSocketAddress(ipAddress, _port);
sch.connect(addr);
return true;
} catch (final IOException e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Could not connect to " + ipAddress);
}
} finally {
if (sch != null) {
try {
sch.close();
} catch (final IOException e) {}
}
}
try {
Thread.sleep(sleep);
} catch (final InterruptedException e) {
}
}
s_logger.debug("Unable to logon to " + ipAddress);
return false;
}
@Override @Override
public String getName() { public String getName() {
return _name; return _name;

View File

@ -3534,15 +3534,18 @@ ServerResource {
if (vmSpec.getType() != VirtualMachine.Type.User) { if (vmSpec.getType() != VirtualMachine.Type.User) {
if ((_kernelVersion < 2006034) && (conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4) if ((_kernelVersion < 2006034) && (conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4)
//wait for 5 minutes at most //wait for 5 minutes at most
for (int count = 0; count < 30; count ++) { String controlIp = null;
boolean succeed = passCmdLine(vmName, vmSpec.getBootArgs()); for (NicTO nic : nics) {
if (succeed) { if (nic.getType() == TrafficType.Control) {
break; controlIp = nic.getIp();
} }
try { }
Thread.sleep(5000); for (int count = 0; count < 30; count ++) {
} catch (InterruptedException e) { passCmdLine(vmName, vmSpec.getBootArgs());
s_logger.trace("Ignoring InterruptedException.", e); //check router is up?
boolean result = _virtRouterResource.connect(controlIp, 1, 5000);
if (result) {
break;
} }
} }
} else { } else {