@@ -117,7 +117,9 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid)
117
117
int retval ;
118
118
xc_interface * xch = xch_of_val (xch_val );
119
119
120
+ caml_enter_blocking_section ();
120
121
retval = xc_get_runstate_info (xch , Int_val (domid ), & info );
122
+ caml_leave_blocking_section ();
121
123
if (retval < 0 )
122
124
failwith_xc (xch );
123
125
@@ -153,7 +155,9 @@ CAMLprim value stub_xenctrlext_get_boot_cpufeatures(value xch_val)
153
155
int ret ;
154
156
xc_interface * xch = xch_of_val (xch_val );
155
157
158
+ caml_enter_blocking_section ();
156
159
ret = xc_get_boot_cpufeatures (xch , & a , & b , & c , & d , & e , & f , & g , & h );
160
+ caml_leave_blocking_section ();
157
161
if (ret < 0 )
158
162
failwith_xc (xch );
159
163
@@ -191,7 +195,9 @@ CAMLprim value stub_xenctrlext_domain_get_acpi_s_state(value xch_val, value domi
191
195
int ret ;
192
196
xc_interface * xch = xch_of_val (xch_val );
193
197
198
+ caml_enter_blocking_section ();
194
199
ret = xc_get_hvm_param (xch , Int_val (domid ), HVM_PARAM_ACPI_S_STATE , & v );
200
+ caml_leave_blocking_section ();
195
201
if (ret != 0 )
196
202
failwith_xc (xch );
197
203
@@ -203,7 +209,9 @@ CAMLprim value stub_xenctrlext_domain_send_s3resume(value xch_val, value domid)
203
209
CAMLparam2 (xch_val , domid );
204
210
xc_interface * xch = xch_of_val (xch_val );
205
211
212
+ caml_enter_blocking_section ();
206
213
xcext_domain_send_s3resume (xch , Int_val (domid ));
214
+ caml_leave_blocking_section ();
207
215
CAMLreturn (Val_unit );
208
216
}
209
217
@@ -213,7 +221,9 @@ CAMLprim value stub_xenctrlext_domain_set_timer_mode(value xch_val, value id, va
213
221
int ret ;
214
222
xc_interface * xch = xch_of_val (xch_val );
215
223
224
+ caml_enter_blocking_section ();
216
225
ret = xcext_domain_set_timer_mode (xch , Int_val (id ), Int_val (mode ));
226
+ caml_leave_blocking_section ();
217
227
if (ret < 0 )
218
228
failwith_xc (xch );
219
229
CAMLreturn (Val_unit );
@@ -243,7 +253,9 @@ CAMLprim value stub_xenctrlext_domain_set_target(value xch_val,
243
253
CAMLparam3 (xch_val , domid , target );
244
254
xc_interface * xch = xch_of_val (xch_val );
245
255
256
+ caml_enter_blocking_section ();
246
257
int retval = xc_domain_set_target (xch , Int_val (domid ), Int_val (target ));
258
+ caml_leave_blocking_section ();
247
259
if (retval )
248
260
failwith_xc (xch );
249
261
CAMLreturn (Val_unit );
@@ -327,7 +339,9 @@ static int get_cpumap_len(value xch_val, value cpumap)
327
339
{
328
340
xc_interface * xch = xch_of_val (xch_val );
329
341
int ml_len = Wosize_val (cpumap );
342
+ caml_enter_blocking_section ();
330
343
int xc_len = xc_get_max_cpus (xch );
344
+ caml_leave_blocking_section ();
331
345
332
346
return (ml_len < xc_len ? ml_len : xc_len );
333
347
}
@@ -341,19 +355,23 @@ CAMLprim value stub_xenctrlext_vcpu_setaffinity_soft(value xch_val, value domid,
341
355
int retval ;
342
356
xc_interface * xch = xch_of_val (xch_val );
343
357
358
+ caml_enter_blocking_section ();
344
359
c_cpumap = xc_cpumap_alloc (xch );
360
+ caml_leave_blocking_section ();
345
361
if (c_cpumap == NULL )
346
362
failwith_xc (xch );
347
363
348
364
for (i = 0 ; i < len ; i ++ ) {
349
365
if (Bool_val (Field (cpumap , i )))
350
366
c_cpumap [i /8 ] |= 1 << (i & 7 );
351
367
}
368
+ caml_enter_blocking_section ();
352
369
retval = xc_vcpu_setaffinity (xch , Int_val (domid ),
353
370
Int_val (vcpu ),
354
371
NULL , c_cpumap ,
355
372
XEN_VCPUAFFINITY_SOFT );
356
373
free (c_cpumap );
374
+ caml_leave_blocking_section ();
357
375
358
376
if (retval < 0 )
359
377
failwith_xc (xch );
@@ -371,7 +389,9 @@ CAMLprim value stub_xenctrlext_numainfo(value xch_val)
371
389
int retval ;
372
390
xc_interface * xch = xch_of_val (xch_val );
373
391
392
+ caml_enter_blocking_section ();
374
393
retval = xc_numainfo (xch , & max_nodes , NULL , NULL );
394
+ caml_leave_blocking_section ();
375
395
if (retval < 0 )
376
396
failwith_xc (xch );
377
397
@@ -383,7 +403,9 @@ CAMLprim value stub_xenctrlext_numainfo(value xch_val)
383
403
caml_raise_out_of_memory ();
384
404
}
385
405
406
+ caml_enter_blocking_section ();
386
407
retval = xc_numainfo (xch , & max_nodes , meminfo , distance );
408
+ caml_leave_blocking_section ();
387
409
if (retval < 0 ) {
388
410
free (meminfo );
389
411
free (distance );
@@ -425,15 +447,19 @@ CAMLprim value stub_xenctrlext_cputopoinfo(value xch_val)
425
447
int retval ;
426
448
xc_interface * xch = xch_of_val (xch_val );
427
449
450
+ caml_enter_blocking_section ();
428
451
retval = xc_cputopoinfo (xch , & max_cpus , NULL );
452
+ caml_leave_blocking_section ();
429
453
if (retval < 0 )
430
454
failwith_xc (xch );
431
455
432
456
cputopo = calloc (max_cpus , sizeof (* cputopo ));
433
457
if (!cputopo )
434
458
caml_raise_out_of_memory ();
435
459
460
+ caml_enter_blocking_section ();
436
461
retval = xc_cputopoinfo (xch , & max_cpus , cputopo );
462
+ caml_leave_blocking_section ();
437
463
if (retval < 0 ) {
438
464
free (cputopo );
439
465
failwith_xc (xch );
@@ -553,7 +579,9 @@ CAMLprim value stub_xenforeignmemory_open(value unit)
553
579
result = caml_alloc (1 , Abstract_tag );
554
580
555
581
// use NULL instead of a xentoollog handle as those bindings are flawed
582
+ caml_enter_blocking_section ();
556
583
fmem = xenforeignmemory_open (NULL , 0 );
584
+ caml_leave_blocking_section ();
557
585
558
586
if (fmem == NULL ) {
559
587
caml_failwith ("Error when opening foreign memory handle" );
@@ -568,13 +596,16 @@ CAMLprim value stub_xenforeignmemory_close(value fmem)
568
596
{
569
597
CAMLparam1 (fmem );
570
598
int retval ;
599
+ struct xenforeignmemory_handle * handle = Xfm_val (fmem );
571
600
572
- if (Xfm_val ( fmem ) == NULL ) {
601
+ if (handle == NULL ) {
573
602
caml_invalid_argument (
574
603
"Error: cannot close NULL foreign memory handle" );
575
604
}
576
605
577
- retval = xenforeignmemory_close (Xfm_val (fmem ));
606
+ caml_enter_blocking_section ();
607
+ retval = xenforeignmemory_close (handle );
608
+ caml_leave_blocking_section ();
578
609
579
610
if (retval < 0 ) {
580
611
caml_failwith ("Error when closing foreign memory handle" );
@@ -632,11 +663,12 @@ CAMLprim value stub_xenforeignmemory_map(value fmem, value dom,
632
663
cell = Field (cell , 1 );
633
664
}
634
665
666
+ caml_enter_blocking_section ();
635
667
retval = xenforeignmemory_map
636
668
(handle , Int_val (dom ), prot , pages_length , arr , NULL );
637
669
the_errno = errno ;
638
-
639
670
free (arr );
671
+ caml_leave_blocking_section ();
640
672
641
673
if (retval == NULL ) {
642
674
raise_unix_errno_msg (the_errno ,
@@ -655,12 +687,15 @@ CAMLprim value stub_xenforeignmemory_unmap(value fmem, value mapping)
655
687
CAMLparam2 (fmem , mapping );
656
688
size_t pages ;
657
689
int retval , the_errno ;
690
+ struct xenforeignmemory_handle * handle = Xfm_val (fmem );
691
+ void * data = Caml_ba_data_val (mapping );
658
692
659
693
// convert mapping to pages and addr
660
694
pages = Caml_ba_array_val (mapping )-> dim [0 ] / 4096 ;
661
695
662
- retval = xenforeignmemory_unmap (Xfm_val (fmem ),
663
- Caml_ba_data_val (mapping ), pages );
696
+ caml_enter_blocking_section ();
697
+ retval = xenforeignmemory_unmap (handle , data , pages );
698
+ caml_leave_blocking_section ();
664
699
the_errno = errno ;
665
700
666
701
if (retval < 0 ) {
0 commit comments