-
Notifications
You must be signed in to change notification settings - Fork 243
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
QEMU_VM: Add nic_extra_param_types support #4045
base: master
Are you sure you want to change the base?
Conversation
e695318
to
c581aee
Compare
@leidwang Hi, Could you please help review this netkvm qemu_vm improvement? I have tested positive and negative logic and kept the original logic that defaults to str. All of that works great for me. |
@vivianQizhu Hi, I'm calling you to review this patch as well. Thanks a lot. |
virttest/qemu_vm.py
Outdated
value_type = nic_extra_params_type.get(key) | ||
if value_type: | ||
try: | ||
converted_val = value_type(val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converted_val = value_type(val) | |
converted_val = eval(value_type)(val) |
Current code is wrong, it can not convert the val to expected type, and it will raise an error.Please have a check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> nic_extra_params_type = {"a":"int"}
>>> value_type = nic_extra_params_type.get("a")
>>> value_type
'int'
>>> val = "10"
>>> converted_val = value_type(val)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
>>> converted_val = eval(value_type)(val)
>>> type(converted_val)
<class 'int'>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leidwang
We have a split opinion on line 1. Currently, I am using it in this way:
>>> nic_extra_params_type = {"a":int}
>>> value_type = nic_extra_params_type.get("a")
>>> value_type
<class 'int'>
>>> val = "10"
>>> converted_val = value_type(val)
>>> type(converted_val)
<class 'int'>
>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nic_extra_params_type = {"a":int}
"int" is not a number, it's a string, I think we need add "" for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing with @leidwang offline, we want to let @vivianQizhu decide.
In my opinion, Any data can be put into a dict of Python class type because all memory is mapped at the System Bottom. I don't think there is a need for" to set the class type.
Leidong's opinion is that he saw some "int"(highlight: "") in our avocado-vt framework and tp-qemu project. We should make the style the same.
We are just waiting for your professional opinion. @vivianQizhu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In a dict, if the value of a key is "int", it is actually no different from "abc".I t is just a string, in this case, we need add "" for it. I think a better format is
nic_extra_params_type = {"a": "int"}
2.Regardless of which writing style we adopt, we should consider how to handle the other style as well, in order to avoid errors caused by inconsistent writing.
Hi @leidwang, I accepted your advice about this patch after talking with @vivianQizhu offline. Thank you~ |
271a3cd
to
50d7ae2
Compare
Add nic_extra_param_types params support for nic_extra_params to optimize virtio-net QEMU cmdline type handling. Signed-off-by: Wenkang Ji <[email protected]>
50d7ae2
to
cb3c45d
Compare
@leidwang, call you to review this patch again. Thanks in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@vivianQizhu please help tp review it when you are free, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you want to fix the issue for param type in newer qemu versions, however this should be fixed in #4056.
Each parameter has a unique type and users should not modify it based on their idea.
@vivianQizhu @PaulYuuu OK, I will try it. |
Yes, it should cover all parameters, also it supports both nic_extra_params and netdev_extra_params. The PR has not yet collected all correct parameter types, it should require all feature owners for review. |
Add nic_extra_param_types params support for nic_extra_params to optimize virtio-net QEMU cmdline type handling.
ID: 3269
Signed-off-by: wji [email protected]