[libvirt] [PATCH 13/23] Add JSON serialization of virNetSocketPtr objects for process re-exec()
Eric Blake
eblake at redhat.com
Thu Aug 16 23:16:50 UTC 2012
On 08/09/2012 09:20 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at 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 at 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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120816/a1217cda/attachment-0001.sig>
More information about the libvir-list
mailing list