amluto / virtme

An easy way to virtualize the running system
GNU General Public License v2.0
330 stars 66 forks source link

run.py: Add --usb argument #30

Closed marcosps closed 5 years ago

marcosps commented 5 years ago

This new argument is responsible to construct the options in QEMU to use USB devices from the host to the guest.

Signed-off-by: Marcos Paulo de Souza marcos.souza.org@gmail.com

marcosps commented 5 years ago

I haven`t found a more clever way to associate a the product/vendor from /sys/block -> /dev/bus/usb bus/address pair. Let me know if you have a better solution than parsing lsusb by hand :)

marcosps commented 5 years ago

Also a -usb argument is added for each new usb product:vendor pair, but this is easy to fix. Let me know what you think about my comment above and then I can fix the "muliplication of -usb" easily.

amluto commented 5 years ago

Could you add some code to validate the format of the --usb argument?

marcosps commented 5 years ago

@amluto Done. I fixed another issue two, before this patch, I was checking for prod:vendor as being integers, now I search for both integers and chars.

One question: I found that if I plug two USB devices from the same prod:vendor, they appear twice in the lsusb output, this making this code to just pick the first one.

What I suggest: --usb 0781:5567,1 / I prefer this one / or --usb 0781:5567[1]

To puck the first one in this case. If the ",X" is not used, virtme would take the first prod:vendor pair listed by lsusb. What do you think? Or should wee proceed with a different approach?

amluto commented 5 years ago

There's an argument that one should be able to pass a bus/device number (read from lsusb). Can QEMU pass through an entire USB port along with everything that gets plugged in? That would be useful, too.

If you really want to be fancy, you could make virtme-lsusb or virtme-run --lsusb show all the things you could pass in.

marcosps commented 5 years ago

@amluto sure, the fancy option seems even nicer. I will send a new version soon.

marcosps commented 5 years ago

I don't plan to work in this support anymore, so far now I'm closing this PR.