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

QEMU_VM: Add nic_extra_param_types support #4045

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heywji
Copy link
Contributor

@heywji heywji commented Dec 30, 2024

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]

@heywji heywji force-pushed the add_nic_types_support branch 9 times, most recently from e695318 to c581aee Compare January 2, 2025 03:38
@heywji
Copy link
Contributor Author

heywji commented Jan 2, 2025

@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.

@heywji
Copy link
Contributor Author

heywji commented Jan 3, 2025

@vivianQizhu Hi, I'm calling you to review this patch as well. Thanks a lot.

value_type = nic_extra_params_type.get(key)
if value_type:
try:
converted_val = value_type(val)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Contributor

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'>

Copy link
Contributor Author

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'>
>>> 

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@leidwang leidwang Jan 8, 2025

Choose a reason for hiding this comment

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

  1. 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.

@heywji
Copy link
Contributor Author

heywji commented Jan 9, 2025

Hi @leidwang,

I accepted your advice about this patch after talking with @vivianQizhu offline.
I will update the code and test it. I will let you review it again when everything is ready.

Thank you~

@heywji heywji force-pushed the add_nic_types_support branch 3 times, most recently from 271a3cd to 50d7ae2 Compare January 10, 2025 09:42
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]>
@heywji heywji force-pushed the add_nic_types_support branch from 50d7ae2 to cb3c45d Compare January 13, 2025 06:07
@heywji
Copy link
Contributor Author

heywji commented Jan 14, 2025

@leidwang, call you to review this patch again. Thanks in advance.

Copy link
Contributor

@leidwang leidwang left a comment

Choose a reason for hiding this comment

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

LGTM.

@heywji
Copy link
Contributor Author

heywji commented Feb 5, 2025

@vivianQizhu please help tp review it when you are free, thanks.

Copy link
Contributor

@PaulYuuu PaulYuuu left a 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
Copy link
Contributor

@PaulYuuu Nice patch for #4056, but I don't find how it handle extra_params, it only handles named parameters, I suppose this PR won't be conflict with that one, as extra_params can only be string now, we need to extend it.

@vivianQizhu
Copy link
Contributor

vivianQizhu commented Feb 8, 2025

@PaulYuuu Correct myself, I see how it handles all params, with _update_args_type_from_qemu().
@heywji Could you try with #4056 and see if it fixes your issue? If so I guess we can close this one.

@heywji
Copy link
Contributor Author

heywji commented Feb 8, 2025

@vivianQizhu @PaulYuuu OK, I will try it.

@PaulYuuu
Copy link
Contributor

PaulYuuu commented Feb 8, 2025

@PaulYuuu Correct myself, I see how it handles all params, with _update_args_type_from_qemu().

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants