[libvirt] [PATCH] Daemonize fuse thread in libvirt_lxc
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
In some startup failure modes, the fuse thread may get itself
wedged. This will cause the entire libvirt_lxc process to
hang trying to the join the thread. There is no compelling
reason to wait for the thread to exit if the whole process
is exiting, so kust daemonize the fus thread instead.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_fuse.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index b6808da..c4be58e 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -320,7 +320,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
goto cleanup1;
}
- if (virThreadCreate(&fuse->thread, true, lxcFuseRun,
+ if (virThreadCreate(&fuse->thread, false, lxcFuseRun,
(void *)fuse) < 0) {
lxcFuseDestroy(fuse);
goto cleanup1;
@@ -351,8 +351,6 @@ void lxcFreeFuse(virLXCFusePtr *f)
fuse_exit(fuse->fuse);
virMutexUnlock(&fuse->lock);
- virThreadJoin(&fuse->thread);
-
VIR_FREE(fuse->mountpoint);
VIR_FREE(*f);
}
--
1.7.11.7
11 years, 8 months
[libvirt] [RFC PATCH 0/6] Add user namespace support for libvirt lxc
by Gao feng
This patchset try to add userns support for libvirt lxc.
Since userns is nearly completed in linux-3.9, the old
kernel doesn't support userns, I add some New XML elements
to let people decide if enable userns.The userns is disabled
by default.
And because the uninit userns has no right to create devices,
so we should create devices for container on host.
This patch alse changes the owner of fuse and tty device.
Cgroupfs is unavailable in userns now,so don't mount cgroupfs
when we enable userns.
Gao feng (6):
LXC: New XML element for user namespace
LXC: introduce virLXCControllerSetupUserns and lxcContainerSetUserns
LXC: only mount cgroupfs when userns is disabled
LXC: Creating devices for container on host side
LXC: create tty device with proper permission for container
LXC: fuse: Change files owner to the root user of container
docs/formatdomain.html.in | 20 +++++-
docs/schemas/domaincommon.rng | 36 ++++++++++
src/conf/domain_conf.c | 36 ++++++++++
src/conf/domain_conf.h | 21 ++++++
src/lxc/lxc_container.c | 122 ++++++++++++++++----------------
src/lxc/lxc_controller.c | 157 +++++++++++++++++++++++++++++++++++++++++-
src/lxc/lxc_fuse.c | 6 ++
7 files changed, 333 insertions(+), 65 deletions(-)
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] Avoid closing uninitialized FDs when LXC startup fails
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If an LXC domain failed to start because of a bogus SELinux
label, virLXCProcessStart would call VIR_CLOSE(0) by mistake.
This is because the code which initializes the member of the
ttyFDs array to -1 got moved too far away from the place where
the array is first allocated.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_process.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index cad6402..942d375 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1077,6 +1077,8 @@ int virLXCProcessStart(virConnectPtr conn,
virReportOOMError();
goto cleanup;
}
+ for (i = 0 ; i < vm->def->nconsoles ; i++)
+ ttyFDs[i] = -1;
/* If you are using a SecurityDriver with dynamic labelling,
then generate a security label for isolation */
@@ -1096,9 +1098,6 @@ int virLXCProcessStart(virConnectPtr conn,
vm->def, NULL) < 0)
goto cleanup;
- for (i = 0 ; i < vm->def->nconsoles ; i++)
- ttyFDs[i] = -1;
-
for (i = 0 ; i < vm->def->nconsoles ; i++) {
char *ttyPath;
if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
--
1.8.1.4
11 years, 8 months
[libvirt] [PATCH] Re-add DTrace probes on 'dispose' functions
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
When converting to virObject, the probes on the 'Free' functions
were removed on the basis that there is a probe on virObjectFree
that suffices. This puts a burden on people writing probe scripts
to identify which object is being dispose. This adds back probes
in the 'Dispose' functions and updates the rpc monitor systemtap
example to use them
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
examples/systemtap/rpc-monitor.stp | 32 +++++++++++++-------------------
src/libvirt_probes.d | 10 ++++++----
src/rpc/virkeepalive.c | 3 +++
src/rpc/virnetclient.c | 3 +++
src/rpc/virnetserverclient.c | 3 +++
src/rpc/virnetsocket.c | 4 +++-
src/rpc/virnettlscontext.c | 6 ++++++
7 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/examples/systemtap/rpc-monitor.stp b/examples/systemtap/rpc-monitor.stp
index 4695c10..c8d5c17 100644
--- a/examples/systemtap/rpc-monitor.stp
+++ b/examples/systemtap/rpc-monitor.stp
@@ -117,11 +117,9 @@ probe libvirt.rpc.socket_new {
remoteAddrs[pid(), sock] = remoteAddr;
}
-probe libvirt.rpc.socket_free {
- if (refs == 1) {
- delete localAddrs[pid(), sock];
- delete remoteAddrs[pid(), sock];
- }
+probe libvirt.rpc.socket_dispose {
+ delete localAddrs[pid(), sock];
+ delete remoteAddrs[pid(), sock];
}
@@ -131,13 +129,11 @@ probe libvirt.rpc.client_new {
print_ts(sprintf("C + %-16p local=%s remote=%s", client, localAddrs[pid(), sock], remoteAddrs[pid(), sock]));
}
-probe libvirt.rpc.client_free {
- if (refs == 1) {
- print_ts(sprintf("C - %-16p local=%s remote=%s", client,
- localAddrs[pid(), clientSocks[pid(), client]],
- remoteAddrs[pid(), clientSocks[pid(), client]]));
- delete clientSocks[pid(), client];
- }
+probe libvirt.rpc.client_dispose {
+ print_ts(sprintf("C - %-16p local=%s remote=%s", client,
+ localAddrs[pid(), clientSocks[pid(), client]],
+ remoteAddrs[pid(), clientSocks[pid(), client]]));
+ delete clientSocks[pid(), client];
}
@@ -147,13 +143,11 @@ probe libvirt.rpc.server_client_new {
print_ts(sprintf("+ S %-16p local=%s remote=%s", client, localAddrs[pid(), sock], remoteAddrs[pid(), sock]));
}
-probe libvirt.rpc.server_client_free {
- if (refs == 1) {
- print_ts(sprintf("- S %-16p local=%s remote=%s", client,
- localAddrs[pid(), serverSocks[pid(), client]],
- remoteAddrs[pid(), serverSocks[pid(), client]]));
- delete serverSocks[pid(), client];
- }
+probe libvirt.rpc.server_client_dispose {
+ print_ts(sprintf("- S %-16p local=%s remote=%s", client,
+ localAddrs[pid(), serverSocks[pid(), client]],
+ remoteAddrs[pid(), serverSocks[pid(), client]]));
+ delete serverSocks[pid(), client];
}
diff --git a/src/libvirt_probes.d b/src/libvirt_probes.d
index 9343fa4..340d665 100644
--- a/src/libvirt_probes.d
+++ b/src/libvirt_probes.d
@@ -26,6 +26,7 @@ provider libvirt {
# file: src/rpc/virnetsocket.c
# prefix: rpc
probe rpc_socket_new(void *sock, int fd, int errfd, pid_t pid, const char *localAddr, const char *remoteAddr);
+ probe rpc_socket_dispose(void *sock);
probe rpc_socket_send_fd(void *sock, int fd);
probe rpc_socket_recv_fd(void *sock, int fd);
@@ -33,7 +34,7 @@ provider libvirt {
# file: src/rpc/virnetserverclient.c
# prefix: rpc
probe rpc_server_client_new(void *client, void *sock);
-
+ probe rpc_server_client_dispose(void *client);
probe rpc_server_client_msg_tx_queue(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
probe rpc_server_client_msg_rx(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
@@ -41,7 +42,7 @@ provider libvirt {
# file: src/rpc/virnetclient.c
# prefix: rpc
probe rpc_client_new(void *client, void *sock);
-
+ probe rpc_client_dispose(void *client);
probe rpc_client_msg_tx_queue(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
probe rpc_client_msg_rx(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
@@ -57,14 +58,14 @@ provider libvirt {
# prefix: rpc
probe rpc_tls_context_new(void *ctxt, const char *cacert, const char *cacrl,
const char *cert, const char *key, int sanityCheckCert, int requireValidCert, int isServer);
-
+ probe rpc_tls_context_dispose(void *ctxt);
probe rpc_tls_context_session_allow(void *ctxt, void *sess, const char *dname);
probe rpc_tls_context_session_deny(void *ctxt, void *sess, const char *dname);
probe rpc_tls_context_session_fail(void *ctxt, void *sess);
probe rpc_tls_session_new(void *sess, void *ctxt, const char *hostname, int isServer);
-
+ probe rpc_tls_session_dispose(void *sess);
probe rpc_tls_session_handshake_pass(void *sess);
probe rpc_tls_session_handshake_fail(void *sess);
@@ -72,6 +73,7 @@ provider libvirt {
# file: src/rpc/virkeepalive.c
# prefix: rpc
probe rpc_keepalive_new(void *ka, void *client);
+ probe rpc_keepalive_dispose(void *ka);
probe rpc_keepalive_start(void *ka, void *client, int interval, int count);
probe rpc_keepalive_stop(void *ka, void *client);
probe rpc_keepalive_send(void *ka, void *client, int prog, int vers, int proc);
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 71dd904..d49082c 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -224,6 +224,9 @@ virKeepAliveDispose(void *obj)
{
virKeepAlivePtr ka = obj;
+ PROBE(RPC_KEEPALIVE_DISPOSE,
+ "ka=%p", ka);
+
ka->freeCB(ka->client);
}
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index bfa1624..1379078 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -596,6 +596,9 @@ void virNetClientDispose(void *obj)
virNetClientPtr client = obj;
int i;
+ PROBE(RPC_CLIENT_DISPOSE,
+ "client=%p", client);
+
if (client->closeFf)
client->closeFf(client->closeOpaque);
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 9e519e6..19063ef 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -704,6 +704,9 @@ void virNetServerClientDispose(void *obj)
{
virNetServerClientPtr client = obj;
+ PROBE(RPC_SERVER_CLIENT_DISPOSE,
+ "client=%p", client);
+
if (client->privateData &&
client->privateDataFreeFunc)
client->privateDataFreeFunc(client->privateData);
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 93980d6..fe4ac71 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -996,7 +996,9 @@ void virNetSocketDispose(void *obj)
{
virNetSocketPtr sock = obj;
- VIR_DEBUG("sock=%p fd=%d", sock, sock->fd);
+ PROBE(RPC_SOCKET_DISPOSE,
+ "sock=%p", sock);
+
if (sock->watch > 0) {
virEventRemoveHandle(sock->watch);
sock->watch = -1;
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 6665268..ece4620 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1114,6 +1114,9 @@ void virNetTLSContextDispose(void *obj)
{
virNetTLSContextPtr ctxt = obj;
+ PROBE(RPC_TLS_CONTEXT_DISPOSE,
+ "ctxt=%p", ctxt);
+
gnutls_dh_params_deinit(ctxt->dhParams);
gnutls_certificate_free_credentials(ctxt->x509cred);
}
@@ -1366,6 +1369,9 @@ void virNetTLSSessionDispose(void *obj)
{
virNetTLSSessionPtr sess = obj;
+ PROBE(RPC_TLS_SESSION_DISPOSE,
+ "sess=%p", sess);
+
VIR_FREE(sess->hostname);
gnutls_deinit(sess->session);
}
--
1.8.1.4
11 years, 8 months
[libvirt] [PATCH] Fix generation of systemtap probes for RPC protocols
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The naming used in the RPC protocols for the LXC monitor and
lock daemon confused the script used to generate systemtap
helper functions. Rename the LXC monitor protocol symbols to
reduce confusion. Adapt the gensystemtap.pl script to cope
with the LXC monitor / lock daemon naming conversions.
This has no functional impact on RPC wire protocol, since
names are only used in the C layer
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/Makefile.am | 8 +++++---
src/lxc/lxc_controller.c | 26 +++++++++++++-------------
src/lxc/lxc_monitor.c | 26 +++++++++++++-------------
src/lxc/lxc_monitor.h | 2 +-
src/lxc/lxc_monitor_protocol.x | 24 ++++++++++++------------
src/lxc/lxc_process.c | 8 ++++----
src/rpc/gensystemtap.pl | 6 +++---
7 files changed, 51 insertions(+), 49 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index a6cc839..0c0dfb3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -460,12 +460,12 @@ LXC_MONITOR_PROTOCOL = $(srcdir)/lxc/lxc_monitor_protocol.x
$(srcdir)/lxc/lxc_monitor_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
$(LXC_MONITOR_PROTOCOL)
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \
- -k virLXCProtocol VIR_LXC_MONITOR_PROTOCOL $(LXC_MONITOR_PROTOCOL) > $@
+ -k virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
$(srcdir)/lxc/lxc_controller_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
$(REMOTE_PROTOCOL)
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \
- -b virLXCProtocol VIR_LXC_MONITOR_PROTOCOL $(LXC_MONITOR_PROTOCOL) > $@
+ -b virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
EXTRA_DIST += \
$(LXC_MONITOR_PROTOCOL) \
@@ -1591,7 +1591,9 @@ RPC_PROBE_FILES = $(srcdir)/rpc/virnetprotocol.x \
$(srcdir)/rpc/virkeepaliveprotocol.x \
$(srcdir)/remote/remote_protocol.x \
$(srcdir)/remote/lxc_protocol.x \
- $(srcdir)/remote/qemu_protocol.x
+ $(srcdir)/remote/qemu_protocol.x \
+ $(srcdir)/lxc/lxc_monitor_protocol.x \
+ $(srcdir)/locking/lock_protocol.x
libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.pl
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gensystemtap.pl $(RPC_PROBE_FILES) > $@
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 5e422ad..becf811 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -713,10 +713,10 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
virObjectUnref(svc);
svc = NULL;
- if (!(ctrl->prog = virNetServerProgramNew(VIR_LXC_PROTOCOL_PROGRAM,
- VIR_LXC_PROTOCOL_PROGRAM_VERSION,
- virLXCProtocolProcs,
- virLXCProtocolNProcs)))
+ if (!(ctrl->prog = virNetServerProgramNew(VIR_LXC_MONITOR_PROGRAM,
+ VIR_LXC_MONITOR_PROGRAM_VERSION,
+ virLXCMonitorProcs,
+ virLXCMonitorNProcs)))
goto error;
virNetServerUpdateServices(ctrl->server, true);
@@ -1415,25 +1415,25 @@ static int
virLXCControllerEventSendExit(virLXCControllerPtr ctrl,
int exitstatus)
{
- virLXCProtocolExitEventMsg msg;
+ virLXCMonitorExitEventMsg msg;
VIR_DEBUG("Exit status %d (client=%p)", exitstatus, ctrl->client);
memset(&msg, 0, sizeof(msg));
switch (exitstatus) {
case 0:
- msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN;
+ msg.status = VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN;
break;
case 1:
- msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT;
+ msg.status = VIR_LXC_MONITOR_EXIT_STATUS_REBOOT;
break;
default:
- msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR;
+ msg.status = VIR_LXC_MONITOR_EXIT_STATUS_ERROR;
break;
}
virLXCControllerEventSend(ctrl,
- VIR_LXC_PROTOCOL_PROC_EXIT_EVENT,
- (xdrproc_t)xdr_virLXCProtocolExitEventMsg,
+ VIR_LXC_MONITOR_PROC_EXIT_EVENT,
+ (xdrproc_t)xdr_virLXCMonitorExitEventMsg,
(void*)&msg);
if (ctrl->client) {
@@ -1451,15 +1451,15 @@ static int
virLXCControllerEventSendInit(virLXCControllerPtr ctrl,
pid_t initpid)
{
- virLXCProtocolInitEventMsg msg;
+ virLXCMonitorInitEventMsg msg;
VIR_DEBUG("Init pid %llu", (unsigned long long)initpid);
memset(&msg, 0, sizeof(msg));
msg.initpid = initpid;
virLXCControllerEventSend(ctrl,
- VIR_LXC_PROTOCOL_PROC_INIT_EVENT,
- (xdrproc_t)xdr_virLXCProtocolInitEventMsg,
+ VIR_LXC_MONITOR_PROC_INIT_EVENT,
+ (xdrproc_t)xdr_virLXCMonitorInitEventMsg,
(void*)&msg);
return 0;
}
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index e3901f8..6d11eda 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -68,15 +68,15 @@ virLXCMonitorHandleEventInit(virNetClientProgramPtr prog,
virNetClientPtr client,
void *evdata, void *opaque);
-static virNetClientProgramEvent virLXCProtocolEvents[] = {
- { VIR_LXC_PROTOCOL_PROC_EXIT_EVENT,
+static virNetClientProgramEvent virLXCMonitorEvents[] = {
+ { VIR_LXC_MONITOR_PROC_EXIT_EVENT,
virLXCMonitorHandleEventExit,
- sizeof(virLXCProtocolExitEventMsg),
- (xdrproc_t)xdr_virLXCProtocolExitEventMsg },
- { VIR_LXC_PROTOCOL_PROC_INIT_EVENT,
+ sizeof(virLXCMonitorExitEventMsg),
+ (xdrproc_t)xdr_virLXCMonitorExitEventMsg },
+ { VIR_LXC_MONITOR_PROC_INIT_EVENT,
virLXCMonitorHandleEventInit,
- sizeof(virLXCProtocolInitEventMsg),
- (xdrproc_t)xdr_virLXCProtocolInitEventMsg },
+ sizeof(virLXCMonitorInitEventMsg),
+ (xdrproc_t)xdr_virLXCMonitorInitEventMsg },
};
@@ -86,7 +86,7 @@ virLXCMonitorHandleEventExit(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
void *evdata, void *opaque)
{
virLXCMonitorPtr mon = opaque;
- virLXCProtocolExitEventMsg *msg = evdata;
+ virLXCMonitorExitEventMsg *msg = evdata;
VIR_DEBUG("Event exit %d", msg->status);
if (mon->cb.exitNotify)
@@ -100,7 +100,7 @@ virLXCMonitorHandleEventInit(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
void *evdata, void *opaque)
{
virLXCMonitorPtr mon = opaque;
- virLXCProtocolInitEventMsg *msg = evdata;
+ virLXCMonitorInitEventMsg *msg = evdata;
VIR_DEBUG("Event init %llu",
(unsigned long long)msg->initpid);
@@ -162,10 +162,10 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
if (virNetClientRegisterAsyncIO(mon->client) < 0)
goto error;
- if (!(mon->program = virNetClientProgramNew(VIR_LXC_PROTOCOL_PROGRAM,
- VIR_LXC_PROTOCOL_PROGRAM_VERSION,
- virLXCProtocolEvents,
- ARRAY_CARDINALITY(virLXCProtocolEvents),
+ if (!(mon->program = virNetClientProgramNew(VIR_LXC_MONITOR_PROGRAM,
+ VIR_LXC_MONITOR_PROGRAM_VERSION,
+ virLXCMonitorEvents,
+ ARRAY_CARDINALITY(virLXCMonitorEvents),
mon)))
goto error;
diff --git a/src/lxc/lxc_monitor.h b/src/lxc/lxc_monitor.h
index cc31a9c..a0d6f37 100644
--- a/src/lxc/lxc_monitor.h
+++ b/src/lxc/lxc_monitor.h
@@ -37,7 +37,7 @@ typedef void (*virLXCMonitorCallbackEOFNotify)(virLXCMonitorPtr mon,
virDomainObjPtr vm);
typedef void (*virLXCMonitorCallbackExitNotify)(virLXCMonitorPtr mon,
- virLXCProtocolExitStatus status,
+ virLXCMonitorExitStatus status,
virDomainObjPtr vm);
typedef void (*virLXCMonitorCallbackInitNotify)(virLXCMonitorPtr mon,
diff --git a/src/lxc/lxc_monitor_protocol.x b/src/lxc/lxc_monitor_protocol.x
index 0f041f6..0926e26 100644
--- a/src/lxc/lxc_monitor_protocol.x
+++ b/src/lxc/lxc_monitor_protocol.x
@@ -4,24 +4,24 @@
* the libvirt_lxc helper program.
*/
-enum virLXCProtocolExitStatus {
- VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR,
- VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN,
- VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT
+enum virLXCMonitorExitStatus {
+ VIR_LXC_MONITOR_EXIT_STATUS_ERROR,
+ VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN,
+ VIR_LXC_MONITOR_EXIT_STATUS_REBOOT
};
-struct virLXCProtocolExitEventMsg {
- enum virLXCProtocolExitStatus status;
+struct virLXCMonitorExitEventMsg {
+ enum virLXCMonitorExitStatus status;
};
-struct virLXCProtocolInitEventMsg {
+struct virLXCMonitorInitEventMsg {
unsigned hyper initpid;
};
-const VIR_LXC_PROTOCOL_PROGRAM = 0x12341234;
-const VIR_LXC_PROTOCOL_PROGRAM_VERSION = 1;
+const VIR_LXC_MONITOR_PROGRAM = 0x12341234;
+const VIR_LXC_MONITOR_PROGRAM_VERSION = 1;
-enum virLXCProtocolProcedure {
- VIR_LXC_PROTOCOL_PROC_EXIT_EVENT = 1, /* skipgen skipgen */
- VIR_LXC_PROTOCOL_PROC_INIT_EVENT = 2 /* skipgen skipgen */
+enum virLXCMonitorProcedure {
+ VIR_LXC_MONITOR_PROC_EXIT_EVENT = 1, /* skipgen skipgen */
+ VIR_LXC_MONITOR_PROC_INIT_EVENT = 2 /* skipgen skipgen */
};
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 942d375..670a032 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -607,19 +607,19 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
}
static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED,
- virLXCProtocolExitStatus status,
+ virLXCMonitorExitStatus status,
virDomainObjPtr vm)
{
virLXCDomainObjPrivatePtr priv = vm->privateData;
switch (status) {
- case VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN:
+ case VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN:
priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
break;
- case VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR:
+ case VIR_LXC_MONITOR_EXIT_STATUS_ERROR:
priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED;
break;
- case VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT:
+ case VIR_LXC_MONITOR_EXIT_STATUS_REBOOT:
priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
priv->wantReboot = true;
break;
diff --git a/src/rpc/gensystemtap.pl b/src/rpc/gensystemtap.pl
index a16fa00..2467300 100755
--- a/src/rpc/gensystemtap.pl
+++ b/src/rpc/gensystemtap.pl
@@ -57,11 +57,11 @@ while (<>) {
$auth{$2} = lc $1;
}
} else {
- if (/(\w+)_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) {
+ if (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) {
$funcs{lc $1} = { id => hex($2), version => undef, progs => [] };
- } elsif (/(\w+)_PROTOCOL_VERSION\s*=\s*(\d+)\s*;/) {
+ } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_(?:PROGRAM|PROTOCOL)_VERSION\s*=\s*(\d+)\s*;/) {
$funcs{lc $1}->{version} = $2;
- } elsif (/(\w+)_PROC_(.*?)\s+=\s+(\d+)/) {
+ } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROC_(.*?)\s+=\s+(\d+)/) {
$funcs{lc $1}->{progs}->[$3] = lc $2;
}
}
--
1.8.1.4
11 years, 8 months
[libvirt] Race/broken mutex when closing a connection
by Viktor Mihajlovski
I received a report of a virsh coredump that happened on a heavy loaded
system. Debugging the corefile I saw that under certain circumstances
the mutex for a connection can be destroyed while another thread is
waiting for the lock on that connection.
Specifically this seems to happen when vshDeinit is called after the
completion of vshRunCommand and at the same time the event loop is
receiving a client disconnect.
vshDeinit calls virConnectClose which unrefs the connection object
destroying the lock mutex before releasing the memory and nulling
the callback pointers.
At the same time the event loop will call remoteClientCloseFunc
which waits for the mutex while the connection is unrefed.
It will obtain the (now invalid but non-error checking) mutex,
copy the closeCallback pointer (shorty before the connection object is
destroyed) and will die upon trying to call closeFreeCallback (NULL
by now).
First I would like to see whether someone finds an obvious flaw
in my reasoning. Then I'd would like to discuss how to get around it.
One thought would be to increase the refcount of the connection
object in remoteClientCloseFunc before calling the closeCallback.
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
11 years, 8 months
[libvirt] [PATCHv5 0/3] DEVICE_DELETED event
by Michael S. Tsirkin
libvirt has a long-standing bug: when removing the device,
it can request removal but does not know when the
removal completes. Add an event so we can fix this in a robust way.
First patch only adds the event for devices with ID, second path adds it
for all devices and adds a path fields. Split this way for ease of
backport (stable downstreams without QOM would want to only take the
first patch), and also because the 2nd/3rd patches might turn out to be
more controversial - if they really turn
out such I'd like just the 1st one to get applied while we discuss 2 and
3.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Changes from v4:
- Add extra triggers and extra fields as requested by Markus
Changes from v3:
- Document that we only emit events for devices with
and ID, as suggested by Markus
Changes from v2:
- move event toward the end of device_unparent,
so that parents are reported after their children,
as suggested by Paolo
Changes from v1:
- move to device_unparent
- address comments by Andreas and Eric
--
Anthony Liguori
Michael S. Tsirkin (3):
qdev: DEVICE_DELETED event
qom: pass original path to unparent method
qmp: add path to device_deleted event
QMP/qmp-events.txt | 18 ++++++++++++++++++
hw/qdev.c | 15 +++++++++++++--
include/monitor/monitor.h | 1 +
include/qom/object.h | 3 ++-
monitor.c | 1 +
qapi-schema.json | 4 +++-
qom/object.c | 4 +++-
7 files changed, 41 insertions(+), 5 deletions(-)
--
MST
11 years, 8 months
Re: [libvirt] if_bridge.h: include in6.h for struct in6_addr use
by Thomas Backlund
Thomas Backlund skrev 13.1.2013 20:38:
> patch both inline and attached as thunderbird tends to mess up ...
> -----
>
> if_bridge.h uses struct in6_addr ip6; but does not include the in6.h
> header.
>
> Found by trying to build libvirt and connman against 3.8-rc3 headers.
>
Ok,
ignore this patch, it's not the correct fix as it introduces
redefinitions...
Btw, the error that I hit that made me suggest this fix was libvirt
config check bailing out:
config.log:/usr/include/linux/if_bridge.h:173:20: error: field 'ip6' has
incomplete type
> Reported-by: Colin Guthrie <colin(a)mageia.org>
> Reported-by: Christiaan Welvaart <cjw(a)daneel.dyndns.org>
> Signed-off-by: Thomas Backlund <tmb(a)mageia.org>
>
> --
>
> diff -Nurp linux-3.8-rc3/include/uapi/linux/if_bridge.h
> linux-3.8-rc3.fix/include/uapi/linux/if_bridge.h
> --- linux-3.8-rc3/include/uapi/linux/if_bridge.h 2013-01-13
> 20:09:54.257271755 +0200
> +++ linux-3.8-rc3.fix/include/uapi/linux/if_bridge.h 2013-01-13
> 20:15:04.153676151 +0200
> @@ -14,6 +14,7 @@
> #define _UAPI_LINUX_IF_BRIDGE_H
>
> #include <linux/types.h>
> +#include <linux/in6.h>
>
> #define SYSFS_BRIDGE_ATTR "bridge"
> #define SYSFS_BRIDGE_FDB "brforward"
>
>
> -----
> Thomas
>
--
Thomas
11 years, 8 months