LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 09-01-2015, 02:10 AM   #1
binary_code
LQ Newbie
 
Registered: Sep 2015
Posts: 5

Rep: Reputation: Disabled
how to create virtual usb


Hello all

I would like to ask how to create virtual usb device - for the user program the device shall seem to be real but i want to tap all read, writes, ioctrl and events and to handle them in my custom handlers.

Any ideas? Shall i patch the usb dirver ?

10x all
 
Old 09-01-2015, 02:35 AM   #2
ericson007
Member
 
Registered: Sep 2004
Location: Japan
Distribution: CentOS 7.1
Posts: 735

Rep: Reputation: 154Reputation: 154
Seeing it is virtualizion in terms of kvm etc in this section, why don't you just create another virtual hard disk which everyone can access and allow it to be shared rather than trying to mount a fake usb drive?
 
Old 09-01-2015, 11:32 AM   #3
binary_code
LQ Newbie
 
Registered: Sep 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
I want to intercept all driver requests - maybe there is some concept of drive stub and driver backend ?
maybe some technique witch parallelization employees to tap the I/O calls ...

some ideas?
 
Old 09-01-2015, 01:27 PM   #4
Quinn L
LQ Newbie
 
Registered: Aug 2015
Posts: 3

Rep: Reputation: Disabled
Maybe you figured it out by now, but maybe it could help to hear the problem you are trying to solve?

In any event I found this https://www.osronline.com/showthread.cfm?link=266881. I don't know if it will help but again if you post a bit more about the problem then there may be another way to solve.
 
Old 09-01-2015, 05:43 PM   #5
binary_code
LQ Newbie
 
Registered: Sep 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
I want to simulate a virtual usb and to intercept all interaction with that device and to simulate real device (if possible)

any ideas?
 
Old 09-01-2015, 06:12 PM   #6
ericson007
Member
 
Registered: Sep 2004
Location: Japan
Distribution: CentOS 7.1
Posts: 735

Rep: Reputation: 154Reputation: 154
http://www.delorie.com/djgpp/doc/ug/...ts/hwirqs.html

Is about intercepting hardware interrupts. I would imagine what you want to do is closely related to something like this, but it could be a disk of any kind. Hope it puts you on the right track but in all honesty I do not know much about that sort of thing since it has never really interested me much on trying to access raw system calls and intercepting data on the storage stack. Never found a need for it. It eludes me as somewhat of an obscure requirement to have this sort of control over a hard disk.

It does however sound like an interesting project you have at hand but a little steep learning curve which I think I will pass.

Enjoy the tinkering.

Last edited by ericson007; 09-01-2015 at 06:14 PM.
 
Old 09-02-2015, 05:19 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
What usb device are you trying to simulate? A hard drive? A printer? A keyboard? If it's a simulated device, why does it have to be usb? Why not sata or rs232?

You need to provide a lot more information than "I want to simulate a usb device" if you want anybody to provide any useful advice. Namely WHAT usb device and WHY.

Last edited by suicidaleggroll; 09-02-2015 at 05:21 PM.
 
Old 09-03-2015, 06:15 PM   #8
binary_code
LQ Newbie
 
Registered: Sep 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
hi all

I just want to simulate the basic USB operations - read, write and interrupts - no complex protocol logic.


if there is driver stub and to tap on that interface ?
some kind of virtual driver?
 
Old 09-03-2015, 07:09 PM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
That's the exact same thing you keep saying, it doesn't help. Maybe try another way of getting your point across, maybe an example?

Let's try this:
Simulators simulate things, they simulate things so that other things THINK that they're talking to the real thing, when they're actually talking to the simulator. Flight simulators pretend to be airplanes, they're used by pilots to pretend they're controlling a real plane, to gain practice. GPS simulators are used to test GPS receivers, they pretend to be a real satellite constellation and the GPS receiver thinks it's listening to broadcasts from real satellites and reacts accordingly. With that in mind, what, specifically, will your simulator be talking to, and what does that person/application/driver THINK it's talking to instead of your simulator?

Or perhaps this:
Applications do not speak USB. They do not talk to USB devices, they don't know how. Applications talk to drivers, drivers talk to USB devices. Do you want to simulate a USB device, so that a driver will talk to you and think it's talking to the real thing? In that case, you need to get MUCH more specific, because every USB device talks differently. If the driver thinks it's talking to a USB keyboard and your simulator doesn't respond like a USB keyboard, the driver will reject you. Every USB device has its own driver that talks to it and only it, and the interaction between that USB device and its driver is completely different than the interaction between any other USB device and its driver. USB devices and drivers come in pairs, you need to pick a driver you want to talk to, and then pretend to be the device that driver expects. USB is NOT a simple or universal interface. It's very complicated, and the packetizing that each device uses is completely different. If you don't pick a SPECIFIC device to simulate, you will never be enumerated and the OS will just ignore you.

Or do you want to simulate a driver that applications will talk to? In that case, sure you can create a kernel module that creates a character device in /dev/. Applications can open that device, they can read from it and write to it, and all of those reads and writes will be handled by your kernel module, but what makes this USB? USB is a physical interface, the point of drivers is to abstract away the physical interface so that the applications don't need to know the details. The application has no idea it's talking to a USB device, it doesn't care, it might as well be a firewire device or a PCI device or a PS/2 device or a SATA device...the physical interface is abstracted away, that's the point of drivers.

Last edited by suicidaleggroll; 09-03-2015 at 07:24 PM.
 
Old 09-08-2015, 06:18 PM   #10
binary_code
LQ Newbie
 
Registered: Sep 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
10x very much

how can I make the os to think that the char device is an usb device?
 
Old 09-08-2015, 07:38 PM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You can't, it doesn't work that way.

As I said before:
Quote:
Or do you want to simulate a driver that applications will talk to? In that case, sure you can create a kernel module that creates a character device in /dev/. Applications can open that device, they can read from it and write to it, and all of those reads and writes will be handled by your kernel module, but what makes this USB? USB is a physical interface, the point of drivers is to abstract away the physical interface so that the applications don't need to know the details. The application has no idea it's talking to a USB device, it doesn't care, it might as well be a firewire device or a PCI device or a PS/2 device or a SATA device...the physical interface is abstracted away, that's the point of drivers.
If it's a character device, then it's NOT USB. There is a reason I said OR in my two examples. You cannot have both. Either your simulator speaks USB, emulates a specific device, and talks to a driver that then translates that data for applications, OR your simulator speaks directly to applications and is NOT USB.

This discussion is just going in circles. I won't be responding to this thread anymore until you start actually answering some of the MYRIAD of questions that have been asked of you. NOBODY can provide the information you need until you tell us what it IS that you need, in actual words and examples.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a live usb CentOS from a virtual CentOS hiva Linux - Newbie 1 07-09-2014 09:25 PM
Create a virtual harddisk using dd ? Xeratul Linux - General 5 12-05-2013 07:30 AM
[SOLVED] how to create second virtual IP? sam_nyc Linux - Newbie 3 04-20-2012 12:24 PM
Is it possible to create a virtual LAN on my machine using virtual box or MS virtula nhammoud Linux - Networking 1 01-27-2011 03:49 PM
Connect two virtual linux machines via virtual USB or serial WebBeing Linux - General 4 07-22-2008 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 10:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration