1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

qemu: parse: Drop qemuParseCommandLinePid and friends

Now that we no longer support attaching to a live QEMU process not
managed by libvirt we can drop the backend functions as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Peter Krempa 2019-06-14 14:43:14 +02:00
parent 215d9393bb
commit 953b88fc88
2 changed files with 0 additions and 99 deletions

View File

@ -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;
}

View File

@ -36,13 +36,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,