[viostor] Fixup VirtIoAdapterControl()#1516
[viostor] Fixup VirtIoAdapterControl()#1516benyamin-codez wants to merge 4 commits intovirtio-win:masterfrom
Conversation
Consolidates the 'adaptExt' declaration and definition to top of list. Refactors the 'index' variable as 'list_idx'. Also removes unnecessary whitespace in switch-case ladder. Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
Relocates catch-all Control Type trace message to the default case for unsupported Control Types only. This is reasonable as all supported Control Types have an identifying trace message anyway. Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
Refactors the 'SupportedControlTypes' bit field to use the Storport 'ScsiAdapterControlMax' method rather than an explicit BOOLEAN array. Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
Adds a 'ScsiAdapterSurpriseRemoval' Control Type.
NOTE: Storport does not appear to call the ScsiAdapterSurpriseRemoval
Control Type on hot-unplug. It calls the ScsiStopAdapter
Control Type instead. We include this Control Type for completeness.
Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
|
[Jenkins CI]: Can one of the admins verify this patch? |
Summary of ChangesHello @benyamin-codez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request provides a good cleanup and enhancement of the VirtIoAdapterControl function. The changes, including variable cleanup, improved tracing, and a more robust way of handling supported control types, significantly improve code quality and maintainability. The addition of ScsiAdapterSurpriseRemoval support is also a good step towards completeness. I have a couple of minor suggestions to further improve code style and readability, but overall this is a solid set of changes.
|
Sorry, I understand the will to help. But I am against refactoring for the sake of refactoring. Let's focus on actual issues, functionality, and enabling better debugging. BTW: removing tracing from the existing path is bad. I am for always enabling tracing during init\deinit and control. And on hot path with higher debug levels. This is really needed on order to understand the flow of operations that happens to the drivers from the OS level. If you want to make something useful here is a feature that I think we could add: Best regards, |
|
Hi Yan, I was just dumping what I had learnt troubleshooting *SurpriseRemoval. I had worked on this some time ago, but it was also recently highlighted in issue #1483. The behaviour for As it stands, I'd like to dump the series of PRs for what I have done already. They really will improve the RAS of the storage drivers. This one is a little bit on the edge but covers the bases for anyone researching this further in the future. If the project doesn't want to use them, then so be it, but I'd like to put them out there for consideration anyway, and you and the team can review them as your time permits. As for this PR, the tracing change still reports for all pathways. You still get a message for any call, either a human readable output or a type code for the relevant enumerator. It is the same mechanics we have in I think I really need to do the ETW PR soon, if not next. It would mean we no longer have a need to differentiate between hot and cold paths in ETW provided we turn off DBG - which we should for Release drivers anyway. The DBG option would then become something devs will compile for as the need arises. With that PR, you will get the full suite of WPP macros such as Adding statistics... It could be of some advantage provided it doesn't impact performance and I think that would be the challenge. I could work on something, but that's quite a pivot, and I'd prefer to first dump what I already have and clear my horizon before embarking on a new mission. Also, the need for this might be somewhat diminished with proper tracing output as problems tend to be more easily discerned. Do you have a NetKVM function that can serve as a primer for me to consider what you have in mind...? Best regards, |
|
How do you get a surprise removal in practice? virtio-blk is a PCI device and my understanding is that QEMU never just rips a PCI device out, but instead it requests the guest OS to remove the device before it is actually removed on the hardware side. |
|
@kevmw The complicated way is to run the surprise removal test from HLK manually: https://learn.microsoft.com/en-us/windows-hardware/test/hlk/testref/reproduce-the-test-failure-by-running-the-test-from-the-command-line I am trying to find the old pnpdtest.exe utility that was much simpler. It was part of the older WDK kits. |
|
@kevmw you can download the old (Windows 7) kit from here https://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO There is pnpdtest.exe for appropriate architecture. It might say that some DLL is missing, but it is also part of the kit, so just copy to the same directory. If you want, I can send you only the test binaries. |
|
So as Yan has pointed out, there is a HLK requirement, but in practice we don't expect QEMU to do this. When we do remove the device on QEMU, we observe some differences between the storage drivers in how this operates: In In |
|
@benyamin-codez Surprise removal is a standard Windows PnP operation. BTW: when having removable device on Windows and removing it from system tray GUI (remember the infamous eject USB device on Windows), I think in such case we also can get a surprise removal. Regarding the difference between actual HW and QEMU - yes, this is a tricky part. With actual HW, I would expect something like a device reset as well or a device is actually gone. The HW will not attempt to do DMA anymore. But in our case the submitted descriptors to the host might be touched from the host side. There is a state machine of the device that accounts for the surprise removal and notifies the "flows" and bunch of places with |
|
@benyamin-codez Check ParaNdis-SM.h for the state machine code. |
Fixes up
VirtIoAdapterControl().By commit:
Cleanup variables
Consolidates the
adaptExtdeclaration and definition to top of list.Refactors the
indexvariable aslist_idx.Also removes unnecessary whitespace in switch-case ladder.
Tracing
Relocates catch-all Control Type trace message to the default case for unsupported Control Types only.
This is reasonable as all supported Control Types have an identifying trace message anyway.
SupportedControlTypes
Refactors the
SupportedControlTypesbit field to use the StorportScsiAdapterControlMaxmethod rather than an explicit BOOLEAN array.Add ScsiAdapterSurpriseRemoval
Adds a
ScsiAdapterSurpriseRemovalControl Type.NOTE: Storport does not appear to call the
ScsiAdapterSurpriseRemovalControl Type on hot-unplug. It calls theScsiStopAdapterControl Type instead. We include this Control Type for completeness.