mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Do not prematurely close loop devices in LXC controller
The LXC controller is closing loop devices as soon as the container has started. This is fine if the loop device was setup as a mounted filesystem, but if we're just passing through the loop device as a disk, nothing else is keeping it open. Thus we must keep the loop device FDs open for as long the libvirt_lxc process is running. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
1760258cc3
commit
0a418355cc
@ -199,22 +199,12 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl,
|
static int virLXCControllerCloseLoopDevices(virLXCControllerPtr ctrl)
|
||||||
bool force)
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0 ; i < ctrl->nloopDevs ; i++) {
|
for (i = 0 ; i < ctrl->nloopDevs ; i++)
|
||||||
if (force) {
|
VIR_FORCE_CLOSE(ctrl->loopDevFds[i]);
|
||||||
VIR_FORCE_CLOSE(ctrl->loopDevFds[i]);
|
|
||||||
} else {
|
|
||||||
if (VIR_CLOSE(ctrl->loopDevFds[i]) < 0) {
|
|
||||||
virReportSystemError(errno, "%s",
|
|
||||||
_("Unable to close loop device"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -225,7 +215,7 @@ static void virLXCControllerStopInit(virLXCControllerPtr ctrl)
|
|||||||
if (ctrl->initpid == 0)
|
if (ctrl->initpid == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
virLXCControllerCloseLoopDevices(ctrl, true);
|
virLXCControllerCloseLoopDevices(ctrl);
|
||||||
virProcessAbort(ctrl->initpid);
|
virProcessAbort(ctrl->initpid);
|
||||||
ctrl->initpid = 0;
|
ctrl->initpid = 0;
|
||||||
}
|
}
|
||||||
@ -1546,10 +1536,6 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
|
|||||||
|
|
||||||
/* Now the container is fully setup... */
|
/* Now the container is fully setup... */
|
||||||
|
|
||||||
/* ...we can close the loop devices... */
|
|
||||||
if (virLXCControllerCloseLoopDevices(ctrl, false) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* ...and reduce our privileges */
|
/* ...and reduce our privileges */
|
||||||
if (lxcControllerClearCapabilities() < 0)
|
if (lxcControllerClearCapabilities() < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user