mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Don't report false error from MigrateFinish
virDomainMigrateFinish* APIs were unfortunately designed to return the pointer to the domain on destination and NULL on error. This looks OK in normal cases but the same API is also called when we know migration failed and thus we expect Finish to return NULL even if it actually did all it was supposed to do without any error. The call is defined to return nonnull domain pointer over RPC, which means returning NULL will always result in an error being send. If this was not in fact an error, the API itself wouldn't set anything to the thread local virError, which makes the RPC layer come up with it's own "Library function returned error but did not set virError" error. This is quite confusing and also hard to detect by the caller. This patch adds a special error code which can be used to check that Finish successfully aborted migration. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
e68f395fcb
commit
44c42b564d
@ -307,6 +307,7 @@ typedef enum {
|
|||||||
VIR_ERR_CPU_INCOMPATIBLE = 91, /* given CPU is incompatible with host
|
VIR_ERR_CPU_INCOMPATIBLE = 91, /* given CPU is incompatible with host
|
||||||
CPU*/
|
CPU*/
|
||||||
VIR_ERR_XML_INVALID_SCHEMA = 92, /* XML document doesn't validate against schema */
|
VIR_ERR_XML_INVALID_SCHEMA = 92, /* XML document doesn't validate against schema */
|
||||||
|
VIR_ERR_MIGRATE_FINISH_OK = 93, /* Finish API succeeded but it is expected to return NULL */
|
||||||
} virErrorNumber;
|
} virErrorNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5751,6 +5751,12 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
|
|
||||||
|
/* Set a special error if Finish is expected to return NULL as a result of
|
||||||
|
* successful call with retcode != 0
|
||||||
|
*/
|
||||||
|
if (retcode != 0 && !dom && !virGetLastError())
|
||||||
|
virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,6 +1369,9 @@ virErrorMsg(virErrorNumber error, const char *info)
|
|||||||
else
|
else
|
||||||
errmsg = _("XML document failed to validate against schema: %s");
|
errmsg = _("XML document failed to validate against schema: %s");
|
||||||
break;
|
break;
|
||||||
|
case VIR_ERR_MIGRATE_FINISH_OK:
|
||||||
|
errmsg = _("migration successfully aborted");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return errmsg;
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user