qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Collin Walling <walling@linux.ibm.com>,
	Thomas Huth <thuth@redhat.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	David Hildenbrand <david@redhat.com>
Subject: [Qemu-devel] [PATCH v1 6/6] s390x/pci: unplug remaining devices on pcihost reset
Date: Wed,  9 Jan 2019 17:53:49 +0100	[thread overview]
Message-ID: <20190109165349.23631-7-david@redhat.com> (raw)
In-Reply-To: <20190109165349.23631-1-david@redhat.com>

When resetting the guest we should unplug and remove all devices that
are still pending. Otherwise the fresh guest will see devices that will
suddenly vanish.

Can be triggered e.g. via
(hmp) device_add virtio-mouse-pci,id=test
(hmp) stop
(hmp) device_del test
(hmp) system_reset
(hmp) c

The device will vanish after roughly 5 minutes. With this patch, the
device will vanish on reboot (S390_RESET_EXTERNAL and S390_RESET_REIPL,
which reset the pcihost bridge via qemu_devices_reset()). If we want
these devices to vanish directly on any reset (S390_RESET_MODIFIED_CLEAR
and S390_RESET_LOAD_NORMAL), we have to modify s390_machine_reset().

s390_pci_generate_plug_event()'s will still be generated, but that is
similar to hotplugging a PCI device before the guest has been started, so
I guess it is not problematic. (we could inject such events when
hotplugging based on "dev->hotplugged" property, when unplugging we would
have to rely on the runstate)

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/s390x/s390-pci-bus.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index bcd8565a14..0212e83069 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -1099,6 +1099,14 @@ static void s390_pcihost_reset(DeviceState *dev)
 {
     S390pciState *s = S390_PCI_HOST_BRIDGE(dev);
     PCIBus *bus = s->parent_obj.bus;
+    S390PCIBusDevice *pbdev, *next;
+
+    /* Unplug all pending devices that were requested to be released */
+    QTAILQ_FOREACH_SAFE(pbdev, &s->zpci_devs, link, next) {
+        if (pbdev->release_timer) {
+            s390_pcihost_timer_cb(pbdev);
+        }
+    }
 
     s->bus_no = 0;
     pci_for_each_device(bus, pci_bus_num(bus), s390_pci_enumerate_bridge, s);
-- 
2.17.2

      parent reply	other threads:[~2019-01-09 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 16:53 [Qemu-devel] [PATCH v1 0/6] s390/pci: hotplug handler fixes and reworks David Hildenbrand
2019-01-09 16:53 ` [Qemu-devel] [PATCH v1 1/6] s390x/pci: Use hotplug_dev instead of looking up the host bridge David Hildenbrand
2019-01-09 16:53 ` [Qemu-devel] [PATCH v1 2/6] s390x/pci: Move some hotplug checks to the pre_plug handler David Hildenbrand
2019-01-09 16:53 ` [Qemu-devel] [PATCH v1 3/6] s390x/pci: Always delete and free the release_timer David Hildenbrand
2019-01-09 16:53 ` [Qemu-devel] [PATCH v1 4/6] s390x/pci: Ignore the unplug call if we already have a release_timer David Hildenbrand
2019-01-09 16:53 ` [Qemu-devel] [PATCH v1 5/6] s390x/pci: Introduce unplug requests and split unplug handler David Hildenbrand
2019-01-10 16:12   ` David Hildenbrand
2019-01-09 16:53 ` David Hildenbrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190109165349.23631-7-david@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    --cc=walling@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).