[libvirt] [RFC PATCH 2/5] qemu: parse: Drop qemuParseCommandLinePid and friends

Peter Krempa pkrempa at redhat.com
Fri Jun 14 13:30:24 UTC 2019


Now that we no longer support attaching to a live non-libvirt qemu we
can drop the backend functions as well.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_parse_command.c | 92 -----------------------------------
 src/qemu/qemu_parse_command.h |  7 ---
 2 files changed, 99 deletions(-)

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index fc3f70fcde..b522882c78 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -2767,95 +2767,3 @@ virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache,

     return def;
 }
-
-
-static int qemuParseProcFileStrings(int pid_value,
-                                    const char *name,
-                                    char ***list)
-{
-    char *path = NULL;
-    int ret = -1;
-    char *data = NULL;
-    ssize_t len;
-    char *tmp;
-    size_t nstr = 0;
-    char **str = NULL;
-
-    if (virAsprintf(&path, "/proc/%d/%s", pid_value, name) < 0)
-        goto cleanup;
-
-    if ((len = virFileReadAll(path, 1024*128, &data)) < 0)
-        goto cleanup;
-
-    tmp = data;
-    while (tmp < (data + len)) {
-        if (VIR_EXPAND_N(str, nstr, 1) < 0)
-            goto cleanup;
-
-        if (VIR_STRDUP(str[nstr-1], tmp) < 0)
-            goto cleanup;
-        /* Skip arg */
-        tmp += strlen(tmp);
-        /* Skip \0 separator */
-        tmp++;
-    }
-
-    if (VIR_EXPAND_N(str, nstr, 1) < 0)
-        goto cleanup;
-
-    str[nstr-1] = NULL;
-
-    ret = nstr-1;
-    *list = str;
-
- cleanup:
-    if (ret < 0)
-        virStringListFree(str);
-    VIR_FREE(data);
-    VIR_FREE(path);
-    return ret;
-}
-
-virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache,
-                                        virCapsPtr caps,
-                                        virDomainXMLOptionPtr xmlopt,
-                                        pid_t pid,
-                                        char **pidfile,
-                                        virDomainChrSourceDefPtr *monConfig,
-                                        bool *monJSON)
-{
-    virDomainDefPtr def = NULL;
-    char **progargv = NULL;
-    char **progenv = NULL;
-    char *exepath = NULL;
-    char *emulator;
-
-    /* The parser requires /proc/pid, which only exists on platforms
-     * like Linux where pid_t fits in int.  */
-    if ((int)pid != pid ||
-        qemuParseProcFileStrings(pid, "cmdline", &progargv) < 0 ||
-        qemuParseProcFileStrings(pid, "environ", &progenv) < 0)
-        goto cleanup;
-
-    if (!(def = qemuParseCommandLine(capsCache, caps, xmlopt, progenv, progargv,
-                                     pidfile, monConfig, monJSON)))
-        goto cleanup;
-
-    if (virAsprintf(&exepath, "/proc/%d/exe", (int)pid) < 0)
-        goto cleanup;
-
-    if (virFileResolveLink(exepath, &emulator) < 0) {
-        virReportSystemError(errno,
-                             _("Unable to resolve %s for pid %u"),
-                             exepath, (int)pid);
-        goto cleanup;
-    }
-    VIR_FREE(def->emulator);
-    def->emulator = emulator;
-
- cleanup:
-    VIR_FREE(exepath);
-    virStringListFree(progargv);
-    virStringListFree(progenv);
-    return def;
-}
diff --git a/src/qemu/qemu_parse_command.h b/src/qemu/qemu_parse_command.h
index 5eeb344c60..4dbb08fd59 100644
--- a/src/qemu/qemu_parse_command.h
+++ b/src/qemu/qemu_parse_command.h
@@ -37,13 +37,6 @@ virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache,
                                            char **pidfile,
                                            virDomainChrSourceDefPtr *monConfig,
                                            bool *monJSON);
-virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache,
-                                        virCapsPtr caps,
-                                        virDomainXMLOptionPtr xmlopt,
-                                        pid_t pid,
-                                        char **pidfile,
-                                        virDomainChrSourceDefPtr *monConfig,
-                                        bool *monJSON);

 void
 qemuParseKeywordsFree(int nkeywords,
-- 
2.21.0




More information about the libvir-list mailing list