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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* blkdump.c
*
* show a running trace of block requests as they fly by.
*
* (c) 2004 Andrew Warfield.
*/
#include <stdio.h>
#include "blktaplib.h"
int request_print(blkif_request_t *req)
{
int i;
unsigned long fas;
if ( (req->operation == BLKIF_OP_READ) ||
(req->operation == BLKIF_OP_WRITE) )
{
printf("[%2u:%2u<%5s] (nr_segs: %03u, dev: %03u, %010llu)\n",
ID_TO_DOM(req->id), ID_TO_IDX(req->id),
blkif_op_name[req->operation],
req->nr_segments, req->handle,
req->sector_number);
for (i=0; i < req->nr_segments; i++) {
fas = req->frame_and_sects[i];
printf(" (pf: 0x%8lx start: %lu stop: %lu)\n",
(fas & PAGE_MASK),
blkif_first_sect(fas),
blkif_last_sect(fas)
);
}
} else {
printf("Unknown request message type.\n");
}
return BLKTAP_PASS;
}
int response_print(blkif_response_t *rsp)
{
if ( (rsp->operation == BLKIF_OP_READ) ||
(rsp->operation == BLKIF_OP_WRITE) )
{
printf("[%2u:%2u>%5s] (status: %d)\n",
ID_TO_DOM(rsp->id), ID_TO_IDX(rsp->id),
blkif_op_name[rsp->operation],
rsp->status);
} else {
printf("Unknown request message type.\n");
}
return BLKTAP_PASS;
}
int main(int argc, char *argv[])
{
blktap_register_request_hook("request_print", request_print);
blktap_register_response_hook("response_print", response_print);
blktap_listen();
return 0;
}
|