Skip to contentSkip to conversation

USB Scanner

DISCUSSION Matthias Henze (L) 3 participants 6 messages Jan 3, 2011 – Jan 4, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

finally I've tried to connect a USB scanner to a KVM VM. I've done so by adding

hostusb: 04a9:1606

to the VMs conf. The scanner is detected by Windows XP and at first it seemed to work. It scanns but then "CapturePerfect" hangs for ever.

lsusb reports:

Bus 002 Device 005: ID 04a9:1606 Canon, Inc.

and "info usb":

Device 0.1, Speed 12 Mb/s, Product QEMU USB Tablet Device 0.3, Speed 12 Mb/s, Product QEMU USB Hub
Device 0.2, Speed 480 Mb/s, Product CANON DR-5010C

and "info usbhost":

Device 1.1, speed 480 Mb/s
Hub: USB device 1d6b:0002, EHCI Host Controller
Device 2.1, speed 480 Mb/s
Hub: USB device 1d6b:0002, EHCI Host Controller
Device 3.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 4.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 5.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 6.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 7.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 8.1, speed 12 Mb/s
Hub: USB device 1d6b:0001, UHCI Host Controller
Device 1.2, speed 480 Mb/s

    Hub: USB device 04b4:6560
  Device 6.2, speed 12 Mb/s
    Class 00: USB device 0000:0000, SE USB Device
  Device 8.2, speed 1.5 Mb/s
    Class 00: USB device 046a:0101, Wireless Desktop
  Device 1.3, speed 480 Mb/s
    Class 00: USB device 0bc2:2101, FreeAgent Go
  Device 1.4, speed 480 Mb/s
    Class 00: USB device 0bc2:2101, FreeAgent Go
  Device 2.5, speed 480 Mb/s
    Class 00: USB device 04a9:1606, CANON   DR-5010C
  Auto filters:
    Device *.* ID 04a9:1606

Can some one pelase help ? This ist a show stopper for this project ...

TIA
Matthias

#1 lore raw
Quoted 53 lines · Matthias Henze (L)

Hi,

finally I've tried to connect a USB scanner to a KVM VM. I've done so by adding

hostusb: 04a9:1606

to the VMs conf. The scanner is detected by Windows XP and at first it seemed to work. It scanns but then "CapturePerfect" hangs for ever.

lsusb reports:

Bus 002 Device 005: ID 04a9:1606 Canon, Inc.

and "info usb":

Device 0.1, Speed 12 Mb/s, Product QEMU USB Tablet Device 0.3, Speed 12 Mb/s, Product QEMU USB Hub
Device 0.2, Speed 480 Mb/s, Product CANON DR-5010C

and "info usbhost":

   Device 1.1, speed 480 Mb/s
     Hub: USB device 1d6b:0002, EHCI Host Controller
   Device 2.1, speed 480 Mb/s
     Hub: USB device 1d6b:0002, EHCI Host Controller
   Device 3.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 4.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 5.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 6.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 7.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 8.1, speed 12 Mb/s
     Hub: USB device 1d6b:0001, UHCI Host Controller
   Device 1.2, speed 480 Mb/s
     Hub: USB device 04b4:6560
   Device 6.2, speed 12 Mb/s
     Class 00: USB device 0000:0000, SE USB Device
   Device 8.2, speed 1.5 Mb/s
     Class 00: USB device 046a:0101, Wireless Desktop
   Device 1.3, speed 480 Mb/s
     Class 00: USB device 0bc2:2101, FreeAgent Go
   Device 1.4, speed 480 Mb/s
     Class 00: USB device 0bc2:2101, FreeAgent Go
   Device 2.5, speed 480 Mb/s
     Class 00: USB device 04a9:1606, CANON   DR-5010C
   Auto filters:
     Device *.* ID 04a9:1606
Quoted 5 lines

Can some one pelase help ? This ist a show stopper for this project ...

TIA
Matthias

Hi Matthias,

I experienced a similar behaviour with Epson and Canon USB Printers. there the ink fill status readout causes a complete hang of the software (Windows still operational). It seems to be related with USB 2.0 devices. An older USB 1.1 HP Printer works slow but fine.

Please check dmesg of the host system, there you should see a lot of USB info messages after plugging in the device.

If you get a BSOD in XP when shutting down Windows or when removing the USB Scanner then it is exactly the same issue that I have. It seems (from my point of view) to be related with the KVM-USB virtualization. I could reduce some of the BSOD's by forcing the host USB system to fall back to USB 1.x (switch in BIOS), but printing with the 2.0 devices was still not possible!

I have currently no real idea how to solve the issue - additionally the transfer rates of USB are horribly - I do not get more than ~ 64K/sec.

If there are improvements on that somewhere "uncomitted" I would like to try them out.

Best regards,

Erik

#2 lore raw
Quoted 6 lines · Erik Rull
Quoted 5 lines · Matthias Henze (L)

Hi,

finally I've tried to connect a USB scanner to a KVM VM. I've done so by adding

<snip>

Quoted 23 lines
Quoted 5 lines

Can some one pelase help ? This ist a show stopper for this project ...

TIA
Matthias

Hi Matthias,

I experienced a similar behaviour with Epson and Canon USB Printers. there the ink fill status readout causes a complete hang of the software (Windows still operational). It seems to be related with USB 2.0 devices. An older USB 1.1 HP Printer works slow but fine.

Please check dmesg of the host system, there you should see a lot of USB info messages after plugging in the device.

If you get a BSOD in XP when shutting down Windows or when removing the USB Scanner then it is exactly the same issue that I have. It seems (from my point of view) to be related with the KVM-USB virtualization. I could reduce some of the BSOD's by forcing the host USB system to fall back to USB 1.x (switch in BIOS), but printing with the 2.0 devices was still not possible!

Quoted 5 lines

I have currently no real idea how to solve the issue - additionally the transfer rates of USB are horribly - I do not get more than ~ 64K/sec.

If there are improvements on that somewhere "uncomitted" I would like to try them out.

The attached work for me with an Epson CX7800. I was able to print and scan with Vista; driver setup for XP was more of a pain - I only got the printer setup working.

It's the EHCI code from

git://git.kiszka.org/qemu.git ehci

with http://www.mail-archive.com/[email protected]/msg38795.html and a couple of local additions. Applies cleanly to qemu-kvm.git as of today (b724fa4bb46b82c54b5f0a2cf9177194020433efO).

EHCI is not ready for prime time, but works for use cases like this one.

David

Quoted 9 lines

Best regards,

Erik

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Makefile.objs +1 -0
index 5170cc2..92bee46 100644
@@ -181,6 +181,7 @@ hw-obj-$(CONFIG_PARALLEL) += parallel.o
 #hw-obj-$(CONFIG_PCSPK) += pcspk.o
 hw-obj-$(CONFIG_PCKBD) += pckbd.o
 hw-obj-$(CONFIG_USB_UHCI) += usb-uhci.o
+hw-obj-$(CONFIG_USB_EHCI) += usb-ehci.o
 hw-obj-$(CONFIG_FDC) += fdc.o
 # needs fixes for cpu hotplug, so moved to Makefile.target:
 # hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o
Makefile.target +1 -1
index 6a4d1ac..762620c 100644
@@ -246,7 +246,7 @@ obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 obj-ia64-y += ide.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
 obj-ia64-y += fdc.o mc146818rtc.o serial.o i8259.o ipf.o
 obj-ia64-y += cirrus_vga.o parallel.o acpi.o piix_pci.o
-obj-ia64-y += usb-uhci.o
+obj-ia64-y += usb-uhci.o usb-ehci.o
 obj-ia64-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 
 # shared objects
default-configs/i386-softmmu.mak +1 -0
index ed00471..fdb7dc1 100644
@@ -10,6 +10,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_USB_UHCI=y
+CONFIG_USB_EHCI=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
 CONFIG_APM=y
default-configs/x86_64-softmmu.mak +1 -0
index 5183203..cf88d9e 100644
@@ -10,6 +10,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_USB_UHCI=y
+CONFIG_USB_EHCI=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
 CONFIG_APM=y
hw/pc_piix.c +5 -1
index fbe2766..7464528 100644
@@ -28,6 +28,7 @@
 #include "pci.h"
 #include "usb-uhci.h"
 #include "usb-ohci.h"
+#include "usb-ehci.h"
 #include "net.h"
 #include "boards.h"
 #include "ide.h"
@@ -171,8 +172,11 @@ static void pc_init1(ram_addr_t ram_size,
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
                  idebus[0], idebus[1], floppy_controller, rtc_state);
 
+    //  TODO the piix3 does not have EHCI - looks like ICH4
+    //  was first southbridge to support it.
     if (pci_enabled && usb_enabled) {
         usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
+        usb_ehci_init(pci_bus, piix3_devfn + 3);
     }
 
     if (pci_enabled && acpi_enabled) {
@@ -182,7 +186,7 @@ static void pc_init1(ram_addr_t ram_size,
         cmos_s3 = qemu_allocate_irqs(pc_cmos_set_s3_resume, rtc_state, 1);
         smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
         /* TODO: Populate SPD eeprom data.  */
-        smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
+        smbus = piix4_pm_init(pci_bus, piix3_devfn + 4, 0xb100,
                               isa_reserve_irq(9), *cmos_s3, *smi_irq,
                               kvm_enabled());
         for (i = 0; i < 8; i++) {
hw/pci_ids.h +1 -0
index 82cba7e..0bb4a1a 100644
@@ -99,6 +99,7 @@
 #define PCI_VENDOR_ID_INTEL              0x8086
 #define PCI_DEVICE_ID_INTEL_82441        0x1237
 #define PCI_DEVICE_ID_INTEL_82801AA_5    0x2415
+#define PCI_DEVICE_ID_INTEL_82801D       0x24CD
 #define PCI_DEVICE_ID_INTEL_ESB_9        0x25ab
 #define PCI_DEVICE_ID_INTEL_82371SB_0    0x7000
 #define PCI_DEVICE_ID_INTEL_82371SB_1    0x7010
hw/usb-bus.c +94 -19

174 lines not on this page · raw message

hw/usb-ehci.c new file +2088 -0

2,088 lines not on this page · raw message

hw/usb-ehci.h new file +8 -0
new file mode 100644
index 0000000..ba087a0
@@ -0,0 +1,8 @@
+#ifndef QEMU_USB_EHCI_H
+#define QEMU_USB_EHCI_H
+
+#include "qemu-common.h"
+
+void usb_ehci_init(PCIBus *bus, int devfn);
+
+#endif
hw/usb-msd.c +1 -1
index 0a95d8d..5ef9836 100644
@@ -607,7 +607,7 @@ static USBDevice *usb_msd_init(const char *filename)
     }
 
     /* create guest device */
-    dev = usb_create(NULL /* FIXME */, "usb-storage");
+    dev = usb_create_v2("usb-storage");
     if (!dev) {
         return NULL;
     }
hw/usb-net.c +1 -1
index 58c672f..9d95379 100644
@@ -1484,7 +1484,7 @@ static USBDevice *usb_net_init(const char *cmdline)
         return NULL;
     }
 
-    dev = usb_create(NULL /* FIXME */, "usb-net");
+    dev = usb_create_v1("usb-net");
     if (!dev) {
         return NULL;
     }
hw/usb-ohci.c +1 -1
index c60fd8d..d38befc 100644
@@ -1702,7 +1702,7 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
 
     ohci->name = dev->info->name;
 
-    usb_bus_new(&ohci->bus, dev);
+    usb_bus_new_v1(&ohci->bus, dev);
     ohci->num_ports = num_ports;
     for (i = 0; i < num_ports; i++) {
         usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
hw/usb-serial.c +2 -2
index c19580f..f1c47b9 100644
@@ -599,7 +599,7 @@ static USBDevice *usb_serial_init(const char *filename)
     if (!cdrv)
         return NULL;
 
-    dev = usb_create(NULL /* FIXME */, "usb-serial");
+    dev = usb_create_v1("usb-serial");
     if (!dev) {
         return NULL;
     }
@@ -622,7 +622,7 @@ static USBDevice *usb_braille_init(const char *unused)
     if (!cdrv)
         return NULL;
 
-    dev = usb_create(NULL /* FIXME */, "usb-braille");
+    dev = usb_create_v1("usb-braille");
     qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
     qdev_init_nofail(&dev->qdev);
 
hw/usb-uhci.c +1 -1
index 1d83400..0528757 100644
@@ -1113,7 +1113,7 @@ static int usb_uhci_common_initfn(UHCIState *s)
     pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
     pci_conf[0x60] = 0x10; // release number
 
-    usb_bus_new(&s->bus, &s->dev.qdev);
+    usb_bus_new_v1(&s->bus, &s->dev.qdev);
     for(i = 0; i < NB_PORTS; i++) {
         usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
     }
hw/usb.h +7 -3
index 00d2802..5040682 100644
@@ -299,18 +299,22 @@ struct USBBus {
     int busnr;
     int nfree;
     int nused;
+    int version;
     QTAILQ_HEAD(, USBPort) free;
     QTAILQ_HEAD(, USBPort) used;
     QTAILQ_ENTRY(USBBus) next;
 };
 
-void usb_bus_new(USBBus *bus, DeviceState *host);
-USBBus *usb_bus_find(int busnr);
+void usb_bus_new_v1(USBBus *bus, DeviceState *host);
+void usb_bus_new_v2(USBBus *bus, DeviceState *host);
+USBBus *usb_bus_find_version(int version);
 void usb_qdev_register(USBDeviceInfo *info);
 void usb_qdev_register_many(USBDeviceInfo *info);
-USBDevice *usb_create(USBBus *bus, const char *name);
+USBDevice *usb_create_v1(const char *name);
+USBDevice *usb_create_v2(const char *name);
 USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
+int usb_bus_migrate_v1(USBDevice *dev);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
                        usb_attachfn attach);
 void usb_unregister_port(USBBus *bus, USBPort *port);
monitor.c +1 -0
index ba45fb5..1050ca7 100644
@@ -25,6 +25,7 @@
 #include "hw/hw.h"
 #include "hw/qdev.h"
 #include "hw/usb.h"
+#include "hw/usb-ehci.h"
 #include "hw/pcmcia.h"
 #include "hw/pc.h"
 #include "hw/pci.h"
usb-bsd.c +1 -1
index 48567a3..b2c3777 100644
@@ -361,7 +361,7 @@ USBDevice *usb_host_device_open(const char *devname)
             goto fail;
         }
 
-        d = usb_create(NULL /* FIXME */, "usb-host");
+        d = usb_create_v1("usb-host");
         dev = DO_UPCAST(USBHostDevice, dev, d);
 
         if (dev_info.udi_speed == 1)
usb-linux.c +81 -54

208 lines not on this page · raw message

#3 lore raw
Quoted 10 lines · David Ahern

The attached work for me with an Epson CX7800. I was able to print and scan with Vista; driver setup for XP was more of a pain - I only got the printer setup working.

It's the EHCI code from

git://git.kiszka.org/qemu.git ehci

Quoted 8 lines

with http://www.mail-archive.com/[email protected]/msg38795.html and a couple of local additions. Applies cleanly to qemu-kvm.git as of today (b724fa4bb46b82c54b5f0a2cf9177194020433efO).

EHCI is not ready for prime time, but works for use cases like this one.

David

Hi David,

thanks for the patch.
Have you tested USB transfer rates using a USB Memory Stick or something similar? If yes, which transfer rates have you reached?

Best regards,

Erik

#4 lore raw
Quoted 17 lines · Erik Rull
Quoted 16 lines · David Ahern

The attached work for me with an Epson CX7800. I was able to print and scan with Vista; driver setup for XP was more of a pain - I only got the printer setup working.

It's the EHCI code from

git://git.kiszka.org/qemu.git ehci

with http://www.mail-archive.com/[email protected]/msg38795.html and a couple of local additions. Applies cleanly to qemu-kvm.git as of today (b724fa4bb46b82c54b5f0a2cf9177194020433efO).

EHCI is not ready for prime time, but works for use cases like this one.

Quoted 8 lines
Quoted 2 lines

David

Hi David,

thanks for the patch.
Have you tested USB transfer rates using a USB Memory Stick or something similar? If yes, which transfer rates have you reached?

USB keys (storage devices) were the primary target I used for testing. In fact, with EHCI I can run a linux guest from a USB key just fine - something I just verified again:

   qemu-kvm -usbdevice host:${USBDEV}

where USBDEV is the vendor:product id from lsusb. Add other args to install from a CD/DVD to the USB key. If your mileage varies first and foremost make sure the VM is using kvm -- speed is horrible with qemu/tcg.

David

Quoted 9 lines

Best regards,

Erik

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 3 lines · David Ahern
Quoted 3 lines

thanks for the patch.
Have you tested USB transfer rates using a USB Memory Stick or something similar? If yes, which transfer rates have you reached?

hmm.... more specifically, 8-11 Mbps depending on type of USB storage device. Harddrives work better than flash.

As an example, on my Dell laptop with a [email protected] the command:

time dd if=/dev/zero of=/tmp/junk oflag=dsync bs=1M count=256

shows the following rates:

Kingston, 8GB stick (enterprise quality versus consumer grade): 9.7 MB/sec

Seagate external drive (older, low end consumer model): 11.6 MB/sec

David