Skip to content

Commit 3d8ced5

Browse files
committed
Merge pull request xapi-project#49 from koushikcgit/revert-35-CA-173358-cream-bugfix
Revert "CA-173358: Remove VBD related data sources from xcp-rrdd"
2 parents 36e6563 + d430733 commit 3d8ced5

File tree

5 files changed

+423
-0
lines changed

5 files changed

+423
-0
lines changed

ocaml/rrdd/OMakefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ OCAML_LIBS = $(ROOT)/ocaml/fhs ../idl/ocaml_backend/xapi_client ../xenops/xensto
1515

1616
UseCamlp4(rpc-light.syntax, rrdd_server)
1717

18+
OCAML_CLIBS = blktap3_stats_stubs
19+
StaticCLibrary(blktap3_stats_stubs, blktap3_stats_stubs)
20+
1821
RRDD = xcp-rrdd
1922
RRDD_FILES = \
2023
../pool_role_shared \
@@ -38,6 +41,7 @@ RRDD_FILES = \
3841
rrdd_server \
3942
rrdd_monitor \
4043
rrdd_stats \
44+
blktap3_stats\
4145
rrdd_main
4246
RRDD_TEST = rrdd_test
4347
RRDD_TEST_FILES = \

ocaml/rrdd/blktap3_stats.ml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
(*
16+
* This module extracts the external declaration to make things easier
17+
* for a library which might be used elsewhere.
18+
*)
19+
20+
(** Define an equivalent blktap3 statistics record *)
21+
type blktap3_stats = {
22+
st_ds_req : int64;
23+
st_f_req : int64;
24+
st_oo_req : int64;
25+
st_rd_req : int64;
26+
st_rd_cnt : int64;
27+
st_rd_sect: int64;
28+
st_rd_sum_usecs : int64;
29+
st_rd_max_usecs : int64;
30+
st_wr_req : int64;
31+
st_wr_cnt : int64;
32+
st_wr_sect: int64;
33+
st_wr_sum_usecs : int64;
34+
st_wr_max_usecs : int64;
35+
}
36+
37+
(** Obtain a blktap3 statistics record using the stubs *)
38+
external get_blktap3_stats:
39+
filename:string -> blktap3_stats = "stub_get_blktap3_stats"

ocaml/rrdd/blktap3_stats.mli

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
(**
15+
* This module defines an equivalent blktap3 stats record and the
16+
* associated API method.
17+
*)
18+
19+
(** Attributes associated with the blktap3 stats struct *)
20+
type blktap3_stats = {
21+
(** BLKIF_OP_DISCARD, not currently supported in blktap3, zero always *)
22+
st_ds_req : int64;
23+
(** BLKIF_OP_FLUSH_DISKCACHE, not currently supported in blktap3, zero always*)
24+
st_f_req : int64;
25+
(** Increased each time we fail to allocate memory for a internal
26+
* request descriptor in response to a ring request. *)
27+
st_oo_req : int64;
28+
(** Received BLKIF_OP_READ requests. *)
29+
st_rd_req : int64;
30+
(** Completed BLKIF_OP_READ requests. *)
31+
st_rd_cnt : int64;
32+
(** Read sectors, after we've forwarded the request to actual storage. *)
33+
st_rd_sect: int64;
34+
(** Sum of the request response time of all BLKIF_OP_READ *)
35+
st_rd_sum_usecs : int64;
36+
(** Absolute maximum BLKIF_OP_READ response time *)
37+
st_rd_max_usecs : int64;
38+
(** Received BLKIF_OP_WRITE requests. *)
39+
st_wr_req : int64;
40+
(** Completed BLKIF_OP_WRITE requests. *)
41+
st_wr_cnt : int64;
42+
(** Write sectors, after we've forwarded the request to actual storage. *)
43+
st_wr_sect: int64;
44+
(** Sum of the request response time of all BLKIF_OP_WRITE *)
45+
st_wr_sum_usecs : int64;
46+
(** Absolute maximum BLKIF_OP_WRITE response time *)
47+
st_wr_max_usecs : int64;
48+
}
49+
50+
(** Get a blktap3 statistics record *)
51+
val get_blktap3_stats: filename:string -> blktap3_stats

ocaml/rrdd/blktap3_stats_stubs.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2006-2009 Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
*/
15+
16+
/*
17+
This stubs file retrieves the blkback statistics struct created by
18+
blktap3 under '/dev/shm/<vbd3-domid-devid>/statistics' *)
19+
*/
20+
21+
#include <stdio.h>
22+
#include <errno.h>
23+
#include <blktap/blktap3.h>
24+
25+
#include <caml/mlvalues.h>
26+
#include <caml/memory.h>
27+
#include <caml/alloc.h>
28+
#include <caml/fail.h>
29+
#include <caml/unixsupport.h>
30+
31+
32+
CAMLprim value stub_get_blktap3_stats(value filename)
33+
{
34+
35+
CAMLparam1(filename);
36+
CAMLlocal1(stats);
37+
38+
FILE *c_fd;
39+
struct blkback_stats c_stats;
40+
41+
c_fd = fopen(String_val(filename), "rb");
42+
43+
if (!c_fd) uerror("fopen", Nothing);
44+
if (fread(&c_stats, sizeof(struct blkback_stats), 1, c_fd) < 1) uerror("fread", Nothing);
45+
46+
stats = caml_alloc_tuple(13);
47+
48+
Store_field(stats, 0, caml_copy_int64((int64) c_stats.st_ds_req));
49+
Store_field(stats, 1, caml_copy_int64((int64) c_stats.st_f_req));
50+
Store_field(stats, 2, caml_copy_int64((int64) c_stats.st_oo_req));
51+
Store_field(stats, 3, caml_copy_int64((int64) c_stats.st_rd_req));
52+
Store_field(stats, 4, caml_copy_int64((int64) c_stats.st_rd_cnt));
53+
Store_field(stats, 5, caml_copy_int64((int64) c_stats.st_rd_sect));
54+
Store_field(stats, 6, caml_copy_int64((int64) c_stats.st_rd_sum_usecs));
55+
Store_field(stats, 7, caml_copy_int64((int64) c_stats.st_rd_max_usecs));
56+
Store_field(stats, 8, caml_copy_int64((int64) c_stats.st_wr_req));
57+
Store_field(stats, 9, caml_copy_int64((int64) c_stats.st_wr_cnt));
58+
Store_field(stats, 10, caml_copy_int64((int64) c_stats.st_wr_sect));
59+
Store_field(stats, 11, caml_copy_int64((int64) c_stats.st_wr_sum_usecs));
60+
Store_field(stats, 12, caml_copy_int64((int64) c_stats.st_wr_max_usecs));
61+
62+
fclose(c_fd);
63+
64+
CAMLreturn(stats);
65+
66+
}

0 commit comments

Comments
 (0)