qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] traversal termination in qbus_find_recursive() due to "max_


From: Laszlo Ersek
Subject: [Qemu-devel] traversal termination in qbus_find_recursive() due to "max_dev"
Date: Thu, 31 Jan 2013 14:23:56 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130108 Thunderbird/10.0.12

Hi,

I'm working on propagating errors out to do_device_add(). I've come
accross qbus_find_recursive().

Re commit 1395af6f ("qdev: add a maximum device allowed field for the
bus."), could someone please explain:

(1) why the early termination due to max_index vs. max_dev merits an
error message -- both non-recursive call-sites print an error of their
own anyway,

(2) why the

  max_dev != 0 &&
  max_dev <= max_index &&
  name != NULL

condition justifies traversal termination -- in general, a bus called
"foo", albeit full of devices, could allow some of those devices to be a
child bus. Let's call one such (direct) child bus "bar".

If we're looking for "bar", or for one of its descendants, the current
logic seems to stop the search early, at "foo".

I think "bus_class->max_dev" should be checked only when we're actually
trying to add the device to the bus. (In qdev_set_parent_bus() -->
bus_add_child().)

- bus_add_child() should check the limit and set an Error,
- qdev_set_parent_bus_nofail() would abort() if there's an Error,
- qdev_set_parent_bus() would change signature and propagate error,
- all callers would be converted to either the new _nofail() or the old
function with the new signature.

I can try to write the patch if there's consensus about what should happen.

Thoughts?

Thanks!
Laszlo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]