[vbox-dev] 答复: How add device or driver (PDM) to VirtualBox

Huihong Luo huisinro at yahoo.com
Mon Jun 29 18:59:29 GMT 2015


The code belongs to our company, and it's quite complicated, so I can't share the code here. I can answer questions.
This is roughly the components you will need:
(1) linux user mode: test.c   --- (open and read/write /dev/vbox_pipe)
(2) linux kernel driver: vbox_pipe.ko
Windows host plugins for the virtual PCI device:
(3)vbox_pipe_pci.dll(4) vbox_pipe_driver.dll
You need two additions, one is the virtual PCI device itself, and the other is the driver to handle the i/o of the virtual device, to pipe in/out to other processes, for example.
Inside vbox_pipe_pci.dll, you  create a PCI device, register some register and map some memory I/O spaces.
Good lucks,
- Huihong
      From: 星策DRACULAX <DRACULAX at vszone.cn>
 To: 'Huihong Luo' <huisinro at yahoo.com>; vbox-dev at virtualbox.org 
 Sent: Monday, June 29, 2015 3:01 AM
 Subject: 答复: [vbox-dev] How add device or driver (PDM) to VirtualBox
   
#yiv9128755192 #yiv9128755192 -- _filtered #yiv9128755192 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv9128755192 {font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;} _filtered #yiv9128755192 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv9128755192 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv9128755192 {panose-1:2 1 6 0 3 1 1 1 1 1;}#yiv9128755192 #yiv9128755192 p.yiv9128755192MsoNormal, #yiv9128755192 li.yiv9128755192MsoNormal, #yiv9128755192 div.yiv9128755192MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:宋体;}#yiv9128755192 a:link, #yiv9128755192 span.yiv9128755192MsoHyperlink {color:blue;text-decoration:underline;}#yiv9128755192 a:visited, #yiv9128755192 span.yiv9128755192MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv9128755192 p.yiv9128755192MsoAcetate, #yiv9128755192 li.yiv9128755192MsoAcetate, #yiv9128755192 div.yiv9128755192MsoAcetate {margin:0cm;margin-bottom:.0001pt;font-size:9.0pt;font-family:宋体;}#yiv9128755192 span.yiv9128755192EmailStyle17 {color:#1F497D;}#yiv9128755192 span.yiv9128755192Char {font-family:宋体;}#yiv9128755192 .yiv9128755192MsoChpDefault {font-size:10.0pt;} _filtered #yiv9128755192 {margin:72.0pt 90.0pt 72.0pt 90.0pt;}#yiv9128755192 div.yiv9128755192WordSection1 {}#yiv9128755192 I am doing the same work now.I try to buile my own virtual pci device and as Luo said, I must read all the vmmdev related code.Could you send me some document or demo on virtual pci device?  

发件人: Huihong Luo [mailto:huisinro at yahoo.com] 
发送时间: 2015年6月27日 14:25
收件人: Klaus Espenlaub; vbox-dev at virtualbox.org
主题: Re: [vbox-dev] How add device or driver (PDM) to VirtualBox  I think that most likely the OP wants to develop a virtual PCI device, so the guest and the host can communicate with each other, like some kind of pipe system. The guest and the host can read/write to each other through shared memory.  If this is indeed the case, one can study vbox's builtin guest/host implementation, basically vbox itself uses a virtual PCI device (Devices/VMMDev/VMMDev.cpp), and then inside Linux guest, there is corresponding VBoxGuest.ko kernel module, which is a PCI driver to interact with the virtual device emulated by vbox. This is how vbox's guest additions work.  I have implemented a simple virtual PCI device, like QEMU's pipe. What I can tell you, this is not an easy job, and you have to understand all the concepts, plus a detailed study of vbox source code.   From: Klaus Espenlaub <klaus.espenlaub at oracle.com>
To: vbox-dev at virtualbox.org 
Sent: Friday, June 26, 2015 6:22 AM
Subject: Re: [vbox-dev] How add device or driver (PDM) to VirtualBox
Marcin,

On 25.06.2015 10:57, Marcin K wrote:
> Hi,
>
> I ask about this before but don't get any answer...

yes, sorry about that, but right now everyone in the dev team is booked 
out with super urgent things which have to be finished before 5.0 is 
released. There's simply not enough time right now for bigger explanations.

>
> How add new device/driver to Virtualbox?
> Is there a someone who understand how PDM works?
>
> I compile VBoxSampleDevice.cpp and add it to VirtualBox but
> system(ubunutu 14) don't show any new device.
> To add dll to Virtualbox I use:
> VBoxManage setextradata global VBoxInternal/PDM/Devices/[[1]]/Path
> g:\VirtualBox\out\win.amd64\release\obj\testingDevice\VBoxSampleDevice.dll

VBoxSampleDevice.cpp is a totally empty piece of code. It compiles, it 
loads, but doesn't expose ANY functionality to the VM.

> Also I try to add device using copy of Virtio device. I copy code
> of DevVirtioNet.cpp modify it (change some names), build dll and add to
> VirtualBox:
> VBoxManage setextradata global VBoxInternal/PDM/Devices/[[3]]/Path
> g:\VirtualBox\out\win.amd64\release\obj\testingDevice\testingDevice.dll
>
> But still nothing change in guest system.
>
> In DevVirtioNet.cpp I found a lot of code which set a lot of parameters
> connected with PCI. I try understand this code but this take, a lot of time.
>
> I also found that I have to set which driver will be use in system also
> in configuration of virtual machine.
> I try to set net ethernet cart type but in VBoxManage I found code which
> allow using only build in drivers so I can't set "My" modified Virtio
> driver.
>
> There is really no instruction or documentation how it's works?

There are lots of examples, in the form of the various device 
implementations :)

Klaus  

> I will be really gratefull for any help or instruction how add new
> device to VirtualBox.
>
>
> Best regards,
> Marcin

_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev  

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20150629/5b9d97b7/attachment.html>


More information about the vbox-dev mailing list