mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
Move daemon handshake FD into virLXCControllerPtr
Keep the FD used to handshake with the libvirtd daemon in the virLXCControllerPtr object. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
eddca75a14
commit
ef07d89f1f
@ -110,6 +110,8 @@ struct _virLXCController {
|
|||||||
char *name;
|
char *name;
|
||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
|
|
||||||
|
int handshakeFd;
|
||||||
|
|
||||||
pid_t initpid;
|
pid_t initpid;
|
||||||
|
|
||||||
size_t nveths;
|
size_t nveths;
|
||||||
@ -203,6 +205,8 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
|
|||||||
virLXCControllerConsoleClose(&(ctrl->consoles[i]));
|
virLXCControllerConsoleClose(&(ctrl->consoles[i]));
|
||||||
VIR_FREE(ctrl->consoles);
|
VIR_FREE(ctrl->consoles);
|
||||||
|
|
||||||
|
VIR_FORCE_CLOSE(ctrl->handshakeFd);
|
||||||
|
|
||||||
virDomainDefFree(ctrl->def);
|
virDomainDefFree(ctrl->def);
|
||||||
VIR_FREE(ctrl->name);
|
VIR_FREE(ctrl->name);
|
||||||
|
|
||||||
@ -242,6 +246,18 @@ static int virLXCControllerConsoleSetNonblocking(virLXCControllerConsolePtr cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int virLXCControllerDaemonHandshake(virLXCControllerPtr ctrl)
|
||||||
|
{
|
||||||
|
if (lxcContainerSendContinue(ctrl->handshakeFd) < 0) {
|
||||||
|
virReportSystemError(errno, "%s",
|
||||||
|
_("error sending continue signal to daemon"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
VIR_FORCE_CLOSE(ctrl->handshakeFd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int virLXCControllerValidateNICs(virLXCControllerPtr ctrl)
|
static int virLXCControllerValidateNICs(virLXCControllerPtr ctrl)
|
||||||
{
|
{
|
||||||
if (ctrl->def->nnets != ctrl->nveths) {
|
if (ctrl->def->nnets != ctrl->nveths) {
|
||||||
@ -1505,8 +1521,7 @@ static int
|
|||||||
virLXCControllerRun(virLXCControllerPtr ctrl,
|
virLXCControllerRun(virLXCControllerPtr ctrl,
|
||||||
virSecurityManagerPtr securityDriver,
|
virSecurityManagerPtr securityDriver,
|
||||||
int monitor,
|
int monitor,
|
||||||
int client,
|
int client)
|
||||||
int handshakefd)
|
|
||||||
{
|
{
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
int control[2] = { -1, -1};
|
int control[2] = { -1, -1};
|
||||||
@ -1697,12 +1712,8 @@ virLXCControllerRun(virLXCControllerPtr ctrl,
|
|||||||
if (lxcControllerClearCapabilities() < 0)
|
if (lxcControllerClearCapabilities() < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (lxcContainerSendContinue(handshakefd) < 0) {
|
if (virLXCControllerDaemonHandshake(ctrl) < 0)
|
||||||
virReportSystemError(errno, "%s",
|
|
||||||
_("error sending continue signal to parent"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
VIR_FORCE_CLOSE(handshakefd);
|
|
||||||
|
|
||||||
if (virSetBlocking(monitor, false) < 0 ||
|
if (virSetBlocking(monitor, false) < 0 ||
|
||||||
virSetBlocking(client, false) < 0) {
|
virSetBlocking(client, false) < 0) {
|
||||||
@ -1723,7 +1734,6 @@ cleanup:
|
|||||||
VIR_FREE(devpts);
|
VIR_FREE(devpts);
|
||||||
VIR_FORCE_CLOSE(control[0]);
|
VIR_FORCE_CLOSE(control[0]);
|
||||||
VIR_FORCE_CLOSE(control[1]);
|
VIR_FORCE_CLOSE(control[1]);
|
||||||
VIR_FORCE_CLOSE(handshakefd);
|
|
||||||
VIR_FORCE_CLOSE(containerhandshake[0]);
|
VIR_FORCE_CLOSE(containerhandshake[0]);
|
||||||
VIR_FORCE_CLOSE(containerhandshake[1]);
|
VIR_FORCE_CLOSE(containerhandshake[1]);
|
||||||
|
|
||||||
@ -1750,7 +1760,7 @@ int main(int argc, char *argv[])
|
|||||||
size_t nveths = 0;
|
size_t nveths = 0;
|
||||||
char **veths = NULL;
|
char **veths = NULL;
|
||||||
int monitor = -1;
|
int monitor = -1;
|
||||||
int handshakefd = -1;
|
int handshakeFd = -1;
|
||||||
int bg = 0;
|
int bg = 0;
|
||||||
char *sockpath = NULL;
|
char *sockpath = NULL;
|
||||||
const struct option options[] = {
|
const struct option options[] = {
|
||||||
@ -1824,7 +1834,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (virStrToLong_i(optarg, NULL, 10, &handshakefd) < 0) {
|
if (virStrToLong_i(optarg, NULL, 10, &handshakeFd) < 0) {
|
||||||
fprintf(stderr, "malformed --handshakefd argument '%s'",
|
fprintf(stderr, "malformed --handshakefd argument '%s'",
|
||||||
optarg);
|
optarg);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1875,7 +1885,7 @@ int main(int argc, char *argv[])
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handshakefd < 0) {
|
if (handshakeFd < 0) {
|
||||||
fprintf(stderr, "%s: missing --handshake argument for container PTY\n",
|
fprintf(stderr, "%s: missing --handshake argument for container PTY\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1891,6 +1901,8 @@ int main(int argc, char *argv[])
|
|||||||
if (!(ctrl = virLXCControllerNew(name)))
|
if (!(ctrl = virLXCControllerNew(name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
ctrl->handshakeFd = handshakeFd;
|
||||||
|
|
||||||
VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
|
VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
|
||||||
NULLSTR(ctrl->def->seclabel.model),
|
NULLSTR(ctrl->def->seclabel.model),
|
||||||
virDomainSeclabelTypeToString(ctrl->def->seclabel.type),
|
virDomainSeclabelTypeToString(ctrl->def->seclabel.type),
|
||||||
@ -1958,8 +1970,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = virLXCControllerRun(ctrl, securityDriver,
|
rc = virLXCControllerRun(ctrl, securityDriver,
|
||||||
monitor, client,
|
monitor, client);
|
||||||
handshakefd);
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virPidFileDelete(LXC_STATE_DIR, name);
|
virPidFileDelete(LXC_STATE_DIR, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user