qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/ide: Fix crash when plugging a piix3-ide device into the


From: John Snow
Subject: Re: [PATCH] hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine
Date: Tue, 27 Apr 2021 14:06:01 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 4/16/21 8:52 AM, Thomas Huth wrote:
QEMU currently crashes when the user tries to do something like:

  qemu-system-x86_64 -M x-remote -device piix3-ide

This happens because the "isabus" variable is not initialized with
the x-remote machine yet. Add a proper check for this condition
and propagate the error to the caller, so we can fail there gracefully.

Signed-off-by: Thomas Huth <thuth@redhat.com>

Seems OK to me for now. I will trust that this won't get in the way of any deeper refactors Phil has planned, since this just adds error pathways to avoid something already broken, and doesn't change anything else.

I'm OK with that.

Reviewed-by: John Snow <jsnow@redhat.com>

Tentatively staged, pending further discussion.

---
  hw/ide/ioport.c           | 16 ++++++++++------
  hw/ide/piix.c             | 22 +++++++++++++++++-----
  hw/isa/isa-bus.c          | 14 ++++++++++----
  include/hw/ide/internal.h |  2 +-
  include/hw/isa/isa.h      | 13 ++++++++-----
  5 files changed, 46 insertions(+), 21 deletions(-)



diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c
index b613ff3bba..e6caa537fa 100644
--- a/hw/ide/ioport.c
+++ b/hw/ide/ioport.c
@@ -50,15 +50,19 @@ static const MemoryRegionPortio ide_portio2_list[] = {
      PORTIO_END_OF_LIST(),
  };
-void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)
+int ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)
  {
+    int ret;
+
      /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA
         bridge has been setup properly to always register with ISA.  */
-    isa_register_portio_list(dev, &bus->portio_list,
-                             iobase, ide_portio_list, bus, "ide");
+    ret = isa_register_portio_list(dev, &bus->portio_list,
+                                   iobase, ide_portio_list, bus, "ide");
- if (iobase2) {
-        isa_register_portio_list(dev, &bus->portio2_list,
-                                 iobase2, ide_portio2_list, bus, "ide");
+    if (ret == 0 && iobase2) {
+        ret = isa_register_portio_list(dev, &bus->portio2_list,
+                                       iobase2, ide_portio2_list, bus, "ide");
      }
+
+    return ret;
  }


Little funky instead of just checking and returning after the first portio list registration, you could leave a little more git blame intact by not doing this, but...

...Then again, I just acked a ton of stuff Phil moved around, so, whatever O:-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]