提交 5048aa52 编写于 作者: J Ján Tomko

qemu: split out qemuBuildVsockDevStr

Split out the device string building to allow reuse for hotplug.

https://bugzilla.redhat.com/show_bug.cgi?id=1291851Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 076a2b40
...@@ -9912,17 +9912,15 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd, ...@@ -9912,17 +9912,15 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd,
} }
static int static char *
qemuBuildVsockCommandLine(virCommandPtr cmd, qemuBuildVsockDevStr(virDomainDefPtr def,
virDomainDefPtr def, virDomainVsockDefPtr vsock,
virDomainVsockDefPtr vsock, virQEMUCapsPtr qemuCaps)
virQEMUCapsPtr qemuCaps)
{ {
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
const char *device = "vhost-vsock-pci";
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *devstr = NULL; const char *device = "vhost-vsock-pci";
int ret = -1; char *ret = NULL;
virBufferAsprintf(&buf, "%s", device); virBufferAsprintf(&buf, "%s", device);
virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
...@@ -9934,7 +9932,26 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, ...@@ -9934,7 +9932,26 @@ qemuBuildVsockCommandLine(virCommandPtr cmd,
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
devstr = virBufferContentAndReset(&buf); ret = virBufferContentAndReset(&buf);
cleanup:
virBufferFreeAndReset(&buf);
return ret;
}
static int
qemuBuildVsockCommandLine(virCommandPtr cmd,
virDomainDefPtr def,
virDomainVsockDefPtr vsock,
virQEMUCapsPtr qemuCaps)
{
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
char *devstr = NULL;
int ret = -1;
if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps)))
goto cleanup;
virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
priv->vhostfd = -1; priv->vhostfd = -1;
...@@ -9942,7 +9959,6 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, ...@@ -9942,7 +9959,6 @@ qemuBuildVsockCommandLine(virCommandPtr cmd,
ret = 0; ret = 0;
cleanup: cleanup:
virBufferFreeAndReset(&buf);
VIR_FREE(devstr); VIR_FREE(devstr);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册