Message ID | 1251791775-5358-2-git-send-email-kraxel@redhat.com |
---|---|
State | Superseded |
Headers | show |
On Tue, Sep 1, 2009 at 10:56 AM, Gerd Hoffmann<kraxel@redhat.com> wrote: > @@ -110,6 +110,9 @@ struct DeviceInfo { > Property *props; > int no_user; > > + /* callbacks */ > + QEMUResetHandler *reset; > + This would remove the need for registration but I had in my mind a bit more complex solution like VMState structures. Even better, VMState could be enhanced so that the reset value of the fields could be specified (when not zero).
On Tue, Sep 1, 2009 at 7:36 PM, Juan Quintela<quintela@trasno.org> wrote: > Blue Swirl <blauwirbel@gmail.com> wrote: >> On Tue, Sep 1, 2009 at 10:56 AM, Gerd Hoffmann<kraxel@redhat.com> wrote: >> >>> @@ -110,6 +110,9 @@ struct DeviceInfo { >>> Property *props; >>> int no_user; >>> >>> + /* callbacks */ >>> + QEMUResetHandler *reset; >>> + >> >> This would remove the need for registration but I had in my mind a bit >> more complex solution like VMState structures. Even better, VMState >> could be enhanced so that the reset value of the fields could be >> specified (when not zero). > > That soonds nice, but ... not every field in the structures are used > during migration. Do we want to merge both things? New flags that tell whether a VMState field is used for savevm or reset?
On 09/01/09 18:30, Blue Swirl wrote: > On Tue, Sep 1, 2009 at 10:56 AM, Gerd Hoffmann<kraxel@redhat.com> wrote: > >> @@ -110,6 +110,9 @@ struct DeviceInfo { >> Property *props; >> int no_user; >> >> + /* callbacks */ >> + QEMUResetHandler *reset; >> + > > This would remove the need for registration but I had in my mind a bit > more complex solution like VMState structures. Even better, VMState > could be enhanced so that the reset value of the fields could be > specified (when not zero). Interesting idea. Could work out pretty nicely. Chances are that the overlap of the fields which must be initialized on reset and which must be saved on migration is pretty high. If so the integration into vmstate would indeed make alot of sense. cheers, Gerd
diff --git a/hw/qdev.c b/hw/qdev.c index ff2f096..e045968 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -211,12 +211,21 @@ DeviceState *qdev_device_add(QemuOpts *opts) calling this function. */ int qdev_init(DeviceState *dev) { - return dev->info->init(dev, dev->info); + int rc; + + rc = dev->info->init(dev, dev->info); + if (rc < 0) + return rc; + if (dev->info->reset) + qemu_register_reset(dev->info->reset, dev); + return 0; } /* Unlink device from bus and free the structure. */ void qdev_free(DeviceState *dev) { + if (dev->info->reset) + qemu_unregister_reset(dev->info->reset, dev); LIST_REMOVE(dev, sibling); qemu_free(dev); } diff --git a/hw/qdev.h b/hw/qdev.h index af735d7..fde29ea 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -110,6 +110,9 @@ struct DeviceInfo { Property *props; int no_user; + /* callbacks */ + QEMUResetHandler *reset; + /* Private to qdev / bus. */ qdev_initfn init; BusInfo *bus_info;
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/qdev.c | 11 ++++++++++- hw/qdev.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletions(-)