From c80b7f0d5a01d4b21c01b323598b4ef520f6fd28 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 6 Feb 2009 19:28:20 +0000 Subject: [PATCH] Fix libvirtd --timeout usage Fix RPC call problems and QEMU startup handling (rhbz #484414) Fix unowned directories (rhbz #483442) --- libvirt-0.6.0-rpccall.patch | 83 +++++++++++++++++++++++ libvirt-0.6.0-timeout.patch | 132 ++++++++++++++++++++++++++++++++++++ libvirt.spec | 13 +++- sources | 1 - 4 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 libvirt-0.6.0-rpccall.patch create mode 100644 libvirt-0.6.0-timeout.patch diff --git a/libvirt-0.6.0-rpccall.patch b/libvirt-0.6.0-rpccall.patch new file mode 100644 index 0000000..23a3e3d --- /dev/null +++ b/libvirt-0.6.0-rpccall.patch @@ -0,0 +1,83 @@ +? mingw-fixes +Index: qemud/event.c +=================================================================== +RCS file: /data/cvs/libvirt/qemud/event.c,v +retrieving revision 1.17 +diff -u -p -u -p -r1.17 event.c +--- qemud/event.c 22 Dec 2008 12:55:47 -0000 1.17 ++++ qemud/event.c 5 Feb 2009 17:12:51 -0000 +@@ -653,6 +653,8 @@ virPollEventToEventHandleType(int events + ret |= VIR_EVENT_HANDLE_WRITABLE; + if(events & POLLERR) + ret |= VIR_EVENT_HANDLE_ERROR; ++ if(events & POLLNVAL) /* Treat NVAL as error, since libvirt doesn't distinguish */ ++ ret |= VIR_EVENT_HANDLE_ERROR; + if(events & POLLHUP) + ret |= VIR_EVENT_HANDLE_HANGUP; + return ret; +Index: src/domain_conf.c +=================================================================== +RCS file: /data/cvs/libvirt/src/domain_conf.c,v +retrieving revision 1.64 +diff -u -p -u -p -r1.64 domain_conf.c +--- src/domain_conf.c 30 Jan 2009 21:52:22 -0000 1.64 ++++ src/domain_conf.c 5 Feb 2009 17:12:51 -0000 +@@ -504,6 +504,7 @@ virDomainObjPtr virDomainAssignDef(virCo + domain->state = VIR_DOMAIN_SHUTOFF; + domain->def = def; + domain->monitor_watch = -1; ++ domain->monitor = -1; + + if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) { + virReportOOMError(conn); +Index: src/remote_internal.c +=================================================================== +RCS file: /data/cvs/libvirt/src/remote_internal.c,v +retrieving revision 1.136 +diff -u -p -u -p -r1.136 remote_internal.c +--- src/remote_internal.c 3 Feb 2009 13:08:07 -0000 1.136 ++++ src/remote_internal.c 5 Feb 2009 17:12:52 -0000 +@@ -6192,17 +6192,17 @@ processCalls(virConnectPtr conn, + continue; + virReportSystemError(in_open ? NULL : conn, errno, + "%s", _("poll on socket failed")); +- return -1; ++ goto error; + } + + if (fds[0].revents & POLLOUT) { + if (processCallSend(conn, priv, in_open) < 0) +- return -1; ++ goto error; + } + + if (fds[0].revents & POLLIN) { + if (processCallRecv(conn, priv, in_open) < 0) +- return -1; ++ goto error; + } + + /* Iterate through waiting threads and if +@@ -6253,9 +6253,21 @@ processCalls(virConnectPtr conn, + if (fds[0].revents & (POLLHUP | POLLERR)) { + errorf(in_open ? NULL : conn, VIR_ERR_INTERNAL_ERROR, + "%s", _("received hangup / error event on socket")); +- return -1; ++ goto error; + } + } ++ ++ ++error: ++ priv->waitDispatch = thiscall->next; ++ DEBUG("Giving up the buck due to I/O error %d %p %p", thiscall->proc_nr, thiscall, priv->waitDispatch); ++ /* See if someone else is still waiting ++ * and if so, then pass the buck ! */ ++ if (priv->waitDispatch) { ++ DEBUG("Passing the buck to %d %p", priv->waitDispatch->proc_nr, priv->waitDispatch); ++ virCondSignal(&priv->waitDispatch->cond); ++ } ++ return -1; + } + + /* diff --git a/libvirt-0.6.0-timeout.patch b/libvirt-0.6.0-timeout.patch new file mode 100644 index 0000000..ac753bc --- /dev/null +++ b/libvirt-0.6.0-timeout.patch @@ -0,0 +1,132 @@ +Index: qemud/event.c +=================================================================== +RCS file: /data/cvs/libvirt/qemud/event.c,v +retrieving revision 1.17 +diff -u -p -u -r1.17 event.c +--- qemud/event.c 22 Dec 2008 12:55:47 -0000 1.17 ++++ qemud/event.c 4 Feb 2009 15:08:06 -0000 +@@ -68,6 +68,7 @@ struct virEventTimeout { + /* State for the main event loop */ + struct virEventLoop { + pthread_mutex_t lock; ++ int running; + pthread_t leader; + int wakeupfd[2]; + int handlesCount; +@@ -521,6 +522,7 @@ int virEventRunOnce(void) { + int ret, timeout, nfds; + + virEventLock(); ++ eventLoop.running = 1; + eventLoop.leader = pthread_self(); + if ((nfds = virEventMakePollFDs(&fds)) < 0) { + virEventUnlock(); +@@ -572,7 +574,7 @@ int virEventRunOnce(void) { + return -1; + } + +- eventLoop.leader = 0; ++ eventLoop.running = 0; + virEventUnlock(); + return 0; + } +@@ -611,7 +613,9 @@ int virEventInit(void) + static int virEventInterruptLocked(void) + { + char c = '\0'; +- if (pthread_self() == eventLoop.leader) ++ ++ if (!eventLoop.running || ++ pthread_self() == eventLoop.leader) + return 0; + + if (safewrite(eventLoop.wakeupfd[1], &c, sizeof(c)) != sizeof(c)) +Index: qemud/qemud.c +=================================================================== +RCS file: /data/cvs/libvirt/qemud/qemud.c,v +retrieving revision 1.138 +diff -u -p -u -r1.138 qemud.c +--- qemud/qemud.c 28 Jan 2009 11:31:39 -0000 1.138 ++++ qemud/qemud.c 4 Feb 2009 15:08:06 -0000 +@@ -2013,11 +2013,15 @@ static int qemudOneLoop(void) { + return 0; + } + +-static void qemudInactiveTimer(int timer ATTRIBUTE_UNUSED, void *data) { ++static void qemudInactiveTimer(int timerid, void *data) { + struct qemud_server *server = (struct qemud_server *)data; +- DEBUG0("Got inactive timer expiry"); +- if (!virStateActive()) { +- DEBUG0("No state active, shutting down"); ++ ++ if (virStateActive() || ++ server->clients) { ++ DEBUG0("Timer expired but still active, not shutting down"); ++ virEventUpdateTimeoutImpl(timerid, -1); ++ } else { ++ DEBUG0("Timer expired and inactive, shutting down"); + server->shutdown = 1; + } + } +@@ -2048,9 +2052,18 @@ static void qemudFreeClient(struct qemud + static int qemudRunLoop(struct qemud_server *server) { + int timerid = -1; + int ret = -1, i; ++ int timerActive = 0; + + virMutexLock(&server->lock); + ++ if (timeout > 0 && ++ (timerid = virEventAddTimeoutImpl(-1, ++ qemudInactiveTimer, ++ server, NULL)) < 0) { ++ VIR_ERROR0(_("Failed to register shutdown timeout")); ++ return -1; ++ } ++ + if (min_workers > max_workers) + max_workers = min_workers; + +@@ -2071,11 +2084,21 @@ static int qemudRunLoop(struct qemud_ser + * if any drivers have active state, if not + * shutdown after timeout seconds + */ +- if (timeout > 0 && !virStateActive() && !server->clients) { +- timerid = virEventAddTimeoutImpl(timeout*1000, +- qemudInactiveTimer, +- server, NULL); +- DEBUG("Scheduling shutdown timer %d", timerid); ++ if (timeout > 0) { ++ if (timerActive) { ++ if (server->clients) { ++ DEBUG("Deactivating shutdown timer %d", timerid); ++ virEventUpdateTimeoutImpl(timerid, -1); ++ timerActive = 0; ++ } ++ } else { ++ if (!virStateActive() && ++ !server->clients) { ++ DEBUG("Activating shutdown timer %d", timerid); ++ virEventUpdateTimeoutImpl(timerid, timeout * 1000); ++ timerActive = 1; ++ } ++ } + } + + virMutexUnlock(&server->lock); +@@ -2129,15 +2152,6 @@ static int qemudRunLoop(struct qemud_ser + } + } + +- /* Unregister any timeout that's active, since we +- * just had an event processed +- */ +- if (timerid != -1) { +- DEBUG("Removing shutdown timer %d", timerid); +- virEventRemoveTimeoutImpl(timerid); +- timerid = -1; +- } +- + if (server->shutdown) { + ret = 0; + break; diff --git a/libvirt.spec b/libvirt.spec index 3b3cd69..8836950 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -47,10 +47,12 @@ Summary: Library providing a simple API virtualization Name: libvirt Version: 0.6.0 -Release: 1%{?dist}%{?extra_release} +Release: 2%{?dist}%{?extra_release} License: LGPLv2+ Group: Development/Libraries Source: libvirt-%{version}.tar.gz +Patch1: %{name}-%{version}-timeout.patch +Patch2: %{name}-%{version}-rpccall.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://libvirt.org/ BuildRequires: python python-devel @@ -177,6 +179,8 @@ of recent versions of Linux (and other OSes). %prep %setup -q +%patch1 -p1 +%patch2 -p1 %build %if ! %{with_xen} @@ -390,6 +394,7 @@ fi %if %{with_network} %dir %{_localstatedir}/run/libvirt/network/ %dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/network/ +%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/ %dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/filter/ %dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/nat/ %endif @@ -408,6 +413,7 @@ fi %{_datadir}/PolicyKit/policy/org.libvirt.unix.policy %endif +%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/ %if %{with_qemu} %dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/ %endif @@ -457,6 +463,11 @@ fi %endif %changelog +* Fri Feb 6 2009 Daniel P. Berrange - 0.6.0-2.fc11 +- Fix libvirtd --timeout usage +- Fix RPC call problems and QEMU startup handling (rhbz #484414) +- Fix unowned directories (rhbz #483442) + * Sat Jan 31 2009 Daniel Veillard - 0.6.0-1.fc11 - upstream release 0.6.0 - thread safety of API diff --git a/sources b/sources index 3bb1875..88ff908 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -abc697978e9c66cbc8d8db4fa3f1c1b6 libvirt-0.5.1.tar.gz 8e0120d5452b37179f682031bf0895ea libvirt-0.6.0.tar.gz