From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIc17-0008Bd-7k for qemu-devel@nongnu.org; Tue, 03 Feb 2015 06:51:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIc14-0004nv-1D for qemu-devel@nongnu.org; Tue, 03 Feb 2015 06:51:41 -0500 Received: from mail-la0-f41.google.com ([209.85.215.41]:32870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIc13-0004nr-Q0 for qemu-devel@nongnu.org; Tue, 03 Feb 2015 06:51:37 -0500 Received: by mail-la0-f41.google.com with SMTP id gm9so50823257lab.0 for ; Tue, 03 Feb 2015 03:51:36 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <54CB09E2.9040506@redhat.com> References: <1422592273-4432-1-git-send-email-lersek@redhat.com> <54CB09E2.9040506@redhat.com> From: Peter Maydell Date: Tue, 3 Feb 2015 11:51:16 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH] hw/arm/virt: explain device-to-transport mapping in create_virtio_devices() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: QEMU Developers On 30 January 2015 at 04:34, Laszlo Ersek wrote: > Peter, > > On 01/30/15 05:31, Laszlo Ersek wrote: >> Signed-off-by: Laszlo Ersek >> --- >> hw/arm/virt.c | 32 ++++++++++++++++++++++++++++---- >> 1 file changed, 28 insertions(+), 4 deletions(-) >> >> diff --git a/hw/arm/virt.c b/hw/arm/virt.c >> index 2353440..091e5ee 100644 >> --- a/hw/arm/virt.c >> +++ b/hw/arm/virt.c >> @@ -441,10 +441,27 @@ static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) >> int i; >> hwaddr size = vbi->memmap[VIRT_MMIO].size; >> >> - /* Note that we have to create the transports in forwards order >> - * so that command line devices are inserted lowest address first, >> - * and then add dtb nodes in reverse order so that they appear in >> - * the finished device tree lowest address first. >> + /* We create the transports in forwards order. Since qbus_realize() >> + * prepends (not appends) new child buses, the incrementing loop below will >> + * create a list of virtio-mmio buses with decreasing base addresses. >> + * >> + * When a -device option is processed from the command line, >> + * qbus_find_recursive() picks the next free virtio-mmio bus in forwards >> + * order. The upshot is that -device options in increasing command line >> + * order are mapped to virtio-mmio buses with decreasing base addresses. >> + * >> + * When this code was originally written, that arrangement ensured that the >> + * guest Linux kernel would give the lowest "name" (/dev/vda, eth0, etc) to >> + * the first -device on the command line. (The end-to-end order is a >> + * function of this loop, qbus_realize(), qbus_find_recursive(), and the >> + * guest kernel's name-to-address assignment strategy.) >> + * >> + * Meanwhile, the kernel's traversal seems to have been reserved; see eg. > > can you please s/reserved/reversed/? > > Result of over-editing, sorry. Sure, no problem. I also suggest I add this para: * * In any case, the kernel makes no guarantee about the stability of * enumeration order of virtio devices (as demonstrated by it changing * between kernel versions). For reliable and stable identification * of disks users must use UUIDs or similar mechanisms. -- PMM