mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Convert daemon/virsh over to use primary event APIs, rather than impl
The daemon code calls virEventAddHandleImpl directly instead of calling the wrapper virEventAddHandle. * tools/console.c, daemon/libvirtd.c, daemon/mdns.c: Convert to use primary event APIs
This commit is contained in:
parent
bcb40b852c
commit
5d2c045cd8
@ -63,6 +63,7 @@
|
||||
#include "remote_driver.h"
|
||||
#include "conf.h"
|
||||
#include "event.h"
|
||||
#include "src/util/event.h"
|
||||
#include "memory.h"
|
||||
#include "stream.h"
|
||||
#include "hooks.h"
|
||||
@ -1104,7 +1105,7 @@ static int qemudNetworkEnable(struct qemud_server *server) {
|
||||
|
||||
sock = server->sockets;
|
||||
while (sock) {
|
||||
if ((sock->watch = virEventAddHandleImpl(sock->fd,
|
||||
if ((sock->watch = virEventAddHandle(sock->fd,
|
||||
VIR_EVENT_HANDLE_READABLE |
|
||||
VIR_EVENT_HANDLE_ERROR |
|
||||
VIR_EVENT_HANDLE_HANGUP,
|
||||
@ -1541,7 +1542,7 @@ error:
|
||||
*/
|
||||
void qemudDispatchClientFailure(struct qemud_client *client) {
|
||||
if (client->watch != -1) {
|
||||
virEventRemoveHandleImpl(client->watch);
|
||||
virEventRemoveHandle(client->watch);
|
||||
client->watch = -1;
|
||||
}
|
||||
|
||||
@ -2235,7 +2236,7 @@ int qemudRegisterClientEvent(struct qemud_server *server,
|
||||
|
||||
mode = qemudCalculateHandleMode(client);
|
||||
|
||||
if ((client->watch = virEventAddHandleImpl(client->fd,
|
||||
if ((client->watch = virEventAddHandle(client->fd,
|
||||
mode,
|
||||
qemudDispatchClientEvent,
|
||||
server, NULL)) < 0)
|
||||
@ -2252,7 +2253,7 @@ void qemudUpdateClientEvent(struct qemud_client *client) {
|
||||
|
||||
mode = qemudCalculateHandleMode(client);
|
||||
|
||||
virEventUpdateHandleImpl(client->watch, mode);
|
||||
virEventUpdateHandle(client->watch, mode);
|
||||
}
|
||||
|
||||
|
||||
@ -2304,7 +2305,7 @@ static void qemudInactiveTimer(int timerid, void *data) {
|
||||
if (virStateActive() ||
|
||||
server->clients) {
|
||||
VIR_DEBUG0("Timer expired but still active, not shutting down");
|
||||
virEventUpdateTimeoutImpl(timerid, -1);
|
||||
virEventUpdateTimeout(timerid, -1);
|
||||
} else {
|
||||
VIR_DEBUG0("Timer expired and inactive, shutting down");
|
||||
server->quitEventThread = 1;
|
||||
@ -2347,7 +2348,7 @@ static void *qemudRunLoop(void *opaque) {
|
||||
virMutexLock(&server->lock);
|
||||
|
||||
if (timeout > 0 &&
|
||||
(timerid = virEventAddTimeoutImpl(-1,
|
||||
(timerid = virEventAddTimeout(-1,
|
||||
qemudInactiveTimer,
|
||||
server, NULL)) < 0) {
|
||||
VIR_ERROR0(_("Failed to register shutdown timeout"));
|
||||
@ -2378,14 +2379,14 @@ static void *qemudRunLoop(void *opaque) {
|
||||
if (timerActive) {
|
||||
if (server->clients) {
|
||||
VIR_DEBUG("Deactivating shutdown timer %d", timerid);
|
||||
virEventUpdateTimeoutImpl(timerid, -1);
|
||||
virEventUpdateTimeout(timerid, -1);
|
||||
timerActive = 0;
|
||||
}
|
||||
} else {
|
||||
if (!virStateActive() &&
|
||||
!server->clients) {
|
||||
VIR_DEBUG("Activating shutdown timer %d", timerid);
|
||||
virEventUpdateTimeoutImpl(timerid, timeout * 1000);
|
||||
virEventUpdateTimeout(timerid, timeout * 1000);
|
||||
timerActive = 1;
|
||||
}
|
||||
}
|
||||
@ -2501,7 +2502,7 @@ static void qemudCleanup(struct qemud_server *server) {
|
||||
while (sock) {
|
||||
struct qemud_socket *next = sock->next;
|
||||
if (sock->watch)
|
||||
virEventRemoveHandleImpl(sock->watch);
|
||||
virEventRemoveHandle(sock->watch);
|
||||
VIR_FORCE_CLOSE(sock->fd);
|
||||
|
||||
/* Unlink unix domain sockets which are not in
|
||||
@ -3081,7 +3082,7 @@ daemonSetupSignals(struct qemud_server *server)
|
||||
sig_action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &sig_action, NULL);
|
||||
|
||||
if (virEventAddHandleImpl(sigpipe[0],
|
||||
if (virEventAddHandle(sigpipe[0],
|
||||
VIR_EVENT_HANDLE_READABLE,
|
||||
qemudDispatchSignalEvent,
|
||||
server, NULL) < 0) {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "libvirtd.h"
|
||||
#include "mdns.h"
|
||||
#include "event.h"
|
||||
#include "src/util/event.h"
|
||||
#include "memory.h"
|
||||
|
||||
#define AVAHI_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
|
||||
@ -257,7 +258,7 @@ static AvahiWatch *libvirtd_mdns_watch_new(const AvahiPoll *api ATTRIBUTE_UNUSED
|
||||
|
||||
AVAHI_DEBUG("New handle %p FD %d Event %d", w, w->fd, event);
|
||||
hEvents = virPollEventToEventHandleType(event);
|
||||
if ((w->watch = virEventAddHandleImpl(fd, hEvents,
|
||||
if ((w->watch = virEventAddHandle(fd, hEvents,
|
||||
libvirtd_mdns_watch_dispatch,
|
||||
w,
|
||||
libvirtd_mdns_watch_dofree)) < 0) {
|
||||
@ -271,7 +272,7 @@ static AvahiWatch *libvirtd_mdns_watch_new(const AvahiPoll *api ATTRIBUTE_UNUSED
|
||||
static void libvirtd_mdns_watch_update(AvahiWatch *w, AvahiWatchEvent event)
|
||||
{
|
||||
AVAHI_DEBUG("Update handle %p FD %d Event %d", w, w->fd, event);
|
||||
virEventUpdateHandleImpl(w->watch, event);
|
||||
virEventUpdateHandle(w->watch, event);
|
||||
}
|
||||
|
||||
static AvahiWatchEvent libvirtd_mdns_watch_get_events(AvahiWatch *w)
|
||||
@ -283,14 +284,14 @@ static AvahiWatchEvent libvirtd_mdns_watch_get_events(AvahiWatch *w)
|
||||
static void libvirtd_mdns_watch_free(AvahiWatch *w)
|
||||
{
|
||||
AVAHI_DEBUG("Free handle %p %d", w, w->fd);
|
||||
virEventRemoveHandleImpl(w->watch);
|
||||
virEventRemoveHandle(w->watch);
|
||||
}
|
||||
|
||||
static void libvirtd_mdns_timeout_dispatch(int timer ATTRIBUTE_UNUSED, void *opaque)
|
||||
{
|
||||
AvahiTimeout *t = (AvahiTimeout*)opaque;
|
||||
AVAHI_DEBUG("Dispatch timeout %p %d", t, timer);
|
||||
virEventUpdateTimeoutImpl(t->timer, -1);
|
||||
virEventUpdateTimeout(t->timer, -1);
|
||||
t->callback(t, t->userdata);
|
||||
}
|
||||
|
||||
@ -329,7 +330,7 @@ static AvahiTimeout *libvirtd_mdns_timeout_new(const AvahiPoll *api ATTRIBUTE_UN
|
||||
timeout = -1;
|
||||
}
|
||||
|
||||
t->timer = virEventAddTimeoutImpl(timeout,
|
||||
t->timer = virEventAddTimeout(timeout,
|
||||
libvirtd_mdns_timeout_dispatch,
|
||||
t,
|
||||
libvirtd_mdns_timeout_dofree);
|
||||
@ -364,13 +365,13 @@ static void libvirtd_mdns_timeout_update(AvahiTimeout *t, const struct timeval *
|
||||
timeout = -1;
|
||||
}
|
||||
|
||||
virEventUpdateTimeoutImpl(t->timer, timeout);
|
||||
virEventUpdateTimeout(t->timer, timeout);
|
||||
}
|
||||
|
||||
static void libvirtd_mdns_timeout_free(AvahiTimeout *t)
|
||||
{
|
||||
AVAHI_DEBUG("Free timeout %p", t);
|
||||
virEventRemoveTimeoutImpl(t->timer);
|
||||
virEventRemoveTimeout(t->timer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
# include "virterror_internal.h"
|
||||
|
||||
# include "daemon/event.h"
|
||||
# include "src/util/event.h"
|
||||
|
||||
/* ie Ctrl-] as per telnet */
|
||||
# define CTRL_CLOSE_BRACKET '\35'
|
||||
@ -93,9 +94,9 @@ virConsoleShutdown(virConsolePtr con)
|
||||
con->quit = true;
|
||||
virStreamEventRemoveCallback(con->st);
|
||||
if (con->stdinWatch != -1)
|
||||
virEventRemoveHandleImpl(con->stdinWatch);
|
||||
virEventRemoveHandle(con->stdinWatch);
|
||||
if (con->stdinWatch != -1)
|
||||
virEventRemoveHandleImpl(con->stdoutWatch);
|
||||
virEventRemoveHandle(con->stdoutWatch);
|
||||
con->stdinWatch = -1;
|
||||
con->stdoutWatch = -1;
|
||||
}
|
||||
@ -134,7 +135,7 @@ virConsoleEventOnStream(virStreamPtr st,
|
||||
}
|
||||
con->streamToTerminal.offset += got;
|
||||
if (con->streamToTerminal.offset)
|
||||
virEventUpdateHandleImpl(con->stdoutWatch,
|
||||
virEventUpdateHandle(con->stdoutWatch,
|
||||
VIR_EVENT_HANDLE_WRITABLE);
|
||||
}
|
||||
|
||||
@ -266,7 +267,7 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (!con->streamToTerminal.offset)
|
||||
virEventUpdateHandleImpl(con->stdoutWatch, 0);
|
||||
virEventUpdateHandle(con->stdoutWatch, 0);
|
||||
|
||||
if (events & VIR_EVENT_HANDLE_ERROR ||
|
||||
events & VIR_EVENT_HANDLE_HANGUP) {
|
||||
@ -331,12 +332,12 @@ int vshRunConsole(virDomainPtr dom, const char *devname)
|
||||
if (virDomainOpenConsole(dom, devname, con->st, 0) < 0)
|
||||
goto cleanup;
|
||||
|
||||
con->stdinWatch = virEventAddHandleImpl(STDIN_FILENO,
|
||||
con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
||||
VIR_EVENT_HANDLE_READABLE,
|
||||
virConsoleEventOnStdin,
|
||||
con,
|
||||
NULL);
|
||||
con->stdoutWatch = virEventAddHandleImpl(STDOUT_FILENO,
|
||||
con->stdoutWatch = virEventAddHandle(STDOUT_FILENO,
|
||||
0,
|
||||
virConsoleEventOnStdout,
|
||||
con,
|
||||
|
Loading…
x
Reference in New Issue
Block a user