4
my $MCONSOLE_SOCKET = 0;
5
my $MCONSOLE_PANIC = 1;
7
my $MCONSOLE_USER_NOTIFY = 3;
9
my @types = ( "socket", "panic", "hang", "user notification" );
11
!defined(socket(SOCK, AF_UNIX, SOCK_DGRAM, 0)) and
12
die "socket() failed : $!\n";
14
# XXX the -u causes mktemp to unlink the file - this is needed because
15
# we don't want a normal file, we want a socket.
17
my $file = `mktemp -u /tmp/mconsole.XXXXXX`;
18
$? != 0 and die "mktemp failed with status $?\n";
21
print "The notification socket is '$file'\n";
23
!defined(bind(SOCK, sockaddr_un($file))) and
24
die "binding '$file' failed : $!\n";
26
print "Run UML with\n\tmconsole=notify:$file\non the command line.\n";
27
print "Then, inside UML, write messages into /proc/mconsole\n";
32
!defined(recv(SOCK, $data, 4096, 0)) and
33
die "recv from '$file' failed : $!";
35
my ($magic, $version, $type, $len, $message) = unpack("LiiiA*", $data);
36
print "Received message -\n";
37
printf "\tmagic = 0x%x\n", $magic;
38
print "\tversion = $version\n";
39
print "\tmessage type = $type (" . $types[$type] . ")\n";
40
print "\tmessage length = $len\n";
41
print "\tmessage = '$message'\n\n";