Skip to content

Commit 2bde707

Browse files
author
Jon Ludlam
committed
Merge pull request #85 from jonludlam/xen-4.6
Xen 4.6 compatibility
2 parents 5c61270 + b71c8c4 commit 2bde707

File tree

6 files changed

+1831
-3
lines changed

6 files changed

+1831
-3
lines changed

configure.ml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let cc verbose c_program =
1818
let c_file = Filename.temp_file "configure" ".c" in
1919
let o_file = c_file ^ ".o" in
2020
output_file c_file c_program;
21-
let found = Sys.command (Printf.sprintf "cc -c %s -o %s %s" c_file o_file (if verbose then "" else "2>/dev/null")) = 0 in
21+
let found = Sys.command (Printf.sprintf "cc -Werror -c %s -o %s %s" c_file o_file (if verbose then "" else "2>/dev/null")) = 0 in
2222
if Sys.file_exists c_file then Sys.remove c_file;
2323
if Sys.file_exists o_file then Sys.remove o_file;
2424
found
@@ -116,6 +116,21 @@ let find_xen_4_5 verbose =
116116
Printf.printf "Looking for xen-4.5: %s\n" (if found then "ok" else "missing");
117117
found
118118

119+
let find_xen_4_6 verbose =
120+
let c_program = [
121+
"#include <stdlib.h>";
122+
"#include <xenctrl.h>";
123+
"#include <xenguest.h>";
124+
"int main(int argc, const char *argv){";
125+
" int r = xc_assign_device(NULL, 0, 0, 0);";
126+
" return 0;";
127+
"}";
128+
] in
129+
let found = cc verbose c_program in
130+
Printf.printf "Looking for xen-4.6: %s\n" (if found then "ok" else "missing");
131+
found
132+
133+
119134
let check_arm_header verbose =
120135
let lines = run verbose "arch" in
121136
let arch = List.hd lines in
@@ -147,6 +162,7 @@ let configure verbose disable_xenctrl disable_xenlight disable_xenguest =
147162
let xenlight_4_4 = find_xenlight_4_4 verbose in
148163
let xen_4_4 = xenlight_4_4 in
149164
let xen_4_5 = find_xen_4_5 verbose in
165+
let xen_4_6 = find_xen_4_6 verbose in
150166
let xc_domain_save_generation_id = find_xc_domain_save_generation_id verbose in
151167
let have_viridian = find_define verbose "HVM_PARAM_VIRIDIAN" in
152168
if not xenctrl then begin
@@ -169,8 +185,10 @@ let configure verbose disable_xenctrl disable_xenlight disable_xenguest =
169185
"# Do not edit";
170186
Printf.sprintf "ENABLE_XENCTRL=--%s-xenctrl" (if disable_xenctrl then "disable" else "enable");
171187
Printf.sprintf "ENABLE_XENGUEST42=--%s-xenguest42" (if xen_4_4 || xen_4_5 || disable_xenguest then "disable" else "enable");
172-
Printf.sprintf "ENABLE_XENGUEST44=%s" (if (xen_4_4 || xen_4_5) && not disable_xenguest then "true" else "false");
188+
Printf.sprintf "ENABLE_XENGUEST44=%s" (if (xen_4_4 || xen_4_5) && (not xen_4_6) && not disable_xenguest then "true" else "false");
189+
Printf.sprintf "ENABLE_XENGUEST46=%s" (if (xen_4_6) && not disable_xenguest then "true" else "false");
173190
Printf.sprintf "HAVE_XEN_4_5=%s" (if xen_4_5 then "true" else "false");
191+
Printf.sprintf "HAVE_XEN_4_6=%s" (if xen_4_6 then "true" else "false");
174192

175193
] in
176194
output_file config_mk lines;
@@ -180,6 +198,7 @@ let configure verbose disable_xenctrl disable_xenlight disable_xenguest =
180198
"/* Do not edit */";
181199
(if have_viridian then "" else "/* ") ^ "#define HAVE_HVM_PARAM_VIRIDIAN" ^ (if have_viridian then "" else " */");
182200
(if xen_4_5 then "" else "/* ") ^ "#define HAVE_XEN_4_5" ^ (if xen_4_5 then "" else " */");
201+
(if xen_4_6 then "" else "/* ") ^ "#define HAVE_XEN_4_6" ^ (if xen_4_6 then "" else " */");
183202
(if xc_domain_save_generation_id then "" else "/* ") ^ "#define HAVE_XC_DOMAIN_SAVE_GENERATION_ID" ^ (if xc_domain_save_generation_id then "" else " */");
184203
] in
185204
output_file config_h lines;

lib/xenctrl_stubs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,11 @@ CAMLprim value stub_xc_domain_assign_device(value xch, value domid, value desc)
11501150
func = Int_val(Field(desc, 3));
11511151
sbdf = encode_sbdf(domain, bus, dev, func);
11521152

1153-
ret = xc_assign_device(_H(xch), _D(domid), sbdf);
1153+
ret = xc_assign_device(_H(xch), _D(domid), sbdf
1154+
#ifdef HAVE_XEN_4_6
1155+
,0
1156+
#endif
1157+
);
11541158

11551159
if (ret < 0)
11561160
failwith_xc(_H(xch));

xenguest-4.6/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CFLAGS += -Werror
2+
CFLAGS += -I.
3+
CFLAGS += -lxenctrl -lxenguest -lxenstore
4+
CFLAGS += -D_GNU_SOURCE
5+
6+
PROGRAMS := xenguest
7+
8+
.PHONY: all
9+
all: build
10+
11+
.PHONY: build
12+
build: $(PROGRAMS)
13+
14+
xenguest: xenguest.o xenguest_stubs.o
15+
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $^ \
16+
-lxenctrl -lxenguest -lxenstore
17+
rm *.o
18+
19+
.PHONY: install
20+
install:
21+
mkdir -p $(BINDIR)
22+
install -m 0755 xenguest $(BINDIR)
23+
24+
.PHONY: uninstall
25+
rm -f $(BINDIR)/xenguest
26+
27+
.PHONY: clean
28+
clean:
29+
rm -f *.o $(PROGRAMS)

0 commit comments

Comments
 (0)