qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] qdev and blockdev refcount leak fixes
@ 2013-09-10 16:21 Stefan Hajnoczi
  2013-09-10 16:21 ` [Qemu-devel] [PATCH 1/6] blockdev: fix drive_init() opts and bs_opts leaks Stefan Hajnoczi
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2013-09-10 16:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Michael Tokarev, Markus Armbruster,
	Stefan Hajnoczi, Paolo Bonzini, Andreas Faerber

It started with a bug report along these lines:

  (qemu) device_add virtio-blk-pci,drive=drive0,x-data-plane=on
  device is incompatible with x-data-plane, use scsi=off
  Device initialization failed.
  Device initialization failed.
  Device 'virtio-blk-pci' could not be initialized
  (qemu) drive_del drive0
  (qemu) drive_add 0 if=none,id=drive0
  Duplicate ID 'drive0' for drive

The drive_add command should succeed since the old "drive0" was deleted.

With the help of Andreas and Paolo we figured out that the problem is not
virtio-blk or dataplane.  There are actually two problems:

1. qdev_device_add() must release its DeviceState reference if
   qdev_init() failed.

2. blockdev_init() must release its QemuOpts on failure or early return when no
   file= option was specified.

This series fixes these problems and then qtest test cases for both bugs.  In
order to do this we need to add QMP response objects to the libqtest API, which
currently discards QMP responses.

Patches 1 & 2 fix the leaks.
Patches 2 & 3 add QMP response objects to libqtest.
Patches 5 & 6 add qtest test cases for the bugs.

Stefan Hajnoczi (6):
  blockdev: fix drive_init() opts and bs_opts leaks
  qdev: unref qdev when device_add fails
  libqtest: rename qmp() to qmp_discard_response()
  libqtest: add qmp(fmt, ...) -> QDict* function
  blockdev-test: add test case for drive_add duplicate IDs
  qdev-monitor-test: add device_add leak test cases

 blockdev.c                | 51 +++++++++++++++--------------
 qdev-monitor.c            |  4 ++-
 tests/Makefile            |  4 +++
 tests/blockdev-test.c     | 59 ++++++++++++++++++++++++++++++++++
 tests/boot-order-test.c   |  4 +--
 tests/fdc-test.c          | 15 +++++----
 tests/ide-test.c          | 10 +++---
 tests/libqtest.c          | 72 +++++++++++++++++++++++++++++++----------
 tests/libqtest.h          | 51 +++++++++++++++++++++++++----
 tests/qdev-monitor-test.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 290 insertions(+), 61 deletions(-)
 create mode 100644 tests/blockdev-test.c
 create mode 100644 tests/qdev-monitor-test.c

-- 
1.8.3.1

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

end of thread, other threads:[~2013-09-11  5:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 16:21 [Qemu-devel] [PATCH 0/6] qdev and blockdev refcount leak fixes Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 1/6] blockdev: fix drive_init() opts and bs_opts leaks Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 2/6] qdev: unref qdev when device_add fails Stefan Hajnoczi
2013-09-10 16:49   ` Paolo Bonzini
2013-09-10 16:59     ` Andreas Färber
2013-09-10 17:04       ` Paolo Bonzini
2013-09-11  5:56       ` Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 3/6] libqtest: rename qmp() to qmp_discard_response() Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 4/6] libqtest: add qmp(fmt, ...) -> QDict* function Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 5/6] blockdev-test: add test case for drive_add duplicate IDs Stefan Hajnoczi
2013-09-10 16:21 ` [Qemu-devel] [PATCH 6/6] qdev-monitor-test: add device_add leak test cases Stefan Hajnoczi

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).