libvirt/0111-Add-a-virNetSocketNewConnectSockFD-method.patch
Cole Robinson adeaf839fd Sync with v1.1.2-maint
Rebuild for libswan soname bump (bz #1009701)
CVE-2013-4311: Insecure polkit usage (bz #1009539, bz #1005332)
CVE-2013-4296: Invalid free memory stats (bz #1006173, bz #1009667)
CVE-2013-4297: Invalid free in NBDDeviceAssociate (bz #1006505, bz #1006511)
Fix virsh block-commit abort (bz #1010056)
2013-09-23 14:35:01 -04:00

70 lines
2.3 KiB
Diff

From 9e7cec4d755341cfb4c27c16aa59b22135612f0e Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Mon, 23 Sep 2013 12:46:26 +0100
Subject: [PATCH] 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>
---
src/libvirt_private.syms | 1 +
src/rpc/virnetsocket.c | 18 ++++++++++++++++++
src/rpc/virnetsocket.h | 2 ++
3 files changed, 21 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 35f0f1b..873d93d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1008,6 +1008,7 @@ virNetSocketLocalAddrString;
virNetSocketNewConnectCommand;
virNetSocketNewConnectExternal;
virNetSocketNewConnectLibSSH2;
+virNetSocketNewConnectSockFD;
virNetSocketNewConnectSSH;
virNetSocketNewConnectTCP;
virNetSocketNewConnectUNIX;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index ae81512..b311aae 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -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;
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index ca9ae91..86bc2f6 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -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);