agent: separate driver loading from driver initialisation
GenericDriver.init_host() existed as an uninvoked hook for driver prerequisites, while AgentManager.init_host() was a pass stub. ResourceTracker._initialize_drivers() loaded drivers but did not call their init_host() hooks, so prerequisites in those hooks were not checked before the first discovery.
Introduce the driver init_host() invocation after RPCService.start() starts the RPC server. AgentManager.init_host() delegates to ResourceTracker.init_host(), which owns the explicitly ordered startup steps:
- _initialize_drivers(): loads drivers only, no init_host() call
- init_drivers(): calls init_host() on every driver, with logging
- discover_all(): returns one discovery snapshot keyed by driver name
- check_duplicate_devices(): raises InvalidConfiguration when two drivers claim the same PCI device, preventing silent double-reporting to Placement
Adds the InvalidConfiguration exception used to signal these errors.
acc_drivers changes from a list to a dict keyed by driver name so each step can address drivers by identity and duplicate reports can name the offending drivers.
Duplicate detection compares a canonical domain
device.function BDF rebuilt from cpid_info rather than the raw JSON string. Drivers serialize cpid_info with differing key order and spacing (pci_str_to_json emits sorted, spaced keys; fake.py emits unsorted, unspaced JSON), so a raw-string comparison would miss genuine duplicates that describe the same address. The rebuilt form also yields a readable address in the error message, and it falls back to the raw value if cpid_info is not the expected BDF JSON.
Unit tests cover the load/init split, init_host() exception propagation, duplicate rejection (including the same address under different serializations), no-duplicate pass-through, and manager delegation to the tracker’s init_host().
Generated-By: Claude Sonnet 4.6 Assisted-By: Codex GPT-6 Change-Id: Id33eae25469eb26f5b1e526aecbcdc85fd728c1d Signed-off-by: Chandan Kumar (raukadah) chkumar@redhat.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号