@@ -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.
@@ -1209,8 +1234,13 @@ def test_get_full_config(uvm_plain):
1209
1234
response = test_microvm .api .vsock .put (guest_cid = 15 , uds_path = "vsock.sock" )
1210
1235
expected_cfg ["vsock" ] = {"guest_cid" : 15 , "uds_path" : "vsock.sock" }
1211
1236
1212
- # TODO Add hot-pluggable memory.
1213
- expected_cfg ["memory-hotplug" ] = None
1237
+ # Add hot-pluggable memory.
1238
+ expected_cfg ["memory-hotplug" ] = {
1239
+ "total_size_mib" : 1024 ,
1240
+ "block_size_mib" : 128 ,
1241
+ "slot_size_mib" : 1024 ,
1242
+ }
1243
+ test_microvm .api .memory_hotplug .put (** expected_cfg ["memory-hotplug" ])
1214
1244
1215
1245
# Add a net device.
1216
1246
iface_id = "1"
0 commit comments