How can I simulate USB storage device connection with qemu?
I'm writing a program for controlling USB storage device connections (this is a classic subject). All it's ok with my program, but now, I want to write some tests. So in order to do that, I realized I'll need some way of simulate USB connections.
And not only the connections, I need to be able to set the device properties: capacity, format, etc...
usb qemu emulation
add a comment |
I'm writing a program for controlling USB storage device connections (this is a classic subject). All it's ok with my program, but now, I want to write some tests. So in order to do that, I realized I'll need some way of simulate USB connections.
And not only the connections, I need to be able to set the device properties: capacity, format, etc...
usb qemu emulation
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
Well... I saw intosystemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests onudev
. I then make the conclusion that they must be usingqemu
to simulate some "hardware thigns."
– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm withusb_add
. I am not up to date with the latest dev, so I can't tell you.
– user55518
Mar 13 '14 at 14:09
add a comment |
I'm writing a program for controlling USB storage device connections (this is a classic subject). All it's ok with my program, but now, I want to write some tests. So in order to do that, I realized I'll need some way of simulate USB connections.
And not only the connections, I need to be able to set the device properties: capacity, format, etc...
usb qemu emulation
I'm writing a program for controlling USB storage device connections (this is a classic subject). All it's ok with my program, but now, I want to write some tests. So in order to do that, I realized I'll need some way of simulate USB connections.
And not only the connections, I need to be able to set the device properties: capacity, format, etc...
usb qemu emulation
usb qemu emulation
edited Sep 22 '16 at 7:59
countermode
5,31842044
5,31842044
asked Mar 12 '14 at 13:58
Raydel MirandaRaydel Miranda
1892313
1892313
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
Well... I saw intosystemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests onudev
. I then make the conclusion that they must be usingqemu
to simulate some "hardware thigns."
– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm withusb_add
. I am not up to date with the latest dev, so I can't tell you.
– user55518
Mar 13 '14 at 14:09
add a comment |
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
Well... I saw intosystemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests onudev
. I then make the conclusion that they must be usingqemu
to simulate some "hardware thigns."
– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm withusb_add
. I am not up to date with the latest dev, so I can't tell you.
– user55518
Mar 13 '14 at 14:09
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
Well... I saw into
systemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests on udev
. I then make the conclusion that they must be using qemu
to simulate some "hardware thigns."– Raydel Miranda
Mar 13 '14 at 12:11
Well... I saw into
systemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests on udev
. I then make the conclusion that they must be using qemu
to simulate some "hardware thigns."– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm with
usb_add
. I am not up to date with the latest dev, so I can't tell you.– user55518
Mar 13 '14 at 14:09
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm with
usb_add
. I am not up to date with the latest dev, so I can't tell you.– user55518
Mar 13 '14 at 14:09
add a comment |
1 Answer
1
active
oldest
votes
I found the solution here: USB emulation
3.11 USB emulation
QEMU emulates a PCI UHCI USB controller. You can virtually plug
virtual USB devices or real host USB devices (experimental, works only
on Linux hosts). QEMU will automatically create and connect virtual
USB hubs as necessary to connect multiple USB devices.
3.11.1 Connecting USB devices
USB devices can be connected with the -usbdevice commandline option or
the usb_add monitor command. Available devices are:
mouse
Virtual Mouse. This will override the PS/2 mouse emulation when
activated.
tablet
Pointer device that uses absolute coordinates (like a
touchscreen). This means QEMU is able to report the mouse position
without having to grab the mouse. Also overrides the PS/2 mouse
emulation when activated.
disk:file
Mass storage device based on file (see disk_images)
host:bus.addr
Pass through the host device identified by bus.addr
(Linux only)
host:vendor_id:product_id
Pass through the host device identified by
vendor_id:product_id (Linux only)
wacom-tablet
Virtual Wacom PenPartner tablet. This device is similar
to the tablet above but it can be used with the tslib library because
in addition to touch coordinates it reports touch pressure.
keyboard
Standard USB keyboard. Will override the PS/2 keyboard (if
present).
serial:[vendorid=vendor_id][,product_id=product_id]:dev
Serial
converter. This emulates an FTDI FT232BM chip connected to host
character device dev. The available character devices are the same as
for the -serial option. The vendorid and productid options can be used
to override the default 0403:6001. For instance,
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
will connect to tcp
port 4444 of ip 192.168.0.2, and plug that to the virtual serial
converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
braille
Braille device. This will use BrlAPI to display the braille
output on a real or fake device.
net:options
Network adapter that supports CDC ethernet and RNDIS
protocols. options specifies NIC options as with -net nic,options (see
description). For instance, user-mode networking can be used with
qemu-system-i386 [...OPTIONS...] -net user,vlan=0 -usbdevice
Currently this cannot be used in machines that support PCI
net:vlan=0
NICs.
bt[:hci-type]
Bluetooth dongle whose type is specified in the same
format as with the -bt hci option, see allowed HCI types. If no type
is given, the HCI logic corresponds to -bt hci,vlan=0. This USB device
implements the USB Transport Layer of HCI. Example usage:
qemu-system-i386
[...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt
device:keyboard,vlan=3
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f119335%2fhow-can-i-simulate-usb-storage-device-connection-with-qemu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found the solution here: USB emulation
3.11 USB emulation
QEMU emulates a PCI UHCI USB controller. You can virtually plug
virtual USB devices or real host USB devices (experimental, works only
on Linux hosts). QEMU will automatically create and connect virtual
USB hubs as necessary to connect multiple USB devices.
3.11.1 Connecting USB devices
USB devices can be connected with the -usbdevice commandline option or
the usb_add monitor command. Available devices are:
mouse
Virtual Mouse. This will override the PS/2 mouse emulation when
activated.
tablet
Pointer device that uses absolute coordinates (like a
touchscreen). This means QEMU is able to report the mouse position
without having to grab the mouse. Also overrides the PS/2 mouse
emulation when activated.
disk:file
Mass storage device based on file (see disk_images)
host:bus.addr
Pass through the host device identified by bus.addr
(Linux only)
host:vendor_id:product_id
Pass through the host device identified by
vendor_id:product_id (Linux only)
wacom-tablet
Virtual Wacom PenPartner tablet. This device is similar
to the tablet above but it can be used with the tslib library because
in addition to touch coordinates it reports touch pressure.
keyboard
Standard USB keyboard. Will override the PS/2 keyboard (if
present).
serial:[vendorid=vendor_id][,product_id=product_id]:dev
Serial
converter. This emulates an FTDI FT232BM chip connected to host
character device dev. The available character devices are the same as
for the -serial option. The vendorid and productid options can be used
to override the default 0403:6001. For instance,
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
will connect to tcp
port 4444 of ip 192.168.0.2, and plug that to the virtual serial
converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
braille
Braille device. This will use BrlAPI to display the braille
output on a real or fake device.
net:options
Network adapter that supports CDC ethernet and RNDIS
protocols. options specifies NIC options as with -net nic,options (see
description). For instance, user-mode networking can be used with
qemu-system-i386 [...OPTIONS...] -net user,vlan=0 -usbdevice
Currently this cannot be used in machines that support PCI
net:vlan=0
NICs.
bt[:hci-type]
Bluetooth dongle whose type is specified in the same
format as with the -bt hci option, see allowed HCI types. If no type
is given, the HCI logic corresponds to -bt hci,vlan=0. This USB device
implements the USB Transport Layer of HCI. Example usage:
qemu-system-i386
[...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt
device:keyboard,vlan=3
add a comment |
I found the solution here: USB emulation
3.11 USB emulation
QEMU emulates a PCI UHCI USB controller. You can virtually plug
virtual USB devices or real host USB devices (experimental, works only
on Linux hosts). QEMU will automatically create and connect virtual
USB hubs as necessary to connect multiple USB devices.
3.11.1 Connecting USB devices
USB devices can be connected with the -usbdevice commandline option or
the usb_add monitor command. Available devices are:
mouse
Virtual Mouse. This will override the PS/2 mouse emulation when
activated.
tablet
Pointer device that uses absolute coordinates (like a
touchscreen). This means QEMU is able to report the mouse position
without having to grab the mouse. Also overrides the PS/2 mouse
emulation when activated.
disk:file
Mass storage device based on file (see disk_images)
host:bus.addr
Pass through the host device identified by bus.addr
(Linux only)
host:vendor_id:product_id
Pass through the host device identified by
vendor_id:product_id (Linux only)
wacom-tablet
Virtual Wacom PenPartner tablet. This device is similar
to the tablet above but it can be used with the tslib library because
in addition to touch coordinates it reports touch pressure.
keyboard
Standard USB keyboard. Will override the PS/2 keyboard (if
present).
serial:[vendorid=vendor_id][,product_id=product_id]:dev
Serial
converter. This emulates an FTDI FT232BM chip connected to host
character device dev. The available character devices are the same as
for the -serial option. The vendorid and productid options can be used
to override the default 0403:6001. For instance,
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
will connect to tcp
port 4444 of ip 192.168.0.2, and plug that to the virtual serial
converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
braille
Braille device. This will use BrlAPI to display the braille
output on a real or fake device.
net:options
Network adapter that supports CDC ethernet and RNDIS
protocols. options specifies NIC options as with -net nic,options (see
description). For instance, user-mode networking can be used with
qemu-system-i386 [...OPTIONS...] -net user,vlan=0 -usbdevice
Currently this cannot be used in machines that support PCI
net:vlan=0
NICs.
bt[:hci-type]
Bluetooth dongle whose type is specified in the same
format as with the -bt hci option, see allowed HCI types. If no type
is given, the HCI logic corresponds to -bt hci,vlan=0. This USB device
implements the USB Transport Layer of HCI. Example usage:
qemu-system-i386
[...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt
device:keyboard,vlan=3
add a comment |
I found the solution here: USB emulation
3.11 USB emulation
QEMU emulates a PCI UHCI USB controller. You can virtually plug
virtual USB devices or real host USB devices (experimental, works only
on Linux hosts). QEMU will automatically create and connect virtual
USB hubs as necessary to connect multiple USB devices.
3.11.1 Connecting USB devices
USB devices can be connected with the -usbdevice commandline option or
the usb_add monitor command. Available devices are:
mouse
Virtual Mouse. This will override the PS/2 mouse emulation when
activated.
tablet
Pointer device that uses absolute coordinates (like a
touchscreen). This means QEMU is able to report the mouse position
without having to grab the mouse. Also overrides the PS/2 mouse
emulation when activated.
disk:file
Mass storage device based on file (see disk_images)
host:bus.addr
Pass through the host device identified by bus.addr
(Linux only)
host:vendor_id:product_id
Pass through the host device identified by
vendor_id:product_id (Linux only)
wacom-tablet
Virtual Wacom PenPartner tablet. This device is similar
to the tablet above but it can be used with the tslib library because
in addition to touch coordinates it reports touch pressure.
keyboard
Standard USB keyboard. Will override the PS/2 keyboard (if
present).
serial:[vendorid=vendor_id][,product_id=product_id]:dev
Serial
converter. This emulates an FTDI FT232BM chip connected to host
character device dev. The available character devices are the same as
for the -serial option. The vendorid and productid options can be used
to override the default 0403:6001. For instance,
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
will connect to tcp
port 4444 of ip 192.168.0.2, and plug that to the virtual serial
converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
braille
Braille device. This will use BrlAPI to display the braille
output on a real or fake device.
net:options
Network adapter that supports CDC ethernet and RNDIS
protocols. options specifies NIC options as with -net nic,options (see
description). For instance, user-mode networking can be used with
qemu-system-i386 [...OPTIONS...] -net user,vlan=0 -usbdevice
Currently this cannot be used in machines that support PCI
net:vlan=0
NICs.
bt[:hci-type]
Bluetooth dongle whose type is specified in the same
format as with the -bt hci option, see allowed HCI types. If no type
is given, the HCI logic corresponds to -bt hci,vlan=0. This USB device
implements the USB Transport Layer of HCI. Example usage:
qemu-system-i386
[...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt
device:keyboard,vlan=3
I found the solution here: USB emulation
3.11 USB emulation
QEMU emulates a PCI UHCI USB controller. You can virtually plug
virtual USB devices or real host USB devices (experimental, works only
on Linux hosts). QEMU will automatically create and connect virtual
USB hubs as necessary to connect multiple USB devices.
3.11.1 Connecting USB devices
USB devices can be connected with the -usbdevice commandline option or
the usb_add monitor command. Available devices are:
mouse
Virtual Mouse. This will override the PS/2 mouse emulation when
activated.
tablet
Pointer device that uses absolute coordinates (like a
touchscreen). This means QEMU is able to report the mouse position
without having to grab the mouse. Also overrides the PS/2 mouse
emulation when activated.
disk:file
Mass storage device based on file (see disk_images)
host:bus.addr
Pass through the host device identified by bus.addr
(Linux only)
host:vendor_id:product_id
Pass through the host device identified by
vendor_id:product_id (Linux only)
wacom-tablet
Virtual Wacom PenPartner tablet. This device is similar
to the tablet above but it can be used with the tslib library because
in addition to touch coordinates it reports touch pressure.
keyboard
Standard USB keyboard. Will override the PS/2 keyboard (if
present).
serial:[vendorid=vendor_id][,product_id=product_id]:dev
Serial
converter. This emulates an FTDI FT232BM chip connected to host
character device dev. The available character devices are the same as
for the -serial option. The vendorid and productid options can be used
to override the default 0403:6001. For instance,
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
will connect to tcp
port 4444 of ip 192.168.0.2, and plug that to the virtual serial
converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
braille
Braille device. This will use BrlAPI to display the braille
output on a real or fake device.
net:options
Network adapter that supports CDC ethernet and RNDIS
protocols. options specifies NIC options as with -net nic,options (see
description). For instance, user-mode networking can be used with
qemu-system-i386 [...OPTIONS...] -net user,vlan=0 -usbdevice
Currently this cannot be used in machines that support PCI
net:vlan=0
NICs.
bt[:hci-type]
Bluetooth dongle whose type is specified in the same
format as with the -bt hci option, see allowed HCI types. If no type
is given, the HCI logic corresponds to -bt hci,vlan=0. This USB device
implements the USB Transport Layer of HCI. Example usage:
qemu-system-i386
[...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt
device:keyboard,vlan=3
edited Sep 22 '16 at 8:58
terdon♦
132k32260441
132k32260441
answered Mar 13 '14 at 14:25
Raydel MirandaRaydel Miranda
1892313
1892313
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f119335%2fhow-can-i-simulate-usb-storage-device-connection-with-qemu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what has the USB simulation to do with qemu?
– user55518
Mar 12 '14 at 22:04
Well... I saw into
systemd
code (freedesktop.org/wiki/Software/systemd) that they usit for tests onudev
. I then make the conclusion that they must be usingqemu
to simulate some "hardware thigns."– Raydel Miranda
Mar 13 '14 at 12:11
How ever if you know other way for doing that, I'll thank you point me the right direction.
– Raydel Miranda
Mar 13 '14 at 12:11
well, qemu/kvm is good for testing. in case of a failure you don't need to reboot. Special usb hardware needs to be forwarded to qemu/kvm with
usb_add
. I am not up to date with the latest dev, so I can't tell you.– user55518
Mar 13 '14 at 14:09