Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qdevices: refreshes the device_add params for QMP hotplug #4053

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(option)
if value:
params[option] = int(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic with L1165~L1168 belong to the refresh_hotplug_procs function. And for node, it already be covered in the Dimm class.

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