patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [DEMO PATCH linux 0/3] usbip: tools: support USB over vsock(7)
@ 2021-10-13 13:53 Alyssa Ross
  2021-10-13 13:53 ` [DEMO PATCH linux 1/3] usbip: tools: in.usbipd: add Alyssa Ross
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alyssa Ross @ 2021-10-13 13:53 UTC (permalink / raw)
  To: devel

This series implements USB over VSOCK sockets, as an alternative to
USB over IP.  This would allow, for example, a host system to share
its USB controller with a VM over VFIO, and then selectively attach to
certain specific USB devices exported by the VM over a VSOCK
connection.  If inter-guest VSOCK were to be implemented in the
kernel, or using a program like vsock-bridge[1] or socat[2], USB
devices could also be shared between VMs in this way, without having
to have a full-on networking setup between those VMs.

I've taken different approaches to implement the VSOCK support in each
of the usbip client and server.  For the server, I added a new
program, in.usbipd, that implements an inetd-style interface, taking a
socket from its environment.  This way, the socket could be a TCP
socket, a VSOCK socket, or something else entirely, and the program
doesn't have to care.  The usbip client, on the other hand, cares
about what type of socket it's communicating over, because it records
address information for the remote server.  Since this meant I had to
teach it about VSOCK anyway, to tell it how to find that information
for VSOCK sockets, it was easier to just extend the existing program
with an option to choose an alternative protocol family than to have
it take a socket from its environment.

I've tested this series by running in.usbipd in a NixOS VM, and then
attaching a device from it to my host system.  The following NixOS
configuration sets up an in.usbipd service listening on a VSOCK
socket:

  systemd.sockets.usbipd = {
    wantedBy = [ "sockets.target" ];
    listenStreams = [ "vsock::3240" ];
    socketConfig.Accept = "yes";
  };

  systemd.services."usbipd@" = {
    serviceConfig.ExecStart = "${usbip}/bin/in.usbipd";
    serviceConfig.StandardInput = "socket";
    serviceConfig.StandardOutput = "socket";
    serviceConfig.StandardError = "journal";
  };

[1]: https://github.com/stefano-garzarella/vsock-bridge
[2]: http://www.dest-unreach.org/socat/

Alyssa Ross (3):
  usbip: tools: in.usbipd: add
  usbip: tools: usbip: record protocol
  usbip: tools: usbip: support vsock(7) connections

 tools/usb/usbip/libsrc/vhci_driver.c |  26 ++-
 tools/usb/usbip/src/Makefile.am      |   4 +-
 tools/usb/usbip/src/in.usbipd.c      | 326 +++++++++++++++++++++++++++
 tools/usb/usbip/src/usbip_attach.c   |  54 ++++-
 tools/usb/usbip/src/usbip_list.c     |  43 +++-
 tools/usb/usbip/src/usbip_network.c  |  51 ++++-
 tools/usb/usbip/src/usbip_network.h  |   4 +-
 7 files changed, 470 insertions(+), 38 deletions(-)
 create mode 100644 tools/usb/usbip/src/in.usbipd.c


base-commit: 620b74d01b9d4393bef6742bf121908322c2fe0b
-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-13 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 13:53 [DEMO PATCH linux 0/3] usbip: tools: support USB over vsock(7) Alyssa Ross
2021-10-13 13:53 ` [DEMO PATCH linux 1/3] usbip: tools: in.usbipd: add Alyssa Ross
2021-10-13 13:53 ` [DEMO PATCH linux 2/3] usbip: tools: usbip: record protocol Alyssa Ross
2021-10-13 13:53 ` [DEMO PATCH linux 3/3] usbip: tools: usbip: support vsock(7) connections Alyssa Ross

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).