* [Qemu-devel] [RFC 05/10] qdev: move reset handler list from vl.c to hw/reset.c
2012-11-30 19:27 [Qemu-devel] [RFC 00/10] CPU DeviceState v8 Eduardo Habkost
` (3 preceding siblings ...)
2012-11-30 19:27 ` [Qemu-devel] [RFC 04/10] qdev: qdev_create(): use error_report() instead of hw_error() Eduardo Habkost
@ 2012-11-30 19:27 ` Eduardo Habkost
2012-12-03 20:19 ` Igor Mammedov
2012-12-03 21:20 ` Igor Mammedov
2012-11-30 19:27 ` [Qemu-devel] [RFC 06/10] qdev: add stubs for vmstate register/unregister functions Eduardo Habkost
` (4 subsequent siblings)
9 siblings, 2 replies; 17+ messages in thread
From: Eduardo Habkost @ 2012-11-30 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber, Anthony Liguori
The core qdev code uses the reset handler list from vl.c, and
currently *-user has some hacks to make CPU reset work.
This moves qemu_register_reset(), qemu_unregister_reset() and
qemu_devices_reset() to a new file, hw/reset.c, that can be used by qdev
and by *-user.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/Makefile.objs | 1 +
hw/ac97.c | 1 +
hw/acpi_ich9.c | 1 +
hw/acpi_piix4.c | 1 +
hw/adb.c | 1 +
hw/arm_boot.c | 1 +
hw/armv7m.c | 1 +
hw/bonito.c | 1 +
hw/cirrus_vga.c | 1 +
hw/cris-boot.c | 1 +
hw/cs4231a.c | 1 +
hw/cuda.c | 1 +
hw/dma.c | 1 +
hw/dp8393x.c | 1 +
hw/eepro100.c | 1 +
hw/es1370.c | 1 +
hw/etraxfs_timer.c | 1 +
hw/gt64xxx.c | 1 +
hw/heathrow_pic.c | 1 +
hw/hw.h | 5 -----
hw/ide/cmd646.c | 1 +
hw/ide/macio.c | 1 +
hw/ide/mmio.c | 1 +
hw/ide/piix.c | 1 +
hw/ide/via.c | 1 +
hw/leon3.c | 1 +
hw/lm32_boards.c | 1 +
hw/lm832x.c | 1 +
hw/loader.c | 1 +
hw/mac_dbdma.c | 1 +
hw/mac_nvram.c | 1 +
hw/mc146818rtc.c | 1 +
hw/microblaze_boot.c | 1 +
hw/milkymist.c | 1 +
hw/mips_fulong2e.c | 1 +
hw/mips_jazz.c | 1 +
hw/mips_malta.c | 1 +
hw/mips_mipssim.c | 1 +
hw/mips_r4k.c | 1 +
hw/nseries.c | 1 +
hw/omap1.c | 1 +
hw/omap2.c | 1 +
hw/openpic.c | 1 +
hw/openrisc_sim.c | 1 +
hw/parallel.c | 1 +
hw/pc.c | 1 +
hw/pckbd.c | 1 +
hw/piix4.c | 1 +
hw/piix_pci.c | 1 +
hw/ppc/e500.c | 1 +
hw/ppc405_boards.c | 1 +
hw/ppc405_uc.c | 1 +
hw/ppc440_bamboo.c | 1 +
hw/ppc4xx_devs.c | 1 +
hw/ppc4xx_pci.c | 1 +
hw/ppc_newworld.c | 1 +
hw/ppc_oldworld.c | 1 +
hw/ppc_prep.c | 1 +
hw/ppce500_spin.c | 1 +
hw/ps2.c | 1 +
hw/qdev.c | 1 +
hw/r2d.c | 1 +
hw/rc4030.c | 1 +
hw/reset.c | 43 +++++++++++++++++++++++++++++++++++++++++++
hw/reset.h | 11 +++++++++++
hw/s390-virtio-bus.c | 1 +
hw/serial.c | 1 +
hw/spapr.c | 1 +
hw/sun4m.c | 1 +
hw/sun4u.c | 1 +
hw/tsc2005.c | 1 +
hw/tsc210x.c | 1 +
hw/usb/hcd-ehci.c | 1 +
hw/usb/hcd-ohci.c | 1 +
hw/usb/hcd-uhci.c | 1 +
hw/vga.c | 1 +
hw/virtex_ml507.c | 1 +
hw/vt82c686.c | 1 +
hw/xics.c | 1 +
hw/xtensa_lx60.c | 1 +
hw/xtensa_sim.c | 1 +
kvm-all.c | 1 +
sysemu.h | 1 -
target-i386/cpu.c | 1 +
target-i386/kvm.c | 1 +
vl.c | 41 +----------------------------------------
xen-all.c | 1 +
87 files changed, 137 insertions(+), 46 deletions(-)
create mode 100644 hw/reset.c
create mode 100644 hw/reset.h
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..1dfed06 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -1,5 +1,6 @@
common-obj-y = usb/ ide/
common-obj-y += loader.o
+common-obj-y += reset.o
common-obj-$(CONFIG_VIRTIO) += virtio-console.o
common-obj-$(CONFIG_VIRTIO) += virtio-rng.o
common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
diff --git a/hw/ac97.c b/hw/ac97.c
index ce6a1dc..c37aaae 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -17,6 +17,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "audiodev.h"
#include "audio/audio.h"
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 61034d3..fc2ff2c 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -22,6 +22,7 @@
*
* This is based on acpi.c.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "pci.h"
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 519269a..a022180 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -18,6 +18,7 @@
* Contributions after 2012-01-13 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "apm.h"
diff --git a/hw/adb.c b/hw/adb.c
index 3b547f0..5f3d6dc 100644
--- a/hw/adb.c
+++ b/hw/adb.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "adb.h"
#include "console.h"
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 92e2cab..c608d1d 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -8,6 +8,7 @@
*/
#include "config.h"
+#include "hw/reset.h"
#include "hw.h"
#include "arm-misc.h"
#include "sysemu.h"
diff --git a/hw/armv7m.c b/hw/armv7m.c
index ce2ec9b..fca329c 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "hw/reset.h"
#include "sysbus.h"
#include "arm-misc.h"
#include "loader.h"
diff --git a/hw/bonito.c b/hw/bonito.c
index 0bf6d4a..4080def 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -39,6 +39,7 @@
#include <assert.h>
+#include "hw/reset.h"
#include "hw.h"
#include "pci.h"
#include "pc.h"
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9bef96e..7e51cc4 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -26,6 +26,7 @@
* Reference: Finn Thogersons' VGADOC4b
* available at http://home.worldonline.dk/~finth/
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pci.h"
#include "console.h"
diff --git a/hw/cris-boot.c b/hw/cris-boot.c
index b21326f..fc0c64b 100644
--- a/hw/cris-boot.c
+++ b/hw/cris-boot.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "loader.h"
#include "elf.h"
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 0257fd8..b54dfc1 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "audiodev.h"
#include "audio/audio.h"
diff --git a/hw/cuda.c b/hw/cuda.c
index f1f408b..0e74501 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc_mac.h"
#include "adb.h"
diff --git a/hw/dma.c b/hw/dma.c
index d6aeac2..0232ceb 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "isa.h"
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index 3f6386e..23fd09f 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -17,6 +17,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "qemu-timer.h"
#include "net.h"
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a189474..0c3e0dd 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -41,6 +41,7 @@
*/
#include <stddef.h> /* offsetof */
+#include "hw/reset.h"
#include "hw.h"
#include "pci.h"
#include "net.h"
diff --git a/hw/es1370.c b/hw/es1370.c
index e0c9729..6c5466f 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -26,6 +26,7 @@
/* #define VERBOSE_ES1370 */
#define SILENT_ES1370
+#include "hw/reset.h"
#include "hw.h"
#include "audiodev.h"
#include "audio/audio.h"
diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c
index f5601dc..cea5e00 100644
--- a/hw/etraxfs_timer.c
+++ b/hw/etraxfs_timer.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "sysbus.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "qemu-timer.h"
#include "ptimer.h"
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index 95d491d..ecda9f9 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "mips.h"
#include "pci.h"
diff --git a/hw/heathrow_pic.c b/hw/heathrow_pic.c
index b9ec8e7..b0e1a9d 100644
--- a/hw/heathrow_pic.c
+++ b/hw/heathrow_pic.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc_mac.h"
diff --git a/hw/hw.h b/hw/hw.h
index f530f6f..fe057f0 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -37,11 +37,6 @@
#endif
#endif
-typedef void QEMUResetHandler(void *opaque);
-
-void qemu_register_reset(QEMUResetHandler *func, void *opaque);
-void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
-
/* handler to set the boot_device order for a specific type of QEMUMachine */
/* return 0 if success */
typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 804db60..0666102 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -27,6 +27,7 @@
#include <hw/pci.h>
#include <hw/isa.h>
#include "block.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "dma.h"
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index d2edcc0..9fe3a9f 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include <hw/hw.h>
#include <hw/ppc_mac.h>
#include <hw/mac_dbdma.h>
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index bcb26c8..4da8c6e 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include <hw/hw.h>
#include "block.h"
#include "dma.h"
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 9431bad..b6c910a 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -28,6 +28,7 @@
#include <hw/pci.h>
#include <hw/isa.h>
#include "blockdev.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "dma.h"
diff --git a/hw/ide/via.c b/hw/ide/via.c
index efda173..9a5a991 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -28,6 +28,7 @@
#include <hw/pci.h>
#include <hw/isa.h>
#include "block.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "dma.h"
diff --git a/hw/leon3.c b/hw/leon3.c
index 7742738..d944641 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "qemu-timer.h"
#include "ptimer.h"
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 772cb8b..30ea613 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -18,6 +18,7 @@
*/
#include "sysbus.h"
+#include "hw/reset.h"
#include "hw.h"
#include "net.h"
#include "flash.h"
diff --git a/hw/lm832x.c b/hw/lm832x.c
index 8e09f9b..7f3fc0c 100644
--- a/hw/lm832x.c
+++ b/hw/lm832x.c
@@ -18,6 +18,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "i2c.h"
#include "qemu-timer.h"
diff --git a/hw/loader.c b/hw/loader.c
index ba01ca6..dafbda4 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -42,6 +42,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "disas.h"
#include "monitor.h"
diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c
index e551156..e1f876f 100644
--- a/hw/mac_dbdma.c
+++ b/hw/mac_dbdma.c
@@ -36,6 +36,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "isa.h"
#include "mac_dbdma.h"
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index a0d14dd..90c848d 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "firmware_abi.h"
#include "sysemu.h"
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index c79fca7..5899be1 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "qemu-timer.h"
#include "sysemu.h"
diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c
index 02c349c..933a677 100644
--- a/hw/microblaze_boot.c
+++ b/hw/microblaze_boot.c
@@ -28,6 +28,7 @@
#include "qemu-config.h"
#include "qemu-common.h"
#include "device_tree.h"
+#include "hw/reset.h"
#include "loader.h"
#include "elf.h"
diff --git a/hw/milkymist.c b/hw/milkymist.c
index 4c8111a..25eb0b8 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -18,6 +18,7 @@
*/
#include "sysbus.h"
+#include "hw/reset.h"
#include "hw.h"
#include "net.h"
#include "flash.h"
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 5fcf900..f14318f 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -18,6 +18,7 @@
* http://www.loongsondeveloper.com/doc/Loongson2EUserGuide.pdf
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "serial.h"
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 0847427..8e31187 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "mips.h"
#include "mips_cpudevs.h"
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 4d2464a..8f96918 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "serial.h"
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index a95a3c1..1a7d3f6 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -24,6 +24,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "mips.h"
#include "mips_cpudevs.h"
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 325098a..a9c7a0f 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -7,6 +7,7 @@
* All peripherial devices are attached to this "bus" with
* the standard PC ISA addresses.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "mips.h"
#include "mips_cpudevs.h"
diff --git a/hw/nseries.c b/hw/nseries.c
index 2de8d21..5604e7c 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -28,6 +28,7 @@
#include "i2c.h"
#include "devices.h"
#include "flash.h"
+#include "hw/reset.h"
#include "hw.h"
#include "bt.h"
#include "loader.h"
diff --git a/hw/omap1.c b/hw/omap1.c
index 4d5815e..a5bac74 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "arm-misc.h"
#include "omap.h"
diff --git a/hw/omap2.c b/hw/omap2.c
index 96aba71..10b0a1a 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -19,6 +19,7 @@
*/
#include "blockdev.h"
+#include "hw/reset.h"
#include "hw.h"
#include "arm-misc.h"
#include "omap.h"
diff --git a/hw/openpic.c b/hw/openpic.c
index 8b3784a..633a47a 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -33,6 +33,7 @@
* Serial interrupts, as implemented in Raven chipset are not supported yet.
*
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc_mac.h"
#include "pci.h"
diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c
index 23c66df..74b0594 100644
--- a/hw/openrisc_sim.c
+++ b/hw/openrisc_sim.c
@@ -18,6 +18,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "boards.h"
#include "elf.h"
diff --git a/hw/parallel.c b/hw/parallel.c
index c4705bc..ba17a4e 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "qemu-char.h"
#include "isa.h"
diff --git a/hw/pc.c b/hw/pc.c
index 2b5bbbf..5f08c5e 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "serial.h"
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 5bb3e0a..6116b58 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "isa.h"
#include "pc.h"
diff --git a/hw/piix4.c b/hw/piix4.c
index ce4eb0d..eb4d918 100644
--- a/hw/piix4.c
+++ b/hw/piix4.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "pci.h"
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index ba1b3de..e9c3b3b 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "pci.h"
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 6749fff..53f980a 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -18,6 +18,7 @@
#include "qemu-common.h"
#include "e500.h"
#include "net.h"
+#include "hw/reset.h"
#include "hw/hw.h"
#include "hw/serial.h"
#include "hw/pci.h"
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index 8dc693f..421cdc3 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc405.h"
diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c
index 0f458ef..3cd0e5b 100644
--- a/hw/ppc405_uc.c
+++ b/hw/ppc405_uc.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc405.h"
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index cc85607..29d000b 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -14,6 +14,7 @@
#include "config.h"
#include "qemu-common.h"
#include "net.h"
+#include "hw/reset.h"
#include "hw.h"
#include "pci.h"
#include "boards.h"
diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c
index bac8d87..4fbf2f7 100644
--- a/hw/ppc4xx_devs.c
+++ b/hw/ppc4xx_devs.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc4xx.h"
diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
index d3ad6a0..a8f4b54 100644
--- a/hw/ppc4xx_pci.c
+++ b/hw/ppc4xx_pci.c
@@ -19,6 +19,7 @@
/* This file implements emulation of the 32-bit PCI controller found in some
* 4xx SoCs, such as the 440EP. */
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc4xx.h"
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 664747e..dbe705e 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -46,6 +46,7 @@
* 0001:05:0c.0 IDE interface [0101]: Broadcom K2 SATA [1166:0240]
*
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc_mac.h"
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index e8138c0..dcb45a6 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ppc.h"
#include "ppc_mac.h"
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index bf15730..02ab5e3 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "nvram.h"
#include "pc.h"
diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
index c1a155b..d6435d1 100644
--- a/hw/ppce500_spin.c
+++ b/hw/ppce500_spin.c
@@ -27,6 +27,7 @@
*
*/
+#include "hw/reset.h"
#include "hw.h"
#include "sysemu.h"
#include "sysbus.h"
diff --git a/hw/ps2.c b/hw/ps2.c
index f93cd24..c1b441d 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "ps2.h"
#include "console.h"
diff --git a/hw/qdev.c b/hw/qdev.c
index 599382c..15b967d 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -27,6 +27,7 @@
#include "net.h"
#include "qdev.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "error.h"
#include "qapi/qapi-visit-core.h"
diff --git a/hw/r2d.c b/hw/r2d.c
index 66212e9..9ce2a8c 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -24,6 +24,7 @@
*/
#include "sysbus.h"
+#include "hw/reset.h"
#include "hw.h"
#include "sh.h"
#include "devices.h"
diff --git a/hw/rc4030.c b/hw/rc4030.c
index e0024c8..d175cf2 100644
--- a/hw/rc4030.c
+++ b/hw/rc4030.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "mips.h"
#include "qemu-timer.h"
diff --git a/hw/reset.c b/hw/reset.c
new file mode 100644
index 0000000..5e34b80
--- /dev/null
+++ b/hw/reset.c
@@ -0,0 +1,43 @@
+#include "hw/reset.h"
+#include "qlist.h"
+
+typedef struct QEMUResetEntry {
+ QTAILQ_ENTRY(QEMUResetEntry) entry;
+ QEMUResetHandler *func;
+ void *opaque;
+} QEMUResetEntry;
+
+static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
+ QTAILQ_HEAD_INITIALIZER(reset_handlers);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque)
+{
+ QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
+
+ re->func = func;
+ re->opaque = opaque;
+ QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
+}
+
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
+{
+ QEMUResetEntry *re;
+
+ QTAILQ_FOREACH(re, &reset_handlers, entry) {
+ if (re->func == func && re->opaque == opaque) {
+ QTAILQ_REMOVE(&reset_handlers, re, entry);
+ g_free(re);
+ return;
+ }
+ }
+}
+
+void qemu_devices_reset(void)
+{
+ QEMUResetEntry *re, *nre;
+
+ /* reset all devices */
+ QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
+ re->func(re->opaque);
+ }
+}
diff --git a/hw/reset.h b/hw/reset.h
new file mode 100644
index 0000000..fce4066
--- /dev/null
+++ b/hw/reset.h
@@ -0,0 +1,11 @@
+/* Device reset handler function registration, used by qdev and other code */
+#ifndef QDEV_RESET_H
+#define QDEV_RESET_H
+
+typedef void QEMUResetHandler(void *opaque);
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque);
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
+void qemu_devices_reset(void);
+
+#endif /* QDEV_RESET_H */
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index e0ac2d1..699e07f 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "block.h"
#include "sysemu.h"
diff --git a/hw/serial.c b/hw/serial.c
index 60283ea..0254e1b 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -27,6 +27,7 @@
#include "qemu-char.h"
#include "qemu-timer.h"
#include "exec-memory.h"
+#include "hw/reset.h"
//#define DEBUG_SERIAL
diff --git a/hw/spapr.c b/hw/spapr.c
index ad3f0ea..97ca1e6 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -25,6 +25,7 @@
*
*/
#include "sysemu.h"
+#include "hw/reset.h"
#include "hw.h"
#include "elf.h"
#include "net.h"
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 1a78676..e3e5958 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -27,6 +27,7 @@
#include "nvram.h"
#include "sparc32_dma.h"
#include "fdc.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "net.h"
#include "boards.h"
diff --git a/hw/sun4u.c b/hw/sun4u.c
index b2b51e3..e263e8e 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pci.h"
#include "apb_pci.h"
diff --git a/hw/tsc2005.c b/hw/tsc2005.c
index 9a500eb..f7a892d 100644
--- a/hw/tsc2005.c
+++ b/hw/tsc2005.c
@@ -18,6 +18,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "qemu-timer.h"
#include "console.h"
diff --git a/hw/tsc210x.c b/hw/tsc210x.c
index 3c448a6..4e3ea2d 100644
--- a/hw/tsc210x.c
+++ b/hw/tsc210x.c
@@ -19,6 +19,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "audio/audio.h"
#include "qemu-timer.h"
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 7df8e21..71e243f 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -28,6 +28,7 @@
*/
#include "hw/usb/hcd-ehci.h"
+#include "hw/reset.h"
/* Capability Registers Base Address - section 2.2 */
#define CAPLENGTH 0x0000 /* 1-byte, 0x0001 reserved */
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 64de906..ac75bbf 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -26,6 +26,7 @@
* o BIOS work to boot from USB storage
*/
+#include "hw/reset.h"
#include "hw/hw.h"
#include "qemu-timer.h"
#include "hw/usb.h"
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 8e47803..b5437c8 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -25,6 +25,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw/hw.h"
#include "hw/usb.h"
#include "hw/pci.h"
diff --git a/hw/vga.c b/hw/vga.c
index 2b0200a..23f0aea 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "vga.h"
#include "console.h"
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index 6ab8fee..ba07f25 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -23,6 +23,7 @@
*/
#include "sysbus.h"
+#include "hw/reset.h"
#include "hw.h"
#include "serial.h"
#include "net.h"
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 5d7c00c..671322d 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -10,6 +10,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "hw/reset.h"
#include "hw.h"
#include "pc.h"
#include "vt82c686.h"
diff --git a/hw/xics.c b/hw/xics.c
index 1da3106..673c8aa 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -25,6 +25,7 @@
*
*/
+#include "hw/reset.h"
#include "hw.h"
#include "hw/spapr.h"
#include "hw/xics.h"
diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c
index 4c42edc..39b0d67 100644
--- a/hw/xtensa_lx60.c
+++ b/hw/xtensa_lx60.c
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "hw/reset.h"
#include "sysemu.h"
#include "boards.h"
#include "loader.h"
diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c
index 0d633e4..c30efc8 100644
--- a/hw/xtensa_sim.c
+++ b/hw/xtensa_sim.c
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "hw/reset.h"
#include "sysemu.h"
#include "boards.h"
#include "loader.h"
diff --git a/kvm-all.c b/kvm-all.c
index 8e9a8d8..9a3010c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -25,6 +25,7 @@
#include "qemu-option.h"
#include "qemu-config.h"
#include "sysemu.h"
+#include "hw/reset.h"
#include "hw/hw.h"
#include "hw/msi.h"
#include "gdbstub.h"
diff --git a/sysemu.h b/sysemu.h
index ab1ef8b..51f19cc 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -57,7 +57,6 @@ void qemu_system_vmstop_request(RunState reason);
int qemu_shutdown_requested_get(void);
int qemu_reset_requested_get(void);
void qemu_system_killed(int signal, pid_t pid);
-void qemu_devices_reset(void);
void qemu_system_reset(bool report);
void qemu_add_exit_notifier(Notifier *notify);
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c6c2ca0..483a6fc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -32,6 +32,7 @@
#include "hyperv.h"
+#include "hw/reset.h"
#include "hw/hw.h"
#if defined(CONFIG_KVM)
#include <linux/kvm_para.h>
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f669281..5f43232 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -21,6 +21,7 @@
#include <linux/kvm_para.h>
#include "qemu-common.h"
+#include "hw/reset.h"
#include "sysemu.h"
#include "kvm.h"
#include "kvm_i386.h"
diff --git a/vl.c b/vl.c
index a3ab384..e053e6a 100644
--- a/vl.c
+++ b/vl.c
@@ -113,6 +113,7 @@ int main(int argc, char **argv)
#include <glib.h>
+#include "hw/reset.h"
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/usb.h"
@@ -1457,14 +1458,6 @@ void vm_start(void)
/* reset/shutdown handler */
-typedef struct QEMUResetEntry {
- QTAILQ_ENTRY(QEMUResetEntry) entry;
- QEMUResetHandler *func;
- void *opaque;
-} QEMUResetEntry;
-
-static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
- QTAILQ_HEAD_INITIALIZER(reset_handlers);
static int reset_requested;
static int shutdown_requested, shutdown_signal = -1;
static pid_t shutdown_pid;
@@ -1561,38 +1554,6 @@ static bool qemu_vmstop_requested(RunState *r)
return false;
}
-void qemu_register_reset(QEMUResetHandler *func, void *opaque)
-{
- QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
-
- re->func = func;
- re->opaque = opaque;
- QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
-}
-
-void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
-{
- QEMUResetEntry *re;
-
- QTAILQ_FOREACH(re, &reset_handlers, entry) {
- if (re->func == func && re->opaque == opaque) {
- QTAILQ_REMOVE(&reset_handlers, re, entry);
- g_free(re);
- return;
- }
- }
-}
-
-void qemu_devices_reset(void)
-{
- QEMUResetEntry *re, *nre;
-
- /* reset all devices */
- QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
- re->func(re->opaque);
- }
-}
-
void qemu_system_reset(bool report)
{
if (current_machine && current_machine->reset) {
diff --git a/xen-all.c b/xen-all.c
index 046cc2a..7d2a79f 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -14,6 +14,7 @@
#include "hw/pc.h"
#include "hw/xen_common.h"
#include "hw/xen_backend.h"
+#include "hw/reset.h"
#include "qmp-commands.h"
#include "range.h"
--
1.7.11.7
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [RFC 08/10] qdev-properties.c: separate core from the code used only by qemu-system-*
2012-11-30 19:27 [Qemu-devel] [RFC 00/10] CPU DeviceState v8 Eduardo Habkost
` (6 preceding siblings ...)
2012-11-30 19:27 ` [Qemu-devel] [RFC 07/10] qdev: add sysbus_get_default() stub Eduardo Habkost
@ 2012-11-30 19:27 ` Eduardo Habkost
2012-11-30 19:27 ` [Qemu-devel] [RFC 09/10] include qdev code into *-user, too Eduardo Habkost
2012-11-30 19:27 ` [Qemu-devel] [RFC 10/10] qom: make CPU a child of DeviceState Eduardo Habkost
9 siblings, 0 replies; 17+ messages in thread
From: Eduardo Habkost @ 2012-11-30 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber, Anthony Liguori
This separates the qdev properties code in two parts:
- qdev-properties.c, that contains most of the qdev properties code;
- qdev-properties-system.c for code specific for qemu-system-*,
containing:
- Property types: drive, chr, netdev, vlan, that depend on code that
won't be included on *-user
- qemu_add_globals(), that depends on qemu-config.o.
This change should help on two things:
- Allowing DeviceState to be used by *-user without pulling
dependencies that are specific for qemu-system-*;
- Writing qdev unit tests without pulling too many dependencies.
The copyright/license header for the new file is directly copied from
qdev-properties.c.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
version]
[ehabkost: added copyright/license information to new qdev*-system.c files]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Yes, there is "changelog" data before the "---" mark, but I believe that
in this case they are important to indicate authorship and the scope of
the Signed-off-by lines (so they need to get into the git commit
message).
Detailed changelog:
Changes v1 (ehabkost) -> v2 (imammedo):
- keep qdev_get_child_bus() in hw/qdev.c
- put qdev_set_nic_properties() in hw/qdev-properties-system.c
Changes v2 -> v3 (ehabkost):
- updated the qdev_init_gpio_in() code on qdev-system.c to current
version
Changes v3 -> v4 (ehabkost):
- Added copyright/license information to qdev-properties-system.c
(based on copyright/license of qdev-properties.c)
- Whitespace change at the end of qdev-properties.c
- Don't create qdev-system.c, now we can keep the qdev.c code as-is
as the qdev.c dependencies were reduced
- Rewrite patch description
Changes v4 -> v5 (ehabkost):
- Remove large copyright header and instead just point to the original
file it was based on
---
hw/Makefile.objs | 1 +
hw/qdev-properties-system.c | 352 ++++++++++++++++++++++++++++++++++++++++++++
hw/qdev-properties.c | 321 +---------------------------------------
hw/qdev-properties.h | 1 +
hw/qdev.c | 13 --
5 files changed, 355 insertions(+), 333 deletions(-)
create mode 100644 hw/qdev-properties-system.c
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 1dfed06..0f7bfe0 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -186,6 +186,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
common-obj-y += bt-hci-csr.o
common-obj-y += msmouse.o ps2.o
common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
common-obj-$(CONFIG_BRLAPI) += baum.o
# xen backend driver support
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 0000000..9a7e0b3
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,352 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * This file is based on code from hw/qdev-properties.c from
+ * commit 4e68f7a0819f179c2ff90a60611806c789911cc2,
+ * Copyright (c) Gerd Hoffmann <kraxel@redhat.com> and other contributors.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "net.h"
+#include "qdev.h"
+#include "qerror.h"
+#include "blockdev.h"
+#include "hw/block-common.h"
+#include "net/hub.h"
+#include "qapi/qapi-visit-core.h"
+
+static void get_pointer(Object *obj, Visitor *v, Property *prop,
+ const char *(*print)(void *ptr),
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ void **ptr = qdev_get_prop_ptr(dev, prop);
+ char *p;
+
+ p = (char *) (*ptr ? print(*ptr) : "");
+ visit_type_str(v, &p, name, errp);
+}
+
+static void set_pointer(Object *obj, Visitor *v, Property *prop,
+ int (*parse)(DeviceState *dev, const char *str,
+ void **ptr),
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Error *local_err = NULL;
+ void **ptr = qdev_get_prop_ptr(dev, prop);
+ char *str;
+ int ret;
+
+ if (dev->state != DEV_STATE_CREATED) {
+ error_set(errp, QERR_PERMISSION_DENIED);
+ return;
+ }
+
+ visit_type_str(v, &str, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ if (!*str) {
+ g_free(str);
+ *ptr = NULL;
+ return;
+ }
+ ret = parse(dev, str, ptr);
+ error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
+ g_free(str);
+}
+
+/* --- drive --- */
+
+static int parse_drive(DeviceState *dev, const char *str, void **ptr)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(str);
+ if (bs == NULL)
+ return -ENOENT;
+ if (bdrv_attach_dev(bs, dev) < 0)
+ return -EEXIST;
+ *ptr = bs;
+ return 0;
+}
+
+static void release_drive(Object *obj, const char *name, void *opaque)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (*ptr) {
+ bdrv_detach_dev(*ptr, dev);
+ blockdev_auto_del(*ptr);
+ }
+}
+
+static const char *print_drive(void *ptr)
+{
+ return bdrv_get_device_name(ptr);
+}
+
+static void get_drive(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ get_pointer(obj, v, opaque, print_drive, name, errp);
+}
+
+static void set_drive(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ set_pointer(obj, v, opaque, parse_drive, name, errp);
+}
+
+PropertyInfo qdev_prop_drive = {
+ .name = "drive",
+ .get = get_drive,
+ .set = set_drive,
+ .release = release_drive,
+};
+
+/* --- character device --- */
+
+static int parse_chr(DeviceState *dev, const char *str, void **ptr)
+{
+ CharDriverState *chr = qemu_chr_find(str);
+ if (chr == NULL) {
+ return -ENOENT;
+ }
+ if (chr->avail_connections < 1) {
+ return -EEXIST;
+ }
+ *ptr = chr;
+ --chr->avail_connections;
+ return 0;
+}
+
+static void release_chr(Object *obj, const char *name, void *opaque)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (*ptr) {
+ qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL);
+ }
+}
+
+
+static const char *print_chr(void *ptr)
+{
+ CharDriverState *chr = ptr;
+
+ return chr->label ? chr->label : "";
+}
+
+static void get_chr(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ get_pointer(obj, v, opaque, print_chr, name, errp);
+}
+
+static void set_chr(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ set_pointer(obj, v, opaque, parse_chr, name, errp);
+}
+
+PropertyInfo qdev_prop_chr = {
+ .name = "chr",
+ .get = get_chr,
+ .set = set_chr,
+ .release = release_chr,
+};
+
+/* --- netdev device --- */
+
+static int parse_netdev(DeviceState *dev, const char *str, void **ptr)
+{
+ NetClientState *netdev = qemu_find_netdev(str);
+
+ if (netdev == NULL) {
+ return -ENOENT;
+ }
+ if (netdev->peer) {
+ return -EEXIST;
+ }
+ *ptr = netdev;
+ return 0;
+}
+
+static const char *print_netdev(void *ptr)
+{
+ NetClientState *netdev = ptr;
+
+ return netdev->name ? netdev->name : "";
+}
+
+static void get_netdev(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ get_pointer(obj, v, opaque, print_netdev, name, errp);
+}
+
+static void set_netdev(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ set_pointer(obj, v, opaque, parse_netdev, name, errp);
+}
+
+PropertyInfo qdev_prop_netdev = {
+ .name = "netdev",
+ .get = get_netdev,
+ .set = set_netdev,
+};
+
+void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
+{
+ qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
+ if (nd->netdev)
+ qdev_prop_set_netdev(dev, "netdev", nd->netdev);
+ if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
+ object_property_find(OBJECT(dev), "vectors", NULL)) {
+ qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
+ }
+ nd->instantiated = 1;
+}
+
+/* --- vlan --- */
+
+static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (*ptr) {
+ int id;
+ if (!net_hub_id_for_client(*ptr, &id)) {
+ return snprintf(dest, len, "%d", id);
+ }
+ }
+
+ return snprintf(dest, len, "<null>");
+}
+
+static void get_vlan(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
+ int32_t id = -1;
+
+ if (*ptr) {
+ int hub_id;
+ if (!net_hub_id_for_client(*ptr, &hub_id)) {
+ id = hub_id;
+ }
+ }
+
+ visit_type_int32(v, &id, name, errp);
+}
+
+static void set_vlan(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
+ Error *local_err = NULL;
+ int32_t id;
+ NetClientState *hubport;
+
+ if (dev->state != DEV_STATE_CREATED) {
+ error_set(errp, QERR_PERMISSION_DENIED);
+ return;
+ }
+
+ visit_type_int32(v, &id, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ if (id == -1) {
+ *ptr = NULL;
+ return;
+ }
+
+ hubport = net_hub_port_find(id);
+ if (!hubport) {
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE,
+ name, prop->info->name);
+ return;
+ }
+ *ptr = hubport;
+}
+
+PropertyInfo qdev_prop_vlan = {
+ .name = "vlan",
+ .print = print_vlan,
+ .get = get_vlan,
+ .set = set_vlan,
+};
+
+
+int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value)
+{
+ Error *errp = NULL;
+ const char *bdrv_name = value ? bdrv_get_device_name(value) : "";
+ object_property_set_str(OBJECT(dev), bdrv_name,
+ name, &errp);
+ if (errp) {
+ qerror_report_err(errp);
+ error_free(errp);
+ return -1;
+ }
+ return 0;
+}
+
+void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value)
+{
+ if (qdev_prop_set_drive(dev, name, value) < 0) {
+ exit(1);
+ }
+}
+
+void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value)
+{
+ Error *errp = NULL;
+ assert(!value || value->label);
+ object_property_set_str(OBJECT(dev),
+ value ? value->label : "", name, &errp);
+ assert_no_error(errp);
+}
+
+void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value)
+{
+ Error *errp = NULL;
+ assert(!value || value->name);
+ object_property_set_str(OBJECT(dev),
+ value ? value->name : "", name, &errp);
+ assert_no_error(errp);
+}
+
+static int qdev_add_one_global(QemuOpts *opts, void *opaque)
+{
+ GlobalProperty *g;
+
+ g = g_malloc0(sizeof(*g));
+ g->driver = qemu_opt_get(opts, "driver");
+ g->property = qemu_opt_get(opts, "property");
+ g->value = qemu_opt_get(opts, "value");
+ qdev_prop_register_global(g);
+ return 0;
+}
+
+void qemu_add_globals(void)
+{
+ qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
+}
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 81d901c..9ec04be 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -13,49 +13,6 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
return ptr;
}
-static void get_pointer(Object *obj, Visitor *v, Property *prop,
- const char *(*print)(void *ptr),
- const char *name, Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- void **ptr = qdev_get_prop_ptr(dev, prop);
- char *p;
-
- p = (char *) (*ptr ? print(*ptr) : "");
- visit_type_str(v, &p, name, errp);
-}
-
-static void set_pointer(Object *obj, Visitor *v, Property *prop,
- int (*parse)(DeviceState *dev, const char *str,
- void **ptr),
- const char *name, Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- Error *local_err = NULL;
- void **ptr = qdev_get_prop_ptr(dev, prop);
- char *str;
- int ret;
-
- if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
- return;
- }
-
- visit_type_str(v, &str, name, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- if (!*str) {
- g_free(str);
- *ptr = NULL;
- return;
- }
- ret = parse(dev, str, ptr);
- error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
- g_free(str);
-}
-
static void get_enum(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
@@ -476,227 +433,6 @@ PropertyInfo qdev_prop_string = {
.set = set_string,
};
-/* --- drive --- */
-
-static int parse_drive(DeviceState *dev, const char *str, void **ptr)
-{
- BlockDriverState *bs;
-
- bs = bdrv_find(str);
- if (bs == NULL)
- return -ENOENT;
- if (bdrv_attach_dev(bs, dev) < 0)
- return -EEXIST;
- *ptr = bs;
- return 0;
-}
-
-static void release_drive(Object *obj, const char *name, void *opaque)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
- BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
-
- if (*ptr) {
- bdrv_detach_dev(*ptr, dev);
- blockdev_auto_del(*ptr);
- }
-}
-
-static const char *print_drive(void *ptr)
-{
- return bdrv_get_device_name(ptr);
-}
-
-static void get_drive(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- get_pointer(obj, v, opaque, print_drive, name, errp);
-}
-
-static void set_drive(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- set_pointer(obj, v, opaque, parse_drive, name, errp);
-}
-
-PropertyInfo qdev_prop_drive = {
- .name = "drive",
- .get = get_drive,
- .set = set_drive,
- .release = release_drive,
-};
-
-/* --- character device --- */
-
-static int parse_chr(DeviceState *dev, const char *str, void **ptr)
-{
- CharDriverState *chr = qemu_chr_find(str);
- if (chr == NULL) {
- return -ENOENT;
- }
- if (chr->avail_connections < 1) {
- return -EEXIST;
- }
- *ptr = chr;
- --chr->avail_connections;
- return 0;
-}
-
-static void release_chr(Object *obj, const char *name, void *opaque)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
- CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
-
- if (*ptr) {
- qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL);
- }
-}
-
-
-static const char *print_chr(void *ptr)
-{
- CharDriverState *chr = ptr;
-
- return chr->label ? chr->label : "";
-}
-
-static void get_chr(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- get_pointer(obj, v, opaque, print_chr, name, errp);
-}
-
-static void set_chr(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- set_pointer(obj, v, opaque, parse_chr, name, errp);
-}
-
-PropertyInfo qdev_prop_chr = {
- .name = "chr",
- .get = get_chr,
- .set = set_chr,
- .release = release_chr,
-};
-
-/* --- netdev device --- */
-
-static int parse_netdev(DeviceState *dev, const char *str, void **ptr)
-{
- NetClientState *netdev = qemu_find_netdev(str);
-
- if (netdev == NULL) {
- return -ENOENT;
- }
- if (netdev->peer) {
- return -EEXIST;
- }
- *ptr = netdev;
- return 0;
-}
-
-static const char *print_netdev(void *ptr)
-{
- NetClientState *netdev = ptr;
-
- return netdev->name ? netdev->name : "";
-}
-
-static void get_netdev(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- get_pointer(obj, v, opaque, print_netdev, name, errp);
-}
-
-static void set_netdev(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- set_pointer(obj, v, opaque, parse_netdev, name, errp);
-}
-
-PropertyInfo qdev_prop_netdev = {
- .name = "netdev",
- .get = get_netdev,
- .set = set_netdev,
-};
-
-/* --- vlan --- */
-
-static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
-{
- NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
-
- if (*ptr) {
- int id;
- if (!net_hub_id_for_client(*ptr, &id)) {
- return snprintf(dest, len, "%d", id);
- }
- }
-
- return snprintf(dest, len, "<null>");
-}
-
-static void get_vlan(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
- NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
- int32_t id = -1;
-
- if (*ptr) {
- int hub_id;
- if (!net_hub_id_for_client(*ptr, &hub_id)) {
- id = hub_id;
- }
- }
-
- visit_type_int32(v, &id, name, errp);
-}
-
-static void set_vlan(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
- NetClientState **ptr = qdev_get_prop_ptr(dev, prop);
- Error *local_err = NULL;
- int32_t id;
- NetClientState *hubport;
-
- if (dev->state != DEV_STATE_CREATED) {
- error_set(errp, QERR_PERMISSION_DENIED);
- return;
- }
-
- visit_type_int32(v, &id, name, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- if (id == -1) {
- *ptr = NULL;
- return;
- }
-
- hubport = net_hub_port_find(id);
- if (!hubport) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- name, prop->info->name);
- return;
- }
- *ptr = hubport;
-}
-
-PropertyInfo qdev_prop_vlan = {
- .name = "vlan",
- .print = print_vlan,
- .get = get_vlan,
- .set = set_vlan,
-};
-
/* --- pointer --- */
/* Not a proper property, just for dirty hacks. TODO Remove it! */
@@ -1158,44 +894,6 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value)
assert_no_error(errp);
}
-int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value)
-{
- Error *errp = NULL;
- const char *bdrv_name = value ? bdrv_get_device_name(value) : "";
- object_property_set_str(OBJECT(dev), bdrv_name,
- name, &errp);
- if (errp) {
- qerror_report_err(errp);
- error_free(errp);
- return -1;
- }
- return 0;
-}
-
-void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value)
-{
- if (qdev_prop_set_drive(dev, name, value) < 0) {
- exit(1);
- }
-}
-void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value)
-{
- Error *errp = NULL;
- assert(!value || value->label);
- object_property_set_str(OBJECT(dev),
- value ? value->label : "", name, &errp);
- assert_no_error(errp);
-}
-
-void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value)
-{
- Error *errp = NULL;
- assert(!value || value->name);
- object_property_set_str(OBJECT(dev),
- value ? value->name : "", name, &errp);
- assert_no_error(errp);
-}
-
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
{
Error *errp = NULL;
@@ -1231,7 +929,7 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
-static void qdev_prop_register_global(GlobalProperty *prop)
+void qdev_prop_register_global(GlobalProperty *prop)
{
QTAILQ_INSERT_TAIL(&global_props, prop, next);
}
@@ -1262,20 +960,3 @@ void qdev_prop_set_globals(DeviceState *dev)
class = object_class_get_parent(class);
} while (class);
}
-
-static int qdev_add_one_global(QemuOpts *opts, void *opaque)
-{
- GlobalProperty *g;
-
- g = g_malloc0(sizeof(*g));
- g->driver = qemu_opt_get(opts, "driver");
- g->property = qemu_opt_get(opts, "property");
- g->value = qemu_opt_get(opts, "value");
- qdev_prop_register_global(g);
- return 0;
-}
-
-void qemu_add_globals(void)
-{
- qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
-}
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
index 5b046ab..ddcf774 100644
--- a/hw/qdev-properties.h
+++ b/hw/qdev-properties.h
@@ -116,6 +116,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
/* FIXME: Remove opaque pointer properties. */
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
+void qdev_prop_register_global(GlobalProperty *prop);
void qdev_prop_register_global_list(GlobalProperty *props);
void qdev_prop_set_globals(DeviceState *dev);
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
diff --git a/hw/qdev.c b/hw/qdev.c
index 15b967d..aaae3a4 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -25,7 +25,6 @@
inherit from a particular bus (e.g. PCI or I2C) rather than
this API directly. */
-#include "net.h"
#include "qdev.h"
#include "hw/reset.h"
#include "sysemu.h"
@@ -313,18 +312,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
dev->gpio_out[n] = pin;
}
-void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
-{
- qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
- if (nd->netdev)
- qdev_prop_set_netdev(dev, "netdev", nd->netdev);
- if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
- object_property_find(OBJECT(dev), "vectors", NULL)) {
- qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
- }
- nd->instantiated = 1;
-}
-
BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
{
BusState *bus;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 17+ messages in thread