static void net_traffic_uniform(struct net_t *net, double *inject_time) { while (1) { struct net_node_t *node; struct net_node_t *dst_node; long long cycle; int i; /* Get current cycle */ cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; /* Inject messages */ for (i = 0; i < net->node_count; i++) { /* Get end node */ node = list_get(net->node_list, i); if (node->kind != net_node_end) continue; /* Turn for next injection? */ if (inject_time[i] > cycle) continue; /* Get a random destination node */ do { dst_node = list_get(net->node_list, random() % list_count(net->node_list)); } while (dst_node->kind != net_node_end || dst_node == node); /* Inject */ while (inject_time[i] < cycle) { inject_time[i] += exp_random(net_injection_rate); if (net_can_send(net, node, dst_node, net_msg_size)) net_send(net, node, dst_node, net_msg_size); } } /* Next cycle */ net_debug("___ cycle %lld ___\n", cycle); esim_process_events(TRUE); } }
static void iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *iTask = opaque; struct scsi_task *task = command_data; iTask->status = status; iTask->do_retry = 0; iTask->task = task; if (status != SCSI_STATUS_GOOD) { if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { error_report("iSCSI CheckCondition: %s", iscsi_get_error(iscsi)); iTask->do_retry = 1; goto out; } if (status == SCSI_STATUS_BUSY) { unsigned retry_time = exp_random(iscsi_retry_times[iTask->retries - 1]); error_report("iSCSI Busy (retry #%u in %u ms): %s", iTask->retries, retry_time, iscsi_get_error(iscsi)); aio_timer_init(iTask->iscsilun->aio_context, &iTask->retry_timer, QEMU_CLOCK_REALTIME, SCALE_MS, iscsi_retry_timer_expired, iTask); timer_mod(&iTask->retry_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time); iTask->do_retry = 1; return; } } error_report("iSCSI Failure: %s", iscsi_get_error(iscsi)); } out: if (iTask->co) { iTask->bh = aio_bh_new(iTask->iscsilun->aio_context, iscsi_co_generic_bh_cb, iTask); qemu_bh_schedule(iTask->bh); } else { iTask->complete = 1; } }