• From: "Daniel P. Berrange" <berrange redhat com>
  • To: Guido Günther <agx sigxcpu org>
  • Cc: libvir-list redhat com
  • Subject: Re: [libvirt] [PATCH/RFC]: hostdev passthrough support
  • Date: Tue, 29 Jul 2008 11:53:46 +0100

On Fri, Jul 25, 2008 at 04:17:30PM -0400, Guido G?nther wrote:
> Hi,
> attached is some basic support for host device passthrough. It enables
> you to passthrough usb devices in qemu/kvm via:
>
> <devices>
> <hostdev type='usb' vendor='0204' product='6025'/>
> <hostdev type='usb' bus='001' device='007'/>
> </devices> This stuff is obviously going to have a correlation with the host
device enumeration support I'd offered a design for a few months
back. As such I'd like to try and keep a consistent XML format
between the two. For reference the original mesage was here: http://www.redhat.com/archives/libvir-list/2008-April/msg00005.html There were basically two ways to identify a device. Some devices
are 'physical' mapped straight to a piece of hardware (USB device,
or PCI card) and would have '<bus>' element with hardware details. eg a USB finger print reader appears as: <device>
<name>usb_device_483_2016_noserial</name>
<key>/org/freedesktop/Hal/devices/usb_device_483_2016_noserial</key>
<parent>/org/freedesktop/Hal/devices/usb_device_0_0_0000_00_1d_3</parent> <bus type="usb">
<vendor id="1155">SGS Thomson Microelectronics</vendor>
<product id="8214">Fingerprint Reader</product> <address bus="003" dev="005"/>
</bus>
</device> Other devices are 'logical' devices, which don't have hardware info
directly associated with them. The reason for this is that one piece
of hardware may present many logical devices each with varying
capabilities. As an example, a wifi card typically exports at least
2 network device - one control interface, and one for traffic. eg a wireless network interface for data traffic <device>
<name>net_00_13_02_b9_f9_d3_0</name>
<key>/org/freedesktop/Hal/devices/net_00_13_02_b9_f9_d3_0</key>
<parent>/org/freedesktop/Hal/devices/pci_8086_4227</parent> <capability type="net">
<hwaddr>00:13:02:b9:f9:d3</hwaddr>
<name>eth0</name> <capability type="80211"/>
</capability>
</device> In this case the unique device identifier is the '<name>' field
but this case varying depending on the capability type. Different virt solutions have different capabilties for device
passthrough. KVM and Xen both support passthrough of physical
devices, either USB or PCI cards. OpenVZ supports passthrough
of logical devices - in particular network interfaces. We need to allow for both possibilities in the domain XML for
this type of device. So, to expand on your proposal, I'd like to see the XML format
have a top level attribute indicating whether we're passing a
logical or physical device, and then the capability name or
bus name respectively. The child elements then need to provide
the appropriate naming. USB has the further annoyance you identified that one could
conceivably do attachment based on USB bus address, or the
vendor+product pair. The downside of former is that a bus
address changes every time you plug a device in. The downside
of the latter is that it is not neccessarily unique. We have
no choice but to allow both I'm afraid :-( Finally, with some systems we may have the option of specifying
a target address - eg PCI device ID seen in guest. So, some examples.... A USB device by vendor+product <hostdev mode='bus' bus='usb'>
<source>
<product id='1155'/>
<vendor id='8214'/>
</source>
</hostdev> A USB device by address <hostdev mode='bus' bus='usb'>
<source>
<address bus='003' dev='005'/>
</source>
</hostdev> A PCI device by address <hostdev mode='bus' bus='pci'>
<source>
<address domain="0000" bus="00" slot="16" function="3"/>
</source>
</hostdev> A network card by name (ie for OpenVZ) <hostdev mode='capability'>
<source name='eth0'/>
</hostdev> A SCSI device by name (eg, SCSI PV passthrough), also specifying
the target adress <hostdev mode='capability' type='scsi'>
<source name='sg3'/>
<target address='0:0:0:0'/>
</hostdev> Conceivably we could allow PCI devices by vendor+product, but
I don't see much call for that since PCI device's don't (yet)
appear/disappear on the fly & have a consistent address. More
to the point none of our underlying hypervisors use anything
other than the PCI address for PCI device passthrough. For USB, if we're doing attachment based on vendor+product,
then libvirt needs to query QEMU to find out the actual
device it chose, so we can fill in the <address> tag. NB I
know QEMU doesn't allow this, but we need it in order todo
unplug reliably, so we'll likely need to do it anyway. > diff --git a/src/domain_conf.h b/src/domain_conf.h
> index b438bc8..1aa5c39 100644
> --- a/src/domain_conf.h
> +++ b/src/domain_conf.h
> @@ -257,7 +257,35 @@ struct _virDomainGraphicsDef {
> } data;
> };
>
> +enum virDomainHostdevType {
> + VIR_DOMAIN_HOSTDEV_TYPE_USB,
> + VIR_DOMAIN_HOSTDEV_TYPE_PCI,
>
> + VIR_DOMAIN_HOSTDEV_TYPE_LAST
> +};
> +
> +typedef struct _virDomainHostdevDef virDomainHostdevDef;
> +typedef virDomainHostdevDef *virDomainHostdevDefPtr;
> +struct _virDomainHostdevDef {
> + int type;
> + union {
> + struct {
> + int byModel;
> + union {
> + unsigned vendor;
> + unsigned bus;
> + };
> + union {
> + unsigned product;
> + unsigned device;
> + };
> + } usb;
> + struct {
> + /* TBD */
> + } pci;
> + };
> + virDomainHostdevDefPtr next;
> +}; Taking into account the various options we need to cope with
I think we'll need something a little larger, along the lines
of enum virDomainHostdevMode {
VIR_DOMAIN_HSOTDEV_MODE_BUS,
VIR_DOMAIN_HSOTDEV_MODE_CAPABILITY,
}; enum virDomainHostdevBusType
VIR_DOMAIN_HSOTDEV_BUS_TYPE_PCI,
VIR_DOMAIN_HSOTDEV_BUS_TYPE_USB,
}; enum virDomainHostdevCapabilityType {
VIR_DOMAIN_HSOTDEV_CAP_TYPE_NET,
VIR_DOMAIN_HSOTDEV_CAP_TYPE_SCSI,
}; struct _virDomainHostdevDef {
int mode; /* enum virDomainHostdevMode */
union {
struct {
int type; /* enum virDomainHostdevBusType */
union {
struct {
unsigned bus;
unsigned device; unsigned vendor;
unsigned product;
} usb;
struct {
unsigned domain;
unsigned bus;
unsigned slot;
unsigned function;
} pci;
} data;
} bus;
struct {
int type; /* enum virDomainHostdevCapabilityType */
union {
struct {
char *name;
} net;
struct {
char *name;
} scsi;
};
} cap;
} source;
char *target;
}; >
> /* Flags for the 'type' field in next struct */
> enum virDomainDeviceType {
> @@ -265,6 +293,7 @@ enum virDomainDeviceType {
> VIR_DOMAIN_DEVICE_NET,
> VIR_DOMAIN_DEVICE_INPUT,
> VIR_DOMAIN_DEVICE_SOUND,
> + VIR_DOMAIN_DEVICE_HOST,
> };
>
> typedef struct _virDomainDeviceDef virDomainDeviceDef;
> @@ -276,6 +305,7 @@ struct _virDomainDeviceDef {
> virDomainNetDefPtr net;
> virDomainInputDefPtr input;
> virDomainSoundDefPtr sound;
> + virDomainHostdevDefPtr hostdev; Careful with indentation - check the HACKING file for an
emacs whitespace rule setting. Modulo, the comments about the XML format, I think your patch is basically
sound & following all our guidelines which is great :-) Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

kvm libvirt: hostdev passthrough support 解决加密狗冲突问题的更多相关文章

  1. Eplan P8 2.7 加密狗 感叹号 解决方法

    Eplan安装完加密狗后一直感叹号异常,最近也是查了很多办法,最后发现是少了个驱动的原因. 就是上面这个驱动,这里放上驱动链接:https://lanzous.com/id5gi8f ,或者随便找一个 ...

  2. [转] XEN, KVM, Libvirt and IPTables

    http://cooker.techsnail.com/index.php/XEN,_KVM,_Libvirt_and_IPTables XEN, KVM, Libvirt and IPTables ...

  3. 编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法]【转】

    转自:http://blog.chinaunix.net/uid-26847859-id-3297170.html 原文地址:编译驱动模块时,出现“stack protector enabled bu ...

  4. Rockey 4加密狗介绍

    Rockey 4加密狗介绍 特点:该加密狗是单片机加密狗时代飞天公司的主力产品,R4一样继承了R2的硬件特征,具有全球唯一性硬件ID.R4内置了硬件随机数生成器,可以进行一些抗跟踪,或在硬件算法中参与 ...

  5. 老王教您怎么做cass7.1 8.0 9.1所有系列的复制狗 加密狗 破解狗

    cass7.1 8.0 9.1所有系列的复制狗 加密狗 破解狗本来是出于好奇看到网上有这样的东西,学了下感觉挺简单的,如果你是cass的初学者想仅仅是想学习这个软件,不想花大价格购买正版的,这个是可以 ...

  6. 磐石加密狗NT88管理层API

    磐石加密狗NT88管理层API   直接贴代码了 1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 ...

  7. 模拟美萍加密狗--Rockey2虚拟狗(五)

    虚拟狗开源后很多网友询问有关使用方法的问题,其实看我前四篇文章就应该了解怎样使用了,但还是写篇教程吧 [一].安装DSF (驱动模拟环境): 运行DSFx86Runtime.msi 如需改变安装目录请 ...

  8. 模拟美萍加密狗--Rockey2虚拟狗(二)

    按好了WDK,看了一天的DSF例子GenericHID,直接头大了,就能改个VID,PID让美萍识别成R2的狗.其他的什么各种描述符,根本无从下手,怪不得网上没有驱动模拟的加密狗,确实太复杂了,特别像 ...

  9. 模拟美萍加密狗--Rockey2虚拟狗(三)

    几经挣扎,我最终还是选择了虚拟设备的方法来模拟Rockey2加密狗.HID.DLL劫持+API劫持的办法技术上虽然简单些,但太繁琐了,不仅要转发大量的函数,还要Hook好几个API,向我这么懒的人可干 ...

随机推荐

  1. BZOJ 1874 取石子游戏 (NIM游戏)

    题解:简单的NIM游戏,直接计算SG函数,至于找先手策略则按字典序异或掉,去除石子后再异或判断,若可行则直接输出. #include <cstdio> const int N=1005; ...

  2. Uber 叫车时,弹出以下代码导致无法打车(An email confirmation has been sent to...),解决办法

    ”鄙人用了虚拟信用卡+广西的手机号码+163邮箱申请了Uber的新帐号...然后输入mastercn优惠码,上网查询只有这个优惠码,应该就能免费的使用一次用车,限额200元.但在点用车时  弹出窗口提 ...

  3. Failed to upgrade Oracle Cluster Registry configuration(root.sh)

        近期在给客户基于Suse 11 sp3安装Oracle 10g RAC,在安装完clusterware运行/u01/app/crs/root.sh时收到错误提示.Failed to upgra ...

  4. windows下使用python googleprotobuf

    首先下载:protobuf-2.5.0.tar.gz 和protoc-2.5.0-win32.zip.两者的版本要对应: 将下载的google protobuf解压,会看到一个python目录,Win ...

  5. SharePoint2013切换账户身份登录设置

    1. 打开Welcome.ascx文件:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE ...

  6. mfc主窗口添加背景图片后,如何实现在背景图片上输出文字

    1.若是文档视图程序的话,在视图类的OnDraw(CDC* pDC)函数中调用pDC->TextOut()函数,就像平常输出文字一样.若是嫌文字的背景颜色破坏了图像,可以在输出文字之前调用pDC ...

  7. MyEclipse下JDBC-MySQL配置总结

    原创文章,转载请注明:MyEclipse下JDBC-MySQL配置总结  By Lucio.Yang 新手,初期配置未成功,后将网上的方法几乎全部尝试才弄好,下面的方法全而不简练,希望高手指正. 1. ...

  8. django中间件templates写法

    def templates_context_process(request): from django.contrib.sites.models import Site from accounts.m ...

  9. 条码知识之十:EAN-128条码(下)

    国际物品编码协会(EAN)和美国统一代码委员会(UCC)将CODE-128码引入EAN/UCC系统,并作如下规定:起始符由一个START A/B/C 加一个辅助字符FNC1构成,以区别普通的CODE- ...

  10. [WPF疑难]如何禁用窗口上的关闭按钮

    原文 [WPF疑难]如何禁用窗口上的关闭按钮 [WPF疑难]如何禁用窗口上的关闭按钮                                           周银辉 哈哈,主要是调用Rem ...