[Top][All Lists]

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

[Qemu-devel] Re: make qdev to use already assigned memory

From: Gerd Hoffmann
Subject: [Qemu-devel] Re: make qdev to use already assigned memory
Date: Fri, 11 Sep 2009 17:26:25 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3


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;

     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.


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.


reply via email to

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