提交 19967958 编写于 作者: D Daniel P. Berrange

Add a virNetSocketNewConnectSockFD method

To allow creation of a virNetSocketPtr instance from a pre-opened
socketpair FD, add a virNetSocketNewConnectSockFD method.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 de51dc9c
......@@ -1011,6 +1011,7 @@ virNetSocketLocalAddrString;
virNetSocketNewConnectCommand;
virNetSocketNewConnectExternal;
virNetSocketNewConnectLibSSH2;
virNetSocketNewConnectSockFD;
virNetSocketNewConnectSSH;
virNetSocketNewConnectTCP;
virNetSocketNewConnectUNIX;
......
......@@ -884,6 +884,24 @@ int virNetSocketNewConnectExternal(const char **cmdargv,
}
int virNetSocketNewConnectSockFD(int sockfd,
virNetSocketPtr *retsock)
{
virSocketAddr localAddr;
localAddr.len = sizeof(localAddr.data);
if (getsockname(sockfd, &localAddr.data.sa, &localAddr.len) < 0) {
virReportSystemError(errno, "%s", _("Unable to get local socket name"));
return -1;
}
if (!(*retsock = virNetSocketNew(&localAddr, NULL, true, sockfd, -1, -1)))
return -1;
return 0;
}
virNetSocketPtr virNetSocketNewPostExecRestart(virJSONValuePtr object)
{
virSocketAddr localAddr;
......
......@@ -97,6 +97,8 @@ int virNetSocketNewConnectLibSSH2(const char *host,
int virNetSocketNewConnectExternal(const char **cmdargv,
virNetSocketPtr *addr);
int virNetSocketNewConnectSockFD(int sockfd,
virNetSocketPtr *retsock);
virNetSocketPtr virNetSocketNewPostExecRestart(virJSONValuePtr object);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册