Put it into separate function called qemuDomainPrepareChannel() and call it from the new qemuProcessPrepareDomain(). Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/qemu/qemu_command.c | 25 +++---------------------- src/qemu/qemu_command.h | 5 ++--- src/qemu/qemu_domain.c | 20 ++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 12 ++++++++---- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6fbfe215bf29..f3e07ab1920c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8513,8 +8513,7 @@ static int qemuBuildChannelsCommandLine(virLogManagerPtr logManager, virCommandPtr cmd, const virDomainDef *def, - virQEMUCapsPtr qemuCaps, - const char *domainChannelTargetDir) + virQEMUCapsPtr qemuCaps) { size_t i; @@ -8553,22 +8552,6 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, return -1; } - /* - * TODO: Refactor so that we generate this (and onther - * things) somewhere else then where we are building the - * command line. - */ - if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - !channel->source.data.nix.path) { - if (virAsprintf(&channel->source.data.nix.path, - "%s/%s", domainChannelTargetDir, - channel->target.name ? channel->target.name - : "unknown.sock") < 0) - return -1; - - channel->source.data.nix.listen = true; - } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) && channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { /* spicevmc was originally introduced via a -device @@ -9237,8 +9220,7 @@ qemuBuildCommandLine(virConnectPtr conn, virBitmapPtr nodeset, size_t *nnicindexes, int **nicindexes, - const char *domainLibDir, - const char *domainChannelTargetDir) + const char *domainLibDir) { size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; @@ -9386,8 +9368,7 @@ qemuBuildCommandLine(virConnectPtr conn, if (qemuBuildParallelsCommandLine(logManager, cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildChannelsCommandLine(logManager, cmd, def, qemuCaps, - domainChannelTargetDir) < 0) + if (qemuBuildChannelsCommandLine(logManager, cmd, def, qemuCaps) < 0) goto error; if (qemuBuildConsoleCommandLine(logManager, cmd, def, qemuCaps) < 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 1e9ce6690603..e128d455c57d 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -63,9 +63,8 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn, virBitmapPtr nodeset, size_t *nnicindexes, int **nicindexes, - const char *domainLibDir, - const char *domainChannelTargetDir) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(16) ATTRIBUTE_NONNULL(17); + const char *domainLibDir) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(16); /* Generate '-device' string for chardev device */ int diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6262bfee47d0..3fce0641d58e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4972,3 +4972,23 @@ qemuDomainDiskByName(virDomainDefPtr def, return ret; } + + +int +qemuDomainPrepareChannel(virDomainChrDefPtr channel, + const char *domainChannelTargetDir) +{ + if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && + channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && + !channel->source.data.nix.path) { + if (virAsprintf(&channel->source.data.nix.path, + "%s/%s", domainChannelTargetDir, + channel->target.name ? channel->target.name + : "unknown.sock") < 0) + return -1; + + channel->source.data.nix.listen = true; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7d2c4fd92ae4..cb1d8124e416 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -589,4 +589,8 @@ int qemuDomainMasterKeyCreate(virQEMUDriverPtr driver, void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv); +int +qemuDomainPrepareChannel(virDomainChrDefPtr chr, + const char *domainChannelTargetDir); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0ccc3ac64385..8c783816688b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5113,6 +5113,12 @@ qemuProcessPrepareDomain(virConnectPtr conn, goto cleanup; } + for (i = 0; i < vm->def->nchannels; i++) { + if (qemuDomainPrepareChannel(vm->def->channels[i], + priv->channelTargetDir) < 0) + goto cleanup; + } + if (VIR_ALLOC(priv->monConfig) < 0) goto cleanup; @@ -5330,8 +5336,7 @@ qemuProcessLaunch(virConnectPtr conn, qemuCheckFips(), priv->autoNodeset, &nnicindexes, &nicindexes, - priv->libDir, - priv->channelTargetDir))) + priv->libDir))) goto cleanup; if (incoming && incoming->fd != -1) @@ -5751,8 +5756,7 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, priv->autoNodeset, NULL, NULL, - priv->libDir, - priv->channelTargetDir); + priv->libDir); cleanup: return cmd; -- 2.8.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list