4

So...

There are virtual machines that basically run an operating system in some simulated environment (which might or might not correspond to the real hardware currently present). There are some possibilities to connect real hardware devices (e.g. USB drives) to a virtual machine.

Then there are some so-called "virtual USB devices" (e.g. the Arduino Leonardo) which can be programmed to respond like an actual USB device, but are basically just a micro chip at the other end of the USB cable that runs some program (they might or might not be connected to other components, for this question, let's assume they aren't).

Of course, one can connect a virtual USB device to a VM (as they are a piece of real hardware).

Would it be possible to skip the hardware part and run a custom program on the host operating system that connects to a virtual machine as if it were a real hardware device (say, as a plugin for the virtualization software, or using freestanding program using some API)?

If yes, are there any existing solutions for further reference?

If no, why don't virtual machines provide this capability (e.g. are there some hardware restrictions)?

3
  • QEMU can probably do that. // Your description of a “virtual” device is actually how almost all USB devices work. Creating an ASIC to handle the protocol is too expensive in most cases. A better criterion might be whether or not link-layer hardware is involved.
    – Daniel B
    Commented Apr 18, 2017 at 20:01
  • hoffmale, is my answer satisfactory? Commented Apr 24, 2017 at 16:10
  • Well, it does answer my main question :) Now I just need to find a hypervisor with said functionality (vmware only offers networking sockets and general COM ports afaict)
    – hoffmale
    Commented Apr 24, 2017 at 20:14

1 Answer 1

6
+50

Short answer: Yes.

This is entirely dependent on the Hypervisor, really.

All virtual hardware is provided to the virtual machines by the Hypervisor. If the Hypervisor supports plugins and the adding of virtual hardware via those plugins, then yes, you can add virtual hardware to your environment this way.

VMware's ESXi supports this, in my personal experience. You can download and install virtual networking devices such as switches from Cisco, and I believe I recall seeing other specialized hardware available in that product as well, though it's been a few years since I've managed a VMware virtual stack.

I don't know if any other Hypervisors support this, but I'd guess that Microsoft's HyperV probably does as well, as they try to maintain feature parity with VMware as much as possible.

I suggest looking into VMware's various APIs as a good place to start.

If you are set on using a particular hypervisor, you'll need to peruse the documentation for that system and determine if they have a similar capability. Each hypervisor will be different, and software written for one is unlikely to work in another without extensive modification.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .