virNetServerServiceGetPort;
virNetServerServiceGetTLSContext;
virNetServerServiceIsReadonly;
-virNetServerServiceNewFD;
virNetServerServiceNewFDOrUNIX;
+virNetServerServiceNewFDs;
virNetServerServiceNewPostExecRestart;
virNetServerServiceNewTCP;
virNetServerServiceNewUNIX;
virNetServerServicePtr svc;
char *path = virGetUNIXSocketPath(3 + i);
virNetServerPtr srv;
+ int fds[] = { 3 + i };
if (!path)
return -1;
/* Systemd passes FDs, starting immediately after stderr,
* so the first FD we'll get is '3'. */
- if (!(svc = virNetServerServiceNewFD(3 + i, 0,
- NULL,
- false, 0, 1)))
+ if (!(svc = virNetServerServiceNewFDs(fds,
+ ARRAY_CARDINALITY(fds),
+ 0,
+ NULL,
+ false, 0, 1)))
return -1;
if (virNetServerAddService(srv, svc) < 0) {
virNetServerServicePtr svc;
char *path = virGetUNIXSocketPath(3 + i);
virNetServerPtr srv;
+ int fds[] = { 3 + i };
if (!path)
return -1;
/* Systemd passes FDs, starting immediately after stderr,
* so the first FD we'll get is '3'. */
- if (!(svc = virNetServerServiceNewFD(3 + i, 0,
- NULL,
- false, 0, 1)))
+ if (!(svc = virNetServerServiceNewFDs(fds,
+ ARRAY_CARDINALITY(fds),
+ 0,
+ NULL,
+ false, 0, 1)))
return -1;
if (virNetServerAddService(srv, svc) < 0) {
nrequests_client_max);
} else {
+ int fds[] = {(*cur_fd)++};
/*
* There's still enough file descriptors. In this case we'll
* use the current one and increment it afterwards. Take care
* with order of operation for pointer arithmetic and auto
* increment on cur_fd - the parentheses are necessary.
*/
- return virNetServerServiceNewFD((*cur_fd)++,
- auth,
- tls,
- readonly,
- max_queued_clients,
- nrequests_client_max);
+ return virNetServerServiceNewFDs(fds,
+ ARRAY_CARDINALITY(fds),
+ auth,
+ tls,
+ readonly,
+ max_queued_clients,
+ nrequests_client_max);
}
}
return svc;
}
-virNetServerServicePtr virNetServerServiceNewFD(int fd,
- int auth,
- virNetTLSContextPtr tls,
- bool readonly,
- size_t max_queued_clients,
- size_t nrequests_client_max)
+virNetServerServicePtr virNetServerServiceNewFDs(int *fds,
+ size_t nfds,
+ int auth,
+ virNetTLSContextPtr tls,
+ bool readonly,
+ size_t max_queued_clients,
+ size_t nrequests_client_max)
{
- virNetServerServicePtr svc;
- virNetSocketPtr sock;
+ virNetServerServicePtr svc = NULL;
+ virNetSocketPtr *socks;
+ size_t i;
- if (virNetSocketNewListenFD(fd,
- &sock) < 0)
- return NULL;
+ if (VIR_ALLOC_N(socks, nfds) < 0)
+ goto cleanup;
- svc = virNetServerServiceNewSocket(&sock,
- 1,
+ for (i = 0; i < nfds; i++) {
+ if (virNetSocketNewListenFD(fds[i],
+ &socks[i]) < 0)
+ goto cleanup;
+ }
+
+ svc = virNetServerServiceNewSocket(socks,
+ nfds,
auth,
tls,
readonly,
max_queued_clients,
nrequests_client_max);
- virObjectUnref(sock);
-
+ cleanup:
+ for (i = 0; i < nfds && socks; i++)
+ virObjectUnref(socks[i]);
+ VIR_FREE(socks);
return svc;
}
bool readonly,
size_t max_queued_clients,
size_t nrequests_client_max);
-virNetServerServicePtr virNetServerServiceNewFD(int fd,
- int auth,
- virNetTLSContextPtr tls,
- bool readonly,
- size_t max_queued_clients,
- size_t nrequests_client_max);
+virNetServerServicePtr virNetServerServiceNewFDs(int *fd,
+ size_t nfds,
+ int auth,
+ virNetTLSContextPtr tls,
+ bool readonly,
+ size_t max_queued_clients,
+ size_t nrequests_client_max);
virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr object);