Skip to content

Commit 1b004fd

Browse files
committed
unit_tests: Add XSA-483 quota test
This failed before the XSA-483 patch, showing that the quota was not reset after domain destruction: FAIL Verify quota usage is as expected Expected: `0' Received: `4' Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
1 parent 54c4c6a commit 1b004fd

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/unit_tests.ml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,41 @@ let check_quota_ent_per_domain store ~domid expected =
840840
~actual:(get_current_entries_quota store domid)
841841
~expected
842842

843+
let test_xsa_483 () =
844+
initialize_main_loop () ;
845+
let one_loop_iteration, store, cons, doms = Xenstored.main () in
846+
let dom0 = Hashtbl.find cons.domains 0 in
847+
848+
(* Domains > 2000 are considered dead on the first query for test purposes *)
849+
let domU = create_domU_conn cons doms 2001 in
850+
851+
run store cons doms
852+
[
853+
(dom0, none, (Write, ["/local/domain/2001"; ""]), (Write, ["OK"]))
854+
; ( dom0
855+
, none
856+
, (Setperms, ["/local/domain/2001"; "r2001"])
857+
, (Setperms, ["OK"])
858+
)
859+
] ;
860+
861+
check_quota_ent_per_domain store ~domid:2001 1 ;
862+
863+
(* domU adds some nodes to its sub-tree *)
864+
run store cons doms
865+
[
866+
(domU, none, (Write, ["/local/domain/2001/x"; ""]), (Write, ["OK"]))
867+
; (domU, none, (Write, ["/local/domain/2001/y"; ""]), (Write, ["OK"]))
868+
; (domU, none, (Write, ["/local/domain/2001/z"; ""]), (Write, ["OK"]))
869+
] ;
870+
check_quota_ent_per_domain store ~domid:2001 4 ;
871+
872+
(* dom2001 dies, is cleaned up *)
873+
one_loop_iteration () ;
874+
875+
(* Its quota should be reset back to 0 *)
876+
check_quota_ent_per_domain store ~domid:2001 0
877+
843878
(* Check that node creation and destruction changes a quota *)
844879
let test_quota () =
845880
let store, doms, cons = initialize () in
@@ -1126,6 +1161,7 @@ let () =
11261161
; ( "Quota tests"
11271162
, [
11281163
("test_quota", `Quick, test_quota)
1164+
; ("test_xsa_483", `Quick, test_xsa_483)
11291165
; ("test_quota_transaction", `Quick, test_quota_transaction)
11301166
; ( "test_quota_transaction_overflow"
11311167
, `Quick

0 commit comments

Comments
 (0)