From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YD6MB-0002Vo-8o for qemu-devel@nongnu.org; Mon, 19 Jan 2015 02:02:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YD6M6-0005JR-Fz for qemu-devel@nongnu.org; Mon, 19 Jan 2015 02:02:39 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:2846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YD6M5-0005GW-K8 for qemu-devel@nongnu.org; Mon, 19 Jan 2015 02:02:34 -0500 From: Ting Wang Date: Mon, 19 Jan 2015 15:01:58 +0800 Message-ID: <1421650918-90656-1-git-send-email-kathy.wangting@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] qdev: The sequence of devices added to bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pbonzini@redhat.com, qemu-devel@nongnu.org Cc: Ting Wang When add a qdev device to bus, bus_add_child will be called. But in this function, the new device is inserted to the head of the list. That means the sequence will be reversed. For example, if there are three virtio-scsi devices with lun 0 to 2 in the same controller, in the Guest, device with lun 0 is always named as sda, device with lun 1 is named as sdc, and device with lun 2 is named as sdb. So the order is different from the lun number. Signed-off-by: Ting Wang --- hw/core/qdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 901f289..7d830a6 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -89,7 +89,7 @@ static void bus_add_child(BusState *bus, DeviceState *child) kid->child = child; object_ref(OBJECT(kid->child)); - QTAILQ_INSERT_HEAD(&bus->children, kid, sibling); + QTAILQ_INSERT_TAIL(&bus->children, kid, sibling); /* This transfers ownership of kid->child to the property. */ snprintf(name, sizeof(name), "child[%d]", kid->index); -- 1.8.5