multipass icon indicating copy to clipboard operation
multipass copied to clipboard

Support adding host devices to instances

Open herryliq opened this issue 3 years ago • 16 comments

I want to capture the video from the web usb camera of multipass instance, but I can not find how to add the video device to multipass instance.

Before use multipass, I had use docker container. Under the docker container, I can add video device just like: docker run -d /dev/video0:/dev/video0 ........

herryliq avatar Dec 22 '20 05:12 herryliq

Hi @herryliq, it's unlikely Multipass will have such functionality in the near term. We're trying to constrain the feature set to avoid "feature creep". We also need to ensure all the features are available across all the platforms (operating systems, hypervisors), which would be difficult for this use case.

That said, using the LXD backend (sudo multipass set local.driver=lxd) you can launch an instance as usual, and then modify it with lxc config edit <instance> --project multipass. You'll be able to add the device there, and it will persist for the instance lifetime. See LXD's documentation on the topic of devices:

https://linuxcontainers.org/lxd/docs/master/instances#devices-configuration

Saviq avatar Dec 22 '20 16:12 Saviq

Thanks for your reply. I will try with LXD.

herryliq avatar Jan 14 '21 04:01 herryliq

@herryliq Did you make it? @Saviq Can I use USB or built-in webcam through multipass mount ... ...?

JinraeKim avatar Jul 03 '22 06:07 JinraeKim

@JinraeKim no, mount only handles file transfers.

Saviq avatar Jul 18 '22 10:07 Saviq

this is really bad luck... I was hoping to recover/repair a SD card I have inserted over USB on my Mac :( whyyyy are the good things never possible. At least I now know. Thanks for your work - it was a nice 5 min with Multipass!

microfx avatar Dec 23 '22 14:12 microfx

I was hoping to recover/repair a SD card I have inserted over USB on my Mac

That sounds like a one-time operation, which I don't think multipass is appropriate for. Fire up a VM and get a full GUI environment just in case.

huyz avatar Dec 24 '22 06:12 huyz

Lol yeah ... I ran into a lot of trouble. Seems like I'm getting old. M1 Arm chip is not the easiest to use a VM with obviously. I bailed. Used my raspberry pi to recover the data ;) Thx for answering tho and merry xmas! Am 24.12.2022 um 07:20 schrieb Huy Z @.***>:

I was hoping to recover/repair a SD card I have inserted over USB on my Mac

That sounds like a one-time operation, which I don't think multipass is appropriate for. Fire up a VM and get a full GUI environment just in case.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

microfx avatar Dec 24 '22 12:12 microfx

Thanks for your reply. I will try with LXD.

if with lxd driver, it is not able to run vpp/dpdk. once the vpp start the vm will stop sudully.

BurlyLuo avatar Aug 03 '23 09:08 BurlyLuo

We're trying to constrain the feature set to avoid "feature creep"

How is USB passthrough considered "feature creep"... ? That's a basic part of virtualization.

Is adding find & replace to a text editor considered "feature creep" too?

raleighlittles avatar Aug 10 '23 20:08 raleighlittles

Hi, I'm using multipass to run a ROS noetic environment as advertised here: https://ubuntu.com//blog/ros-development-on-linux-windows-and-macos My goal was to run the Examples on the library ORB_SLAM3 (computer vision library), which needed noetic to be compiled. The host machine is Ubuntu 23.10 and i can see the laptop camera feed on cheese app. Running the example on Noetic VM I cannot see the camera feed. Is it possible to access laptop camera on the Noetic VM? If one major use case is ROS, I think this is a indispensable feature for multipass.

AndrewBloom avatar Oct 13 '23 00:10 AndrewBloom

Hi @AndrewBloom, I am afraid Multipass cannot forward your cameras to the VM today. Thank you for the suggestion and use case, something to consider for sure in the context of this feature request.

ricab avatar Oct 13 '23 09:10 ricab

Hi @AndrewBloom, I am afraid Multipass cannot forward your cameras to the VM today. Thank you for the suggestion and use case, something to consider for sure in the context of this feature request.

Hi @ricab , As I understand, although it's not a native feature of multipass, multipass itself works based on drivers like qemu, lxd, etc. that could allow usb access. Unfortunately I didn't find a guide online that really shows step by step how to configure the drivers and then be able to use your image for noetic with the configured driver.

From my research I found that qemu supports usb passthrough, but seems not supporting usb cameras that have a live stream. (USB devices requiring real time streaming (i.e. USB Video Cameras) are not supported yet. from https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices)

Maybe LXD would be able to support that as per @Saviq hint?

would be good to understand, first of all, if I change the driver, do I have to recreate the vm? like if I did multipass launch ros2-humble --name humble-vm while the driver was qemu, and then i did some work on it, if I change the driver to lxd, can I reuse that vm or should I start again from scratch?

Once I set the driver with multipass set local.driver=lxd, what other steps are necessary to use noetic and have a non empty result for lsusb on the client?

this guide https://qiita.com/nindanaoto/items/20858eca08aad90b5bab seems to do something quite similar, but I wanted to use the already made image for ROS on multipass, I think the point of this article was to showcase this user case https://ubuntu.com//blog/ros-development-on-linux-windows-and-macos.

I also posted questions here: https://askubuntu.com/questions/1489519/multipass-with-qemu-driver-how-to-access-usb-camera https://unix.stackexchange.com/questions/759303/multipass-with-qemu-driver-how-to-access-usb-camera

AndrewBloom avatar Oct 19 '23 00:10 AndrewBloom

Hi @AndrewBloom, yes, this should be possible to implement with most, if not all, our drivers. It just wasn't selected for development so far. You are free to try directly with LXD following the advise above (or any other driver), but Multipass itself has no support for that right now.

As for the driver switch, have a look at this documentation, section "Instance Scopes" in particular. In short, instances you create with QEMU are not available in LXD, or vice-versa. They are available in QEMU again if you switch back to it.

ricab avatar Oct 19 '23 10:10 ricab

In case someone wants to try out usbip (USB/IP), which bypasses the whole ”driver” layer by using TCP:

https://github.com/lure23/ESP32-WSL https://github.com/lure23/ESP32-Mac

I was able to use a USB dev-board connected to a PC, from Multipass running within Mac. Likely not good enough for webcams. My interest in Multipass is to use it WSL-like for a sandboxed Linux prompt, under Mac.

  • Will check the suggested LXD driver solution, as well.

akauppi avatar Jan 02 '24 05:01 akauppi

  • Will check the suggested LXD driver solution, as well.

LXD only works on Linux.

lure23 avatar Jan 04 '24 10:01 lure23