Skip to content
Browse files

Running make indent on codebase

EUCA-3902
  • Loading branch information...
1 parent ecf7884 commit 673fd1ba12487afebf4ad3500f427c48e525b9b6 @gelinasc gelinasc committed May 8, 2013
View
48 cluster/handlers.c
@@ -2150,7 +2150,8 @@ int refresh_resources(ncMetadata * pMeta, int timeout, int dolock)
resourceCacheStage->resources[i].hostname,
ncResDst->nodeStatus,
ncResDst->memorySizeAvailable, ncResDst->memorySizeMax,
- ncResDst->diskSizeAvailable, ncResDst->diskSizeMax, ncResDst->numberOfCoresAvailable, ncResDst->numberOfCoresMax, (ncResDst->migrationCapable == TRUE) ? "TRUE" : "FALSE");
+ ncResDst->diskSizeAvailable, ncResDst->diskSizeMax, ncResDst->numberOfCoresAvailable, ncResDst->numberOfCoresMax,
+ (ncResDst->migrationCapable == TRUE) ? "TRUE" : "FALSE");
resourceCacheStage->resources[i].maxMemory = ncResDst->memorySizeMax;
resourceCacheStage->resources[i].availMemory = ncResDst->memorySizeAvailable;
resourceCacheStage->resources[i].maxDisk = ncResDst->diskSizeMax;
@@ -2256,12 +2257,14 @@ static int migration_handler(ccInstance * myInstance, char *host, char *src, cha
if (!strcmp(host, dst)) {
if ((migration_state == MIGRATION_READY) && !strcmp(myInstance->state, "Extant")) {
- LOGDEBUG("[%s] destination node %s reports %s(%s), checking source node %s\n", myInstance->instanceId, host, myInstance->state, migration_state_names[myInstance->migration_state], src);
+ LOGDEBUG("[%s] destination node %s reports %s(%s), checking source node %s\n", myInstance->instanceId, host, myInstance->state,
+ migration_state_names[myInstance->migration_state], src);
ccInstance *srcInstance = NULL;
rc = find_instanceCacheId(myInstance->instanceId, &srcInstance);
if (!rc) {
if (srcInstance->migration_state == MIGRATION_READY) {
- LOGINFO("[%s] source node %s last reported %s(%s), destination node %s reports %s(%s), preparing to commit migration\n", myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state, migration_state_names[myInstance->migration_state]);
+ LOGINFO("[%s] source node %s last reported %s(%s), destination node %s reports %s(%s), preparing to commit migration\n", myInstance->instanceId, src,
+ srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state, migration_state_names[myInstance->migration_state]);
EUCA_FREE(*node);
EUCA_FREE(*instance);
EUCA_FREE(*action);
@@ -2272,7 +2275,8 @@ static int migration_handler(ccInstance * myInstance, char *host, char *src, cha
LOGDEBUG("[%s] source node %s last reported migration to %s in progress\n", myInstance->instanceId, src, dst);
} else if (srcInstance->migration_state == NOT_MIGRATING) {
LOGINFO("[%s] source node %s last reported %s(%s), destination node %s reports %s(%s), preparing to roll back destination node\n",
- myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state, migration_state_names[myInstance->migration_state]);
+ myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state,
+ migration_state_names[myInstance->migration_state]);
EUCA_FREE(*node);
EUCA_FREE(*instance);
EUCA_FREE(*action);
@@ -2288,7 +2292,8 @@ static int migration_handler(ccInstance * myInstance, char *host, char *src, cha
}
EUCA_FREE(srcInstance);
} else if (((migration_state == MIGRATION_CLEANING) || (migration_state == MIGRATION_READY)) && !strcmp(myInstance->state, "Teardown")) {
- LOGDEBUG("[%s] destination node %s reports %s(%s), checking source node %s\n", myInstance->instanceId, host, myInstance->state, migration_state_names[myInstance->migration_state], src);
+ LOGDEBUG("[%s] destination node %s reports %s(%s), checking source node %s\n", myInstance->instanceId, host, myInstance->state,
+ migration_state_names[myInstance->migration_state], src);
ccInstance *srcInstance = NULL;
rc = find_instanceCacheId(myInstance->instanceId, &srcInstance);
if (!rc) {
@@ -2304,7 +2309,8 @@ static int migration_handler(ccInstance * myInstance, char *host, char *src, cha
/* if (((srcInstance->migration_state == MIGRATION_PREPARING) || (srcInstance->migration_state == MIGRATION_READY)) && !strcmp(srcInstance->state, "Extant")) { */
if ((srcInstance->migration_state == MIGRATION_READY) && !strcmp(srcInstance->state, "Extant")) {
LOGINFO("[%s] source node %s last reported %s(%s), destination node %s reports %s(%s), preparing to roll back source node\n",
- myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state, migration_state_names[myInstance->migration_state]);
+ myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state,
+ migration_state_names[myInstance->migration_state]);
EUCA_FREE(*node);
EUCA_FREE(*instance);
EUCA_FREE(*action);
@@ -2313,14 +2319,16 @@ static int migration_handler(ccInstance * myInstance, char *host, char *src, cha
*action = strdup("rollback");
} else {
LOGDEBUG("[%s] source node %s last reported %s(%s), destination node %s reports %s(%s), doing nothing\n",
- myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state, migration_state_names[myInstance->migration_state]);
+ myInstance->instanceId, src, srcInstance->state, migration_state_names[srcInstance->migration_state], dst, myInstance->state,
+ migration_state_names[myInstance->migration_state]);
}
} else {
LOGDEBUG("[%s] could not find migration source node %s in the instance cache\n", myInstance->instanceId, src);
}
EUCA_FREE(srcInstance);
} else {
- LOGDEBUG("[%s] ignoring update from destination node %s during migration: %s(%s)\n", myInstance->instanceId, host, myInstance->state, migration_state_names[myInstance->migration_state]);
+ LOGDEBUG("[%s] ignoring update from destination node %s during migration: %s(%s)\n", myInstance->instanceId, host, myInstance->state,
+ migration_state_names[myInstance->migration_state]);
}
} else if (!strcmp(host, src)) {
LOGDEBUG("[%s] received state %s(%s) from source node %s\n", myInstance->instanceId, myInstance->state, migration_state_names[migration_state], host);
@@ -3120,14 +3128,14 @@ static int schedule_instance_migration(ncInstance * instance, char **includeNode
LOGINFO("[%s] attempting to schedule migration to specific node: %s\n", instance->instanceId, includeNodes[0]);
if (!strcmp(instance->migration_src, includeNodes[0])) {
LOGERROR("[%s] cannot schedule SAME-NODE migration from %s to %s\n", instance->instanceId, instance->migration_src, includeNodes[0]);
- * replyString = strdup("source and destination cannot be the same");
+ *replyString = strdup("source and destination cannot be the same");
ret = 1;
goto out;
}
ret = schedule_instance_explicit(&(instance->params), includeNodes[0], outresid, TRUE);
if (resourceCacheLocal->resources[*outresid].migrationCapable == FALSE) {
LOGWARN("[%s] cannot schedule migration to node (%s) that is not migration capable\n", instance->instanceId, includeNodes[0]);
- * replyString = strdup("requested destination is not migration capable");
+ *replyString = strdup("requested destination is not migration capable");
ret = 1;
goto out;
}
@@ -3162,7 +3170,8 @@ static int schedule_instance_migration(ncInstance * instance, char **includeNode
LOGDEBUG("[%s] cannot schedule src_index=%d == dst_index=%d (%s > %s), trying again...\n",
instance->instanceId, inresid, *outresid, instance->migration_src, resourceCacheLocal->resources[*outresid].hostname);
} else if (resourceCacheLocal->resources[*outresid].migrationCapable == FALSE) {
- LOGDEBUG("[%s] cannot schedule src_index=%d, dst_index=%d because node %s is not migration capable\n", instance->instanceId, inresid, *outresid, resourceCacheLocal->resources[*outresid].hostname);
+ LOGDEBUG("[%s] cannot schedule src_index=%d, dst_index=%d because node %s is not migration capable\n", instance->instanceId, inresid, *outresid,
+ resourceCacheLocal->resources[*outresid].hostname);
} else if (check_for_string_in_list(resourceCacheLocal->resources[*outresid].hostname, excludeNodes, excludeNodeCount)) {
// Exclusion list takes priority over inclusion list.
LOGDEBUG("[%s] cannot schedule src_index=%d, dst_index=%d because node %s is in destination-exclusion list\n",
@@ -3193,7 +3202,7 @@ static int schedule_instance_migration(ncInstance * instance, char **includeNode
out:
if (ret) {
LOGERROR("[%s] migration scheduler could not schedule destination node\n", instance->instanceId);
- * replyString = strdup("not enough resources available for migration");
+ *replyString = strdup("not enough resources available for migration");
*outresid = -1;
}
@@ -4505,11 +4514,13 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
if (allowHosts) {
// destinationHosts is whitelist, pass as includeNodes.
LOGDEBUG("[%s] scheduling instance with a destination-inclusion list\n", nc_instances[idx]->instanceId);
- rc = schedule_instance_migration(nc_instances[idx], destinationNodes, NULL, destinationNodeCount, 0, src_index, &dst_index, &resourceCacheLocal, &(pMeta->replyString));
+ rc = schedule_instance_migration(nc_instances[idx], destinationNodes, NULL, destinationNodeCount, 0, src_index, &dst_index, &resourceCacheLocal,
+ &(pMeta->replyString));
} else {
LOGDEBUG("[%s] scheduling instance with a destination-exclusion list\n", nc_instances[idx]->instanceId);
// destinationHosts is blacklist, pass as excludeNodes.
- rc = schedule_instance_migration(nc_instances[idx], NULL, destinationNodes, 0, destinationNodeCount, src_index, &dst_index, &resourceCacheLocal, &(pMeta->replyString));
+ rc = schedule_instance_migration(nc_instances[idx], NULL, destinationNodes, 0, destinationNodeCount, src_index, &dst_index, &resourceCacheLocal,
+ &(pMeta->replyString));
}
if (rc || (dst_index == -1)) {
@@ -4543,7 +4554,7 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
nc_instances, found_instances, nodeAction, credentials);
if (rc) {
LOGERROR("failed: request to prepare migration[s] from source %s\n", resourceCacheLocal.resources[src_index].hostname);
- if (pMeta->replyString == NULL) { // NC did not send back an error string
+ if (pMeta->replyString == NULL) { // NC did not send back an error string
pMeta->replyString = strdup("source host was not able to prepare for migration(s)");
}
ret = 1;
@@ -4580,8 +4591,9 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
}
}
- if(dst_index < 0) {
- LOGERROR("[%s] failed: request to prepare migration on destination %s. Invalid resource index -1.\n", nc_instances[idx]->instanceId, resourceCacheLocal.resources[dst_index].hostname);
+ if (dst_index < 0) {
+ LOGERROR("[%s] failed: request to prepare migration on destination %s. Invalid resource index -1.\n", nc_instances[idx]->instanceId,
+ resourceCacheLocal.resources[dst_index].hostname);
exit(1);
}
@@ -4627,7 +4639,6 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
ret = 1;
goto out;
}
-
// Might not have migration_dst in instance struct here if rollback.
// FIXME: In some cases, such as certain rollback requests to source node, this can put the source node's IP in ->migration_dst. Debug.
if (!strlen(nc_instances[0]->migration_dst)) {
@@ -4651,6 +4662,7 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
ret = 1;
goto out;
}
+
out:
for (int z = 0; z < found_instances; z++) {
EUCA_FREE(cc_instances[z]);
View
2 cluster/server-marshal.c
@@ -2013,7 +2013,7 @@ adb_MigrateInstancesResponse_t *MigrateInstancesMarshal(adb_MigrateInstances_t *
snprintf(statusMessage, 255, "ERROR");
}
}
- if (ccMeta.replyString != NULL) { // if replyString is set, we have a more detailed status/error message
+ if (ccMeta.replyString != NULL) { // if replyString is set, we have a more detailed status/error message
snprintf(statusMessage, sizeof(statusMessage), ccMeta.replyString);
EUCA_FREE(ccMeta.replyString); // the caller must free
}
View
5 net/vnetwork.c
@@ -1715,9 +1715,8 @@ int vnetGenerateNetworkParams(vnetConfig * vnetconfig, char *instId, int vlan, i
for (i = vnetconfig->addrIndexMin; ((i < vnetconfig->addrIndexMax) && !found); i++) {
#if 0
LOGDEBUG("HELLO: %d outmac:%s inip:%s ip:%s mac:%d match:%d\n", i, outmac, hex2dot(inip), hex2dot(vnetconfig->networks[0].addrs[i].ip), machexcmp(outmac,
- vnetconfig->
- networks[0].addrs[i].
- mac),
+ vnetconfig->networks
+ [0].addrs[i].mac),
(vnetconfig->networks[0].addrs[i].ip == inip));
#endif // 0
View
2 node/client-marshal-adb.c
@@ -1464,7 +1464,7 @@ int ncMigrateInstancesStub(ncStub * pStub, ncMetadata * pMeta, ncInstance ** ins
LOGERROR("returned an error\n");
status = 1;
}
- char * statusMessage = adb_ncMigrateInstancesResponseType_get_statusMessage(response, env);
+ char *statusMessage = adb_ncMigrateInstancesResponseType_get_statusMessage(response, env);
if (statusMessage != NULL)
pMeta->replyString = strdup(statusMessage);
}
View
87 node/handlers.c
@@ -324,16 +324,18 @@ static void printNCServiceStateInfo()
int i = 0, j = 0;
//Don't bother if not at trace logging
if (log_level_get() <= EUCA_LOG_TRACE) {
- sem_p(service_state_sem);
+ sem_p(service_state_sem);
LOGTRACE("Printing %d services\n", nc_state.servicesLen);
for (i = 0; i < nc_state.servicesLen; i++) {
LOGTRACE("Service - %s %s %s %s\n", nc_state.services[i].name, nc_state.services[i].partition, nc_state.services[i].type, nc_state.services[i].uris[0]);
}
for (i = 0; i < nc_state.disabledServicesLen; i++) {
- LOGTRACE("Disabled Service - %s %s %s %s\n", nc_state.disabledServices[i].name, nc_state.disabledServices[i].partition, nc_state.disabledServices[i].type, nc_state.disabledServices[i].uris[0]);
+ LOGTRACE("Disabled Service - %s %s %s %s\n", nc_state.disabledServices[i].name, nc_state.disabledServices[i].partition, nc_state.disabledServices[i].type,
+ nc_state.disabledServices[i].uris[0]);
}
for (i = 0; i < nc_state.servicesLen; i++) {
- LOGTRACE("Notready Service - %s %s %s %s\n", nc_state.notreadyServices[i].name, nc_state.notreadyServices[i].partition, nc_state.notreadyServices[i].type, nc_state.notreadyServices[i].uris[0]);
+ LOGTRACE("Notready Service - %s %s %s %s\n", nc_state.notreadyServices[i].name, nc_state.notreadyServices[i].partition, nc_state.notreadyServices[i].type,
+ nc_state.notreadyServices[i].uris[0]);
}
sem_v(service_state_sem);
}
@@ -350,10 +352,12 @@ static void printMsgServiceStateInfo(ncMetadata * pMeta)
LOGTRACE("Msg-Meta: Service - %s %s %s %s\n", pMeta->services[i].name, pMeta->services[i].partition, pMeta->services[i].type, pMeta->services[i].uris[0]);
}
for (i = 0; i < pMeta->disabledServicesLen; i++) {
- LOGTRACE("Msg-Meta: Disabled Service - %s %s %s %s\n", pMeta->disabledServices[i].name, pMeta->disabledServices[i].partition, pMeta->disabledServices[i].type, pMeta->disabledServices[i].uris[0]);
+ LOGTRACE("Msg-Meta: Disabled Service - %s %s %s %s\n", pMeta->disabledServices[i].name, pMeta->disabledServices[i].partition, pMeta->disabledServices[i].type,
+ pMeta->disabledServices[i].uris[0]);
}
for (i = 0; i < pMeta->servicesLen; i++) {
- LOGTRACE("Msg-Meta: Notready Service - %s %s %s %s\n", pMeta->notreadyServices[i].name, pMeta->notreadyServices[i].partition, pMeta->notreadyServices[i].type, pMeta->notreadyServices[i].uris[0]);
+ LOGTRACE("Msg-Meta: Notready Service - %s %s %s %s\n", pMeta->notreadyServices[i].name, pMeta->notreadyServices[i].partition, pMeta->notreadyServices[i].type,
+ pMeta->notreadyServices[i].uris[0]);
}
}
}
@@ -846,15 +850,15 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
// no need to bug for domains without state on Hypervisor
if (old_state == TEARDOWN || old_state == STAGING || old_state == BUNDLING_SHUTOFF || old_state == CREATEIMAGE_SHUTOFF)
return;
-
- { // all this is done while holding the hypervisor lock, with a valid connection
+
+ { // all this is done while holding the hypervisor lock, with a valid connection
virConnectPtr conn = lock_hypervisor_conn();
if (conn == NULL)
return;
-
+
virDomainPtr dom = virDomainLookupByName(conn, instance->instanceId);
-
- if (dom == NULL) { // hypervisor doesn't know about it
+
+ if (dom == NULL) { // hypervisor doesn't know about it
if (old_state == BUNDLING_SHUTDOWN) {
LOGINFO("[%s] detected disappearance of bundled domain\n", instance->instanceId);
change_state(instance, BUNDLING_SHUTOFF);
@@ -882,7 +886,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
unlock_hypervisor_conn();
return;
}
-
+
error = virDomainGetInfo(dom, &info);
if ((error < 0) || (info.state == VIR_DOMAIN_NOSTATE)) {
LOGWARN("[%s] failed to get information for domain\n", instance->instanceId);
@@ -891,7 +895,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
unlock_hypervisor_conn();
return;
}
-
+
new_state = info.state;
switch (old_state) {
case BOOTING:
@@ -907,7 +911,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
instance->migration_state = MIGRATION_IN_PROGRESS;
LOGDEBUG("[%s] incoming (%s < %s) migration_state set to '%s'\n", instance->instanceId,
instance->migration_dst, instance->migration_src, migration_state_names[instance->migration_state]);
-
+
} else if ((old_state == BOOTING || old_state == PAUSED)
&& (new_state == RUNNING || new_state == BLOCKED)) {
LOGINFO("[%s] completing incoming (%s < %s) migration...\n", instance->instanceId, instance->migration_dst, instance->migration_src);
@@ -920,7 +924,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
// copy_intances is called upon return in monitoring_thread().
--incoming_migrations_in_progress;
LOGINFO("[%s] incoming migration complete (%d other migrations currently in progress)\n", instance->instanceId, incoming_migrations_in_progress);
-
+
// FIXME: Consolidate this sequence and the sequence in handlers_kvm.c into a util function?
if (!incoming_migrations_in_progress) {
LOGINFO("no remaining incoming migrations -- deauthorizing all migration clients\n");
@@ -940,7 +944,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
break;
}
}
-
+
if (new_state == SHUTOFF || new_state == SHUTDOWN || new_state == CRASHED) {
LOGWARN("[%s] hypervisor reported previously running domain as %s\n", instance->instanceId, instance_state_names[new_state]);
}
@@ -965,15 +969,15 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
default:
LOGERROR("[%s] unexpected state (%d) in refresh\n", instance->instanceId, old_state);
}
-
+
virDomainFree(dom);
unlock_hypervisor_conn();
}
-
+
// if instance is running, try to find out its IP address
if (instance->state == RUNNING || instance->state == BLOCKED || instance->state == PAUSED) {
ip = NULL;
-
+
if (!strncmp(instance->ncnet.publicIp, "0.0.0.0", 24)) {
if (!strcmp(nc_state.vnetconfig->mode, "SYSTEM") || !strcmp(nc_state.vnetconfig->mode, "STATIC")) {
rc = mac2ip(nc_state.vnetconfig, instance->ncnet.privateMac, &ip);
@@ -984,7 +988,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
}
}
}
-
+
if (!strncmp(instance->ncnet.privateIp, "0.0.0.0", 24)) {
rc = mac2ip(nc_state.vnetconfig, instance->ncnet.privateMac, &ip);
if (!rc && ip) {
@@ -1275,7 +1279,7 @@ void *monitoring_thread(void *arg)
//!
//! @param[in] instance struct to fill in
//!
-void set_instance_params(ncInstance *instance)
+void set_instance_params(ncInstance * instance)
{
char *s = NULL;
@@ -1336,8 +1340,8 @@ void *startup_thread(void *arg)
LOGERROR("[%s] could not contact the hypervisor, abandoning the instance\n", instance->instanceId);
goto shutoff;
}
- unlock_hypervisor_conn(); // unlock right away, since we are just checking on it
-
+ unlock_hypervisor_conn(); // unlock right away, since we are just checking on it
+
// set up networking
if ((error = vnetStartNetwork(nc_state.vnetconfig, instance->ncnet.vlan, NULL, NULL, NULL, &brname)) != EUCA_OK) {
LOGERROR("[%s] start network failed for instance, terminating it\n", instance->instanceId);
@@ -1387,15 +1391,15 @@ void *startup_thread(void *arg)
LOGINFO("[%s] attempt %d of %d to create the instance\n", instance->instanceId, i + 1, MAX_CREATE_TRYS);
}
- { // all this is done while holding the hypervisor lock, with a valid connection
+ { // all this is done while holding the hypervisor lock, with a valid connection
virConnectPtr conn = lock_hypervisor_conn();
- if (conn == NULL) { // get a new connection for each loop iteration
+ if (conn == NULL) { // get a new connection for each loop iteration
LOGERROR("[%s] could not contact the hypervisor, abandoning the instance\n", instance->instanceId);
goto shutoff;
}
-
+
sem_p(loop_sem);
-
+
// We have seen virDomainCreateLinux() on occasion block indefinitely,
// which freezes all activity on the NC since hyp_sem and loop_sem are
// being held by the thread. (This is on Lucid with AppArmor enabled.)
@@ -1411,12 +1415,12 @@ void *startup_thread(void *arg)
// #6 0x00007f359f3619ca in start_thread () from /lib/libpthread.so.0
// #7 0x00007f359f0be70d in clone () from /lib/libc.so.6
// #8 0x0000000000000000 in ?? ()
-
- if ((cpid = fork()) < 0) { // fork error
+
+ if ((cpid = fork()) < 0) { // fork error
LOGERROR("[%s] failed to fork to start instance\n", instance->instanceId);
- } else if (cpid == 0) { // child process - creates the domain
+ } else if (cpid == 0) { // child process - creates the domain
if ((dom = virDomainCreateLinux(conn, xml, 0)) != NULL) {
- virDomainFree(dom); // To be safe. Docs are not clear on whether the handle exists outside the process.
+ virDomainFree(dom); // To be safe. Docs are not clear on whether the handle exists outside the process.
exit(0);
} else {
exit(1);
@@ -1435,16 +1439,16 @@ void *startup_thread(void *arg)
} else {
created = TRUE;
}
-
+
if (try_killing) {
killwait(cpid);
}
}
-
+
sem_v(loop_sem);
unlock_hypervisor_conn(); // guard against libvirtd connection badness
}
-
+
if (created)
break;
sleep(1);
@@ -1456,7 +1460,7 @@ void *startup_thread(void *arg)
//! @TODO bring back correlationId
eventlog("NC", instance->userId, "", "instanceBoot", "begin");
- { // make instance state changes while under lock
+ { // make instance state changes while under lock
sem_p(inst_sem);
// check one more time for cancellation
if (instance->state == TEARDOWN) {
@@ -1509,15 +1513,13 @@ void *restart_thread(void *arg)
LOGERROR("[%s] start network failed for instance, terminating it\n", instance->instanceId);
goto shutoff;
}
-
// Check the hypervisor connection
LOGDEBUG("[%s] spawning restart thread\n", instance->instanceId);
virConnectPtr conn = lock_hypervisor_conn();
if (conn == NULL) {
LOGERROR("[%s] could not contact the hypervisor, abandoning the instance\n", instance->instanceId);
goto shutoff;
}
-
// Save our instance bridge name for later use
euca_strncpy(instance->params.guestNicDeviceName, brname, sizeof(instance->params.guestNicDeviceName));
LOGINFO("[%s] started network\n", instance->instanceId);
@@ -1552,7 +1554,7 @@ void *restart_thread(void *arg)
for (i = 0; i < MAX_CREATE_TRYS; i++) {
if (i > 0)
LOGINFO("[%s] attempt %d of %d to create the instance\n", instance->instanceId, i + 1, MAX_CREATE_TRYS);
-
+
{
sem_p(loop_sem);
pid_t cpid = fork();
@@ -1587,19 +1589,19 @@ void *restart_thread(void *arg)
}
sem_v(loop_sem);
}
-
+
if (created)
break;
sleep(1);
}
unlock_hypervisor_conn();
-
+
if (!created) {
goto shutoff;
}
//! @TODO bring back correlationId
eventlog("NC", instance->userId, "", "instanceBoot", "begin");
-
+
sem_p(inst_sem);
{
// check one more time for cancellation
@@ -1647,7 +1649,7 @@ void adopt_instances()
conn = lock_hypervisor_conn();
if (conn == NULL)
return;
-
+
LOGINFO("looking for existing domains\n");
virSetErrorFunc(NULL, libvirt_err_handler);
@@ -3148,7 +3150,8 @@ int doMigrateInstances(ncMetadata * pMeta, ncInstance ** instances, int instance
return (EUCA_UNSUPPORTED_ERROR);
} else {
// Ignore the fact src & dst are the same if a rollback--it doesn't matter.
- LOGDEBUG("[%s] ignoring apparent same-node migration hosts (%s > %s) for action '%s'\n", instances[i]->instanceId, instances[i]->migration_src, instances[i]->migration_dst, action);
+ LOGDEBUG("[%s] ignoring apparent same-node migration hosts (%s > %s) for action '%s'\n", instances[i]->instanceId, instances[i]->migration_src,
+ instances[i]->migration_dst, action);
}
}
}
View
2 node/handlers.h
@@ -314,7 +314,7 @@ int wait_state_transition(ncInstance * instance, instance_states from_state, ins
void adopt_instances();
int get_instance_xml(const char *gen_libvirt_cmd_path, char *userId, char *instanceId, char *platform, char *ramdiskId, char *kernelId,
char *disk_path, virtualMachine * params, char *privMac, char *brname, int use_virtio_net, int use_virtio_root, char **xml);
-void set_instance_params(ncInstance *instance);
+void set_instance_params(ncInstance * instance);
void *monitoring_thread(void *arg);
void *startup_thread(void *arg);
void *restart_thread(void *arg);
View
41 node/handlers_default.c
@@ -437,7 +437,7 @@ int shutdown_then_destroy_domain(virDomainPtr dom)
LOGDEBUG("shutting down instance\n");
error = virDomainShutdown(dom);
- if (! error) { // give it time to shut down
+ if (!error) { // give it time to shut down
time_t deadline = time(NULL) + SHUTDOWN_GRACE_PERIOD_SEC;
int dom_status = -1;
while (time(NULL) < deadline) {
@@ -447,17 +447,17 @@ int shutdown_then_destroy_domain(virDomainPtr dom)
break;
sleep(1);
}
-
- if (dom_status != 1) { // 0 = not running, -1 = does not exist
+
+ if (dom_status != 1) { // 0 = not running, -1 = does not exist
virDomainFree(dom);
return 0;
}
}
-
+
LOGDEBUG("destroying instance\n");
error = virDomainDestroy(dom);
virDomainFree(dom);
-
+
return error;
}
@@ -518,7 +518,7 @@ int find_and_terminate_instance(struct nc_state_t *nc_state, ncMetadata * pMeta,
if (conn) {
virDomainPtr dom = virDomainLookupByName(conn, instanceId);
if (dom) {
- err = shutdown_then_destroy_domain(dom); // the function frees 'dom'
+ err = shutdown_then_destroy_domain(dom); // the function frees 'dom'
if (err == 0) {
LOGINFO("[%s] instance terminated\n", instanceId);
} else {
@@ -554,7 +554,7 @@ static int doTerminateInstance(struct nc_state_t *nc, ncMetadata * pMeta, char *
char resourceName[1][MAX_SENSOR_NAME_LEN] = { {0} };
char resourceAlias[1][MAX_SENSOR_NAME_LEN] = { {0} };
- sem_p(hyp_sem); // we serialize all hypervisor calls and sensor_refresh_resources() may ultimately call the hypervisor
+ sem_p(hyp_sem); // we serialize all hypervisor calls and sensor_refresh_resources() may ultimately call the hypervisor
euca_strncpy(resourceName[0], instanceId, MAX_SENSOR_NAME_LEN);
sensor_refresh_resources(resourceName, resourceAlias, 1); // refresh stats so latest instance measurements are captured before it disappears
sem_v(hyp_sem);
@@ -941,7 +941,7 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
if (instance == NULL)
return EUCA_NOT_FOUND_ERROR;
- { // connect to hypervisor and query it
+ { // connect to hypervisor and query it
virConnectPtr conn = lock_hypervisor_conn();
if (conn == NULL) {
LOGERROR("[%s][%s] cannot get connection to hypervisor\n", instanceId, volumeId);
@@ -1014,22 +1014,19 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
ret = EUCA_ERROR;
goto release;
}
-
// make sure there is a block device
if (check_block(remoteDevReal)) {
LOGERROR("[%s][%s] cannot verify that host device '%s' is available for hypervisor attach\n", instanceId, volumeId, remoteDevReal);
ret = EUCA_ERROR;
goto release;
}
-
// generate XML for libvirt attachment request
if (gen_volume_xml(volumeId, instance, localDevReal, remoteDevReal) // creates vol-XXX.xml
|| gen_libvirt_volume_xml(volumeId, instance)) { // creates vol-XXX-libvirt.xml via XSLT transform
LOGERROR("[%s][%s] could not produce attach device xml\n", instanceId, volumeId);
ret = EUCA_ERROR;
goto release;
}
-
// invoke hooks
char path[MAX_PATH];
char lpath[MAX_PATH];
@@ -1040,15 +1037,14 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
ret = EUCA_ERROR;
goto release;
}
-
// read in libvirt XML, which may have been modified by the hook above
if ((xml = file2str(lpath)) == NULL) {
LOGERROR("[%s][%s] failed to read volume XML from %s\n", instance->instanceId, volumeId, lpath);
ret = EUCA_ERROR;
goto release;
}
- { // connect to hypervisor, find the domain, attach the volume
+ { // connect to hypervisor, find the domain, attach the volume
virConnectPtr conn = lock_hypervisor_conn();
if (conn == NULL) {
LOGERROR("[%s][%s] cannot get connection to hypervisor\n", instanceId, volumeId);
@@ -1063,32 +1059,32 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
unlock_hypervisor_conn();
goto release;
}
-
+
int err = 0;
for (int i = 1; i <= VOL_RETRIES; i++) {
err = virDomainAttachDevice(dom, xml);
if (err) {
LOGERROR("[%s][%s] failed to attach host device '%s' to guest device '%s' on attempt %d of 3\n", instanceId, volumeId, remoteDevReal, localDevReal, i);
LOGDEBUG("[%s][%s] virDomainAttachDevice() failed (err=%d) XML='%s'\n", instanceId, volumeId, err, xml);
- sleep(3); // sleep a bit and retry.
+ sleep(3); // sleep a bit and retry.
} else {
break;
}
}
-
+
if (err) {
LOGERROR("[%s][%s] failed to attach host device '%s' to guest device '%s' after %d tries\n", instanceId, volumeId, remoteDevReal, localDevReal, VOL_RETRIES);
LOGDEBUG("[%s][%s] virDomainAttachDevice() failed (err=%d) XML='%s'\n", instanceId, volumeId, err, xml);
ret = EUCA_ERROR;
}
-
- virDomainFree(dom); // release libvirt resource
+
+ virDomainFree(dom); // release libvirt resource
unlock_hypervisor_conn();
}
release:
- { // record volume state in memory and on disk
+ { // record volume state in memory and on disk
char *next_vol_state;
if (ret == EUCA_OK) {
next_vol_state = VOL_STATE_ATTACHED;
@@ -1099,13 +1095,13 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
volume = save_volume(instance, volumeId, NULL, NULL, NULL, NULL, next_vol_state); // now we can record remoteDevReal
save_instance_struct(instance);
copy_instances();
- update_disk_aliases(instance); // ask sensor subsystem to track the volume
+ update_disk_aliases(instance); // ask sensor subsystem to track the volume
sem_v(inst_sem);
}
if (volume == NULL && xml != NULL) {
LOGERROR("[%s][%s] failed to save the volume record, aborting volume attachment (detaching)\n", instanceId, volumeId);
-
+
// connect to hypervisor, find the domain, detach the volume
virConnectPtr conn = lock_hypervisor_conn();
if (conn == NULL) {
@@ -1125,7 +1121,6 @@ static int doAttachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
}
ret = EUCA_ERROR;
}
-
// if iSCSI and there were problems, try to disconnect the target
if (ret != EUCA_OK && have_remote_device) {
LOGDEBUG("[%s][%s] attempting to disconnect iscsi target due to attachment failure\n", instanceId, volumeId);
@@ -1315,7 +1310,7 @@ static int doDetachVolume(struct nc_state_t *nc, ncMetadata * pMeta, char *insta
release:
virDomainFree(dom); // release libvirt resource
- unlock_hypervisor_conn(); // unlock the connection to the hypervisor
+ unlock_hypervisor_conn(); // unlock the connection to the hypervisor
// record volume state in memory and on disk
char *next_vol_state;
View
17 node/handlers_kvm.c
@@ -276,22 +276,19 @@ static void *rebooting_thread(void *arg)
unlock_hypervisor_conn();
return NULL;
}
-
// obtain the most up-to-date XML for domain from libvirt
- xml = virDomainGetXMLDesc(dom, 0);
+ xml = virDomainGetXMLDesc(dom, 0);
if (xml == NULL) {
LOGERROR("[%s] cannot obtain metadata for instance to reboot, giving up\n", instance->instanceId);
unlock_hypervisor_conn();
return NULL;
}
-
// try shutdown first, then kill it if uncooperative
if (shutdown_then_destroy_domain(dom) != EUCA_OK) {
LOGERROR("[%s] failed to shutdown and destroy the instance to reboot, giving up\n", instance->instanceId);
unlock_hypervisor_conn();
return NULL;
}
-
// Add a shift to values of three of the metrics: ones that
// drop back to zero after a reboot. The shift, which is based
// on the latest value, ensures that values sent upstream do
@@ -706,7 +703,8 @@ static int doMigrateInstances(struct nc_state_t *nc, ncMetadata * pMeta, ncInsta
migration_rollback(instance);
sem_v(inst_sem);
} else {
- LOGINFO("[%s] ignoring request to roll back migration on source with instance in state %s(%s) -- duplicate rollback request?\n", instance->instanceId, instance->stateName, migration_state_names[instance->migration_state]);
+ LOGINFO("[%s] ignoring request to roll back migration on source with instance in state %s(%s) -- duplicate rollback request?\n", instance->instanceId,
+ instance->stateName, migration_state_names[instance->migration_state]);
}
} else {
LOGERROR("[%s] action '%s' is not valid\n", instance->instanceId, action);
@@ -736,7 +734,6 @@ static int doMigrateInstances(struct nc_state_t *nc, ncMetadata * pMeta, ncInsta
LOGERROR("[%s] action '%s' is not valid or not implemented\n", instance_req->instanceId, action);
return (EUCA_INVALID_ERROR);
}
-
// Everything from here on is specific to "prepare" on a destination.
// allocate a new instance struct
@@ -758,10 +755,10 @@ static int doMigrateInstances(struct nc_state_t *nc, ncMetadata * pMeta, ncInsta
* (This is intended for development/testing only!)
*/
/*
- sem_v(inst_sem);
- LOGERROR("[%s] FORCING FAILURE!\n", instance->instanceId);
- goto failed_dest;
- */
+ sem_v(inst_sem);
+ LOGERROR("[%s] FORCING FAILURE!\n", instance->instanceId);
+ goto failed_dest;
+ */
// Establish migration-credential keys.
LOGINFO("[%s] migration destination preparing %s > %s [creds=%s]\n", instance->instanceId, SP(instance->migration_src), SP(instance->migration_dst),
View
2 node/handlers_xen.c
@@ -293,7 +293,7 @@ static int doRebootInstance(struct nc_state_t *nc, ncMetadata * pMeta, char *ins
if (err == 0) {
LOGINFO("[%s] rebooting Xen domain for instance\n", instanceId);
}
- virDomainFree(dom); //! @todo is this necessary?
+ virDomainFree(dom); //! @todo is this necessary?
// Add a shift to values of three of the metrics: ones that
// drop back to zero after a reboot. The shift, which is based
View
60 storage/ebs_utils.c
@@ -228,7 +228,6 @@ int replace_sc_url(const char *volume_string, const char *scUrl, char *restrict
EUCA_FREE(vol_prefix);
return EUCA_ERROR;
}
-
// We're done with the prefix...
EUCA_FREE(vol_prefix);
@@ -525,35 +524,36 @@ int disconnect_ebs_volume_with_struct(char *sc_url, int use_ws_sec, char *ws_sec
//!
//! @note should be invoked only by functions in this file that acquired the necessary lock.
//!
-static int cleanup_volume_attachment (char *sc_url, int use_ws_sec, char *ws_sec_policy_file, ebs_volume_data *vol_data, char *connect_string, char *local_ip, char *local_iqn, int norescan) {
- int rc = 0;
-
- LOGDEBUG("[%s] attempting to disconnect iscsi target\n", vol_data->volumeId);
- if (disconnect_iscsi_target(connect_string, norescan) != 0) {
- LOGERROR("[%s] failed to disconnet iscsi target\n", vol_data->volumeId);
- LOGDEBUG("Skipping SC Call due to previous errors\n");
- return EUCA_ERROR;
- }
-
- //TODO: decrypt token using node pk
- LOGTRACE("Calling scClientCall with url: %s and token %s\n", sc_url, vol_data->token);
- rc = scClientCall(NULL, NULL, use_ws_sec, ws_sec_policy_file, DEFAULT_SC_CALL_TIMEOUT, sc_url, "UnexportVolume", vol_data->volumeId, vol_data->token, local_ip, local_iqn);
- if (rc) {
- LOGERROR("ERROR unexporting volume %s\n", vol_data->volumeId);
- return EUCA_ERROR;
- } else {
- //Ok, now refresh local session to be sure it's gone.
- char *refreshedDev = NULL;
- //Should return error of not found.
- refreshedDev = get_iscsi_target(connect_string);
- if (refreshedDev) {
- //Failure, should have NULL.
- return EUCA_ERROR;
- } else {
- //We're good
- return EUCA_OK;
- }
- }
+static int cleanup_volume_attachment(char *sc_url, int use_ws_sec, char *ws_sec_policy_file, ebs_volume_data * vol_data, char *connect_string, char *local_ip, char *local_iqn,
+ int norescan)
+{
+ int rc = 0;
+
+ LOGDEBUG("[%s] attempting to disconnect iscsi target\n", vol_data->volumeId);
+ if (disconnect_iscsi_target(connect_string, norescan) != 0) {
+ LOGERROR("[%s] failed to disconnet iscsi target\n", vol_data->volumeId);
+ LOGDEBUG("Skipping SC Call due to previous errors\n");
+ return EUCA_ERROR;
+ }
+ //TODO: decrypt token using node pk
+ LOGTRACE("Calling scClientCall with url: %s and token %s\n", sc_url, vol_data->token);
+ rc = scClientCall(NULL, NULL, use_ws_sec, ws_sec_policy_file, DEFAULT_SC_CALL_TIMEOUT, sc_url, "UnexportVolume", vol_data->volumeId, vol_data->token, local_ip, local_iqn);
+ if (rc) {
+ LOGERROR("ERROR unexporting volume %s\n", vol_data->volumeId);
+ return EUCA_ERROR;
+ } else {
+ //Ok, now refresh local session to be sure it's gone.
+ char *refreshedDev = NULL;
+ //Should return error of not found.
+ refreshedDev = get_iscsi_target(connect_string);
+ if (refreshedDev) {
+ //Failure, should have NULL.
+ return EUCA_ERROR;
+ } else {
+ //We're good
+ return EUCA_OK;
+ }
+ }
}
#ifdef _UNIT_TEST
View
3 storage/ebs_utils.h
@@ -144,7 +144,8 @@ int connect_ebs_volume(char *sc_url, char *attachment_token, int use_ws_sec, cha
ebs_volume_data ** vol_data);
int disconnect_ebs_volume(char *sc_url, int use_ws_sec, char *ws_sec_policy_file, char *volume_string, char *connect_string, char *local_ip, char *local_iqn);
int disconnect_ebs_volume_with_struct(char *sc_url, int use_ws_sec, char *ws_sec_policy_file, ebs_volume_data * vol_data, char *local_ip, char *local_iqn);
-static int cleanup_volume_attachment (char *sc_url, int use_ws_sec, char *ws_sec_policy_file, ebs_volume_data *vol_data, char *connect_string, char *local_ip, char *local_iqn, int norescan);
+static int cleanup_volume_attachment(char *sc_url, int use_ws_sec, char *ws_sec_policy_file, ebs_volume_data * vol_data, char *connect_string, char *local_ip, char *local_iqn,
+ int norescan);
/*----------------------------------------------------------------------------*\
| |
View
4 storage/vbr.c
@@ -1846,7 +1846,7 @@ static artifact *art_alloc_vbr(virtualBootRecord * vbr, boolean do_make_work_cop
goto u_out;
// extract size from the digest
- long long bb_size_bytes = euca_strtoll(blob_digest, "<size>", "</size>"); // pull size from the digest
+ long long bb_size_bytes = euca_strtoll(blob_digest, "<size>", "</size>"); // pull size from the digest
if (bb_size_bytes < 1)
goto u_out;
vbr->sizeBytes = bb_size_bytes; // record size in VBR now that we know it
@@ -1870,7 +1870,7 @@ static artifact *art_alloc_vbr(virtualBootRecord * vbr, boolean do_make_work_cop
goto w_out;
}
// extract size from the digest
- long long bb_size_bytes = euca_strtoll(blob_digest, "<size>", "</size>"); // pull size from the digest
+ long long bb_size_bytes = euca_strtoll(blob_digest, "<size>", "</size>"); // pull size from the digest
if (bb_size_bytes < 1) {
LOGERROR("[%s] incorrect image digest or error returned from Walrus\n", current_instanceId);
goto w_out;
View
19 storage/walrus.c
@@ -154,9 +154,8 @@ struct request {
};
//! Defines the struct for passing information into curl progress function
-struct progress_data_t
-{
- char * url;
+struct progress_data_t {
+ char *url;
time_t last_update;
};
@@ -304,7 +303,7 @@ static int walrus_request_timeout(const char *walrus_op, const char *verb, const
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 360L); // must have at least a 360 baud modem
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); // abort if below speed limit for this many seconds
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //! @todo remove the comment once we want to follow redirects (e.g., on HTTP 407)
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //! @todo remove the comment once we want to follow redirects (e.g., on HTTP 407)
// enable periodic progress statements in the log
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); // enable progress function invocation
@@ -458,18 +457,18 @@ static int walrus_request_timeout(const char *walrus_op, const char *verb, const
break;
}
}
-
+
if (code == EUCA_OK || bail == TRUE) {
- break; // bail out of the retry loop
+ break; // bail out of the retry loop
} else if ((attempt + 1) <= TOTAL_ATTEMPTS) {
LOGWARN("download attempt %d of %d will commence in %d sec for %s\n", (attempt + 1), TOTAL_ATTEMPTS, timeout, url);
sleep(timeout);
timeout <<= 1;
if (timeout > MAX_TIMEOUT)
timeout = MAX_TIMEOUT;
-
- lseek(fd, 0L, SEEK_SET); // move the file pointer to the beginning for the retry
+
+ lseek(fd, 0L, SEEK_SET); // move the file pointer to the beginning for the retry
}
}
close(fd);
@@ -666,7 +665,7 @@ static size_t write_data(void *buffer, size_t size, size_t nmemb, void *params)
assert(params != NULL);
int fd = ((struct request *)params)->fd;
- int wrote = write(fd, buffer, size * nmemb); // any blocking in this call is not subject to connection timeouts
+ int wrote = write(fd, buffer, size * nmemb); // any blocking in this call is not subject to connection timeouts
((struct request *)params)->total_wrote += wrote;
((struct request *)params)->total_calls++;
@@ -777,7 +776,7 @@ static size_t write_data_zlib(void *buffer, size_t size, size_t nmemb, void *par
static int progress_function(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
- struct progress_data_t * progress_data = (struct progress_data_t *)clientp;
+ struct progress_data_t *progress_data = (struct progress_data_t *)clientp;
time_t now = time(NULL);
if ((progress_data->last_update + PROGRESS_UPDATE_SEC) <= now) {
View
2 util/data.h
@@ -275,7 +275,7 @@ typedef struct virtualBootRecord_t {
libvirtBusType guestDeviceBus; //!< BUS_TYPE_{IDE|SCSI|VIRTIO|XEN}
libvirtSourceType backingType; //!< SOURCE_TYPE_{FILE|BLOCK}
char backingPath[CHAR_BUFFER_SIZE]; //!< path to file or block device that backs the resource
- char preparedResourceLocation[VERY_BIG_CHAR_BUFFER_SIZE]; //!< e.g., URL + resourceLocation for Walrus downloads, sc url for ebs volumes prior to SC call, then connection string for ebs volumes returned from SC
+ char preparedResourceLocation[VERY_BIG_CHAR_BUFFER_SIZE]; //!< e.g., URL + resourceLocation for Walrus downloads, sc url for ebs volumes prior to SC call, then connection string for ebs volumes returned from SC
//! @}
} virtualBootRecord;
View
2 util/sensor.c
@@ -467,7 +467,7 @@ static void sensor_bottom_half(void)
sensor_refresh_resources(resourceNames, resourceAliases, MAX_SENSOR_RESOURCES);
if (hyp_sem)
sem_v(hyp_sem);
-
+
useconds_t stop_usec = time_usec();
// adjust the next sleep time to account for how long sensor refresh took

0 comments on commit 673fd1b

Please sign in to comment.
Something went wrong with that request. Please try again.