Skip to content

Instantly share code, notes, and snippets.

@dscape dscape/out.log Secret
Last active Nov 20, 2018

Embed
What would you like to do?
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Running any VM customizations...
A customization command failed:
["controlvm", "13e6f29d-db68-4639-8a49-d75fafce637b", "usbattach", "p=0x7811;v=0x7392;s=0x000087b375caedec;l=0xfd120000"]
The following error was experienced:
VBoxManage: error: Cannot attach a USB device to the machine which is not running or paused (machine state: PoweredOff)
VBoxManage: error: Details: code VBOX_E_INVALID_VM_STATE (0x80bb0002), component Console, interface IConsole, callee nsISupports
VBoxManage: error: Context: "AttachUSBDevice(usbId.raw())" at line 955 of file VBoxManageControlVM.cpp
Please fix this customization and try again.
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--usb', 'on']
vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'edimax7718un', '--vendorid', '0x7392']
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu10"
config.vm.provider :virtualbox do |vb|
vb.customize ["controlvm", :id, "usbattach", "p=0x7811;v=0x7392;s=0x000087b375caedec;l=0xfd120000"]
end
end
@daraosn

This comment has been minimized.

Copy link

daraosn commented Apr 11, 2014

Thanks for the solution.

@mindriot101

This comment has been minimized.

Copy link

mindriot101 commented May 7, 2014

Thanks for this, it really helped. A note on the solution: the --name parameter passed into the call to usbfilter add is the name of the virtual machine. This can be set in the virtualbox config block as such

  VB_NAME = "virtualbox_name"
  # ...
  config.vm.provider "virtualbox" do |vb|
    vb.name = VB_NAME
    vb.customize ['modifyvm', :id, '--usb', 'on']
    vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', VB_NAME, '--vendorid', '0x7392']
  end
@billmalarky

This comment has been minimized.

Copy link

billmalarky commented Jun 15, 2014

Thanks guys this comment thread really saved my day. I might also add the following info for anyone else who stumbles across it. I ended up passing the USB product ID as well. Here's an example.

vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'your_vm_name', '--vendorid', '0x0C45', '--productid', '0x6483']

You can find the USB device vendor ID and product ID on linux with the command : lsusb
On windows, you can use the microsoft tool usbview.exe
http://msdn.microsoft.com/en-us/library/windows/hardware/ff560019(v=vs.85).aspx

See more info about additional USB virtualbox parameters here (for example search for "usbfilter")
http://www.virtualbox.org/manual/ch08.html#idp59179408

@nhed

This comment has been minimized.

Copy link

nhed commented Jan 7, 2015

@billmalarky you may be better off using the VBoxManage list usbhost as it should work anywhere that VirtualBox is installed and this code is virtualbox specific

@mlt

This comment has been minimized.

Copy link

mlt commented Jan 27, 2015

The check for filter existence is missing. Every time machine is brought up, a new rule is appended. Also name is a filter name and not a VM name.

@AnvilStriker

This comment has been minimized.

Copy link

AnvilStriker commented Jul 3, 2015

Comments above indicate that the name parameter should be the name of the VM, but the VirtualBox User Manual (section 8.28) says "name is a name for the new filter". Have you guys determined that the manual is wrong? If so, how did you determine that?

@dragon788

This comment has been minimized.

Copy link

dragon788 commented Jan 17, 2016

@AnvilStriker Indeed --target requires the VM's name, but in Vagrant speak that is ':id' without the quotes. --name is what you want to pass the USB device as.

From the manual:
The target parameter selects the virtual machine that the filter should be attached to or use "global" to apply it to all virtual machines. name is a name for the new filter and for global filters, action says whether to allow machines access to devices that fit the filter description ("hold") or not to give them access ("ignore").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.