extern int log_time_hv;
extern int log_time_guest;
extern char *log_dir;
+extern int discard_overflowed_data;
static int log_time_hv_needts = 1;
static int log_time_guest_needts = 1;
dom->domid, errno, strerror(errno));
}
- if (buffer->max_capacity &&
+ if (discard_overflowed_data && buffer->max_capacity &&
buffer->size > buffer->max_capacity) {
/* Discard the middle of the data. */
if (buffer->consumed == buffer->size) {
buffer->consumed = 0;
buffer->size = 0;
+ if (buffer->max_capacity &&
+ buffer->capacity > buffer->max_capacity) {
+ buffer->data = realloc(buffer->data, buffer->max_capacity);
+ buffer->capacity = buffer->max_capacity;
+ }
}
}
d->next_period < next_timeout)
next_timeout = d->next_period;
} else if (d->xce_handle != -1) {
- int evtchn_fd = xc_evtchn_fd(d->xce_handle);
- FD_SET(evtchn_fd, &readfds);
- max_fd = MAX(evtchn_fd, max_fd);
+ if (discard_overflowed_data ||
+ !d->buffer.max_capacity ||
+ d->buffer.size < d->buffer.max_capacity) {
+ int evtchn_fd = xc_evtchn_fd(d->xce_handle);
+ FD_SET(evtchn_fd, &readfds);
+ max_fd = MAX(evtchn_fd, max_fd);
+ }
}
if (d->master_fd != -1) {
int log_time_hv = 0;
int log_time_guest = 0;
char *log_dir = NULL;
+int discard_overflowed_data = 1;
static void handle_hup(int sig)
{
static void usage(char *name)
{
- printf("Usage: %s [-h] [-V] [-v] [-i] [--log=none|guest|hv|all] [--log-dir=DIR] [--pid-file=PATH] [-t, --timestamp=none|guest|hv|all]\n", name);
+ printf("Usage: %s [-h] [-V] [-v] [-i] [--log=none|guest|hv|all] [--log-dir=DIR] [--pid-file=PATH] [-t, --timestamp=none|guest|hv|all] [-o, --overflow-data=discard|keep]\n", name);
}
static void version(char *name)
int main(int argc, char **argv)
{
- const char *sopts = "hVvit:";
+ const char *sopts = "hVvit:o:";
struct option lopts[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "log-dir", 1, 0, 'r' },
{ "pid-file", 1, 0, 'p' },
{ "timestamp", 1, 0, 't' },
+ { "overflow-data", 1, 0, 'o'},
{ 0 },
};
bool is_interactive = false;
log_time_hv = 0;
}
break;
+ case 'o':
+ if (!strcmp(optarg, "keep")) {
+ discard_overflowed_data = 0;
+ } else if (!strcmp(optarg, "discard")) {
+ discard_overflowed_data = 1;
+ }
+ break;
case '?':
fprintf(stderr,
"Try `%s --help' for more information\n",