Skip to content

Commit dda1133

Browse files
committed
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
1 parent 9fa56e2 commit dda1133

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,41 @@ public String connect(final String ipAddress, final int port) {
12151215
return "Unable to connect";
12161216
}
12171217

1218+
public boolean connect(final String ipAddress, int retry, int sleep) {
1219+
for (int i = 0; i <= retry; i++) {
1220+
SocketChannel sch = null;
1221+
try {
1222+
if (s_logger.isDebugEnabled()) {
1223+
s_logger.debug("Trying to connect to " + ipAddress);
1224+
}
1225+
sch = SocketChannel.open();
1226+
sch.configureBlocking(true);
1227+
1228+
final InetSocketAddress addr = new InetSocketAddress(ipAddress, _port);
1229+
sch.connect(addr);
1230+
return true;
1231+
} catch (final IOException e) {
1232+
if (s_logger.isDebugEnabled()) {
1233+
s_logger.debug("Could not connect to " + ipAddress);
1234+
}
1235+
} finally {
1236+
if (sch != null) {
1237+
try {
1238+
sch.close();
1239+
} catch (final IOException e) {}
1240+
}
1241+
}
1242+
try {
1243+
Thread.sleep(sleep);
1244+
} catch (final InterruptedException e) {
1245+
}
1246+
}
1247+
1248+
s_logger.debug("Unable to logon to " + ipAddress);
1249+
1250+
return false;
1251+
}
1252+
12181253
@Override
12191254
public String getName() {
12201255
return _name;

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,16 +3534,19 @@ protected StartAnswer execute(StartCommand cmd) {
35343534
if (vmSpec.getType() != VirtualMachine.Type.User) {
35353535
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)
35363536
//wait for 5 minutes at most
3537+
String controlIp = null;
3538+
for (NicTO nic : nics) {
3539+
if (nic.getType() == TrafficType.Control) {
3540+
controlIp = nic.getIp();
3541+
}
3542+
}
35373543
for (int count = 0; count < 30; count ++) {
3538-
boolean succeed = passCmdLine(vmName, vmSpec.getBootArgs());
3539-
if (succeed) {
3544+
passCmdLine(vmName, vmSpec.getBootArgs());
3545+
//check router is up?
3546+
boolean result = _virtRouterResource.connect(controlIp, 1, 5000);
3547+
if (result) {
35403548
break;
35413549
}
3542-
try {
3543-
Thread.sleep(5000);
3544-
} catch (InterruptedException e) {
3545-
s_logger.trace("Ignoring InterruptedException.", e);
3546-
}
35473550
}
35483551
} else {
35493552
passCmdLine(vmName, vmSpec.getBootArgs() );

0 commit comments

Comments
 (0)