|
|
147b37 |
From fd11d55c30553c37d3d71d202348ac22029cba8d Mon Sep 17 00:00:00 2001
|
|
|
147b37 |
Message-Id: <fd11d55c30553c37d3d71d202348ac22029cba8d@dist-git>
|
|
|
147b37 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
147b37 |
Date: Fri, 13 Apr 2018 10:09:29 +0200
|
|
|
147b37 |
Subject: [PATCH] qemu: Use dynamic buffer for storing PTY aliases
|
|
|
147b37 |
MIME-Version: 1.0
|
|
|
147b37 |
Content-Type: text/plain; charset=UTF-8
|
|
|
147b37 |
Content-Transfer-Encoding: 8bit
|
|
|
147b37 |
|
|
|
147b37 |
RHEL-7.6: https://bugzilla.redhat.com/show_bug.cgi?id=1560976
|
|
|
147b37 |
RHEL-7.5.z: https://bugzilla.redhat.com/show_bug.cgi?id=1566525
|
|
|
147b37 |
|
|
|
147b37 |
For historical reasons we've used 32 bytes long static buffer for
|
|
|
147b37 |
storing PTY aliases. This breaks users scenario where they try to
|
|
|
147b37 |
start a machine with user alias consisting of "ua-$uuid".
|
|
|
147b37 |
|
|
|
147b37 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
147b37 |
(cherry picked from commit c4c32cb300beba41ecbca3ee4884c65630bde861)
|
|
|
147b37 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
147b37 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
147b37 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
147b37 |
---
|
|
|
147b37 |
src/qemu/qemu_process.c | 39 ++++++++++++++++++++-------------------
|
|
|
147b37 |
1 file changed, 20 insertions(+), 19 deletions(-)
|
|
|
147b37 |
|
|
|
147b37 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
147b37 |
index c86f7d3c5b..04147f381e 100644
|
|
|
147b37 |
--- a/src/qemu/qemu_process.c
|
|
|
147b37 |
+++ b/src/qemu/qemu_process.c
|
|
|
147b37 |
@@ -1931,21 +1931,18 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
|
|
|
147b37 |
int count,
|
|
|
147b37 |
virHashTablePtr info)
|
|
|
147b37 |
{
|
|
|
147b37 |
+ char *id = NULL;
|
|
|
147b37 |
size_t i;
|
|
|
147b37 |
+ int ret = -1;
|
|
|
147b37 |
|
|
|
147b37 |
for (i = 0; i < count; i++) {
|
|
|
147b37 |
virDomainChrDefPtr chr = devices[i];
|
|
|
147b37 |
if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) {
|
|
|
147b37 |
- char id[32];
|
|
|
147b37 |
qemuMonitorChardevInfoPtr entry;
|
|
|
147b37 |
|
|
|
147b37 |
- if (snprintf(id, sizeof(id), "char%s",
|
|
|
147b37 |
- chr->info.alias) >= sizeof(id)) {
|
|
|
147b37 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
147b37 |
- _("failed to format device alias "
|
|
|
147b37 |
- "for PTY retrieval"));
|
|
|
147b37 |
+ VIR_FREE(id);
|
|
|
147b37 |
+ if (virAsprintf(&id, "char%s", chr->info.alias) < 0)
|
|
|
147b37 |
return -1;
|
|
|
147b37 |
- }
|
|
|
147b37 |
|
|
|
147b37 |
entry = virHashLookup(info, id);
|
|
|
147b37 |
if (!entry || !entry->ptyPath) {
|
|
|
147b37 |
@@ -1955,7 +1952,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
|
|
|
147b37 |
*/
|
|
|
147b37 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
147b37 |
_("no assigned pty for device %s"), id);
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
+ goto cleanup;
|
|
|
147b37 |
} else {
|
|
|
147b37 |
/* 'info chardev' had no pty path for this chardev,
|
|
|
147b37 |
* but the log output had, so we're fine
|
|
|
147b37 |
@@ -1966,11 +1963,14 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
|
|
|
147b37 |
|
|
|
147b37 |
VIR_FREE(chr->source->data.file.path);
|
|
|
147b37 |
if (VIR_STRDUP(chr->source->data.file.path, entry->ptyPath) < 0)
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
+ goto cleanup;
|
|
|
147b37 |
}
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- return 0;
|
|
|
147b37 |
+ ret = 0;
|
|
|
147b37 |
+ cleanup:
|
|
|
147b37 |
+ VIR_FREE(id);
|
|
|
147b37 |
+ return ret;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
static int
|
|
|
147b37 |
@@ -2022,7 +2022,8 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
|
|
|
147b37 |
int agentReason = VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL;
|
|
|
147b37 |
qemuMonitorChardevInfoPtr entry;
|
|
|
147b37 |
virObjectEventPtr event = NULL;
|
|
|
147b37 |
- char id[32];
|
|
|
147b37 |
+ char *id = NULL;
|
|
|
147b37 |
+ int ret = -1;
|
|
|
147b37 |
|
|
|
147b37 |
if (booted)
|
|
|
147b37 |
agentReason = VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_DOMAIN_STARTED;
|
|
|
147b37 |
@@ -2030,13 +2031,10 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
|
|
|
147b37 |
for (i = 0; i < vm->def->nchannels; i++) {
|
|
|
147b37 |
virDomainChrDefPtr chr = vm->def->channels[i];
|
|
|
147b37 |
if (chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
|
|
|
147b37 |
- if (snprintf(id, sizeof(id), "char%s",
|
|
|
147b37 |
- chr->info.alias) >= sizeof(id)) {
|
|
|
147b37 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
147b37 |
- _("failed to format device alias "
|
|
|
147b37 |
- "for PTY retrieval"));
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
- }
|
|
|
147b37 |
+
|
|
|
147b37 |
+ VIR_FREE(id);
|
|
|
147b37 |
+ if (virAsprintf(&id, "char%s", chr->info.alias) < 0)
|
|
|
147b37 |
+ goto cleanup;
|
|
|
147b37 |
|
|
|
147b37 |
/* port state not reported */
|
|
|
147b37 |
if (!(entry = virHashLookup(info, id)) ||
|
|
|
147b37 |
@@ -2053,7 +2051,10 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
|
|
|
147b37 |
}
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- return 0;
|
|
|
147b37 |
+ ret = 0;
|
|
|
147b37 |
+ cleanup:
|
|
|
147b37 |
+ VIR_FREE(id);
|
|
|
147b37 |
+ return ret;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
|
|
|
147b37 |
--
|
|
|
147b37 |
2.17.0
|
|
|
147b37 |
|