qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/pci: fixed crash when using rombar=0 for hotplugged devices
@ 2014-10-21 12:37 Marcel Apfelbaum
  2014-10-21 22:06 ` Paolo Bonzini
  2014-10-22  6:18 ` Michael S. Tsirkin
  0 siblings, 2 replies; 14+ messages in thread
From: Marcel Apfelbaum @ 2014-10-21 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst

ROM images must be loaded at startup. Usage of rombar=0 after that
is not allowed, but should not crash QEMU.

Check that the device is not hotplugged before trying to
insert the rom file.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/pci/pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6ce75aa..3907c90 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1776,7 +1776,12 @@ static int pci_qdev_init(DeviceState *qdev)
         pci_dev->romfile = g_strdup(pc->romfile);
         is_default_rom = true;
     }
-    pci_add_option_rom(pci_dev, is_default_rom);
+
+    rc = pci_add_option_rom(pci_dev, is_default_rom);
+    if (rc != 0) {
+        pci_unregister_device(DEVICE(pci_dev));
+        return rc;
+    }
 
     return 0;
 }
@@ -1940,6 +1945,10 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
         if (class == 0x0300) {
             rom_add_vga(pdev->romfile);
         } else {
+            if (DEVICE(pdev)->hotplugged) {
+                error_report("PCI: rombar can't be 0 for hotplugged devices!");
+                return -1;
+            }
             rom_add_option(pdev->romfile, -1);
         }
         return 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-10-22 18:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21 12:37 [Qemu-devel] [PATCH] hw/pci: fixed crash when using rombar=0 for hotplugged devices Marcel Apfelbaum
2014-10-21 22:06 ` Paolo Bonzini
2014-10-22  6:26   ` Michael S. Tsirkin
2014-10-22  7:41   ` Marcel Apfelbaum
2014-10-22  8:02     ` Michael S. Tsirkin
2014-10-22 16:26       ` Alex Williamson
2014-10-22 18:24         ` Marcel Apfelbaum
2014-10-22  6:18 ` Michael S. Tsirkin
2014-10-22  7:34   ` Marcel Apfelbaum
2014-10-22  7:58     ` Michael S. Tsirkin
2014-10-22  8:16       ` Marcel Apfelbaum
2014-10-22  8:31         ` Michael S. Tsirkin
2014-10-22 15:28           ` Marcel Apfelbaum
2014-10-22 15:49             ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).