diff mbox

segfault due to missing qdev_create()?

Message ID AANLkTi=wTmt1kYJv5DNQhzuHvOfScp+GtB-GMZmpwyDu@mail.gmail.com
State New, archived
Headers show

Commit Message

Hollis Blanchard Aug. 4, 2010, 6:27 p.m. UTC
I am able to run qemu with the following commandline:
/usr/local/bin/qemu-system-ppcemb -enable-kvm -kernel uImage.bamboo
-nographic -M bamboo ppc440-angstrom-linux.img

However, when I try to use virtio instead, I get this segfault:
/usr/local/bin/qemu-system-ppcemb -enable-kvm -kernel uImage.bamboo
-drive file=ppc440-angstrom-linux.img,if=virtio -nographic -M bamboo

#0  0x1009864c in qbus_find_recursive (bus=0x0, name=0x0, info=0x10287238)
    at /home/hollisb/work/qemu.git/hw/qdev.c:461
#1  0x10099cc4 in qdev_device_add (opts=0x108a07a0)
    at /home/hollisb/work/qemu.git/hw/qdev.c:229
#2  0x101a4220 in device_init_func (opts=<value optimized out>,
    opaque=<value optimized out>) at /home/hollisb/work/qemu.git/vl.c:1519
#3  0x1002baf8 in qemu_opts_foreach (list=<value optimized out>,
    func=0x101a4204 <device_init_func>, opaque=0x0,
    abort_on_failure=<value optimized out>) at qemu-option.c:978
#4  0x101a68e0 in main (argc=<value optimized out>,
    argv=<value optimized out>, envp=<value optimized out>)
    at /home/hollisb/work/qemu.git/vl.c:2890

This patch avoids the segfault, but just gives me this message: No
'PCI' bus found for device 'virtio-blk-pci'


FWIW, hw/ppc4xx_pci.c is my PCI controller. Do I need to add some qdev
magic to that file to make this work?

-Hollis

Comments

Markus Armbruster Aug. 21, 2010, 10:19 a.m. UTC | #1
Hollis Blanchard <hollis@penguinppc.org> writes:

> I am able to run qemu with the following commandline:
> /usr/local/bin/qemu-system-ppcemb -enable-kvm -kernel uImage.bamboo
> -nographic -M bamboo ppc440-angstrom-linux.img
>
> However, when I try to use virtio instead, I get this segfault:
> /usr/local/bin/qemu-system-ppcemb -enable-kvm -kernel uImage.bamboo
> -drive file=ppc440-angstrom-linux.img,if=virtio -nographic -M bamboo
>
> #0  0x1009864c in qbus_find_recursive (bus=0x0, name=0x0, info=0x10287238)
>     at /home/hollisb/work/qemu.git/hw/qdev.c:461
> #1  0x10099cc4 in qdev_device_add (opts=0x108a07a0)
>     at /home/hollisb/work/qemu.git/hw/qdev.c:229
> #2  0x101a4220 in device_init_func (opts=<value optimized out>,
>     opaque=<value optimized out>) at /home/hollisb/work/qemu.git/vl.c:1519
> #3  0x1002baf8 in qemu_opts_foreach (list=<value optimized out>,
>     func=0x101a4204 <device_init_func>, opaque=0x0,
>     abort_on_failure=<value optimized out>) at qemu-option.c:978
> #4  0x101a68e0 in main (argc=<value optimized out>,
>     argv=<value optimized out>, envp=<value optimized out>)
>     at /home/hollisb/work/qemu.git/vl.c:2890
>
> This patch avoids the segfault, but just gives me this message: No
> 'PCI' bus found for device 'virtio-blk-pci'
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index e99c73f..8fe4f06 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -455,6 +455,9 @@ static BusState *qbus_find_recursive(BusState *bus, const ch
>      BusState *child, *ret;
>      int match = 1;
>
> +       if (!bus)
> +               return NULL;
> +
>      if (name && (strcmp(bus->name, name) != 0)) {
>          match = 0;
>      }

Is your main_system_bus still null?

We should report the problem, not crash, of course.

>
> FWIW, hw/ppc4xx_pci.c is my PCI controller. Do I need to add some qdev
> magic to that file to make this work?

Yes, you need to convert the device providing your PCI bus to qdev
before you can use any qdevified PCI devices.

piix_pci.c could serve as an example.  qdev works starts with commit
8a14daa5.

My KVM Forum slides might help with the basics:
http://www.linux-kvm.org/wiki/images/f/fe/2010-forum-armbru-qdev.pdf

I can try to assist and advice, just ask.
diff mbox

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f..8fe4f06 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -455,6 +455,9 @@  static BusState *qbus_find_recursive(BusState *bus, const ch
     BusState *child, *ret;
     int match = 1;

+       if (!bus)
+               return NULL;
+
     if (name && (strcmp(bus->name, name) != 0)) {
         match = 0;
     }