From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mm81D-0000k6-CB for qemu-devel@nongnu.org; Fri, 11 Sep 2009 11:26:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mm818-0000fa-Af for qemu-devel@nongnu.org; Fri, 11 Sep 2009 11:26:34 -0400 Received: from [199.232.76.173] (port=35120 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm818-0000fQ-4W for qemu-devel@nongnu.org; Fri, 11 Sep 2009 11:26:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8744) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mm817-0000BH-Eq for qemu-devel@nongnu.org; Fri, 11 Sep 2009 11:26:29 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8BFQSCo019100 for ; Fri, 11 Sep 2009 11:26:28 -0400 Message-ID: <4AAA6C21.8060909@redhat.com> Date: Fri, 11 Sep 2009 17:26:25 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: make qdev to use already assigned memory List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org Hi, > DeviceState *qdev_create_here(DeviceState *dev, BusState *bus, const char *name) > > The only change is that it don't want qemu_malloc(), it just initialize > the device in the memory that I bring there. Why do I want this? I'd prefer to not have such a function. At the end of the qdev conversion we want to have all drivers in a state where you can create the devices using the basic sequence ... (1) qdev_create() (2) setting properties (2) qdev_init() ... from generic code. qdev_create_here() simply doesn't fit in here. It can by definition not be called by generic code. Only a very few special cases could actually make use of it. It would make alot of sense to allow *bus* data structures being embedded though. A bus is never ever created on its own, it is allways created by the parent device (lsi creates a scsi bus, ...). Would that solve your problems? > PIIX3IrqState *irq_state = qemu_malloc(sizeof(*irq_state)); > > irq_state->pic = pic; > dev = qdev_create(NULL, "i440FX-pcihost"); > s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev)); > b = pci_register_bus(&s->busdev.qdev, "pci.0", > piix3_set_irq, pci_slot_get_pirq, irq_state, 0, 4); > s->bus = b; > qdev_init(dev); > > d = pci_create_simple(b, 0, "i440FX"); > *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d); > (*pi440fx_state)->irq_state = irq_state; I think that one can also be solved by splitting pci bus registration and pci bus irq setup into two functions. > hw/fdc.c > struct fdctrl_t { > /* Command FIFO */ /* 1st field */ > uint8_t fifo[512]; > .... > }; > And now I will call qemu_memalign() for the whole structure. Doesn't fly. isa-fdc is pretty close to the state where it can be created via -device, we just need the drive windup. When creating the floppy controller via '-device isa-fdc,driveA=foo,driveB=bar' or simliar, who will call qemu_memalign then? Also note that DeviceState must be at offset zero of the device state struct. cheers, Gerd