提交 62aff792 编写于 作者: J Jovanka Gulicoska 提交者: Cole Robinson

qemu: Replace VIR_ERROR with standard vir*Error in state driver init

上级 9c9afba4
...@@ -290,14 +290,16 @@ qemuAutostartDomain(virDomainObjPtr vm, ...@@ -290,14 +290,16 @@ qemuAutostartDomain(virDomainObjPtr vm,
if (vm->autostart && if (vm->autostart &&
!virDomainObjIsActive(vm)) { !virDomainObjIsActive(vm)) {
if (qemuProcessBeginJob(data->driver, vm) < 0) { if (qemuProcessBeginJob(data->driver, vm) < 0) {
VIR_ERROR(_("Failed to start job on VM '%s': %s"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to start job on VM '%s': %s"),
vm->def->name, virGetLastErrorMessage()); vm->def->name, virGetLastErrorMessage());
goto cleanup; goto cleanup;
} }
if (qemuDomainObjStart(data->conn, data->driver, vm, flags, if (qemuDomainObjStart(data->conn, data->driver, vm, flags,
QEMU_ASYNC_JOB_START) < 0) { QEMU_ASYNC_JOB_START) < 0) {
VIR_ERROR(_("Failed to autostart VM '%s': %s"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart VM '%s': %s"),
vm->def->name, virGetLastErrorMessage()); vm->def->name, virGetLastErrorMessage());
} }
...@@ -450,7 +452,8 @@ qemuSecurityInit(virQEMUDriverPtr driver) ...@@ -450,7 +452,8 @@ qemuSecurityInit(virQEMUDriverPtr driver)
return 0; return 0;
error: error:
VIR_ERROR(_("Failed to initialize security drivers")); virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialize security drivers"));
virObjectUnref(stack); virObjectUnref(stack);
virObjectUnref(mgr); virObjectUnref(mgr);
virObjectUnref(cfg); virObjectUnref(cfg);
...@@ -471,7 +474,6 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -471,7 +474,6 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
virDomainSnapshotDefPtr def = NULL; virDomainSnapshotDefPtr def = NULL;
virDomainSnapshotObjPtr snap = NULL; virDomainSnapshotObjPtr snap = NULL;
virDomainSnapshotObjPtr current = NULL; virDomainSnapshotObjPtr current = NULL;
char ebuf[1024];
unsigned int flags = (VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE | unsigned int flags = (VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE |
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL); VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL);
...@@ -481,7 +483,9 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -481,7 +483,9 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
virObjectLock(vm); virObjectLock(vm);
if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) { if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
VIR_ERROR(_("Failed to allocate memory for snapshot directory for domain %s"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to allocate memory for "
"snapshot directory for domain %s"),
vm->def->name); vm->def->name);
goto cleanup; goto cleanup;
} }
...@@ -494,9 +498,10 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -494,9 +498,10 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
if (!(dir = opendir(snapDir))) { if (!(dir = opendir(snapDir))) {
if (errno != ENOENT) if (errno != ENOENT)
VIR_ERROR(_("Failed to open snapshot directory %s for domain %s: %s"), virReportSystemError(errno,
snapDir, vm->def->name, _("Failed to open snapshot directory %s "
virStrerror(errno, ebuf, sizeof(ebuf))); "for domain %s"),
snapDir, vm->def->name);
goto cleanup; goto cleanup;
} }
...@@ -509,14 +514,16 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -509,14 +514,16 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
VIR_INFO("Loading snapshot file '%s'", entry->d_name); VIR_INFO("Loading snapshot file '%s'", entry->d_name);
if (virAsprintf(&fullpath, "%s/%s", snapDir, entry->d_name) < 0) { 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; continue;
} }
if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) { if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) {
/* Nothing we can do here, skip this one */ /* Nothing we can do here, skip this one */
VIR_ERROR(_("Failed to read snapshot file %s: %s"), fullpath, virReportSystemError(errno,
virStrerror(errno, ebuf, sizeof(ebuf))); _("Failed to read snapshot file %s"),
fullpath);
VIR_FREE(fullpath); VIR_FREE(fullpath);
continue; continue;
} }
...@@ -526,7 +533,8 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -526,7 +533,8 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
flags); flags);
if (def == NULL) { if (def == NULL) {
/* Nothing we can do here, skip this one */ /* Nothing we can do here, skip this one */
VIR_ERROR(_("Failed to parse snapshot XML from file '%s'"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse snapshot XML from file '%s'"),
fullpath); fullpath);
VIR_FREE(fullpath); VIR_FREE(fullpath);
VIR_FREE(xmlStr); VIR_FREE(xmlStr);
...@@ -546,16 +554,20 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -546,16 +554,20 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
VIR_FREE(xmlStr); VIR_FREE(xmlStr);
} }
if (direrr < 0) 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) { if (vm->current_snapshot != current) {
VIR_ERROR(_("Too many snapshots claiming to be current for domain %s"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Too many snapshots claiming to be current for domain %s"),
vm->def->name); vm->def->name);
vm->current_snapshot = NULL; vm->current_snapshot = NULL;
} }
if (virDomainSnapshotUpdateRelations(vm->snapshots) < 0) if (virDomainSnapshotUpdateRelations(vm->snapshots) < 0)
VIR_ERROR(_("Snapshots have inconsistent relations for domain %s"), virReportError(VIR_ERR_INTERNAL_ERROR,
_("Snapshots have inconsistent relations for domain %s"),
vm->def->name); vm->def->name);
/* FIXME: qemu keeps internal track of snapshots. We can get access /* FIXME: qemu keeps internal track of snapshots. We can get access
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册