mirror of https://gitee.com/openkylin/libvirt.git
qemu: Replace VIR_ERROR with standard vir*Error in state driver init
This commit is contained in:
parent
9c9afba4c0
commit
62aff792ac
|
@ -290,15 +290,17 @@ 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,
|
||||||
vm->def->name, virGetLastErrorMessage());
|
_("Failed to start job on VM '%s': %s"),
|
||||||
|
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,
|
||||||
vm->def->name, virGetLastErrorMessage());
|
_("Failed to autostart VM '%s': %s"),
|
||||||
|
vm->def->name, virGetLastErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuProcessEndJob(data->driver, vm);
|
qemuProcessEndJob(data->driver, vm);
|
||||||
|
@ -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,
|
||||||
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,8 +483,10 @@ 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,
|
||||||
vm->def->name);
|
_("Failed to allocate memory for "
|
||||||
|
"snapshot directory for domain %s"),
|
||||||
|
vm->def->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
||||||
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,8 +533,9 @@ 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,
|
||||||
fullpath);
|
_("Failed to parse snapshot XML from file '%s'"),
|
||||||
|
fullpath);
|
||||||
VIR_FREE(fullpath);
|
VIR_FREE(fullpath);
|
||||||
VIR_FREE(xmlStr);
|
VIR_FREE(xmlStr);
|
||||||
continue;
|
continue;
|
||||||
|
@ -546,17 +554,21 @@ 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,
|
||||||
vm->def->name);
|
_("Too many snapshots claiming to be current for domain %s"),
|
||||||
|
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,
|
||||||
vm->def->name);
|
_("Snapshots have inconsistent relations for domain %s"),
|
||||||
|
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
|
||||||
* to this info via the "info snapshots" monitor command for running
|
* to this info via the "info snapshots" monitor command for running
|
||||||
|
|
Loading…
Reference in New Issue