mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemu: monitor: Refactor error handling for 'savevm'
Unify few error conditions into a single error reporting case.
This commit is contained in:
parent
ef01addb38
commit
0c1b0d83bb
@ -2640,7 +2640,10 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
|
||||
int
|
||||
qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
|
||||
const char *name)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
char *reply = NULL;
|
||||
@ -2654,21 +2657,16 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
if (qemuMonitorHMPCommand(mon, cmd, &reply))
|
||||
goto cleanup;
|
||||
|
||||
if (strstr(reply, "Error while creating snapshot") != NULL) {
|
||||
if (strstr(reply, "Error while creating snapshot") ||
|
||||
strstr(reply, "Could not open VM state file") ||
|
||||
(strstr(reply, "Error") && strstr(reply, "while writing VM"))) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("Failed to take snapshot: %s"), reply);
|
||||
goto cleanup;
|
||||
} else if (strstr(reply, "No block device can accept snapshots") != NULL) {
|
||||
} else if (strstr(reply, "No block device can accept snapshots")) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("this domain does not have a device to take snapshots"));
|
||||
goto cleanup;
|
||||
} else if (strstr(reply, "Could not open VM state file") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
} else if (strstr(reply, "Error") != NULL
|
||||
&& strstr(reply, "while writing VM") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user