Remove the old-style 'device_add' helpers which parse the commandline
arguments to JSON since we now coverted all usage to use JSON directly.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 34 --------
src/qemu/qemu_monitor.h | 7 --
src/qemu/qemu_monitor_json.c | 151 -----------------------------------
src/qemu/qemu_monitor_json.h | 2 -
tests/qemumonitorjsontest.c | 2 -
5 files changed, 196 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index fe65d46ae9..7ff6a1161f 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2858,40 +2858,6 @@ qemuMonitorDelDevice(qemuMonitor *mon,
}
-int
-qemuMonitorAddDeviceWithFd(qemuMonitor *mon,
- const char *devicestr,
- int fd,
- const char *fdname)
-{
- int ret;
-
- VIR_DEBUG("device=%s fd=%d fdname=%s", devicestr, fd, NULLSTR(fdname));
-
- QEMU_CHECK_MONITOR(mon);
-
- if (fd >= 0 && qemuMonitorSendFileHandle(mon, fdname, fd) < 0)
- return -1;
-
- ret = qemuMonitorJSONAddDevice(mon, devicestr);
-
- if (ret < 0 && fd >= 0) {
- if (qemuMonitorCloseFileHandle(mon, fdname) < 0)
- VIR_WARN("failed to close device handle '%s'", fdname);
- }
-
- return ret;
-}
-
-
-int
-qemuMonitorAddDevice(qemuMonitor *mon,
- const char *devicestr)
-{
- return qemuMonitorAddDeviceWithFd(mon, devicestr, -1, NULL);
-}
-
-
/**
* qemuMonitorAddDeviceProps:
* @mon: monitor object
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 5edf6a161b..52ff34d316 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1030,13 +1030,6 @@ int qemuMonitorAttachPCIDiskController(qemuMonitor *mon,
int qemuMonitorAddDeviceProps(qemuMonitor *mon,
virJSONValue **props);
-int qemuMonitorAddDevice(qemuMonitor *mon,
- const char *devicestr);
-
-int qemuMonitorAddDeviceWithFd(qemuMonitor *mon,
- const char *devicestr,
- int fd,
- const char *fdname);
int qemuMonitorDelDevice(qemuMonitor *mon,
const char *devalias);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f831cfeeb5..579d986e02 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -579,144 +579,6 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
}
-static void
-qemuMonitorJSONParseKeywordsFree(int nkeywords,
- char **keywords,
- char **values)
-{
- size_t i;
- for (i = 0; i < nkeywords; i++) {
- g_free(keywords[i]);
- g_free(values[i]);
- }
- g_free(keywords);
- g_free(values);
-}
-
-
-/*
- * Takes a string containing a set of key=value,key=value,key...
- * parameters and splits them up, returning two arrays with
- * the individual keys and values.
- * The "=value" part is optional and if a key with no value is found,
- * NULL will be placed into corresponding place in retvalues.
- */
-static int
-qemuMonitorJSONParseKeywords(const char *str,
- char ***retkeywords,
- char ***retvalues,
- int *retnkeywords)
-{
- int keywordCount = 0;
- int keywordAlloc = 0;
- char **keywords = NULL;
- char **values = NULL;
- const char *start = str;
- const char *end;
-
- *retkeywords = NULL;
- *retvalues = NULL;
- *retnkeywords = 0;
- end = start + strlen(str);
-
- while (start) {
- const char *separator;
- const char *endmark;
- char *keyword;
- char *value = NULL;
-
- endmark = start;
- do {
- /* QEMU accepts ',,' as an escape for a literal comma;
- * skip past those here while searching for the end of the
- * value, then strip them down below */
- endmark = strchr(endmark, ',');
- } while (endmark && endmark[1] == ',' && (endmark +=
2));
- if (!endmark)
- endmark = end;
- if (!(separator = strchr(start, '=')))
- separator = end;
-
- if (separator >= endmark)
- separator = endmark;
-
- keyword = g_strndup(start, separator - start);
-
- if (separator < endmark) {
- separator++;
- value = g_strndup(separator, endmark - separator);
- if (strchr(value, ',')) {
- char *p = strchr(value, ',') + 1;
- char *q = p + 1;
- while (*q) {
- if (*q == ',')
- q++;
- *p++ = *q++;
- }
- *p = '\0';
- }
- }
-
- if (keywordAlloc == keywordCount) {
- VIR_REALLOC_N(keywords, keywordAlloc + 10);
- VIR_REALLOC_N(values, keywordAlloc + 10);
- keywordAlloc += 10;
- }
-
- keywords[keywordCount] = keyword;
- values[keywordCount] = value;
- keywordCount++;
-
- start = endmark < end ? endmark + 1 : NULL;
- }
-
- *retkeywords = keywords;
- *retvalues = values;
- *retnkeywords = keywordCount;
- return 0;
-}
-
-
-static virJSONValue *
-qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
-{
- virJSONValue *ret = virJSONValueNewObject();
- char **keywords = NULL;
- char **values = NULL;
- int nkeywords = 0;
- size_t i;
-
- if (qemuMonitorJSONParseKeywords(str, &keywords, &values, &nkeywords)
< 0)
- goto error;
-
- for (i = 0; i < nkeywords; i++) {
- if (values[i] == NULL) {
- if (i != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected empty keyword in %s"), str);
- goto error;
- } else {
- /* This 3rd arg isn't a typo - the way the parser works is
- * that the value ended up in the keyword field */
- if (virJSONValueObjectAppendString(ret, firstkeyword, keywords[i]) <
0)
- goto error;
- }
- } else {
- if (virJSONValueObjectAppendString(ret, keywords[i], values[i]) < 0)
- goto error;
- }
- }
-
- qemuMonitorJSONParseKeywordsFree(nkeywords, keywords, values);
- return ret;
-
- error:
- qemuMonitorJSONParseKeywordsFree(nkeywords, keywords, values);
- virJSONValueFree(ret);
- return NULL;
-}
-
-
static void qemuMonitorJSONHandleShutdown(qemuMonitor *mon, virJSONValue *data)
{
bool guest = false;
@@ -4576,19 +4438,6 @@ qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
}
-int
-qemuMonitorJSONAddDevice(qemuMonitor *mon,
- const char *devicestr)
-{
- g_autoptr(virJSONValue) props = NULL;
-
- if (!(props = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver")))
- return -1;
-
- return qemuMonitorJSONAddDeviceProps(mon, &props);
-}
-
-
int
qemuMonitorJSONAddObject(qemuMonitor *mon,
virJSONValue **props)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 8dc2350642..c841de0a03 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -237,8 +237,6 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitor *mon,
int qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
virJSONValue **props);
-int qemuMonitorJSONAddDevice(qemuMonitor *mon,
- const char *devicestr);
int qemuMonitorJSONDelDevice(qemuMonitor *mon,
const char *devalias);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 1e4c2fd14e..30a19d27e8 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1184,7 +1184,6 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate,
VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
"localhost", 12345, 12346, "certsubjectval")
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
-GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar",
"formatstr", 1024, 1234, 31234, true, true)
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb",
"targetnode", 1024, 1234, 31234, true)
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true,
"/foo/bar1", "backingnode", "backingfilename", 1024)
@@ -3024,7 +3023,6 @@ mymain(void)
DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate);
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
DO_TEST_GEN(qemuMonitorJSONDelDevice);
- DO_TEST_GEN(qemuMonitorJSONAddDevice);
DO_TEST_GEN(qemuMonitorJSONDriveMirror);
DO_TEST_GEN(qemuMonitorJSONBlockdevMirror);
DO_TEST_GEN(qemuMonitorJSONBlockStream);
--
2.31.1