Message ID | 20170601212921.30241-4-quintela@redhat.com |
---|---|
State | New |
Headers | show |
On Thu, Jun 01, 2017 at 11:29:13PM +0200, Juan Quintela wrote: > They are indpendent, and nowadays almost every device register things > with qdev->vmsd. > > Signed-off-by: Juan Quintela <quintela@redhat.com> > --- > hw/net/vmxnet3.c | 1 + > hw/ppc/spapr.c | 1 + > hw/s390x/s390-skeys.c | 1 + > hw/s390x/s390-virtio-ccw.c | 1 + > include/migration/register.h | 64 ++++++++++++++++++++++++++++++++++++++++++++ > include/migration/vmstate.h | 45 ------------------------------- > migration/block.c | 1 + > migration/ram.c | 1 + > migration/savevm.c | 1 + > slirp/slirp.c | 1 + > 10 files changed, 72 insertions(+), 45 deletions(-) > create mode 100644 include/migration/register.h > > diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c > index 8b1fab2..21ac646 100644 > --- a/hw/net/vmxnet3.c > +++ b/hw/net/vmxnet3.c > @@ -26,6 +26,7 @@ > #include "qemu/bswap.h" > #include "hw/pci/msix.h" > #include "hw/pci/msi.h" > +#include "migration/register.h" > > #include "vmxnet3.h" > #include "vmxnet_debug.h" > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index ab3aab1..a44efbf 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -39,6 +39,7 @@ > #include "sysemu/hw_accel.h" > #include "kvm_ppc.h" > #include "migration/migration.h" > +#include "migration/register.h" > #include "mmu-hash64.h" > #include "mmu-book3s-v3.h" > #include "qom/cpu.h" > diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c > index 619152c..58f084a 100644 > --- a/hw/s390x/s390-skeys.c > +++ b/hw/s390x/s390-skeys.c > @@ -15,6 +15,7 @@ > #include "hw/s390x/storage-keys.h" > #include "qemu/error-report.h" > #include "sysemu/kvm.h" > +#include "migration/register.h" > > #define S390_SKEYS_BUFFER_SIZE 131072 /* Room for 128k storage keys */ > #define S390_SKEYS_SAVE_FLAG_EOS 0x01 > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c > index c9021f2..51d14d3 100644 > --- a/hw/s390x/s390-virtio-ccw.c > +++ b/hw/s390x/s390-virtio-ccw.c > @@ -28,6 +28,7 @@ > #include "ipl.h" > #include "hw/s390x/s390-virtio-ccw.h" > #include "hw/s390x/css-bridge.h" > +#include "migration/register.h" > > static const char *const reset_dev_types[] = { > TYPE_VIRTUAL_CSS_BRIDGE, > diff --git a/include/migration/register.h b/include/migration/register.h > new file mode 100644 > index 0000000..844afaf > --- /dev/null > +++ b/include/migration/register.h > @@ -0,0 +1,64 @@ > +/* > + * QEMU migration vmstate registration > + * > + * Copyright IBM, Corp. 2008 > + * > + * Authors: > + * Anthony Liguori <aliguori@us.ibm.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + */ > + > +#ifndef MIGRATION_REGISTER_H > +#define MIGRATION_REGISTER_H > + > +typedef void SaveStateHandler(QEMUFile *f, void *opaque); > +typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); > + > +typedef struct SaveVMHandlers { > + /* This runs inside the iothread lock. */ > + SaveStateHandler *save_state; > + > + void (*cleanup)(void *opaque); > + int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); > + int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); > + > + /* This runs both outside and inside the iothread lock. */ > + bool (*is_active)(void *opaque); > + > + /* This runs outside the iothread lock in the migration case, and > + * within the lock in the savevm case. The callback had better only > + * use data that is local to the migration thread or protected > + * by other locks. > + */ > + int (*save_live_iterate)(QEMUFile *f, void *opaque); > + > + /* This runs outside the iothread lock! */ > + int (*save_live_setup)(QEMUFile *f, void *opaque); > + void (*save_live_pending)(QEMUFile *f, void *opaque, > + uint64_t threshold_size, > + uint64_t *non_postcopiable_pending, > + uint64_t *postcopiable_pending); > + LoadStateHandler *load_state; > +} SaveVMHandlers; > + > +int register_savevm(DeviceState *dev, > + const char *idstr, > + int instance_id, > + int version_id, > + SaveStateHandler *save_state, > + LoadStateHandler *load_state, > + void *opaque); Looks like this patch needs a rebasing since this function is already remove... > + > +int register_savevm_live(DeviceState *dev, > + const char *idstr, > + int instance_id, > + int version_id, > + SaveVMHandlers *ops, > + void *opaque); > + > +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); > + > +#endif > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h > index b95c9bb..6de554d 100644 > --- a/include/migration/vmstate.h > +++ b/include/migration/vmstate.h > @@ -29,53 +29,8 @@ > > #include "migration/qjson.h" > > -typedef void SaveStateHandler(QEMUFile *f, void *opaque); > typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); Should be removed too? Other than mentioned above: Reviewed-by: Peter Xu <peterx@redhat.com> Thanks, > > -typedef struct SaveVMHandlers { > - /* This runs inside the iothread lock. */ > - SaveStateHandler *save_state; > - > - void (*cleanup)(void *opaque); > - int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); > - int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); > - > - /* This runs both outside and inside the iothread lock. */ > - bool (*is_active)(void *opaque); > - > - /* This runs outside the iothread lock in the migration case, and > - * within the lock in the savevm case. The callback had better only > - * use data that is local to the migration thread or protected > - * by other locks. > - */ > - int (*save_live_iterate)(QEMUFile *f, void *opaque); > - > - /* This runs outside the iothread lock! */ > - int (*save_live_setup)(QEMUFile *f, void *opaque); > - void (*save_live_pending)(QEMUFile *f, void *opaque, > - uint64_t threshold_size, > - uint64_t *non_postcopiable_pending, > - uint64_t *postcopiable_pending); > - LoadStateHandler *load_state; > -} SaveVMHandlers;
Peter Xu <peterx@redhat.com> wrote: > On Thu, Jun 01, 2017 at 11:29:13PM +0200, Juan Quintela wrote: >> They are indpendent, and nowadays almost every device register things >> with qdev->vmsd. >> >> Signed-off-by: Juan Quintela <quintela@redhat.com> >> + >> +int register_savevm(DeviceState *dev, >> + const char *idstr, >> + int instance_id, >> + int version_id, >> + SaveStateHandler *save_state, >> + LoadStateHandler *load_state, >> + void *opaque); > > Looks like this patch needs a rebasing since this function is already > remove... > >> + >> +int register_savevm_live(DeviceState *dev, >> + const char *idstr, >> + int instance_id, >> + int version_id, >> + SaveVMHandlers *ops, >> + void *opaque); >> + >> +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); >> + >> +#endif >> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h >> index b95c9bb..6de554d 100644 >> --- a/include/migration/vmstate.h >> +++ b/include/migration/vmstate.h >> @@ -29,53 +29,8 @@ >> >> #include "migration/qjson.h" >> >> -typedef void SaveStateHandler(QEMUFile *f, void *opaque); >> typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); > > Should be removed too? > > Other than mentioned above: > > Reviewed-by: Peter Xu <peterx@redhat.com> Local copy already have this two bits fixed. It is just that I posted this series before that changes got into upstream. Later, Juan.
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 8b1fab2..21ac646 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -26,6 +26,7 @@ #include "qemu/bswap.h" #include "hw/pci/msix.h" #include "hw/pci/msi.h" +#include "migration/register.h" #include "vmxnet3.h" #include "vmxnet_debug.h" diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ab3aab1..a44efbf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -39,6 +39,7 @@ #include "sysemu/hw_accel.h" #include "kvm_ppc.h" #include "migration/migration.h" +#include "migration/register.h" #include "mmu-hash64.h" #include "mmu-book3s-v3.h" #include "qom/cpu.h" diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 619152c..58f084a 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -15,6 +15,7 @@ #include "hw/s390x/storage-keys.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" +#include "migration/register.h" #define S390_SKEYS_BUFFER_SIZE 131072 /* Room for 128k storage keys */ #define S390_SKEYS_SAVE_FLAG_EOS 0x01 diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c9021f2..51d14d3 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -28,6 +28,7 @@ #include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/css-bridge.h" +#include "migration/register.h" static const char *const reset_dev_types[] = { TYPE_VIRTUAL_CSS_BRIDGE, diff --git a/include/migration/register.h b/include/migration/register.h new file mode 100644 index 0000000..844afaf --- /dev/null +++ b/include/migration/register.h @@ -0,0 +1,64 @@ +/* + * QEMU migration vmstate registration + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori <aliguori@us.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef MIGRATION_REGISTER_H +#define MIGRATION_REGISTER_H + +typedef void SaveStateHandler(QEMUFile *f, void *opaque); +typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); + +typedef struct SaveVMHandlers { + /* This runs inside the iothread lock. */ + SaveStateHandler *save_state; + + void (*cleanup)(void *opaque); + int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); + int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); + + /* This runs both outside and inside the iothread lock. */ + bool (*is_active)(void *opaque); + + /* This runs outside the iothread lock in the migration case, and + * within the lock in the savevm case. The callback had better only + * use data that is local to the migration thread or protected + * by other locks. + */ + int (*save_live_iterate)(QEMUFile *f, void *opaque); + + /* This runs outside the iothread lock! */ + int (*save_live_setup)(QEMUFile *f, void *opaque); + void (*save_live_pending)(QEMUFile *f, void *opaque, + uint64_t threshold_size, + uint64_t *non_postcopiable_pending, + uint64_t *postcopiable_pending); + LoadStateHandler *load_state; +} SaveVMHandlers; + +int register_savevm(DeviceState *dev, + const char *idstr, + int instance_id, + int version_id, + SaveStateHandler *save_state, + LoadStateHandler *load_state, + void *opaque); + +int register_savevm_live(DeviceState *dev, + const char *idstr, + int instance_id, + int version_id, + SaveVMHandlers *ops, + void *opaque); + +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); + +#endif diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index b95c9bb..6de554d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -29,53 +29,8 @@ #include "migration/qjson.h" -typedef void SaveStateHandler(QEMUFile *f, void *opaque); typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); -typedef struct SaveVMHandlers { - /* This runs inside the iothread lock. */ - SaveStateHandler *save_state; - - void (*cleanup)(void *opaque); - int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); - int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); - - /* This runs both outside and inside the iothread lock. */ - bool (*is_active)(void *opaque); - - /* This runs outside the iothread lock in the migration case, and - * within the lock in the savevm case. The callback had better only - * use data that is local to the migration thread or protected - * by other locks. - */ - int (*save_live_iterate)(QEMUFile *f, void *opaque); - - /* This runs outside the iothread lock! */ - int (*save_live_setup)(QEMUFile *f, void *opaque); - void (*save_live_pending)(QEMUFile *f, void *opaque, - uint64_t threshold_size, - uint64_t *non_postcopiable_pending, - uint64_t *postcopiable_pending); - LoadStateHandler *load_state; -} SaveVMHandlers; - -int register_savevm(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque); - -int register_savevm_live(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveVMHandlers *ops, - void *opaque); - -void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); - typedef struct VMStateInfo VMStateInfo; typedef struct VMStateDescription VMStateDescription; typedef struct VMStateField VMStateField; diff --git a/migration/block.c b/migration/block.c index 4d8c2e9..30ab531 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "block.h" #include "migration/misc.h" #include "migration/migration.h" +#include "migration/register.h" #include "sysemu/blockdev.h" #include "qemu-file.h" #include "migration/vmstate.h" diff --git a/migration/ram.c b/migration/ram.c index f387e9c..31b4d6a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -38,6 +38,7 @@ #include "xbzrle.h" #include "ram.h" #include "migration/migration.h" +#include "migration/register.h" #include "migration/misc.h" #include "qemu-file.h" #include "migration/vmstate.h" diff --git a/migration/savevm.c b/migration/savevm.c index d683877..543635b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -37,6 +37,7 @@ #include "migration/migration.h" #include "migration/snapshot.h" #include "migration/misc.h" +#include "migration/register.h" #include "ram.h" #include "qemu-file-channel.h" #include "qemu-file.h" diff --git a/slirp/slirp.c b/slirp/slirp.c index 2f2ec2c..e988523 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -25,6 +25,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "qemu/error-report.h" +#include "migration/register.h" #include "sysemu/char.h" #include "slirp.h" #include "hw/hw.h"
They are indpendent, and nowadays almost every device register things with qdev->vmsd. Signed-off-by: Juan Quintela <quintela@redhat.com> --- hw/net/vmxnet3.c | 1 + hw/ppc/spapr.c | 1 + hw/s390x/s390-skeys.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + include/migration/register.h | 64 ++++++++++++++++++++++++++++++++++++++++++++ include/migration/vmstate.h | 45 ------------------------------- migration/block.c | 1 + migration/ram.c | 1 + migration/savevm.c | 1 + slirp/slirp.c | 1 + 10 files changed, 72 insertions(+), 45 deletions(-) create mode 100644 include/migration/register.h