From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [DEMO PATCH linux 0/3] usbip: tools: support USB over vsock(7)
Date: Wed, 13 Oct 2021 13:53:10 +0000 [thread overview]
Message-ID: <20211013135313.2494599-1-hi@alyssa.is> (raw)
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
next reply other threads:[~2021-10-13 13:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 13:53 Alyssa Ross [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211013135313.2494599-1-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).