avocado-vt icon indicating copy to clipboard operation
avocado-vt copied to clipboard

qemu_vm: Avoid overwrite existing virtio properties

Open PaulYuuu opened this issue 2 years ago • 9 comments

  1. "virtio_dev_xxx" are global settings for virtio devices, but they will always be set if we define them, even if the device has set these properties. The property setting by the device should be higher than the global one.
  2. virtio_dev_xxx will set properties to whole virtio devices, but some devices cannot work well that property such as "vhost-user-fs-pci" + "iommu_platform", so the new parameter virtio_dev_filter can filter out some devices which we want to set those properties.

ID: 2111781 Signed-off-by: Yihuang Yu [email protected]

PaulYuuu avatar Jul 28 '22 08:07 PaulYuuu

Hello @vivianQizhu @yanan-fu @yiqianwei, would you help review? Thanks in advance.

PaulYuuu avatar Aug 03 '22 02:08 PaulYuuu

Hello @vivianQizhu @yanan-fu @yiqianwei, would you help review? Thanks in advance.

Hey, any comments?

PaulYuuu avatar Aug 30 '22 11:08 PaulYuuu

With this implementation, there are two different sets of logic that can change the same device configuration. I think it's going to be a little confused. But yes, the existing logic is for all virtio device, does not allow device specific setting.
Could you please share more about the requirements ? Why does it needs different setting for the device you want to change with device.params. Thanks!

yanan-fu avatar Sep 19 '22 05:09 yanan-fu

With this implementation, there are two different sets of logic that can change the same device configuration. I think it's going to be a little confused. But yes, the existing logic is for all virtio device, does not allow device specific setting. Could you please share more about the requirements ? Why does it needs different setting for the device you want to change with device.params. Thanks!

OK, in one case, most virtio devices want to enable iommu_platform, and only one or a few devices cannot enable it because of the limitation, such as virtio-iommu, virtio-balloon. Actually the iommu_platform should not display in the device help output, but developers think this usage can avoid in the libvirt layer and it's a wrong usage, so not plan to correct it. If we use xxx_extra_params, we need to set each device, but virtio_dev_xxx can set all virtio devices, as long as this parameter appears in the help output. So with this change, the virtio parameters can be controlled relatively flexibly, even if it's a workaround.

PaulYuuu avatar Sep 26 '22 02:09 PaulYuuu

OK, in one case, most virtio devices want to enable iommu_platform, and only one or a few devices cannot enable it because of the limitation, such as virtio-iommu, virtio-balloon. Actually the iommu_platform should not display in the device help output, but developers think this usage can avoid in the libvirt layer and it's a wrong usage, so not plan to correct it.

Okay, If those virtio devices which show iommu_platform in help info but does not support it actually, how do you think about defining blacklist for them ?

yanan-fu avatar Sep 28 '22 14:09 yanan-fu

Okay, If those virtio devices which show iommu_platform in help info but does not support it actually, how do you think about defining blacklist for them ?

I thought about it before, but it's hard to maintain, I mean we don't know how many virtio devices will be introduced in the future, and what the support status of these properties of them.

PaulYuuu avatar Sep 29 '22 02:09 PaulYuuu

Okay, If those virtio devices which show iommu_platform in help info but does not support it actually, how do you think about defining blacklist for them ?

I thought about it before, but it's hard to maintain, I mean we don't know how many virtio devices will be introduced in the future, and what the support status of these properties of them.

I think it is same for test case level to handle xxx_extra_params, when new virtio device be introduced and have the same problem, case need be updated accordingly IMO, and may be not only one cases.

yanan-fu avatar Sep 29 '22 03:09 yanan-fu

I think it is same for test case level to handle xxx_extra_params, when new virtio device be introduced and have the same problem, case need be updated accordingly IMO, and may be not only one cases.

In case users use compiled qemu themselves, there has a lot of virtio devices, we hard to maintain them in a white/black list. This just provides a flexible method to control virtio_dev_xxx parameters, this change will keep the previous usage and support _extra_params as well.

However, not many people/feature owners will set iommu-related parameters as a global setting.

PaulYuuu avatar Oct 26 '22 07:10 PaulYuuu

@yanan-fu updated according to our offline discussion, I think these are the minimal changes based on the conversation.

PaulYuuu avatar Nov 22 '22 03:11 PaulYuuu

Test:

>>> import re
>>> devices = [{'dev': 'virtio-net-pci'}, {'dev': 'vhost-vsock'}, {'dev': 'pxb-pcie'}, {'dev': 'virtio-balloon-pci'}, {'dev': 'virtio-iommu-pci'}, {'dev': 'vhost-user-fs-pci'}]
>>> virtio_dev_filter = '^(?:(?:virtio-)|(?:vhost-))(?!(?:balloon)|(?:iommu))'
>>> list(filter(lambda x: re.search(virtio_dev_filter, x.get('dev')), devices))
[{'dev': 'virtio-net-pci'}, {'dev': 'vhost-vsock'}, {'dev': 'vhost-user-fs-pci'}]
>>> virtio_dev_filter = '^(?:(?:virtio-)|(?:vhost-))(?!(?:user)|(?:net))'
>>> list(filter(lambda x: re.search(virtio_dev_filter, x.get('dev')), devices))
[{'dev': 'vhost-vsock'}, {'dev': 'virtio-balloon-pci'}, {'dev': 'virtio-iommu-pci'}]
>>> virtio_dev_filter = '^(?:(?:virtio-)|(?:vhost-))(?:net)'
>>> list(filter(lambda x: re.search(virtio_dev_filter, x.get('dev')), devices))
[{'dev': 'virtio-net-pci'}]

PaulYuuu avatar Dec 09 '22 04:12 PaulYuuu

Re-push to fix the CI failure.

PaulYuuu avatar Jan 15 '23 12:01 PaulYuuu

Hello @vivianQizhu, could you also help to review?

PaulYuuu avatar Jan 31 '23 14:01 PaulYuuu