Qubesadmin...how to determine block device size

Back in version 4.2 I wrote some python code that determines what block storage devices are available through sys-usb, and lets the select one (or it can preselect if there’s just one…or just do it automatically, depending).

One thing this could do was determine the storage size of the block device. It was handy for the user to be able to read; also the logic was set up to ignore anything of zero size (so it wouldn’t offer a USB hub as though it were a storage device). [Also, in some cases the easiest way to distinguish two devices is to read their sizes.]

The massive changes made for version 4.3, mostly very good once you are used to them, have made this difficult–as in difficult enough I can’t figure out how to determine the size of a device.

And I notice sizes are not given in the app (sorry I don’t know its name) that lets you assign devices to running VMs; whereas they used to be. So maybe it’s just not possible any more?

Any ideas on how to do this?

man blockdev

No idea about Python.

Yeah looking at the output of qubesd-query -e dom0 admin.vm.device.block.Available VMNAME the size doesn’t seem to be exposed anymore.

Maybe validate that the device ID (e.g. loop0) doesn’t contain slashes, then get the size with qvm-run --pass-io --user=root -- VMNAME blockdev --getsize64 /dev/"$ID" and validate that it only contains digits.

Backend does know that information, not exposing it via API looks like a bug. Care to open an issue on github?

Thanks qubist for doing that–I don’t have a github account!

I hope the API gets fixed not just qui-devices.

No worries. I am not sure I described it correctly but hopefully it may at least serve as a starting point.