mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
agent/device: Pass root bus sysfs path to pcipath_to_sysfs()
Currently pcipath_to_sysfs() generates the path to the root bus node in sysfs via create_pci_root_bus_path(). This is inconvenient for testing, though, so instead make it take this as a parameter and generate the path in the (single) caller. As a bonus this will make life a bit easier when we want to support machines with multiple PCI roots. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
fda48a9bf0
commit
066ce7ab51
@ -50,10 +50,9 @@ pub fn online_device(path: &str) -> Result<()> {
|
|||||||
// pciPathToSysfs fetches the sysfs path for a PCI path, relative to
|
// pciPathToSysfs fetches the sysfs path for a PCI path, relative to
|
||||||
// the syfs path for the PCI host bridge, based on the PCI path
|
// the syfs path for the PCI host bridge, based on the PCI path
|
||||||
// provided.
|
// provided.
|
||||||
fn pcipath_to_sysfs(pcipath: &pci::Path) -> Result<String> {
|
fn pcipath_to_sysfs(root_bus_sysfs: &str, pcipath: &pci::Path) -> Result<String> {
|
||||||
let mut bus = "0000:00".to_string();
|
let mut bus = "0000:00".to_string();
|
||||||
let mut relpath = String::new();
|
let mut relpath = String::new();
|
||||||
let root_bus_sysfs = format!("{}{}", SYSFS_DIR, create_pci_root_bus_path());
|
|
||||||
|
|
||||||
for i in 0..pcipath.len() {
|
for i in 0..pcipath.len() {
|
||||||
let bdf = format!("{}:{}.0", bus, pcipath[i]);
|
let bdf = format!("{}:{}.0", bus, pcipath[i]);
|
||||||
@ -148,7 +147,8 @@ pub async fn get_pci_device_name(
|
|||||||
sandbox: &Arc<Mutex<Sandbox>>,
|
sandbox: &Arc<Mutex<Sandbox>>,
|
||||||
pcipath: &pci::Path,
|
pcipath: &pci::Path,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let sysfs_rel_path = pcipath_to_sysfs(pcipath)?;
|
let root_bus_sysfs = format!("{}{}", SYSFS_DIR, create_pci_root_bus_path());
|
||||||
|
let sysfs_rel_path = pcipath_to_sysfs(&root_bus_sysfs, pcipath)?;
|
||||||
|
|
||||||
rescan_pci_bus()?;
|
rescan_pci_bus()?;
|
||||||
get_device_name(sandbox, &sysfs_rel_path).await
|
get_device_name(sandbox, &sysfs_rel_path).await
|
||||||
|
Loading…
Reference in New Issue
Block a user