1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

qemu: replace qemuMonitorEscapeShell by virBufferEscapeShell

This commit is contained in:
Guido Günther 2011-10-18 21:09:13 +02:00
parent 04323fbcb4
commit 46a1168129
2 changed files with 5 additions and 45 deletions

View File

@ -139,48 +139,6 @@ char *qemuMonitorEscapeArg(const char *in)
return out;
}
char *qemuMonitorEscapeShell(const char *in)
{
int len = 2; /* leading and trailing single quote */
int i, j;
char *out;
for (i = 0; in[i] != '\0'; i++) {
switch(in[i]) {
case '\'':
len += 4; /* '\'' */
break;
default:
len += 1;
break;
}
}
if (VIR_ALLOC_N(out, len + 1) < 0)
return NULL;
j = 0;
out[j++] = '\'';
for (i = 0; in[i] != '\0'; i++) {
switch(in[i]) {
case '\'':
out[j++] = '\'';
out[j++] = '\\';
out[j++] = '\'';
out[j++] = '\'';
break;
default:
out[j++] = in[i];
break;
}
}
out[j++] = '\'';
out[j] = '\0';
return out;
}
#if DEBUG_RAW_IO
# include <c-ctype.h>
static char * qemuMonitorEscapeNonPrintable(const char *text)
@ -1734,6 +1692,7 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
char *dest = NULL;
int ret = -1;
char *safe_target = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
VIR_DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%x",
mon, argv, target, offset, flags);
@ -1757,11 +1716,13 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
}
/* Migrate to file */
safe_target = qemuMonitorEscapeShell(target);
if (!safe_target) {
virBufferEscapeShell(&buf, target);
if (virBufferError(&buf)) {
virReportOOMError();
virBufferFreeAndReset(&buf);
goto cleanup;
}
safe_target = virBufferContentAndReset(&buf);
/* Two dd processes, sharing the same stdout, are necessary to
* allow starting at an alignment of 512, but without wasting

View File

@ -127,7 +127,6 @@ struct _qemuMonitorCallbacks {
char *qemuMonitorEscapeArg(const char *in);
char *qemuMonitorEscapeShell(const char *in);
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
virDomainChrSourceDefPtr config,