Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Notes:
new in v2
This is not required to fix the issue by the last patch in the series,
however it improves the code that we decide whether to use virtlogd or
not by checking the same variable that is updated while preparing the
guest start.
src/qemu/qemu_command.c | 132 +++++++++++++++++++++++++++++++-----------------
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_process.c | 6 ++-
3 files changed, 93 insertions(+), 48 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 015af1036c..e6c50d1a64 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5043,7 +5043,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
const virDomainChrSourceDef *dev,
const char *alias,
virQEMUCapsPtr qemuCaps,
- bool nowait)
+ bool nowait,
+ bool chardevStdioLogd)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool telnet;
@@ -5081,8 +5082,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
_("append not supported in this QEMU binary"));
goto cleanup;
}
- if (qemuBuildChrChardevFileStr(virQEMUCapsGet(qemuCaps,
QEMU_CAPS_CHARDEV_FILE_APPEND) ?
- logManager : NULL, cmd, def, &buf,
+ if (qemuBuildChrChardevFileStr(chardevStdioLogd ? logManager : NULL,
+ cmd, def, &buf,
"path", dev->data.file.path,
"append", dev->data.file.append) <
0)
goto cleanup;
@@ -5562,8 +5563,9 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
- const virDomainChrSourceDef *monitor_chr,
- bool monitor_json)
+ virDomainChrSourceDefPtr monitor_chr,
+ bool monitor_json,
+ bool chardevStdioLogd)
{
char *chrdev;
@@ -5575,7 +5577,8 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager,
if (!(chrdev = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
monitor_chr, "monitor",
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chrdev);
@@ -5720,7 +5723,8 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
const virDomainDef *def,
virDomainRNGDefPtr rng,
virQEMUCapsPtr qemuCaps,
- char **chr)
+ char **chr,
+ bool chardevStdioLogd)
{
*chr = NULL;
@@ -5733,7 +5737,8 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
case VIR_DOMAIN_RNG_BACKEND_EGD:
if (!(*chr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
rng->source.chardev,
- rng->info.alias, qemuCaps, true)))
+ rng->info.alias, qemuCaps, true,
+ chardevStdioLogd)))
return -1;
}
@@ -5881,7 +5886,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
@@ -5897,7 +5903,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
/* possibly add character device for backend */
if (qemuBuildRNGBackendChrdevStr(logManager, cmd, cfg, def,
- rng, qemuCaps, &tmp) < 0)
+ rng, qemuCaps, &tmp,
+ chardevStdioLogd) < 0)
return -1;
if (tmp) {
@@ -8256,7 +8263,8 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
virDomainDefPtr def,
virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps,
- unsigned int bootindex)
+ unsigned int bootindex,
+ bool chardevStdioLogd)
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
char *chardev = NULL;
@@ -8274,7 +8282,8 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
case VIR_DOMAIN_CHR_TYPE_UNIX:
if (!(chardev = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
net->data.vhostuser,
- net->info.alias, qemuCaps, false)))
+ net->info.alias, qemuCaps, false,
+ chardevStdioLogd)))
goto error;
break;
@@ -8353,7 +8362,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
virNetDevVPortProfileOp vmop,
bool standalone,
size_t *nnicindexes,
- int **nicindexes)
+ int **nicindexes,
+ bool chardevStdioLogd)
{
int ret = -1;
char *nic = NULL, *host = NULL;
@@ -8466,7 +8476,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
ret = qemuBuildVhostuserCommandLine(driver, logManager, cmd, def,
- net, qemuCaps, bootindex);
+ net, qemuCaps, bootindex,
+ chardevStdioLogd);
goto cleanup;
break;
@@ -8661,7 +8672,8 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver,
bool standalone,
size_t *nnicindexes,
int **nicindexes,
- unsigned int *bootHostdevNet)
+ unsigned int *bootHostdevNet,
+ bool chardevStdioLogd)
{
size_t i;
int last_good_net = -1;
@@ -8695,7 +8707,8 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver,
if (qemuBuildInterfaceCommandLine(driver, logManager, cmd, def, net,
qemuCaps, vlan, bootNet, vmop,
standalone, nnicindexes,
- nicindexes) < 0)
+ nicindexes,
+ chardevStdioLogd) < 0)
goto error;
last_good_net = i;
@@ -8731,7 +8744,8 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
virDomainSmartcardDefPtr smartcard;
@@ -8818,7 +8832,8 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
smartcard->data.passthru,
smartcard->info.alias,
- qemuCaps, true))) {
+ qemuCaps, true,
+ chardevStdioLogd))) {
virBufferFreeAndReset(&opt);
return -1;
}
@@ -8942,7 +8957,8 @@ qemuBuildShmemBackendChrStr(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
virDomainShmemDefPtr shmem,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
char *devstr = NULL;
@@ -8951,7 +8967,8 @@ qemuBuildShmemBackendChrStr(virLogManagerPtr logManager,
devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
&shmem->server.chr,
- shmem->info.alias, qemuCaps, true);
+ shmem->info.alias, qemuCaps, true,
+ chardevStdioLogd);
return devstr;
}
@@ -9007,7 +9024,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
virDomainShmemDefPtr shmem,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
char *devstr = NULL;
@@ -9065,7 +9083,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
if (shmem->server.enabled) {
if (!(devstr = qemuBuildShmemBackendChrStr(logManager, cmd, cfg, def,
- shmem, qemuCaps)))
+ shmem, qemuCaps,
+ chardevStdioLogd)))
return -1;
virCommandAddArgList(cmd, "-chardev", devstr, NULL);
@@ -9097,7 +9116,8 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
bool havespice = false;
@@ -9121,7 +9141,8 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
serial->source,
serial->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9147,7 +9168,8 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
@@ -9160,7 +9182,8 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
parallel->source,
parallel->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9187,7 +9210,8 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
@@ -9206,7 +9230,8 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
channel->source,
channel->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9229,7 +9254,8 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
channel->source,
channel->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9251,7 +9277,8 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
@@ -9272,7 +9299,8 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
console->source,
console->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9286,7 +9314,8 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
console->source,
console->info.alias,
- qemuCaps, true)))
+ qemuCaps, true,
+ chardevStdioLogd)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9404,7 +9433,8 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ bool chardevStdioLogd)
{
size_t i;
@@ -9415,7 +9445,8 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
redirdev->source,
redirdev->info.alias,
- qemuCaps, true))) {
+ qemuCaps, true,
+ chardevStdioLogd))) {
return -1;
}
@@ -9880,7 +9911,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
virBitmapPtr nodeset,
size_t *nnicindexes,
int **nicindexes,
- const char *domainLibDir)
+ const char *domainLibDir,
+ bool chardevStdioLogd)
{
size_t i;
char uuid[VIR_UUID_STRING_BUFLEN];
@@ -9986,7 +10018,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildMonitorCommandLine(logManager, cmd, cfg, def,
qemuCaps, monitor_chr,
- monitor_json) < 0)
+ monitor_json,
+ chardevStdioLogd) < 0)
goto error;
if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0)
@@ -10018,22 +10051,28 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildNetCommandLine(driver, logManager, cmd, def,
qemuCaps, vmop, standalone,
- nnicindexes, nicindexes, &bootHostdevNet) < 0)
+ nnicindexes, nicindexes, &bootHostdevNet,
+ chardevStdioLogd) < 0)
goto error;
- if (qemuBuildSmartcardCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildSmartcardCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
- if (qemuBuildSerialCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildSerialCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
- if (qemuBuildParallelsCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildParallelsCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
- if (qemuBuildChannelsCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildChannelsCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
- if (qemuBuildConsoleCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildConsoleCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0)
@@ -10057,7 +10096,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildWatchdogCommandLine(cmd, def, qemuCaps) < 0)
goto error;
- if (qemuBuildRedirdevCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildRedirdevCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
if (qemuBuildHostdevCommandLine(cmd, def, qemuCaps, &bootHostdevNet) < 0)
@@ -10069,7 +10109,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildMemballoonCommandLine(cmd, def, qemuCaps) < 0)
goto error;
- if (qemuBuildRNGCommandLine(logManager, cmd, cfg, def, qemuCaps) < 0)
+ if (qemuBuildRNGCommandLine(logManager, cmd, cfg, def, qemuCaps,
+ chardevStdioLogd) < 0)
goto error;
if (qemuBuildNVRAMCommandLine(cmd, def, qemuCaps) < 0)
@@ -10106,7 +10147,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
for (i = 0; i < def->nshmems; i++) {
if (qemuBuildShmemCommandLine(logManager, cmd, cfg,
- def, def->shmems[i], qemuCaps))
+ def, def->shmems[i], qemuCaps,
+ chardevStdioLogd))
goto error;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 09cb00ee9b..f5e3e5fbef 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -57,7 +57,8 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
virBitmapPtr nodeset,
size_t *nnicindexes,
int **nicindexes,
- const char *domainLibDir)
+ const char *domainLibDir,
+ bool chardevStdioLogd)
ATTRIBUTE_NONNULL(15);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 77c2e5f6d3..fbcd51c1f1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5657,7 +5657,8 @@ qemuProcessLaunch(virConnectPtr conn,
qemuCheckFips(),
priv->autoNodeset,
&nnicindexes, &nicindexes,
- priv->libDir)))
+ priv->libDir,
+ priv->chardevStdioLogd)))
goto cleanup;
if (incoming && incoming->fd != -1)
@@ -6091,7 +6092,8 @@ qemuProcessCreatePretendCmd(virConnectPtr conn,
priv->autoNodeset,
NULL,
NULL,
- priv->libDir);
+ priv->libDir,
+ priv->chardevStdioLogd);
cleanup:
return cmd;
--
2.13.0