migration: simplify blockers
PATCH v2 1/1 migration: simplify blockers
Modify migrate_add_blocker and migrate_del_blocker to take an Error ** reason. This allows migration to own the Error object, so that if an error occurs, migration code can free the Error and clear the client handle, simplifying client code. This is a pre-requisite for a future patch that will allow one Error blocker to be registered for multiple migration modes.
No functional change.
--- backends/tpm/tpm_emulator.c | 10 ++-------- block/parallels.c | 6 ++---- block/qcow.c | 6 ++---- block/vdi.c | 6 ++---- block/vhdx.c | 6 ++---- block/vmdk.c | 6 ++---- block/vpc.c | 6 ++---- block/vvfat.c | 6 ++---- dump/dump.c | 4 ++-- hw/9pfs/9p.c | 10 ++-------- hw/display/virtio-gpu-base.c | 8 ++------ hw/intc/arm_gic_kvm.c | 3 +-- hw/intc/arm_gicv3_its_kvm.c | 3 +-- hw/intc/arm_gicv3_kvm.c | 3 +-- hw/misc/ivshmem.c | 8 ++------ hw/ppc/pef.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_events.c | 2 +- hw/ppc/spapr_rtas.c | 2 +- hw/remote/proxy.c | 7 ++----- hw/s390x/s390-virtio-ccw.c | 9 +++------ hw/scsi/vhost-scsi.c | 8 +++----- hw/vfio/migration.c | 13 ++----------- hw/virtio/vhost.c | 8 ++------ include/migration/blocker.h | 22 +++++++++++++++------- migration/migration.c | 22 ++++++++++++++-------- stubs/migr-blocker.c | 4 ++-- target/i386/kvm/kvm.c | 8 ++++---- target/i386/nvmm/nvmm-all.c | 3 +-- target/i386/sev.c | 2 +- target/i386/whpx/whpx-all.c | 3 +-- ui/vdagent.c | 5 ++--- 32 files changed, 83 insertions(+), 130 deletions(-)
backends/tpm/tpm_emulator.c +2 -8
@@ -535,11 +535,8 @@ static int tpm_emulator_block_migration(TPMEmulator *tpm_emu)error_setg (&tpm_emu->migration_blocker,"Migration disabled: TPM emulator does not support " "migration" ); -if (migrate_add_blocker (tpm_emu->migration_blocker, &err) <0 ) { +if (migrate_add_blocker (&tpm_emu->migration_blocker, &err) <0 ) {error_report_err (err); -error_free (tpm_emu->migration_blocker); - tpm_emu->migration_blocker =NULL ; -return -1 ; } }
@@ -1017,10 +1014,7 @@ static void tpm_emulator_inst_finalize(Object *obj)qapi_free_TPMEmulatorOptions (tpm_emu->options); -if (tpm_emu->migration_blocker) { -migrate_del_blocker (tpm_emu->migration_blocker); -error_free (tpm_emu->migration_blocker); - } +migrate_del_blocker (&tpm_emu->migration_blocker);tpm_sized_buffer_reset (&state_blobs->volatil);tpm_sized_buffer_reset (&state_blobs->permanent);
block/parallels.c +2 -4
@@ -877,9 +877,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The Parallels format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; }qemu_co_mutex_init (&s->lock);
@@ -911,8 +910,7 @@ static void parallels_close(BlockDriverState *bs)g_free (s->bat_dirty_bmap);qemu_vfree (s->header); -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); }static BlockDriver bdrv_parallels = {
block/qcow.c +2 -4
@@ -304,9 +304,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The qcow format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; }
@@ -798,8 +797,7 @@ static void qcow_close(BlockDriverState *bs)g_free (s->cluster_cache);g_free (s->cluster_data); -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); } static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
block/vdi.c +2 -4
@@ -495,9 +495,8 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The vdi format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail_free_bmap; }
@@ -986,8 +985,7 @@ static void vdi_close(BlockDriverState *bs)qemu_vfree (s->bmap); -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); }static int vdi_has_zero_init (BlockDriverState *bs)
block/vhdx.c +2 -4
@@ -985,8 +985,7 @@ static void vhdx_close(BlockDriverState *bs) s->bat =NULL ;qemu_vfree (s->parent_entries); s->parent_entries =NULL ; -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker);qemu_vfree (s->log.hdr); s->log.hdr =NULL ;vhdx_region_unregister_all (s);
@@ -1093,9 +1092,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The vhdx format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; }
block/vmdk.c +2 -4
@@ -1359,9 +1359,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The vmdk format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; }
@@ -2852,8 +2851,7 @@ static void vmdk_close(BlockDriverState *bs)vmdk_free_extents (bs);g_free (s->create_type); -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); }static int64_t coroutine_fn
block/vpc.c +2 -4
@@ -449,9 +449,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,error_setg (&s->migration_blocker,"The vpc format used by node '%s' " "does not support live migration" ,bdrv_get_device_or_node_name (bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; }
@@ -1188,8 +1187,7 @@ static void vpc_close(BlockDriverState *bs)g_free (s->pageentry_u8);#endif -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); }static QemuOptsList vpc_create_opts = {
block/vvfat.c +2 -4
@@ -1267,9 +1267,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,"The vvfat (rw) format used by node '%s' " "does not support live migration" , bdrv_get_device_or_node_name(bs)); - ret =migrate_add_blocker (s->migration_blocker, errp); + ret =migrate_add_blocker (&s->migration_blocker, errp);if (ret <0 ) { -error_free (s->migration_blocker); goto fail; } }
@@ -3237,8 +3236,7 @@ static void vvfat_close(BlockDriverState *bs)g_free (s->cluster_buffer);if (s->qcow) { -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); +migrate_del_blocker (&s->migration_blocker); } }
dump/dump.c +2 -2
@@ -114,7 +114,7 @@ static int dump_cleanup(DumpState *s)qemu_mutex_unlock_iothread (); } } -migrate_del_blocker (dump_migration_blocker); +migrate_del_blocker (&dump_migration_blocker);return 0 ; }
@@ -2167,7 +2167,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,* Allows even for -only-migratable, but forbid migration during the * process of dump guest memory. */ -if (migrate_add_blocker_internal (dump_migration_blocker, errp)) { +if (migrate_add_blocker_internal (&dump_migration_blocker, errp)) {/* Remember to release the fd before passing it over to dump state */ close (fd);return ;
hw/9pfs/9p.c +2 -8
@@ -408,11 +408,7 @@ static int coroutine_fn put_fid(V9fsPDU *pdu, V9fsFidState *fidp)* delete the migration blocker. Ideally, this * should be hooked to transport close notification */ -if (pdu->s->migration_blocker) { -migrate_del_blocker (pdu->s->migration_blocker); -error_free (pdu->s->migration_blocker); - pdu->s->migration_blocker =NULL ; - } +migrate_del_blocker (&pdu->s->migration_blocker); }return free_fid (pdu, fidp); }
@@ -1508,10 +1504,8 @@ static void coroutine_fn v9fs_attach(void *opaque)error_setg (&s->migration_blocker,"Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'" , s->ctx.fs_root ? s->ctx.fs_root :"NULL" , s->tag); - err =migrate_add_blocker (s->migration_blocker,NULL ); + err =migrate_add_blocker (&s->migration_blocker,NULL );if (err <0 ) { -error_free (s->migration_blocker); - s->migration_blocker =NULL ;clunk_fid (s, fid); goto out; }
hw/display/virtio-gpu-base.c +2 -6
@@ -167,8 +167,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,if (virtio_gpu_virgl_enabled (g->conf)) {error_setg (&g->migration_blocker,"virgl is not yet migratable" ); -if (migrate_add_blocker (g->migration_blocker, errp) <0 ) { -error_free (g->migration_blocker); +if (migrate_add_blocker (&g->migration_blocker, errp) <0 ) {return false; } }
@@ -232,10 +231,7 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev) {VirtIOGPUBase *g =VIRTIO_GPU_BASE (qdev); -if (g->migration_blocker) { -migrate_del_blocker (g->migration_blocker); -error_free (g->migration_blocker); - } +migrate_del_blocker (&g->migration_blocker); } static void
hw/intc/arm_gic_kvm.c +1 -2
@@ -516,8 +516,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)if (!kvm_arm_gic_can_save_restore (s)) {error_setg (&s->migration_blocker,"This operating system kernel does " "not support vGICv2 migration" ); -if (migrate_add_blocker (s->migration_blocker, errp) <0 ) { -error_free (s->migration_blocker); +if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {return ; } }
hw/intc/arm_gicv3_its_kvm.c +1 -2
@@ -114,8 +114,7 @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) GITS_CTLR)) {error_setg (&s->migration_blocker,"This operating system kernel " "does not support vITS migration" ); -if (migrate_add_blocker (s->migration_blocker, errp) <0 ) { -error_free (s->migration_blocker); +if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {return ; } } else {
hw/intc/arm_gicv3_kvm.c +1 -2
@@ -878,8 +878,7 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) GICD_CTLR)) {error_setg (&s->migration_blocker,"This operating system kernel does " "not support vGICv3 migration" ); -if (migrate_add_blocker (s->migration_blocker, errp) <0 ) { -error_free (s->migration_blocker); +if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {return ; } }
hw/misc/ivshmem.c +2 -6
@@ -903,8 +903,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)if (!ivshmem_is_master (s)) {error_setg (&s->migration_blocker,"Migration is disabled when using feature 'peer mode' in device 'ivshmem'" ); -if (migrate_add_blocker (s->migration_blocker, errp) <0 ) { -error_free (s->migration_blocker); +if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {return ; } }
@@ -922,10 +921,7 @@ static void ivshmem_exit(PCIDevice *dev)IVShmemState *s =IVSHMEM_COMMON (dev);int i; -if (s->migration_blocker) { -migrate_del_blocker (s->migration_blocker); -error_free (s->migration_blocker); - } +migrate_del_blocker (&s->migration_blocker);if (memory_region_is_mapped (s->ivshmem_bar2)) {if (!s->hostmem) {
hw/ppc/pef.c +1 -1
@@ -63,7 +63,7 @@ static int kvmppc_svm_init(ConfidentialGuestSupport *cgs, Error **errp)/* add migration blocker */ error_setg (&pef_mig_blocker,"PEF: Migration is not implemented" );/* NB: This can fail if --only-migratable is used */ -migrate_add_blocker (pef_mig_blocker, &error_fatal); +migrate_add_blocker (&pef_mig_blocker, &error_fatal); cgs->ready = true;
hw/ppc/spapr.c +1 -1
@@ -1727,7 +1727,7 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)/* Signal all vCPUs waiting on this condition */ qemu_cond_broadcast (&spapr->fwnmi_machine_check_interlock_cond); -migrate_del_blocker (spapr->fwnmi_migration_blocker); +migrate_del_blocker (&spapr->fwnmi_migration_blocker); }static void spapr_create_nvram (SpaprMachineState *spapr)
hw/ppc/spapr_events.c +1 -1
@@ -920,7 +920,7 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered)* fails when running with -only-migrate. A proper interface to * delay migration completion for a bit could avoid that. */ - ret =migrate_add_blocker (spapr->fwnmi_migration_blocker,NULL ); + ret =migrate_add_blocker (&spapr->fwnmi_migration_blocker,NULL );if (ret == -EBUSY ) {warn_report ("Received a fwnmi while migration was in progress" ); }
hw/ppc/spapr_rtas.c +1 -1
@@ -495,7 +495,7 @@ static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, spapr->fwnmi_machine_check_interlock =-1 ;qemu_cond_signal (&spapr->fwnmi_machine_check_interlock_cond);rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); -migrate_del_blocker (spapr->fwnmi_migration_blocker); +migrate_del_blocker (&spapr->fwnmi_migration_blocker); } static struct rtas_call {
hw/remote/proxy.c +2 -5
@@ -108,8 +108,7 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)error_setg (&dev->migration_blocker,"%s does not support migration" ,TYPE_PCI_PROXY_DEV ); -if (migrate_add_blocker (dev->migration_blocker, errp) <0 ) { -error_free (dev->migration_blocker); +if (migrate_add_blocker (&dev->migration_blocker, errp) <0 ) {object_unref (dev->ioc);return ; }
@@ -135,9 +134,7 @@ static void pci_proxy_dev_exit(PCIDevice *pdev)qio_channel_close (dev->ioc,NULL ); } -migrate_del_blocker (dev->migration_blocker); - -error_free (dev->migration_blocker); +migrate_del_blocker (&dev->migration_blocker);proxy_memory_listener_deconfigure (&dev->proxy_listener);
hw/s390x/s390-virtio-ccw.c +3 -6
@@ -331,8 +331,7 @@ static void s390_machine_unprotect(S390CcwMachineState *ms) {s390_pv_vm_disable (); ms->pv = false; -migrate_del_blocker (pv_mig_blocker); -error_free_or_abort (&pv_mig_blocker); +migrate_del_blocker (&pv_mig_blocker);ram_block_discard_disable (false); }
@@ -355,11 +354,10 @@ static int s390_machine_protect(S390CcwMachineState *ms)error_setg (&pv_mig_blocker,"protected VMs are currently not migratable." ); - rc =migrate_add_blocker (pv_mig_blocker, &local_err); + rc =migrate_add_blocker (&pv_mig_blocker, &local_err);if (rc) {ram_block_discard_disable (false);error_report_err (local_err); -error_free_or_abort (&pv_mig_blocker);return rc; }
@@ -367,8 +365,7 @@ static int s390_machine_protect(S390CcwMachineState *ms) rc =s390_pv_vm_enable ();if (rc) {ram_block_discard_disable (false); -migrate_del_blocker (pv_mig_blocker); -error_free_or_abort (&pv_mig_blocker); +migrate_del_blocker (&pv_mig_blocker);return rc; }
hw/scsi/vhost-scsi.c +3 -5
@@ -209,7 +209,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)"When external environment supports it (Orchestrator migrates " "target SCSI device state or use shared storage over network), " "set 'migratable' property to true to enable migration."); -if (migrate_add_blocker (vsc->migration_blocker, errp) <0 ) { +if (migrate_add_blocker (&vsc->migration_blocker, errp) <0 ) { goto free_virtio; } }
@@ -242,10 +242,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) free_vqs:g_free (vqs);if (!vsc->migratable) { -migrate_del_blocker (vsc->migration_blocker); +migrate_del_blocker (&vsc->migration_blocker); } free_virtio: -error_free (vsc->migration_blocker);virtio_scsi_common_unrealize (dev); close_fd:if (vhostfd >=0 ) {
@@ -261,8 +260,7 @@ static void vhost_scsi_unrealize(DeviceState *dev)struct vhost_virtqueue *vqs = vsc->dev.vqs;if (!vsc->migratable) { -migrate_del_blocker (vsc->migration_blocker); -error_free (vsc->migration_blocker); +migrate_del_blocker (&vsc->migration_blocker); }/* This will stop vhost backend. */
hw/vfio/migration.c +2 -11
@@ -889,12 +889,7 @@ add_blocker: "VFIO device doesn't support migration");g_free (info); - ret =migrate_add_blocker (vbasedev->migration_blocker, errp); -if (ret <0 ) { -error_free (vbasedev->migration_blocker); - vbasedev->migration_blocker =NULL ; - } -return ret; +return migrate_add_blocker (&vbasedev->migration_blocker, errp); }void vfio_migration_finalize (VFIODevice *vbasedev)
@@ -908,9 +903,5 @@ void vfio_migration_finalize(VFIODevice *vbasedev)vfio_migration_exit (vbasedev); } -if (vbasedev->migration_blocker) { -migrate_del_blocker (vbasedev->migration_blocker); -error_free (vbasedev->migration_blocker); - vbasedev->migration_blocker =NULL ; - } +migrate_del_blocker (&vbasedev->migration_blocker); }
hw/virtio/vhost.c +2 -6
@@ -1479,9 +1479,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, }if (hdev->migration_blocker !=NULL ) { - r =migrate_add_blocker (hdev->migration_blocker, errp); + r =migrate_add_blocker (&hdev->migration_blocker, errp);if (r <0 ) { -error_free (hdev->migration_blocker); goto fail_busyloop; } }
@@ -1531,10 +1530,7 @@ void vhost_dev_cleanup(struct vhost_dev *hdev)memory_listener_unregister (&hdev->memory_listener);QLIST_REMOVE (hdev, entry); } -if (hdev->migration_blocker) { -migrate_del_blocker (hdev->migration_blocker); -error_free (hdev->migration_blocker); - } +migrate_del_blocker (&hdev->migration_blocker);g_free (hdev->mem);g_free (hdev->mem_sections);if (hdev->vhost_ops) {
include/migration/blocker.h +15 -7
@@ -17,19 +17,22 @@/** * @migrate_add_blocker - prevent migration from proceeding * -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now. * * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set. +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it. */ -int migrate_add_blocker (Error *reason,Error **errp); +int migrate_add_blocker (Error **reasonp,Error **errp);/** * @migrate_add_blocker_internal - prevent migration from proceeding without * only-migrate implications * -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now. *
@@ -38,14 +41,19 @@ int migrate_add_blocker(Error *reason, Error **errp);* Some of the migration blockers can be temporary (e.g., for a few seconds), * so it shouldn't need to conflict with "-only-migratable". For those cases, * we can call this function rather than @migrate_add_blocker(). +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it. */ -int migrate_add_blocker_internal (Error *reason,Error **errp); +int migrate_add_blocker_internal (Error **reasonp,Error **errp);/** -* @migrate_del_blocker - remove a blocking error from migration +* @migrate_del_blocker - remove a blocking error from migration and free it. +* +* @reasonp - address of the error blocking migration * -* @reason - the error blocking migration +* This function frees *@reasonp and sets it to NULL. */ -void migrate_del_blocker (Error *reason); +void migrate_del_blocker (Error **reasonp);#endif
migration/migration.c +14 -8
@@ -2205,35 +2205,41 @@ void migrate_init(MigrationState *s) s->threshold_size =0 ; } -int migrate_add_blocker_internal (Error *reason,Error **errp) +int migrate_add_blocker_internal (Error **reasonp,Error **errp) {/* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too. */ if (runstate_check (RUN_STATE_SAVE_VM ) || !migration_is_idle ()) { -error_propagate_prepend (errp,error_copy (reason), +error_propagate_prepend (errp, *reasonp,"disallowing migration blocker " "(migration/snapshot in progress) for: " ); + *reasonp =NULL ;return -EBUSY ; } - migration_blockers =g_slist_prepend (migration_blockers, reason); + migration_blockers =g_slist_prepend (migration_blockers, *reasonp);return 0 ; } -int migrate_add_blocker (Error *reason,Error **errp) +int migrate_add_blocker (Error **reasonp,Error **errp) {if (only_migratable) { -error_propagate_prepend (errp,error_copy (reason), +error_propagate_prepend (errp, *reasonp,"disallowing migration blocker " "(--only-migratable) for: " ); + *reasonp =NULL ;return -EACCES ; } -return migrate_add_blocker_internal (reason, errp); +return migrate_add_blocker_internal (reasonp, errp); } -void migrate_del_blocker (Error *reason) +void migrate_del_blocker (Error **reasonp) { - migration_blockers =g_slist_remove (migration_blockers, reason); +if (*reasonp) { + migration_blockers =g_slist_remove (migration_blockers, *reasonp); +error_free (*reasonp); + *reasonp =NULL ; + } }void qmp_migrate_incoming (const char *uri,Error **errp)
stubs/migr-blocker.c +2 -2
@@ -1,11 +1,11 @@#include "qemu/osdep.h" #include "migration/blocker.h" -int migrate_add_blocker (Error *reason,Error **errp) +int migrate_add_blocker (Error **reasonp,Error **errp) {return 0 ; } -void migrate_del_blocker (Error *reason) +void migrate_del_blocker (Error **reasonp) { }
target/i386/kvm/kvm.c +4 -4
@@ -1576,7 +1576,7 @@ static int hyperv_init_vcpu(X86CPU *cpu)error_setg (&hv_passthrough_mig_blocker,"'hv-passthrough' CPU flag prevents migration, use explicit" " set of hv-* flags instead" ); - ret =migrate_add_blocker (hv_passthrough_mig_blocker, &local_err); + ret =migrate_add_blocker (&hv_passthrough_mig_blocker, &local_err);if (ret <0 ) {error_report_err (local_err);return ret;
@@ -1590,7 +1590,7 @@ static int hyperv_init_vcpu(X86CPU *cpu)" use explicit 'hv-no-nonarch-coresharing=on' instead (but" " make sure SMT is disabled and/or that vCPUs are properly" " pinned)"); - ret =migrate_add_blocker (hv_no_nonarch_cs_mig_blocker, &local_err); + ret =migrate_add_blocker (&hv_no_nonarch_cs_mig_blocker, &local_err);if (ret <0 ) {error_report_err (local_err);return ret;
@@ -2111,7 +2111,7 @@ int kvm_arch_init_vcpu(CPUState *cs)error_setg (&invtsc_mig_blocker,"State blocked by non-migratable CPU device" " (invtsc flag)" ); - r =migrate_add_blocker (invtsc_mig_blocker, &local_err); + r =migrate_add_blocker (&invtsc_mig_blocker, &local_err);if (r <0 ) {error_report_err (local_err);return r;
@@ -2169,7 +2169,7 @@ int kvm_arch_init_vcpu(CPUState *cs)return 0 ; fail: -migrate_del_blocker (invtsc_mig_blocker); +migrate_del_blocker (&invtsc_mig_blocker);return r; }
target/i386/nvmm/nvmm-all.c +1 -2
@@ -935,9 +935,8 @@ nvmm_init_vcpu(CPUState *cpu)error_setg (&nvmm_migration_blocker,"NVMM: Migration not supported" ); -if (migrate_add_blocker (nvmm_migration_blocker, &local_error) <0 ) { +if (migrate_add_blocker (&nvmm_migration_blocker, &local_error) <0 ) {error_report_err (local_error); -error_free (nvmm_migration_blocker);return -EINVAL ; } }
target/i386/sev.c +1 -1
@@ -891,7 +891,7 @@ sev_launch_finish(SevGuestState *sev)/* add migration blocker */ error_setg (&sev_mig_blocker,"SEV: Migration is not implemented" ); -migrate_add_blocker (sev_mig_blocker, &error_fatal); +migrate_add_blocker (&sev_mig_blocker, &error_fatal); } static void
target/i386/whpx/whpx-all.c +1 -2
@@ -2169,9 +2169,8 @@ int whpx_init_vcpu(CPUState *cpu)"State blocked due to non-migratable CPUID feature support," "dirty memory tracking support, and XSAVE/XRSTOR support"); -if (migrate_add_blocker (whpx_migration_blocker, &local_error) <0 ) { +if (migrate_add_blocker (&whpx_migration_blocker, &local_error) <0 ) {error_report_err (local_error); -error_free (whpx_migration_blocker); ret = -EINVAL ; goto error; }
ui/vdagent.c +2 -3
@@ -670,7 +670,7 @@ static void vdagent_chr_open(Chardev *chr,return ;#endif -if (migrate_add_blocker (vd->migration_blocker, errp) !=0 ) { +if (migrate_add_blocker (&vd->migration_blocker, errp) !=0 ) {return ; }
@@ -920,10 +920,9 @@ static void vdagent_chr_fini(Object *obj) {VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (obj); -migrate_del_blocker (vd->migration_blocker); +migrate_del_blocker (&vd->migration_blocker);vdagent_disconnect (vd);buffer_free (&vd->outbuf); -error_free (vd->migration_blocker); }static const TypeInfo vdagent_chr_type_info = {
Signature · 1 line
1.8.3.1
Quoted 10 lines · Steve Sistare
Modify
migrate_add_blockerandmigrate_del_blockerto take an Error ** reason. This allows migration to own the Error object, so that if an error occurs, migration code can free the Error and clear the client handle, simplifying client code. This is a pre-requisite for a future patch that will allow one Error blocker to be registered for multiple migration modes.No functional change.
Signed-off-by Steve Sistare <[email protected]>
One trivial comment below.
[...]
Quoted 7 lines
include/migration/blocker.h +0
-0@@ -17,19 +17,22 @@/** * @migrate_add_blocker - prevent migration from proceeding
include/migration/blocker.h line 27
Quoted 10 lines
include/migration/blocker.h +4
-1* -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now. * * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set. +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it.
This statement reads weird. IMHO the caller still owns @reasonp, but if it succeeded it should only free it with a migrate_del_blocker() later.
Quoted 14 lines
include/migration/blocker.h +2
-2*/ -int migrate_add_blocker (Error *reason,Error **errp); +int migrate_add_blocker (Error **reasonp,Error **errp);/** * @migrate_add_blocker_internal - prevent migration from proceeding without * only-migrate implications * -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now. *
include/migration/blocker.h int migrate_add_blocker(Error *reason, Error **errp); · line 46
Quoted 6 lines
include/migration/blocker.h +3
-0@@ -38,14 +41,19 @@ int migrate_add_blocker(Error *reason, Error **errp);* Some of the migration blockers can be temporary (e.g., for a few seconds), * so it shouldn't need to conflict with "-only-migratable". For those cases, * we can call this function rather than @migrate_add_blocker(). +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it.
Same here?
Quoted 1 line
include/migration/blocker.h +0
-0*/
Signature · 1 line
Peter Xu
Quoted 30 lines · Peter Xu
Quoted 10 lines · Steve Sistare
Modify
migrate_add_blockerandmigrate_del_blockerto take an Error ** reason. This allows migration to own the Error object, so that if an error occurs, migration code can free the Error and clear the client handle, simplifying client code. This is a pre-requisite for a future patch that will allow one Error blocker to be registered for multiple migration modes.No functional change.
Signed-off-by Steve Sistare <[email protected]>Acked-by Peter Xu <[email protected]>One trivial comment below.
[...]
Quoted 12 lines
include/migration/blocker.h +1
-1@@ -17,19 +17,22 @@/** * @migrate_add_blocker - prevent migration from proceeding * -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now.
Quoted 8 lines
include/migration/blocker.h line 27
Quoted 5 lines
include/migration/blocker.h +3
-0* * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set. +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it. This statement reads weird. IMHO the caller still owns @reasonp, but if it succeeded it should only free it with a
migrate_del_blocker()later.
How about:
On success, the caller must not free @reasonp, except by calling migrate_del_blocker.
Same below.
- Steve
Quoted 25 lines
Quoted 14 lines
include/migration/blocker.h +2
-2*/ -int migrate_add_blocker (Error *reason,Error **errp); +int migrate_add_blocker (Error **reasonp,Error **errp);/** * @migrate_add_blocker_internal - prevent migration from proceeding without * only-migrate implications * -* @reason - an error to be returned whenever migration is attempted +* @reasonp - address of an error to be returned whenever migration is attempted * * @errp - [out] The reason (if any) we cannot block migration right now. * include/migration/blocker.h int migrate_add_blocker(Error *reason, Error **errp); · line 46
Quoted 6 lines
include/migration/blocker.h +3
-0@@ -38,14 +41,19 @@ int migrate_add_blocker(Error *reason, Error **errp);* Some of the migration blockers can be temporary (e.g., for a few seconds), * so it shouldn't need to conflict with "-only-migratable". For those cases, * we can call this function rather than @migrate_add_blocker(). +* +* *@reasonp is freed and set to NULL if failure is returned. +* On success, the caller no longer owns *@reasonp and must not free it. Same here?
Quoted 1 line
include/migration/blocker.h +0
-0*/
Quoted 8 lines · Steven Sistare
Quoted 5 lines
Quoted 2 lines
+ * *@reasonp is freed and set to NULL if failure is returned.
+ * On success, the caller no longer owns *@reasonp and must not free it.This statement reads weird. IMHO the caller still owns @reasonp, but if it succeeded it should only free it with a
migrate_del_blocker()later.How about:
On success, the caller must not free @reasonp, except by callingmigrate_del_blocker.
LGTM, thanks.
Signature · 1 line
Peter Xu
Quoted 4 lines · Peter Xu
Quoted 3 lines · Steven Sistare
Quoted 3 lines
Quoted 2 lines
+ * *@reasonp is freed and set to NULL if failure is returned.
+ * On success, the caller no longer owns *@reasonp and must not free it.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This statement reads weird. IMHO the caller still owns @reasonp, but if it succeeded it should only free it with a
migrate_del_blocker()later.How about:
On success, the caller must not free @reasonp, except by callingmigrate_del_blocker.LGTM, thanks.
Hi Peter, I will fix the comment, rebase, and repost. Please consider upgrading your Acked-By to an RB.
- Steve