Skip to content

Commit

Permalink
qdevices: refreshes the device_add params for QMP hotplug
Browse files Browse the repository at this point in the history
device_add no longer accept string values in QMP command.
Casts the node and requested-size values to integer before
doing the QMP hotplug.

Signed-off-by: mcasquer <[email protected]>
  • Loading branch information
mcasquer committed Jan 17, 2025
1 parent fc37acd commit e4e648f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,23 @@ def hotplug_hmp(self):
out = "device_add %s" % _convert_args(self.params)
return out

def _refresh_hotplug_props(self, params):
"""
Refresh hotplug optional props as per params.
:return: A dict containing hotplug optional props.
"""
return params

def hotplug_qmp(self):
""":return: the hotplug monitor command"""
return "device_add", self.params
params = self.params.copy()
params = self._refresh_hotplug_props(params)
for option in ["node", "requested-size"]:
value = params.get_param(option)
if value:
params[option] = int(value)
return "device_add", params

def hotplug_hmp_nd(self):
""":return: the hotplug monitor command without dynamic parameters"""
Expand Down Expand Up @@ -1827,6 +1841,11 @@ def __init__(self, params=None, dimm_type="pc-dimm"):
super(Dimm, self).__init__(**kwargs)
self.set_param("driver", dimm_type)

def _refresh_hotplug_props(self, params):
if params.get("node"):
params["node"] = int(params.get("node"))
return params

def verify_hotplug(self, out, monitor):
out = monitor.info("memory-devices", debug=False)
if "unknown command" in out: # Old qemu don't have info qtree
Expand Down

0 comments on commit e4e648f

Please sign in to comment.