summaryrefslogtreecommitdiffstats
path: root/util/loglevel.c
blob: e24923e5a452ab9cc17df577ca1beefd51d8a90a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "cachepc/uapi.h"

#include <sys/ioctl.h>
#include <fcntl.h>
#include <err.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

int
main(int argc, const char **argv)
{
	uint32_t arg;
	int fd, ret;

	fd = open("/dev/kvm", O_RDONLY);
	if (fd < 0) err(1, "open");

	if (argc > 1 && !strcmp(argv[1], "debug"))
		arg = CPC_LOGLVL_DBG;
	else if (argc > 1 && !strcmp(argv[1], "info"))
		arg = CPC_LOGLVL_INFO;
	else
		arg = 0;

	printf("loglevel: %i\n", arg);
	ret = ioctl(fd, KVM_CPC_LOGLEVEL, &arg);
	if (ret == -1) err(1, "ioctl KVM_CPC_LOGLEVEL");

	close(fd);
}