On 08/09/2012 09:20 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add two new APIs virNetSocketNewPostExecRestart and
virNetSocketPreExecRestart which allow a virNetSocketPtr
object to be created from a JSON object and saved to a
JSON object, for the purpose of re-exec'ing a process.
As well as saving the state in JSON format, the second
method will disable the O_CLOEXEC flag so that the open
file descriptors are preserved across the process re-exec()
Same problem as 12/23 regarding _when_ you clear O_CLOEXEC.
Since it is not possible to serialize SASL or TLS encryption
state, an error will be raised if attempting to perform
serialization on non-raw sockets
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/libvirt_private.syms | 2 +
src/rpc/virnetsocket.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++
src/rpc/virnetsocket.h | 6 +++
3 files changed, 116 insertions(+)
+virNetSocketPtr virNetSocketNewPostExecRestart(virJSONValuePtr object)
+{
+ virSocketAddr localAddr;
+ virSocketAddr remoteAddr;
+ int fd, thepid, errfd;
+ bool isClient;
+
+ if (virJSONValueObjectGetNumberInt(object, "fd", &fd) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing fd data in JSON document"));
+ return NULL;
+ }
+
+ if (virJSONValueObjectGetNumberInt(object, "pid", &thepid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing pid data in JSON document"));
+ return NULL;
+ }
+
+ if (virJSONValueObjectGetNumberInt(object, "errfd", &errfd) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing errfd data in JSON document"));
+ return NULL;
+ }
Do you need to re-enable FD_CLOEXEC on fd and errfd at this point?
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org