maint: clean up error reporting in migration

The choice of error message and category was not consistent
in the migration code; furthermore, the use of virLibConnError
is no longer necessary now that we have a generic virReportError.

* src/qemu/qemu_migration.c (virDomainMigrate*): Prefer
virReportError over virLibConnError.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2013-12-28 06:40:10 -07:00
parent c8ed177af4
commit 27553573f2

View File

@ -4468,7 +4468,7 @@ virDomainMigrateVersion1(virDomainPtr domain,
goto done;
if (uri == NULL && uri_out == NULL) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare did not set uri"));
goto done;
}
@ -4560,7 +4560,7 @@ virDomainMigrateVersion2(virDomainPtr domain,
* and pass it to Prepare2.
*/
if (!domain->conn->driver->domainGetXMLDesc) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
virReportUnsupportedError();
return NULL;
}
@ -4590,7 +4590,7 @@ virDomainMigrateVersion2(virDomainPtr domain,
goto done;
if (uri == NULL && uri_out == NULL) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare2 did not set uri"));
cancelled = 1;
/* Make sure Finish doesn't overwrite the error */
@ -4715,7 +4715,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
!domain->conn->driver->domainMigrateConfirm3Params ||
!dconn->driver->domainMigratePrepare3Params ||
!dconn->driver->domainMigrateFinish3Params))) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
virReportUnsupportedError();
return NULL;
}
@ -4797,7 +4797,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
} else if (!uri &&
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_URI, &uri) <= 0) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare3 did not set uri"));
cancelled = 1;
orig_err = virSaveLastError();
@ -5010,7 +5010,7 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain,
(!useParams &&
!domain->conn->driver->domainMigratePerform &&
!domain->conn->driver->domainMigratePerform3)) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
virReportUnsupportedError();
return -1;
}
@ -5039,13 +5039,13 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain,
} else {
VIR_DEBUG("Using migration protocol 2");
if (xmlin) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML "
"during migration"));
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during "
"migration"));
return -1;
}
if (uri) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to override peer2peer migration URI"));
return -1;
}
@ -5132,7 +5132,7 @@ virDomainMigrateDirect(virDomainPtr domain,
} else {
VIR_DEBUG("Using migration protocol 2");
if (xmlin) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during migration"));
return -1;
}
@ -5261,14 +5261,14 @@ virDomainMigrate(virDomainPtr domain,
if (flags & VIR_MIGRATE_OFFLINE) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
goto error;
}
if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the destination host"));
goto error;
@ -5308,13 +5308,13 @@ virDomainMigrate(virDomainPtr domain,
if (flags & VIR_MIGRATE_CHANGE_PROTECTION &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("cannot enforce change protection"));
goto error;
}
flags &= ~VIR_MIGRATE_CHANGE_PROTECTION;
if (flags & VIR_MIGRATE_TUNNELLED) {
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot perform tunnelled migration without using peer2peer flag"));
goto error;
}
@ -5487,14 +5487,14 @@ virDomainMigrate2(virDomainPtr domain,
if (flags & VIR_MIGRATE_OFFLINE) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
goto error;
}
if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the destination host"));
goto error;
@ -5531,13 +5531,13 @@ virDomainMigrate2(virDomainPtr domain,
if (flags & VIR_MIGRATE_CHANGE_PROTECTION &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("cannot enforce change protection"));
goto error;
}
flags &= ~VIR_MIGRATE_CHANGE_PROTECTION;
if (flags & VIR_MIGRATE_TUNNELLED) {
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot perform tunnelled migration without using peer2peer flag"));
goto error;
}
@ -5556,7 +5556,7 @@ virDomainMigrate2(virDomainPtr domain,
VIR_DRV_FEATURE_MIGRATION_V2)) {
VIR_DEBUG("Using migration protocol 2");
if (dxml) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during migration"));
goto error;
}
@ -5568,7 +5568,7 @@ virDomainMigrate2(virDomainPtr domain,
VIR_DRV_FEATURE_MIGRATION_V1)) {
VIR_DEBUG("Using migration protocol 1");
if (dxml) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during migration"));
goto error;
}
@ -5670,14 +5670,14 @@ virDomainMigrate3(virDomainPtr domain,
if (flags & VIR_MIGRATE_OFFLINE) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
goto error;
}
if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the destination host"));
goto error;
@ -5692,7 +5692,7 @@ virDomainMigrate3(virDomainPtr domain,
if (flags & VIR_MIGRATE_CHANGE_PROTECTION &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("cannot enforce change protection"));
goto error;
}
@ -5712,7 +5712,7 @@ virDomainMigrate3(virDomainPtr domain,
if (!virTypedParamsCheck(params, nparams, compatParams,
ARRAY_CARDINALITY(compatParams))) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Migration APIs with extensible parameters are not "
"supported but extended parameters were passed"));
goto error;
@ -5742,7 +5742,7 @@ virDomainMigrate3(virDomainPtr domain,
VIR_DRV_FEATURE_MIGRATION_V2)) {
VIR_DEBUG("Using migration protocol 2");
if (dxml) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during "
"migration"));
goto error;
@ -5755,7 +5755,7 @@ virDomainMigrate3(virDomainPtr domain,
VIR_DRV_FEATURE_MIGRATION_V1)) {
VIR_DEBUG("Using migration protocol 1");
if (dxml) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during "
"migration"));
goto error;
@ -5881,7 +5881,7 @@ virDomainMigrateToURI(virDomainPtr domain,
if (flags & VIR_MIGRATE_OFFLINE &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
goto error;
@ -5908,7 +5908,7 @@ virDomainMigrateToURI(virDomainPtr domain,
goto error;
} else {
/* Cannot do a migration with only the perform step */
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("direct migration is not supported by the"
" connection driver"));
goto error;
@ -6056,7 +6056,7 @@ virDomainMigrateToURI2(virDomainPtr domain,
goto error;
} else {
/* Cannot do a migration with only the perform step */
virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("direct migration is not supported by the"
" connection driver"));
goto error;
@ -6161,7 +6161,7 @@ virDomainMigrateToURI3(virDomainPtr domain,
if (flags & VIR_MIGRATE_PEER2PEER) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_P2P)) {
virLibConnError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Peer-to-peer migration is not supported by "
"the connection driver"));
goto error;
@ -6179,7 +6179,7 @@ virDomainMigrateToURI3(virDomainPtr domain,
dconnuri, uri, bandwidth) < 0)
goto error;
} else {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Peer-to-peer migration with extensible "
"parameters is not supported but extended "
"parameters were passed"));
@ -6189,14 +6189,14 @@ virDomainMigrateToURI3(virDomainPtr domain,
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_DIRECT)) {
/* Cannot do a migration with only the perform step */
virLibConnError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Direct migration is not supported by the"
" connection driver"));
goto error;
}
if (!compat) {
virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Direct migration does not support extensible "
"parameters"));
goto error;