mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 11:01:19 +00:00
Add a virNetSocketNewConnectSockFD method
To allow creation of a virNetSocketPtr instance from a pre-opened socketpair FD, add a virNetSocketNewConnectSockFD method. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
de51dc9c9a
commit
199679585b
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user