mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: Escape snapshot name passed to {save,load,del}vm
This commit is contained in:
parent
89241fe0d1
commit
81711cee34
@ -2566,13 +2566,15 @@ cleanup:
|
||||
|
||||
int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
{
|
||||
char *cmd;
|
||||
char *cmd = NULL;
|
||||
char *reply = NULL;
|
||||
int ret = -1;
|
||||
char *safename;
|
||||
|
||||
if (virAsprintf(&cmd, "savevm \"%s\"", name) < 0) {
|
||||
if (!(safename = qemuMonitorEscapeArg(name)) ||
|
||||
virAsprintf(&cmd, "savevm \"%s\"", safename) < 0) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
|
||||
@ -2604,6 +2606,7 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(safename);
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(reply);
|
||||
return ret;
|
||||
@ -2611,13 +2614,15 @@ cleanup:
|
||||
|
||||
int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
{
|
||||
char *cmd;
|
||||
char *cmd = NULL;
|
||||
char *reply = NULL;
|
||||
int ret = -1;
|
||||
char *safename;
|
||||
|
||||
if (virAsprintf(&cmd, "loadvm \"%s\"", name) < 0) {
|
||||
if (!(safename = qemuMonitorEscapeArg(name)) ||
|
||||
virAsprintf(&cmd, "loadvm \"%s\"", safename) < 0) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
|
||||
@ -2660,6 +2665,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(safename);
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(reply);
|
||||
return ret;
|
||||
@ -2667,13 +2673,15 @@ cleanup:
|
||||
|
||||
int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
{
|
||||
char *cmd;
|
||||
char *cmd = NULL;
|
||||
char *reply = NULL;
|
||||
int ret = -1;
|
||||
char *safename;
|
||||
|
||||
if (virAsprintf(&cmd, "delvm \"%s\"", name) < 0) {
|
||||
if (!(safename = qemuMonitorEscapeArg(name)) ||
|
||||
virAsprintf(&cmd, "delvm \"%s\"", safename) < 0) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
|
||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
||||
@ -2700,6 +2708,7 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(safename);
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(reply);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user