From fa4afdcc60aba49473ad6450b3e9e32f7ed673ab Mon Sep 17 00:00:00 2001
Message-Id: <fa4afdcc60aba49473ad6450b3e9e32f7ed673ab.1429739396.git.jen@redhat.com>
In-Reply-To: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com>
References: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Thu, 16 Apr 2015 15:06:42 -0500
Subject: [CHANGE 10/11] qdev: add qbus_reset_all
To: rhvirt-patches@redhat.com,
    jen@redhat.com

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1429196803-9785-3-git-send-email-pbonzini@redhat.com>
Patchwork-id: 64823
O-Subject: [RHEL6.7 qemu-kvm PATCH 2/3] qdev: add qbus_reset_all
Bugzilla: 1141594
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit d0508c3664290baad379f6513c92cae6e5aac95b)
Signed-off-by: Jeff E. Nelson <jen@redhat.com>

Conflicts:
	hw/qdev-core.h [use qdev.h instead]
	hw/qdev.c [no qbus_reset_all_fn, no qbus_reset_one]
---
 hw/qdev.c |  5 +++++
 hw/qdev.h | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

Signed-off-by: Jeff E. Nelson <jen@redhat.com>
---
 hw/qdev.c |  5 +++++
 hw/qdev.h | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/hw/qdev.c b/hw/qdev.c
index 640a63b..33ab045 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -324,6 +324,11 @@ void qdev_reset_all(DeviceState *dev)
     qdev_walk_children(dev, qdev_reset_one, NULL, NULL);
 }
 
+void qbus_reset_all(BusState *bus)
+{
+    qbus_walk_children(bus, qdev_reset_one, NULL, NULL);
+}
+
 /* can be used as ->unplug() callback for the simple cases */
 int qdev_simple_unplug_cb(DeviceState *dev)
 {
diff --git a/hw/qdev.h b/hw/qdev.h
index 3d74c9a..1edcbd3 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -198,6 +198,21 @@ int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
 int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
                        qbus_walkerfn *busfn, void *opaque);
 void qdev_reset_all(DeviceState *dev);
+
+/**
+ * @qbus_reset_all:
+ * @bus: Bus to be reset.
+ *
+ * Reset @bus and perform a bus-level ("hard") reset of all devices connected
+ * to it, including recursive processing of all buses below @bus itself.  A
+ * hard reset means that qbus_reset_all will reset all state of the device.
+ * For PCI devices, for example, this will include the base address registers
+ * or configuration space.
+ *
+ * [RHEL note: the above does not apply here.  This QEMU does not have a
+ *  bus-level reset callback!]
+ */
+void qbus_reset_all(BusState *bus);
 void qbus_free(BusState *bus);
 
 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
-- 
2.1.0

