Commit 21d58b575e79c5d0739b695b272ea89bb052a7bf

Authored by Mark McLoughlin
Committed by Anthony Liguori
1 parent 5c634ef3

Change default PCI class of virtio-console to PCI_CLASS_SERIAL_OTHER

We're using PCI_CLASS_DISPLAY_OTHER now, but qemu-kvm.git is using
PCI_CLASS_OTHERS because:

  "As a PCI_CLASS_DISPLAY_OTHER, it reduces primary display somehow on
   Windows XP (possibly Windows disables acceleration since it fails
   to find a driver)."

While this is valid, many versions of X will get confused by it.
Class major number of 0 gets treated as a possibly prehistoric VGA
device, and then the autoconfig logic gets confused trying to figure
out whether the virtio console or the pv vga device are the real VGA.

We should really set a proper class ID. 0x0780 (serial / other) seems
most appropriate. This shouldn't require any kernel changes, the
modalias for virtio looks like:

  alias:          pci:v00001AF4d*sv*sd*bc*sc*i*

so won't care what the base class or subclass are.

It shows up in the guest as:

  00:05.0 Communication controller: Qumranet, Inc. Virtio console

A new qdev type is introduced to allow devices using the old class
to be created for compatibility with qemu-0.10.x.

Reported-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pci_ids.h
... ... @@ -35,6 +35,9 @@
35 35 #define PCI_CLASS_BRIDGE_PCI 0x0604
36 36 #define PCI_CLASS_BRIDGE_OTHER 0x0680
37 37  
  38 +#define PCI_CLASS_SERIAL_OTHER 0x0780
  39 +
  40 +#define PCI_CLASS_PROCESSOR_CO 0x0b40
38 41 #define PCI_CLASS_COMMUNICATION_OTHER 0x0780
39 42  
40 43 #define PCI_CLASS_PROCESSOR_CO 0x0b40
... ...
hw/virtio-pci.c
... ... @@ -449,7 +449,8 @@ static void virtio_blk_init_pci_0_10(PCIDevice *pci_dev)
449 449 virtio_blk_init_pci_with_class(pci_dev, PCI_CLASS_STORAGE_OTHER);
450 450 }
451 451  
452   -static void virtio_console_init_pci(PCIDevice *pci_dev)
  452 +static void virtio_console_init_pci_with_class(PCIDevice *pci_dev,
  453 + uint16_t class_code)
453 454 {
454 455 VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
455 456 VirtIODevice *vdev;
... ... @@ -458,8 +459,17 @@ static void virtio_console_init_pci(PCIDevice *pci_dev)
458 459 virtio_init_pci(proxy, vdev,
459 460 PCI_VENDOR_ID_REDHAT_QUMRANET,
460 461 PCI_DEVICE_ID_VIRTIO_CONSOLE,
461   - PCI_CLASS_DISPLAY_OTHER,
462   - 0x00);
  462 + class_code, 0x00);
  463 +}
  464 +
  465 +static void virtio_console_init_pci(PCIDevice *pci_dev)
  466 +{
  467 + virtio_console_init_pci_with_class(pci_dev, PCI_CLASS_SERIAL_OTHER);
  468 +}
  469 +
  470 +static void virtio_console_init_pci_0_10(PCIDevice *pci_dev)
  471 +{
  472 + virtio_console_init_pci_with_class(pci_dev, PCI_CLASS_DISPLAY_OTHER);
463 473 }
464 474  
465 475 static void virtio_net_init_pci(PCIDevice *pci_dev)
... ... @@ -511,6 +521,10 @@ static PCIDeviceInfo virtio_info[] = {
511 521 .qdev.size = sizeof(VirtIOPCIProxy),
512 522 .init = virtio_blk_init_pci_0_10,
513 523 },{
  524 + .qdev.name = "virtio-console-pci-0-10",
  525 + .qdev.size = sizeof(VirtIOPCIProxy),
  526 + .init = virtio_console_init_pci_0_10,
  527 + },{
514 528 /* end of list */
515 529 }
516 530 };
... ...