Skip to contentSkip to conversation

all vga: refuse hotplugging.

PATCH In review Gerd Hoffmann 3 participants 9 messages May 26, 2010 – May 31, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 all vga: refuse hotplugging.

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

---
 hw/cirrus_vga.c |    4 ++++
 hw/vga-pci.c    |    4 ++++
 hw/vmware_vga.c |    4 ++++
 3 files changed, 12 insertions(+), 0 deletions(-)
hw/cirrus_vga.c +4 -0
index ba48289..5175725 100644
@@ -3188,6 +3188,10 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
      uint8_t *pci_conf = d->dev.config;
      int device_id = CIRRUS_ID_CLGD5446;
 
+     if (dev->qdev.hotplugged) {
+         return -1;
+     }
+
      /* setup VGA */
      vga_common_init(&s->vga, VGA_RAM_SIZE);
      cirrus_init_common(s, device_id, 1);
hw/vga-pci.c +4 -0
index c8d260c..a2de201 100644
@@ -79,6 +79,10 @@ static int pci_vga_initfn(PCIDevice *dev)
      VGACommonState *s = &d->vga;
      uint8_t *pci_conf = d->dev.config;
 
+     if (dev->qdev.hotplugged) {
+         return -1;
+     }
+
      // vga + console init
      vga_common_init(s, VGA_RAM_SIZE);
      vga_init(s);
hw/vmware_vga.c +4 -0
index 4e7a75d..d12d86f 100644
@@ -1232,6 +1232,10 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
     struct pci_vmsvga_state_s *s =
         DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
 
+    if (dev->qdev.hotplugged) {
+        return -1;
+    }
+
     pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
     pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
     s->card.config[PCI_COMMAND]	= PCI_COMMAND_IO |
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 3 lines · Gerd Hoffmann

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

Do you know the reason why we get hw_error()? Theoretically vga hotplug should be possible at least for secondary graphic cards (even though I suspect most operating systems wouldn't cope).

#2 lore raw
Quoted 6 lines · Stefano Stabellini
Quoted 3 lines · Gerd Hoffmann

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

Do you know the reason why we get hw_error()?

Because the card tries to register the legacy vga ports which are already taken by the primary card. I also don't know whenever you can pci hot-plug hardware which uses non-pci ressources at all.

Quoted 3 lines

Theoretically vga hotplug should be possible at least for secondary graphic cards (even though I suspect most operating systems wouldn't cope).

Yes. Assuming the virtual hardware in question can actually act as secondary, i.e. is fully programmable without the legacy vga ports. The standard vga can't. The cirrus looks doable, at least you can access the vga ports using the mmio bar.

cheers,
Gerd

#3 lore raw
Quoted 12 lines · Gerd Hoffmann
Quoted 6 lines · Stefano Stabellini
Quoted 3 lines · Gerd Hoffmann

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

Do you know the reason why we get hw_error()?

Because the card tries to register the legacy vga ports which are already taken by the primary card. I also don't know whenever you can pci hot-plug hardware which uses non-pci ressources at all.

Quoted 8 lines
Quoted 3 lines

Theoretically vga hotplug should be possible at least for secondary graphic cards (even though I suspect most operating systems wouldn't cope).

Yes. Assuming the virtual hardware in question can actually act as secondary, i.e. is fully programmable without the legacy vga ports. The standard vga can't. The cirrus looks doable, at least you can access the vga ports using the mmio bar.

I see, good point.

I guess the right fix here would be to return -1 in the stdvga case but continue in the cirrus case and avoid registering the vga ioports when used as secondary adapter.

#4 lore raw

Hi,

Quoted 10 lines
Quoted 4 lines

Yes. Assuming the virtual hardware in question can actually act as secondary, i.e. is fully programmable without the legacy vga ports. The standard vga can't. The cirrus looks doable, at least you can access the vga ports using the mmio bar.

I see, good point.

I guess the right fix here would be to return -1 in the stdvga case but continue in the cirrus case and avoid registering the vga ioports when used as secondary adapter.

Except that this most likely is a non-trivial effort as we have to find and test sane ways to handle multiple guest displays.

I think having two gfx screens mapped to two qemu consoles, then be able to switch between them via Ctrl-Alt-<nr> (like you switch today to text consoles) could be doable without too much effort. Question is how useful this would be as you can't see your two screens at the same time.

With qxl+spice the spice client will open a new window for the secondary display. With vnc+sdl you'll see the primary display only.

cheers,
Gerd

#5 lore raw
Quoted 13 lines · Gerd Hoffmann
   Hi,
Quoted 10 lines
Quoted 4 lines

Yes. Assuming the virtual hardware in question can actually act as secondary, i.e. is fully programmable without the legacy vga ports. The standard vga can't. The cirrus looks doable, at least you can access the vga ports using the mmio bar.

I see, good point.

I guess the right fix here would be to return -1 in the stdvga case but continue in the cirrus case and avoid registering the vga ioports when used as secondary adapter.

Quoted 8 lines

Except that this most likely is a non-trivial effort as we have to find and test sane ways to handle multiple guest displays.

I think having two gfx screens mapped to two qemu consoles, then be able to switch between them via Ctrl-Alt-<nr> (like you switch today to text consoles) could be doable without too much effort. Question is how useful this would be as you can't see your two screens at the same time.

Actually I was thinking of registering multiple graphic consoles, each of them could be rendered by a different frontend (sdl/vnc) independently. We would have multiple DisplayStates for that.

Quoted 2 lines

With qxl+spice the spice client will open a new window for the secondary display. With vnc+sdl you'll see the primary display only.

So you are doing exactly what I wrote above, right?

#6 lore raw

Hi,

Quoted 8 lines
Quoted 4 lines

I think having two gfx screens mapped to two qemu consoles, then be able to switch between them via Ctrl-Alt-<nr> (like you switch today to text consoles) could be doable without too much effort. Question is how useful this would be as you can't see your two screens at the same time.

Actually I was thinking of registering multiple graphic consoles, each of them could be rendered by a different frontend (sdl/vnc) independently. We would have multiple DisplayStates for that.

Possible, but certainly alot of work. Tons of code in qemu can't handle multiple DisplayStates. Try it and you'll see.

Quoted 4 lines
Quoted 2 lines

With qxl+spice the spice client will open a new window for the secondary display. With vnc+sdl you'll see the primary display only.

So you are doing exactly what I wrote above, right?

No. The secondary display has no DisplayState. That is the reason why only the spice client will see it.

cheers,
Gerd

#7 lore raw
In reply to Gerd Hoffmann
Quoted 2 lines

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

I think this is wrong. There's no reason why VGA adapters shouldn't be hotplugged. You should fix the underlying problems that prevent hotplugging (or make them fail gracefully).

Paul

#8 lore raw
Quoted 5 lines · Paul Brook
Quoted 2 lines

Try to pci hotplug a vga card, watch qemu die with hw_error(). This patch fixes it.

I think this is wrong. There's no reason why VGA adapters shouldn't be hotplugged. You should fix the underlying problems that prevent hotplugging

The qemu code base simply isn't prepared for that. Making vga hotplug requires alot of infrastructure work within qemu, see discussion with Stefano in this thread. I'm also not fully sure it is possible to hotplug the primary vga due to the legacy vga i/o ports.

Quoted 1 line

(or make them fail gracefully).

Make hotplug fail gracefully is exactly what the patch does because making hotplug work is impossible short-term IMHO.

cheers,
Gerd