qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Monitor command pci_add regressed (qdev)
@ 2009-06-10 17:43 Markus Armbruster
  2009-06-12  8:52 ` Gerd Hoffmann
  2009-06-16 14:24 ` [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..." Markus Armbruster
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Armbruster @ 2009-06-10 17:43 UTC (permalink / raw)
  To: qemu-devel, paul

gdb --args qemu -monitor stdio tmp.qcow2 -S
[...]
QEMU 0.10.50 monitor - type 'help' for more information
(qemu) pci_add pci_addr=auto storage if=virtio,file=foo.img
Program received signal SIGSEGV, Segmentation fault.
0x080630c5 in virtio_blk_init (dev=0x849a008)
    at /home/armbru/work/qemu/hw/virtio-blk.c:368
368         bs->private = dev;

This used to work just fine.

Culprit seems to be commit 07e3af9a.  qdev_init_bdrv() fails, and
virtio_blk_init() doesn't check the failure.

I haven't investigated why qdev_init_bdrv() fails (the old code got the
BlockDriverState just fine).  Regardless, there are scenarios where
qdev_init_bdrv() rightly fails, so virtio_blk_init() needs fixing.

Returning NULL would be easy enough, but its caller
virtio_blk_init_pci() doesn't check its value, and it is a qdev init()
callback, which can't fail.  How to handle the error?  exit(1) would be
just fine for -drive, but not for a monitor command.

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

* Re: [Qemu-devel] Monitor command pci_add regressed (qdev)
  2009-06-10 17:43 [Qemu-devel] Monitor command pci_add regressed (qdev) Markus Armbruster
@ 2009-06-12  8:52 ` Gerd Hoffmann
  2009-06-16 14:24 ` [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..." Markus Armbruster
  1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-06-12  8:52 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, paul

On 06/10/09 19:43, Markus Armbruster wrote:
> gdb --args qemu -monitor stdio tmp.qcow2 -S

> (qemu) pci_add pci_addr=auto storage if=virtio,file=foo.img
> Program received signal SIGSEGV, Segmentation fault.

> Culprit seems to be commit 07e3af9a.  qdev_init_bdrv() fails, and
> virtio_blk_init() doesn't check the failure.
>
> I haven't investigated why qdev_init_bdrv() fails (the old code got the
> BlockDriverState just fine).  Regardless, there are scenarios where
> qdev_init_bdrv() rightly fails, so virtio_blk_init() needs fixing.
>
> Returning NULL would be easy enough, but its caller
> virtio_blk_init_pci() doesn't check its value, and it is a qdev init()
> callback, which can't fail.  How to handle the error?  exit(1) would be
> just fine for -drive, but not for a monitor command.

I think the correct long-term fix is to cleanly separate the guest-side 
stuff (virtio or whatever else block device) and the host-side 
(BlockDriverState) and how the two are linked together.

The BlockDriverState setup can fail for a number of reasons.
The virtio blk setup shouldn't fail.  So setting up BlockDriverState 
first, when succeeded setup virtio-blk, then link the two should work fine.

Dunno how much work that would be with the current qemu code structure 
though.  Maybe we should allow device initialization fail for the time 
being.

cheers,
   Gerd

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

* [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..."
  2009-06-10 17:43 [Qemu-devel] Monitor command pci_add regressed (qdev) Markus Armbruster
  2009-06-12  8:52 ` Gerd Hoffmann
@ 2009-06-16 14:24 ` Markus Armbruster
  2009-06-16 20:58   ` Gerd Hoffmann
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2009-06-16 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: paul

qemu_pci_hot_add_storage() runs qdev_init() twice.  Broken in commit
07e3af9a "Virtio-blk qdev conversion".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/pci-hotplug.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index abe5bae..4d49c29 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -122,7 +122,6 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus,
         break;
     case IF_VIRTIO:
         opaque = pci_create_simple(pci_bus, -1, "virtio-blk-pci");
-        qdev_init(opaque);
         break;
     }
 
-- 
1.6.0.6

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

* Re: [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..."
  2009-06-16 14:24 ` [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..." Markus Armbruster
@ 2009-06-16 20:58   ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-06-16 20:58 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, paul

   Hi,

>       case IF_VIRTIO:
>           opaque = pci_create_simple(pci_bus, -1, "virtio-blk-pci");
> -        qdev_init(opaque);
>           break;

Yep, pci_create_simple() calls qdev_init() already.
Patch looks good.

cheers,
   Gerd

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

end of thread, other threads:[~2009-06-16 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-10 17:43 [Qemu-devel] Monitor command pci_add regressed (qdev) Markus Armbruster
2009-06-12  8:52 ` Gerd Hoffmann
2009-06-16 14:24 ` [Qemu-devel] [PATCH] qdev: Fix regression in "pci_add ... storage if=virtio, ..." Markus Armbruster
2009-06-16 20:58   ` Gerd Hoffmann

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