You are not logged in.

#1 2016-03-06 19:02:10

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

[SOLVED] Using Webcam in QEMU Guest

Does anyone know how I can pass my laptop's webcam (at /dev/video0) to my Windows 7 QEMU guest?

Last edited by tony5429 (2016-03-11 12:19:07)

Offline

#2 2016-03-09 14:41:00

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

Re: [SOLVED] Using Webcam in QEMU Guest

OK, so I was able to get some info on the webcam by booting into Windows (not via QEMU this time, but just booting into a Windows partition on the hard drive using GRUB). That Windows partition has never had any trouble seeing and using the webcam. I've uploaded screenshots of the webcam info from Windows here: http://imgur.com/a/GESEO

It seems to me that the webcam is a USB device so, back in Linux, I ran lsusb which gave me these results:

[tony@laptop ~]$ lsusb
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 04f2:b336 Chicony Electronics Co., Ltd 
Bus 003 Device 003: ID 0489:e046 Foxconn / Hon Hai 
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I tried passing each of these devices to QEMU by running the following command and substituting the $X and $Y for each associated bus and device number. However, my Windows 7 QEMU guest was never able to see the webcam. Any ideas?

qemu-system-x86_64 -enable-kvm -m 2G -drive file=win7.img,format=raw -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device usb-host,hostbus=$X,hostaddr=$Y

Offline

#3 2016-03-10 11:37:11

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

Re: [SOLVED] Using Webcam in QEMU Guest

No one has any ideas? If it's helpful, here is the path to the associated V4L device in Linux...

[tony@laptop ~]$ ls /dev/v4l/by-id
usb-HD_WebCam_HD_WebCam-video-index0
[tony@laptop ~]$ ls /dev/v4l/by-path
pci-0000:00:1a.0-usb-0:1.3:1.0-video-index0

I'm running out of ideas here...

Offline

#4 2016-03-11 12:18:28

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

Re: [SOLVED] Using Webcam in QEMU Guest

Got it to work! A bit of Googling revealed that "04f2:b336 Chicony Electronics Co., Ltd" was the webcam and dmesg confirmed that it was in fact a USB 2.0 device (as it was using ehci-pci). The error I kept receiving when trying to use this particular device was:

libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/003/004: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.

So I used chmod (as root) to give libusb read/write access to the device and that solved the problem!

Offline

#5 2016-03-11 16:23:41

epatpol
Member
Registered: 2016-03-11
Posts: 4

Re: [SOLVED] Using Webcam in QEMU Guest

Well you solved it by yourself, but thank you for following through! I always imagine myself being the guide that has the same error one day only to find the forum post with the same problem but with no solutions, and that is sad!

Relevant : https://xkcd.com/979/

Offline

#6 2020-04-17 08:06:23

idarlund
Member
Registered: 2020-04-17
Posts: 1

Re: [SOLVED] Using Webcam in QEMU Guest

epatpol wrote:

Well you solved it by yourself, but thank you for following through! I always imagine myself being the guide that has the same error one day only to find the forum post with the same problem but with no solutions, and that is sad!

Relevant : https://xkcd.com/979/

And today is that day!
Working from home in this covid-19 crisis and needed my camera in windows virtual for some video conferencing.

Thanks alot for your solutiuon tony5429 smile

Offline

Board footer

Powered by FluxBB