---
src/qemu/qemu_monitor.c | 49 ++++------------------------------------------
src/qemu/qemu_monitor.h | 1 -
2 files changed, 5 insertions(+), 45 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c9dd69e..182e63d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -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
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 3ec78ad..90e7b45 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -127,7 +127,6 @@ struct _qemuMonitorCallbacks {
char *qemuMonitorEscapeArg(const char *in);
-char *qemuMonitorEscapeShell(const char *in);
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
virDomainChrSourceDefPtr config,
--
1.7.6.3
Show replies by date
On 10/18/2011 01:36 PM, Guido Günther wrote:
---
src/qemu/qemu_monitor.c | 49 ++++------------------------------------------
src/qemu/qemu_monitor.h | 1 -
2 files changed, 5 insertions(+), 45 deletions(-)
ACK, and nice diffstat ratio.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org