Skip to content

lsblk.py: add devid in output#60

Open
Ythogtha wants to merge 2 commits into
masterfrom
agf-lsblk-devid
Open

lsblk.py: add devid in output#60
Ythogtha wants to merge 2 commits into
masterfrom
agf-lsblk-devid

Conversation

@Ythogtha

@Ythogtha Ythogtha commented Mar 13, 2026

Copy link
Copy Markdown

Add a function to get disk/by-id names from a device name, and add it to the output

Any resemblance with a previous PR is not completely random.

Performance tests are on par with the previous PR, which is : not good enough.
New version will call once the udev database, and get all data readily available, which is way better.

Here is a comparison of the four methods, times are for querying sequentially the three hosts of the pool.
Pool (l1, l2, l3) is the corresponding pool on XOlab.
Pool (yp1, yp2, yp3) is a virtual home pool.
Using command: xe host-call-plugin host-uuid=<uuid> plugin=lsblk.py fn=list_block_devices.

|------+-------+-------+---------+----------|
| host | org   | find  | udevadm | exportdb |
|------+-------+-------+---------+----------|
| l1   | 1,220 | 4,024 | 4,452   | 1,747    |
| l2   | 1,449 | 3,806 | 4,248   | 1,566    |
| l3   | 1,352 | 4,016 | 4,465   | 1,715    |
|------+-------+-------+---------+----------|
| yp1  | 0,198 | 1,140 | 1,108   | 0,274    |
| yp2  | 0,248 | 1,082 | 1,068   | 0,343    |
| yp3  | 0,243 | 1,127 | 1,090   | 0,322    |
|------+-------+-------+---------+----------|

There are other differences between the three methods

  • find returns [""] of no link are found.
  • udevadm (which makes a udevadm call for each device), filter results for /dev/disk/by-id/
  • exportdb (which calls udevadm once at the beginning), returns all links in /dev/disk/by-*/

The scope of the links returned could be tuned to limit to by-id, or not, performances wouldn't be altered.

@Ythogtha Ythogtha requested a review from Nambrok March 13, 2026 15:07
@Ythogtha Ythogtha force-pushed the agf-lsblk-devid branch 17 times, most recently from fe01fbb to e95e45a Compare March 16, 2026 09:59
@stormi stormi requested a review from a team March 16, 2026 14:41
@psafont

psafont commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Hi, I'm looking at the PR. I've refreshed the CI to test the changes on Python 3.6 on master, and so I've rebased your commits on it

@Ythogtha

Copy link
Copy Markdown
Author

Hi, I'm looking at the PR. I've refreshed the CI to test the changes on Python 3.6 on master, and so I've rebased your commits on it

Ok!
And please, do not hesitate to give your insight, if any.

@psafont

psafont commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Looks OK from what I've seen, can you squash the commits?

Add a function to get disk/by-id names from a device name, and add it to the output

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
@Wescoeur

Copy link
Copy Markdown
Member

Ping for review @Nambrok

@Nambrok Nambrok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have not identified problems with the code, by I do think we only want the by-id one to identify disks.
In this configuration, we also have FS and partition path, those could change.

Currently restricting to by-id.

Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
@Ythogtha

Ythogtha commented Jun 1, 2026

Copy link
Copy Markdown
Author

I have not identified problems with the code, by I do think we only want the by-id one to identify disks. In this configuration, we also have FS and partition path, those could change.

Done, with a simple way to change behavior in the future, and include other by-something, like by-label for example.

@Ythogtha Ythogtha requested a review from Nambrok June 1, 2026 13:09
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