日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

USB redirection

發(fā)布時(shí)間:2023/12/31 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 USB redirection 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

物理上插在某A機(jī)器上,需要在某B系統(tǒng)中使用,而這個(gè)B系統(tǒng),運(yùn)行在某臺(tái)服務(wù)器C的虛擬化環(huán)境中。

A:192.168.131.102 (USB在此物理機(jī))
B:192.168.131.101上起的虛擬機(jī) centos
C:192.168.131.101

A配置

使用kvm管理工具 virt-manager 的過程中,通過USB passthrough,映射本地usb設(shè)備。意外發(fā)現(xiàn)有usb重定向選項(xiàng)。

usb重定向的類型選擇中,除了Spice通道,還有TCP的方式,可以填寫host和port。

yum install dnfdnf install usbredir-server -yyum install usbutils

查看usb

yum install usbutilsBus 002 Device 006: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick Bus 002 Device 002: ID 8087:8002 Intel Corp. Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 004: ID 046b:ff10 American Megatrends, Inc. Virtual Keyboard and Mouse Bus 001 Device 003: ID 046b:ff01 American Megatrends, Inc. Bus 001 Device 002: ID 8087:800a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub選擇usb的ip號(hào) usbredirserver -p 8686 -v 3 0930:6545 端口可以自定義。verbosity level(-v)級(jí)別從0-5,0:Silent 1:Errors 2:Warnings 3:Info 4:Debug 5:Debug++。

這將把對(duì)應(yīng)的usb設(shè)備映射到網(wǎng)上。可以通過 netstat 命令檢查,新開一個(gè)終端

yum install net-toolsusbredirserver -p 8686 -v 3 0930:6545

通過netstat -altunp檢查

netstat -altunp | grep usbredirserve tcp6 0 0 :::8686 :::* LISTEN 48338/usbredirserve

B配置

先創(chuàng)建虛擬機(jī),編寫xml文件:

<domain type='kvm'><name>centostest</name><uuid>be26b846-42a1-455c-9c96-2ce7ad2a220f</uuid><memory unit='KiB'>208896</memory><currentMemory unit='KiB'>208896</currentMemory><vcpu placement='static'>2</vcpu><os><type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type><boot dev='hd'/><bootmenu enable='yes'/></os><features><acpi/><apic/><pae/></features><clock offset='localtime'/><on_poweroff>destroy</on_poweroff><on_reboot>restart</on_reboot><on_crash>restart</on_crash><devices><emulator>/usr/libexec/qemu-kvm</emulator><disk type='file' device='disk'><driver name='qemu' type='qcow2'/><source file='/centostest.img'/><target dev='vda' bus='virtio'/><address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/></disk><disk type='file' device='cdrom'><driver name='qemu' type='raw'/><source file='/root/CentOS-7.6-x86_64-DVD-1810.iso'/><target dev='hdc' bus='ide'/><readonly/><address type='drive' controller='0' bus='1' target='0' unit='0'/></disk><controller type='usb' index='0' model='piix3-uhci'><address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/></controller><controller type='pci' index='0' model='pci-root'/><controller type='ide' index='0'><address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/></controller><interface type='bridge'><mac address='52:54:00:9d:ca:db'/><source bridge='br0'/><virtualport type='openvswitch'><parameters interfaceid='850c7add-a5b3-4b42-888e-4593569b0690'/></virtualport><target dev='tap0'/><model type='virtio'/><address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/></interface><input type='mouse' bus='ps2'/><input type='keyboard' bus='ps2'/><graphics type='vnc' port='5910' autoport='no' listen='0.0.0.0' keymap='en-us'><listen type='address' address='0.0.0.0'/>

創(chuàng)建

virsh define centostest.xml Domain centostest defined from centostest.xmlvirsh start centOS Domain centOS started

修改xml文件,加入

<redirdev bus='usb' type='tcp'><source mode='connect' host='192.168.131.102' service='8686'/><protocol type='raw'/><address type='usb' bus='0' port='1'/> </redirdev>

重啟動(dòng)虛擬機(jī)即可

總結(jié)

以上是生活随笔為你收集整理的USB redirection的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。