@@ -981,6 +981,31 @@ def test_api_entropy(uvm_plain):
981
981
test_microvm .api .entropy .put ()
982
982
983
983
984
+ def test_api_memory_hotplug (uvm_plain ):
985
+ """
986
+ Test hotplug related API commands.
987
+ """
988
+ test_microvm = uvm_plain
989
+ test_microvm .spawn ()
990
+ test_microvm .basic_config ()
991
+
992
+ # Adding hotplug memory region should be OK.
993
+ test_microvm .api .memory_hotplug .put (
994
+ total_size_mib = 1024 , block_size_mib = 128 , slot_size_mib = 1024
995
+ )
996
+
997
+ # Overwriting an existing should be OK.
998
+ # Omitting optional values should be ok
999
+ test_microvm .api .memory_hotplug .put (total_size_mib = 1024 )
1000
+
1001
+ # Start the microvm
1002
+ test_microvm .start ()
1003
+
1004
+ # API should be rejected after boot
1005
+ with pytest .raises (RuntimeError ):
1006
+ test_microvm .api .memory_hotplug .put (total_size_mib = 1024 )
1007
+
1008
+
984
1009
def test_api_balloon (uvm_nano ):
985
1010
"""
986
1011
Test balloon related API commands.
@@ -1211,8 +1236,13 @@ def test_get_full_config(uvm_plain):
1211
1236
response = test_microvm .api .vsock .put (guest_cid = 15 , uds_path = "vsock.sock" )
1212
1237
expected_cfg ["vsock" ] = {"guest_cid" : 15 , "uds_path" : "vsock.sock" }
1213
1238
1214
- # TODO Add hot-pluggable memory.
1215
- expected_cfg ["memory-hotplug" ] = None
1239
+ # Add hot-pluggable memory.
1240
+ expected_cfg ["memory-hotplug" ] = {
1241
+ "total_size_mib" : 1024 ,
1242
+ "block_size_mib" : 128 ,
1243
+ "slot_size_mib" : 1024 ,
1244
+ }
1245
+ test_microvm .api .memory_hotplug .put (** expected_cfg ["memory-hotplug" ])
1216
1246
1217
1247
# Add a net device.
1218
1248
iface_id = "1"
0 commit comments