From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
Currently, lxcContainer[Send|Waitfor]Continue only tell
us 'fd', but we had to deal with the interaction between
lxc_[container|controller|process].
This patch adds parameters to identify the caller.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 16 +++++++++-------
src/lxc/lxc_container.h | 4 ++--
src/lxc/lxc_controller.c | 6 +++---
src/lxc/lxc_process.c | 2 +-
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index ed1fe29..c7371ca 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -351,19 +351,20 @@ cleanup:
/**
* lxcContainerSendContinue:
* @control: control FD to child
+ * @caller: function invoker
*
* Sends the continue message via the socket pair stored in the vm
* structure.
*
* Returns 0 on success or -1 in case of error
*/
-int lxcContainerSendContinue(int control)
+int lxcContainerSendContinue(int control, const char *caller)
{
int rc = -1;
lxc_message_t msg = LXC_CONTINUE_MSG;
int writeCount = 0;
- VIR_DEBUG("Send continue on fd %d", control);
+ VIR_DEBUG("Send continue on fd %d by %s", control, caller);
writeCount = safewrite(control, &msg, sizeof(msg));
if (writeCount != sizeof(msg)) {
goto error_out;
@@ -377,6 +378,7 @@ error_out:
/**
* lxcContainerWaitForContinue:
* @control: Control FD from parent
+ * @caller: function invoker
*
* This function will wait for the container continue message from the
* parent process. It will send this message on the socket pair stored in
@@ -384,14 +386,14 @@ error_out:
*
* Returns 0 on success or -1 in case of error
*/
-int lxcContainerWaitForContinue(int control)
+int lxcContainerWaitForContinue(int control, const char *caller)
{
lxc_message_t msg;
int readLen;
- VIR_DEBUG("Wait continue on fd %d", control);
+ VIR_DEBUG("%s wait continue on fd %d", caller, control);
readLen = saferead(control, &msg, sizeof(msg));
- VIR_DEBUG("Got continue on fd %d %d", control, readLen);
+ VIR_DEBUG("%s got continue on fd %d %d", caller, control, readLen);
if (readLen != sizeof(msg)) {
if (readLen >= 0)
errno = EIO;
@@ -1813,7 +1815,7 @@ static int lxcContainerChild(void *data)
/* Wait for controller to finish setup tasks, including
* things like move of network interfaces, uid/gid mapping
*/
- if (lxcContainerWaitForContinue(argv->monitor) < 0) {
+ if (lxcContainerWaitForContinue(argv->monitor, __func__) < 0) {
virReportSystemError(errno, "%s",
_("Failed to read the container continue
message"));
goto cleanup;
@@ -1880,7 +1882,7 @@ static int lxcContainerChild(void *data)
if (lxcContainerDropCapabilities(!!hasReboot) < 0)
goto cleanup;
- if (lxcContainerSendContinue(argv->handshakefd) < 0) {
+ if (lxcContainerSendContinue(argv->handshakefd, __func__) < 0) {
virReportSystemError(errno, "%s",
_("Failed to send continue signal to
controller"));
goto cleanup;
diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h
index e74a7d7..77fb2a0 100644
--- a/src/lxc/lxc_container.h
+++ b/src/lxc/lxc_container.h
@@ -49,8 +49,8 @@ enum {
# define LXC_DEV_MAJ_FUSE 10
# define LXC_DEV_MIN_FUSE 229
-int lxcContainerSendContinue(int control);
-int lxcContainerWaitForContinue(int control);
+int lxcContainerSendContinue(int control, const char *caller);
+int lxcContainerWaitForContinue(int control, const char *caller);
int lxcContainerStart(virDomainDefPtr def,
virSecurityManagerPtr securityDriver,
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 851a773..25dbbec 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -319,7 +319,7 @@ static int
virLXCControllerConsoleSetNonblocking(virLXCControllerConsolePtr cons
static int virLXCControllerDaemonHandshake(virLXCControllerPtr ctrl)
{
- if (lxcContainerSendContinue(ctrl->handshakeFd) < 0) {
+ if (lxcContainerSendContinue(ctrl->handshakeFd, __func__) < 0) {
virReportSystemError(errno, "%s",
_("error sending continue signal to daemon"));
return -1;
@@ -2176,13 +2176,13 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
if (virLXCControllerMoveInterfaces(ctrl) < 0)
goto cleanup;
- if (lxcContainerSendContinue(control[0]) < 0) {
+ if (lxcContainerSendContinue(control[0], __func__) < 0) {
virReportSystemError(errno, "%s",
_("Unable to send container continue message"));
goto cleanup;
}
- if (lxcContainerWaitForContinue(containerhandshake[0]) < 0) {
+ if (lxcContainerWaitForContinue(containerhandshake[0], __func__) < 0) {
virReportSystemError(errno, "%s",
_("error receiving signal from container"));
goto cleanup;
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index f088e8e..de20dd0 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1264,7 +1264,7 @@ int virLXCProcessStart(virConnectPtr conn,
if (virAtomicIntInc(&driver->nactive) == 1 &&
driver->inhibitCallback)
driver->inhibitCallback(true, driver->inhibitOpaque);
- if (lxcContainerWaitForContinue(handshakefds[0]) < 0) {
+ if (lxcContainerWaitForContinue(handshakefds[0], __func__) < 0) {
char out[1024];
if (!(virLXCProcessReadLogOutput(vm, logfile, pos, out, 1024) < 0)) {
--
1.8.2.1