Replace VIR_ERROR with virReportError and virReportSystemError
---
src/qemu/qemu_driver.c | 55 ++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 249393a..e711204 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -290,15 +290,17 @@ qemuAutostartDomain(virDomainObjPtr vm,
if (vm->autostart &&
!virDomainObjIsActive(vm)) {
if (qemuProcessBeginJob(data->driver, vm) < 0) {
- VIR_ERROR(_("Failed to start job on VM '%s': %s"),
- vm->def->name, virGetLastErrorMessage());
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to start job on VM '%s': %s"),
+ vm->def->name, virGetLastErrorMessage());
goto cleanup;
}
if (qemuDomainObjStart(data->conn, data->driver, vm, flags,
QEMU_ASYNC_JOB_START) < 0) {
- VIR_ERROR(_("Failed to autostart VM '%s': %s"),
- vm->def->name, virGetLastErrorMessage());
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to autostart VM '%s': %s"),
+ vm->def->name, virGetLastErrorMessage());
}
qemuProcessEndJob(data->driver, vm);
@@ -450,7 +452,8 @@ qemuSecurityInit(virQEMUDriverPtr driver)
return 0;
error:
- VIR_ERROR(_("Failed to initialize security drivers"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to initialize security drivers"));
virObjectUnref(stack);
virObjectUnref(mgr);
virObjectUnref(cfg);
@@ -481,8 +484,10 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
virObjectLock(vm);
if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) <
0) {
- VIR_ERROR(_("Failed to allocate memory for snapshot directory for domain
%s"),
- vm->def->name);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to allocate memory for "
+ "snapshot directory for domain %s"),
+ vm->def->name);
goto cleanup;
}
@@ -494,9 +499,11 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
if (!(dir = opendir(snapDir))) {
if (errno != ENOENT)
- VIR_ERROR(_("Failed to open snapshot directory %s for domain %s:
%s"),
- snapDir, vm->def->name,
- virStrerror(errno, ebuf, sizeof(ebuf)));
+ virReportSystemError(errno,
+ _("Failed to open snapshot directory %s "
+ "for domain %s: %s"),
+ snapDir, vm->def->name,
+ virStrerror(errno, ebuf, sizeof(ebuf)));
goto cleanup;
}
@@ -509,14 +516,17 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
VIR_INFO("Loading snapshot file '%s'", entry->d_name);
if (virAsprintf(&fullpath, "%s/%s", snapDir, entry->d_name) <
0) {
- VIR_ERROR(_("Failed to allocate memory for path"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to allocate memory for path"));
continue;
}
if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) {
/* Nothing we can do here, skip this one */
- VIR_ERROR(_("Failed to read snapshot file %s: %s"), fullpath,
- virStrerror(errno, ebuf, sizeof(ebuf)));
+ virReportSystemError(errno,
+ _("Failed to read snapshot file %s: %s"),
+ fullpath,
+ virStrerror(errno, ebuf, sizeof(ebuf)));
VIR_FREE(fullpath);
continue;
}
@@ -526,8 +536,9 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
flags);
if (def == NULL) {
/* Nothing we can do here, skip this one */
- VIR_ERROR(_("Failed to parse snapshot XML from file
'%s'"),
- fullpath);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to parse snapshot XML from file
'%s'"),
+ fullpath);
VIR_FREE(fullpath);
VIR_FREE(xmlStr);
continue;
@@ -546,17 +557,21 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
VIR_FREE(xmlStr);
}
if (direrr < 0)
- VIR_ERROR(_("Failed to fully read directory %s"), snapDir);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to fully read directory %s"),
+ snapDir);
if (vm->current_snapshot != current) {
- VIR_ERROR(_("Too many snapshots claiming to be current for domain
%s"),
- vm->def->name);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Too many snapshots claiming to be current for domain
%s"),
+ vm->def->name);
vm->current_snapshot = NULL;
}
if (virDomainSnapshotUpdateRelations(vm->snapshots) < 0)
- VIR_ERROR(_("Snapshots have inconsistent relations for domain %s"),
- vm->def->name);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Snapshots have inconsistent relations for domain
%s"),
+ vm->def->name);
/* FIXME: qemu keeps internal track of snapshots. We can get access
* to this info via the "info snapshots" monitor command for running
--
2.5.5