migration: Don't free the reason after calling migrate_add_blocker
PATCH 1/1 migration: Don't free the reason after calling migrate_add_blocker
--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)
hw/intc/arm_gicv3_kvm.c +0 -1
@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }
target/i386/sev.c +0 -1
@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 23 lines · Bin Guo
Signed-off-by Bin Guo <[email protected]>--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)hw/intc/arm_gicv3_kvm.c +0
-1@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }target/i386/sev.c +0
-0
target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1666
Quoted 7 lines
target/i386/sev.c +0
-1@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }
Does this fix use-after-free bugs?
Quoted 20 lines · Markus Armbruster
Quoted 18 lines · Bin Guo
Signed-off-by Bin Guo <[email protected]>--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)hw/intc/arm_gicv3_kvm.c +0
-1@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }
Quoted 14 lines
target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1666
Quoted 12 lines
target/i386/sev.c +0
-1@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }Does this fix use-after-free bugs?
I don't think so, because when migrate_add_blocker() returns error, the Error for the blocker will have been propagated into the errp parameter, and then set to NULL. So these two error_free calls should be a no-op.
But wow, the migrate_add_blocker API design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 18 lines · Markus Armbruster
Quoted 18 lines
Signed-off-by Bin Guo <[email protected]>--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)hw/intc/arm_gicv3_kvm.c +0
-1@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }
Quoted 14 lines
target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1666
Quoted 12 lines
target/i386/sev.c +0
-1@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }Does this fix use-after-free bugs?
No, just delete the unnecessary code and follow the best practice. Function migrate_add_blocker will free the reason and set it to NULL if failure is returned.
Quoted 35 lines · Bin Guo
Quoted 18 lines · Markus Armbruster
Quoted 18 lines
Signed-off-by Bin Guo <[email protected]>--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)hw/intc/arm_gicv3_kvm.c +0
-1@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }Quoted 14 lines
target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1666
Quoted 12 lines
target/i386/sev.c +0
-1@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }Does this fix use-after-free bugs?
Quoted 3 lines
No, just delete the unnecessary code and follow the best practice. Function
migrate_add_blockerwill free the reason and set it to NULL if failure is returned.
Please work the second sentence into the commit message.
Quoted 36 lines · Daniel P. Berrangé
Quoted 20 lines · Markus Armbruster
Quoted 18 lines · Bin Guo
Signed-off-by Bin Guo <[email protected]>--- hw/intc/arm_gicv3_kvm.c | 1 - target/i386/sev.c | 1 - 2 files changed, 2 deletions(-)hw/intc/arm_gicv3_kvm.c +0
-1@@ -841,7 +841,6 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)error_setg (&kvm_nv_migration_blocker,"Live migration disabled because KVM nested virt is enabled" );if (migrate_add_blocker (&kvm_nv_migration_blocker, errp)) { -error_free (kvm_nv_migration_blocker);return ; }Quoted 14 lines
target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1666
Quoted 12 lines
target/i386/sev.c +0
-1@@ -1661,7 +1661,6 @@ sev_snp_launch_finish(SevCommonState *sev_common) ret =migrate_add_blocker (&sev_mig_blocker, &local_err);if (local_err) {error_report_err (local_err); -error_free (sev_mig_blocker);exit (1 ); } }Does this fix use-after-free bugs?
Quoted 8 lines
I don't think so, because when
migrate_add_blocker()returns error, the Error for the blocker will have been propagated into the errp parameter, and then set to NULL. So these twoerror_freecalls should be a no-op.But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.
It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Quoted 1 line · Markus Armbruster
Daniel P. Berrangé <[email protected]> writes:
[...]
Quoted 7 lines
Quoted 3 lines
But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Alright, my confusion has been maximised. Giving up on this.
Quoted 10 lines · Markus Armbruster
Quoted 1 line · Markus Armbruster
Daniel P. Berrangé <[email protected]> writes:
[...]
Quoted 4 lines
Quoted 3 lines
But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.
Quoted 5 lines
Quoted 3 lines
It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Alright, my confusion has been maximised. Giving up on this.
Besides the use of two Error** that might be confusing, what is more confusing (if not wrong..): migrate_add_blocker() will take ownership of the 1st Error**, no matter whether the helper succeeded or not. However, it only resets the first Error** if failed.
I think it means if migrate_add_blocker() succeeded, the caller will have a non-NULL pointer, even if it has lost the ownership of that pointer.
I'm guessing it never caused issue only because we don't usually error_free() the migration blocker anywhere.. but I think maybe we should at least do an error_copy() in add_blockers()..
Signature · 1 line
Peter Xu
Quoted 22 lines · Peter Xu
Quoted 10 lines · Markus Armbruster
Quoted 1 line · Markus Armbruster
Daniel P. Berrangé <[email protected]> writes:
[...]
Quoted 4 lines
Quoted 3 lines
But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.Quoted 5 lines
Quoted 3 lines
It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Alright, my confusion has been maximised. Giving up on this.
Besides the use of two Error** that might be confusing, what is more confusing (if not wrong..):
migrate_add_blocker()will take ownership of the 1st Error**, no matter whether the helper succeeded or not. However, it only resets the first Error** if failed.
Quoted 6 lines
I think it means if
migrate_add_blocker()succeeded, the caller will have a non-NULL pointer, even if it has lost the ownership of that pointer.I'm guessing it never caused issue only because we don't usually
error_free()the migration blocker anywhere.. but I think maybe we should at least do anerror_copy()inadd_blockers()..
IMHO we should not even be using an Error object for the the blocker. AFAICT, internally all we care about is the formatted string. The main reason for using an Error object appears to be to have a convenient pointer to use as an identifier to later pass to del_blocker.
I'd be inclined to just have passed in a fixed string, and return an integer identifier for the blocker. eg
int64 migrate_add_blocker(const char *reason, Error **errp);
void migrate_del_blocker(int64 blockerid);The migrate_add_blocker method would strdup(reason) to keep its own copy.
The usage would thus be clear & simple:
int64 blockerid = migrate_add_blocker("cannot migrate vfio", errp);
if (!blockerid) {
return;
}
... some time later...
migrate_del_blocker(blockerid);In some cases we needed dynamically formatted strings, which could have been achieved thus:
g_autofree char *msg = g_strdup_printf("cannot migrate vfio %d", blah);
int64 blockerid = migrate_add_blocker(msg, errp);
...the rest as above...yes, this costs an extra strdup(), but that is an acceptable & negligible overhead in the context in which we're doing this.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 60 lines · Daniel P. Berrangé
Quoted 22 lines · Peter Xu
Quoted 10 lines · Markus Armbruster
Quoted 1 line · Markus Armbruster
Daniel P. Berrangé <[email protected]> writes:
[...]
Quoted 4 lines
Quoted 3 lines
But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.Quoted 5 lines
Quoted 3 lines
It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Alright, my confusion has been maximised. Giving up on this.
Besides the use of two Error** that might be confusing, what is more confusing (if not wrong..):
migrate_add_blocker()will take ownership of the 1st Error**, no matter whether the helper succeeded or not. However, it only resets the first Error** if failed.Quoted 6 lines
I think it means if
migrate_add_blocker()succeeded, the caller will have a non-NULL pointer, even if it has lost the ownership of that pointer.I'm guessing it never caused issue only because we don't usually
error_free()the migration blocker anywhere.. but I think maybe we should at least do anerror_copy()inadd_blockers()..IMHO we should not even be using an Error object for the the blocker. AFAICT, internally all we care about is the formatted string. The main reason for using an Error object appears to be to have a convenient pointer to use as an identifier to later pass to
del_blocker.I'd be inclined to just have passed in a fixed string, and return an integer identifier for the blocker. eg
int64 migrate_add_blocker(const char *reason, Error **errp); void migrate_del_blocker(int64 blockerid);The
migrate_add_blockermethod would strdup(reason) to keep its own copy.The usage would thus be clear & simple:
int64 blockerid = migrate_add_blocker("cannot migrate vfio", errp); if (!blockerid) { return; } ... some time later... migrate_del_blocker(blockerid);In some cases we needed dynamically formatted strings, which could have been achieved thus:
Quoted 7 lines
g_autofree char *msg = g_strdup_printf("cannot migrate vfio %d", blah); int64 blockerid = migrate_add_blocker(msg, errp); ...the rest as above...yes, this costs an extra
strdup(), but that is an acceptable & negligible overhead in the context in which we're doing this.
Hmm, I must disagree. This is more complex than what we have today. Calling error_setg(err, "msg") is pretty standard, already gives us formatting and keeps all (potentially) user-facing messages uniform.
Asking for people to deal with strings and storing an int64 in their code is not improving the situation. Besides, the Error is already used by the block layer when blocking operations, for instance. If anything we should be integrating the two usages instead of inventing yet another for the migration code. See:
replication.c:
error_setg(&s->blocker,
"Block device is in use by internal backup job");
...
bdrv_op_block_all(top_bs, s->blocker);
block.c:
void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)
{
BdrvOpBlocker *blocker;
assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
blocker = g_new0(BdrvOpBlocker, 1);
blocker->reason = reason;
QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list);
}Quoted 2 lines
With regards,
Daniel
Quoted 66 lines · Fabiano Rosas
Quoted 64 lines · Daniel P. Berrangé
Quoted 22 lines · Peter Xu
Quoted 10 lines · Markus Armbruster
Quoted 1 line · Markus Armbruster
Daniel P. Berrangé <[email protected]> writes:
[...]
Quoted 4 lines
Quoted 3 lines
But wow, the
migrate_add_blockerAPI design is unpleasant with its pair of "Error **" parameters - it is practically designed to maximise confusion & surprise.Quoted 5 lines
Quoted 3 lines
It's quite a sight, isn't it?
I'll give it a quick Friday afternoon try.
Alright, my confusion has been maximised. Giving up on this.
Besides the use of two Error** that might be confusing, what is more confusing (if not wrong..):
migrate_add_blocker()will take ownership of the 1st Error**, no matter whether the helper succeeded or not. However, it only resets the first Error** if failed.Quoted 6 lines
I think it means if
migrate_add_blocker()succeeded, the caller will have a non-NULL pointer, even if it has lost the ownership of that pointer.I'm guessing it never caused issue only because we don't usually
error_free()the migration blocker anywhere.. but I think maybe we should at least do anerror_copy()inadd_blockers()..IMHO we should not even be using an Error object for the the blocker. AFAICT, internally all we care about is the formatted string. The main reason for using an Error object appears to be to have a convenient pointer to use as an identifier to later pass to
del_blocker.I'd be inclined to just have passed in a fixed string, and return an integer identifier for the blocker. eg
int64 migrate_add_blocker(const char *reason, Error **errp); void migrate_del_blocker(int64 blockerid);The
migrate_add_blockermethod would strdup(reason) to keep its own copy.The usage would thus be clear & simple:
int64 blockerid = migrate_add_blocker("cannot migrate vfio", errp); if (!blockerid) { return; } ... some time later... migrate_del_blocker(blockerid);In some cases we needed dynamically formatted strings, which could have been achieved thus:
g_autofree char *msg = g_strdup_printf("cannot migrate vfio %d", blah); int64 blockerid = migrate_add_blocker(msg, errp); ...the rest as above...
Quoted 7 lines
Quoted 3 lines
yes, this costs an extra
strdup(), but that is an acceptable & negligible overhead in the context in which we're doing this.Hmm, I must disagree. This is more complex than what we have today. Calling
error_setg(err, "msg")is pretty standard, already gives us formatting and keeps all (potentially) user-facing messages uniform.
IMHO this usage in migration is not really about error reporting though, and the lifecycle ownership of the Error objects in this migration usage is very diferent from the typical lifecycle ownership of Error objects used in reporting errors, which I think leads to a surprising / unusual API.
Quoted 5 lines
Asking for people to deal with strings and storing an int64 in their code is not improving the situation. Besides, the Error is already used by the block layer when blocking operations, for instance. If anything we should be integrating the two usages instead of inventing yet another for the migration code. See:
Yes, having a common API for these two similar use cases would be a useful thing. I'm just not convinced we should be (mis|re)using the Error object for either of these two situations.
Quoted 9 lines
replication.c:
error_setg(&s->blocker,"Block device is in use by internal backup job");...
bdrv_op_block_all(top_bs, s->blocker);
block.c:
voidbdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)
Quoted 8 lines
{
BdrvOpBlocker *blocker;
assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
blocker = g_new0(BdrvOpBlocker, 1);
blocker->reason = reason;
QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list);
}With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 44 lines · Daniel P. Berrangé
Quoted 35 lines · Fabiano Rosas
Quoted 34 lines · Daniel P. Berrangé
IMHO we should not even be using an Error object for the the blocker. AFAICT, internally all we care about is the formatted string. The main reason for using an Error object appears to be to have a convenient pointer to use as an identifier to later pass to
del_blocker.I'd be inclined to just have passed in a fixed string, and return an integer identifier for the blocker. eg
int64 migrate_add_blocker(const char *reason, Error **errp); void migrate_del_blocker(int64 blockerid);The
migrate_add_blockermethod would strdup(reason) to keep its own copy.The usage would thus be clear & simple:
int64 blockerid = migrate_add_blocker("cannot migrate vfio", errp); if (!blockerid) { return; } ... some time later... migrate_del_blocker(blockerid);In some cases we needed dynamically formatted strings, which could have been achieved thus:
g_autofree char *msg = g_strdup_printf("cannot migrate vfio %d", blah); int64 blockerid = migrate_add_blocker(msg, errp); ...the rest as above...Quoted 7 lines
Quoted 3 lines
yes, this costs an extra
strdup(), but that is an acceptable & negligible overhead in the context in which we're doing this.Hmm, I must disagree. This is more complex than what we have today. Calling
error_setg(err, "msg")is pretty standard, already gives us formatting and keeps all (potentially) user-facing messages uniform.
Quoted 5 lines
IMHO this usage in migration is not really about error reporting though, and the lifecycle ownership of the Error objects in this migration usage is very diferent from the typical lifecycle ownership of Error objects used in reporting errors, which I think leads to a surprising / unusual API.
I think a blocker interface where you pass the error to use when the blocker blocks something is defensible.
Passing an error message or even a text snippet to be interpolated into the error message would also be defensible.
We're using the former, and it has turned out to be confusing. Less so in the block layer, where we sensibly pass Error *. More so in migration, where we pass Error **. Error ** is almost always used to receive an error, so when we use it for something else, we risk confusion.
Quoted 9 lines
Quoted 5 lines
Asking for people to deal with strings and storing an int64 in their code is not improving the situation. Besides, the Error is already used by the block layer when blocking operations, for instance. If anything we should be integrating the two usages instead of inventing yet another for the migration code. See:
Yes, having a common API for these two similar use cases would be a useful thing. I'm just not convinced we should be (mis|re)using the Error object for either of these two situations.
I guess we could have a generic Blocker object instead of using Error for the purpose.
In addition to an error message, an Error object has an error class (rarely used remnant of the past), where in the source code the Error object was created (reported to the user when handling &error_abort), and an optional hint. Is any of this useful for blockers?
Quoted 20 lines
Quoted 8 lines
replication.c:
error_setg(&s->blocker,"Block device is in use by internal backup job");...
bdrv_op_block_all(top_bs, s->blocker);
block.c:
voidbdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)Quoted 8 lines
{ BdrvOpBlocker *blocker; assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX); blocker = g_new0(BdrvOpBlocker, 1); blocker->reason = reason; QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list); }With regards,
Daniel
Quoted 46 lines · Markus Armbruster
Quoted 44 lines · Daniel P. Berrangé
Quoted 42 lines · Fabiano Rosas
Quoted 30 lines · Daniel P. Berrangé
IMHO we should not even be using an Error object for the the blocker. AFAICT, internally all we care about is the formatted string. The main reason for using an Error object appears to be to have a convenient pointer to use as an identifier to later pass to
del_blocker.I'd be inclined to just have passed in a fixed string, and return an integer identifier for the blocker. eg
int64 migrate_add_blocker(const char *reason, Error **errp); void migrate_del_blocker(int64 blockerid);The
migrate_add_blockermethod would strdup(reason) to keep its own copy.The usage would thus be clear & simple:
int64 blockerid = migrate_add_blocker("cannot migrate vfio", errp); if (!blockerid) { return; } ... some time later... migrate_del_blocker(blockerid);In some cases we needed dynamically formatted strings, which could have been achieved thus:
Quoted 7 lines
g_autofree char *msg = g_strdup_printf("cannot migrate vfio %d", blah); int64 blockerid = migrate_add_blocker(msg, errp); ...the rest as above...yes, this costs an extra
strdup(), but that is an acceptable & negligible overhead in the context in which we're doing this.Hmm, I must disagree. This is more complex than what we have today. Calling
error_setg(err, "msg")is pretty standard, already gives us formatting and keeps all (potentially) user-facing messages uniform.
Quoted 5 lines
Quoted 5 lines
IMHO this usage in migration is not really about error reporting though, and the lifecycle ownership of the Error objects in this migration usage is very diferent from the typical lifecycle ownership of Error objects used in reporting errors, which I think leads to a surprising / unusual API.
The blocker does eventually show up to the user via migration_is_blocked().
I get that there is an initial surprise to passing an Error around for something that is not strictly an error, but IMO this is just a small idiosyncrasy. For the lifecycle point, we could probably simplify what we're doing in migration, I don't see why the Error ** needs to be cleared in case the blocker cannot be installed.
Quoted 4 lines
I think a blocker interface where you pass the error to use when the blocker blocks something is defensible.
Quoted 9 lines
Passing an error message or even a text snippet to be interpolated into the error message would also be defensible.
We're using the former, and it has turned out to be confusing. Less so in the block layer, where we sensibly pass Error *. More so in migration, where we pass Error **. Error ** is almost always used to receive an error, so when we use it for something else, we risk confusion.
I don't understand exactly why we need the Error **, it looks like we're just storing that error twice, once via the device's migration_blocker and another via the migration core's GSList *migration_blockers.
The block layer doesn't have the use case of blocking the blocker like migration does, but it still looks like the two are doing pretty much the same, with the block "op" being analogous to the migration "mode".
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Asking for people to deal with strings and storing an int64 in their code is not improving the situation. Besides, the Error is already used by the block layer when blocking operations, for instance. If anything we should be integrating the two usages instead of inventing yet another for the migration code. See:
Yes, having a common API for these two similar use cases would be a useful thing. I'm just not convinced we should be (mis|re)using the Error object for either of these two situations.
Quoted 8 lines
I guess we could have a generic Blocker object instead of using Error for the purpose.
In addition to an error message, an Error object has an error class (rarely used remnant of the past), where in the source code the Error object was created (reported to the user when handling
&error_abort), and an optional hint. Is any of this useful for blockers?
I haven't found the need for those.
Quoted 20 lines
Quoted 20 lines
Quoted 8 lines
replication.c:
error_setg(&s->blocker,"Block device is in use by internal backup job");...
bdrv_op_block_all(top_bs, s->blocker);
block.c:
voidbdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)Quoted 8 lines
{ BdrvOpBlocker *blocker; assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX); blocker = g_new0(BdrvOpBlocker, 1); blocker->reason = reason; QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list); }With regards,
Daniel