提交 f670008b 编写于 作者: M Martin Kletzander

qemu: Move channel path generation out of command creation

Put it into separate function called qemuDomainPrepareChannel() and call
it from the new qemuProcessPrepareDomain().
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 ee12b781
......@@ -8379,8 +8379,7 @@ static int
qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
const char *domainChannelTargetDir)
virQEMUCapsPtr qemuCaps)
{
size_t i;
......@@ -8412,22 +8411,6 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
break;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
/*
* 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
......@@ -9091,8 +9074,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
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];
......@@ -9237,8 +9219,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
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)
......
......@@ -58,9 +58,8 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
virBitmapPtr nodeset,
size_t *nnicindexes,
int **nicindexes,
const char *domainLibDir,
const char *domainChannelTargetDir)
ATTRIBUTE_NONNULL(15) ATTRIBUTE_NONNULL(16);
const char *domainLibDir)
ATTRIBUTE_NONNULL(15);
/* Generate '-device' string for chardev device */
int
......
......@@ -5545,3 +5545,23 @@ qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
return 0;
}
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;
}
......@@ -686,4 +686,8 @@ int qemuDomainSecretPrepare(virConnectPtr conn, virDomainObjPtr vm)
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
ATTRIBUTE_NONNULL(1);
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
const char *domainChannelTargetDir)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
#endif /* __QEMU_DOMAIN_H__ */
......@@ -4885,6 +4885,12 @@ qemuProcessPrepareDomain(virConnectPtr conn,
if (qemuDomainSecretPrepare(conn, vm) < 0)
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;
......@@ -5100,8 +5106,7 @@ qemuProcessLaunch(virConnectPtr conn,
qemuCheckFips(),
priv->autoNodeset,
&nnicindexes, &nicindexes,
priv->libDir,
priv->channelTargetDir)))
priv->libDir)))
goto cleanup;
if (incoming && incoming->fd != -1)
......@@ -5520,8 +5525,7 @@ qemuProcessCreatePretendCmd(virConnectPtr conn,
priv->autoNodeset,
NULL,
NULL,
priv->libDir,
priv->channelTargetDir);
priv->libDir);
cleanup:
return cmd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册