Merge lp:~xnox/qtmir/no-more-cgmanager-or-upstart into lp:qtmir

Proposed by Dimitri John Ledkov
Status: Approved
Approved by: Gerry Boland
Approved revision: 640
Proposed branch: lp:~xnox/qtmir/no-more-cgmanager-or-upstart
Merge into: lp:qtmir
Diff against target: 279 lines (+2/-185)
7 files modified
CMakeLists.txt (+0/-1)
debian/control (+0/-1)
src/modules/Unity/Application/CMakeLists.txt (+0/-2)
src/modules/Unity/Application/cgmanager.cpp (+0/-117)
src/modules/Unity/Application/cgmanager.h (+0/-42)
src/modules/Unity/Application/dbusfocusinfo.cpp (+2/-19)
src/modules/Unity/Application/dbusfocusinfo.h (+0/-3)
To merge this branch: bzr merge lp:~xnox/qtmir/no-more-cgmanager-or-upstart
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Review via email: mp+323036@code.launchpad.net

Commit message

Drop cgmanager dependency, since ubuntu-app-launch moved to systemd, there is no longer any upstart cgroups.

Description of the change

Drop cgmanager dependency, since ubuntu-app-launch moved to systemd, there is no longer any upstart cgroups.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

ok

review: Approve

Unmerged revisions

640. By Dimitri John Ledkov

Drop cgmanager dependency, since ubuntu-app-launch moved to systemd, there is no longer any upstart cgroups.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2017-03-24 11:29:56 +0000
3+++ CMakeLists.txt 2017-04-24 13:56:27 +0000
4@@ -91,7 +91,6 @@
5 pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
6 pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
7 pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)
8-pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
9 pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)
10 pkg_check_modules(VALGRIND valgrind REQUIRED)
11
12
13=== modified file 'debian/control'
14--- debian/control 2017-03-24 11:29:56 +0000
15+++ debian/control 2017-04-24 13:56:27 +0000
16@@ -6,7 +6,6 @@
17 cmake-extras (>= 0.10),
18 debhelper (>= 9),
19 google-mock (>= 1.6.0+svn437),
20- libcgmanager-dev,
21 libcontent-hub-dev (>= 0.2),
22 libfontconfig1-dev,
23 libgles2-mesa-dev,
24
25=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
26--- src/modules/Unity/Application/CMakeLists.txt 2017-03-13 16:49:49 +0000
27+++ src/modules/Unity/Application/CMakeLists.txt 2017-04-24 13:56:27 +0000
28@@ -14,7 +14,6 @@
29 ${UBUNTU_PLATFORM_API_INCLUDE_DIRS}
30 ${UBUNTU_APP_LAUNCH_INCLUDE_DIRS}
31 ${GSETTINGS_QT_INCLUDE_DIRS}
32- ${CGMANAGER_INCLUDE_DIRS}
33
34 ${LTTNG_INCLUDE_DIRS}
35 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
36@@ -30,7 +29,6 @@
37 set(QMLMIRPLUGIN_SRC
38 application_manager.cpp
39 application.cpp
40- cgmanager.cpp
41 ../../../common/abstractdbusservicemonitor.cpp
42 ../../../common/debughelpers.cpp
43 dbusfocusinfo.cpp
44
45=== removed file 'src/modules/Unity/Application/cgmanager.cpp'
46--- src/modules/Unity/Application/cgmanager.cpp 2016-08-08 13:55:43 +0000
47+++ src/modules/Unity/Application/cgmanager.cpp 1970-01-01 00:00:00 +0000
48@@ -1,117 +0,0 @@
49-/*
50- * Copyright (C) 2016 Canonical, Ltd.
51- *
52- * This program is free software: you can redistribute it and/or modify it under
53- * the terms of the GNU Lesser General Public License version 3, as published by
54- * the Free Software Foundation.
55- *
56- * This program is distributed in the hope that it will be useful, but WITHOUT
57- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
58- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
59- * Lesser General Public License for more details.
60- *
61- * You should have received a copy of the GNU Lesser General Public License
62- * along with this program. If not, see <http://www.gnu.org/licenses/>.
63- */
64-
65-#include "cgmanager.h"
66-
67-// QPA mirserver
68-#include <logging.h>
69-
70-#include <cgmanager/cgmanager.h>
71-
72-#include <QDBusArgument>
73-#include <QDBusMessage>
74-
75-using namespace qtmir;
76-
77-// According to D-Bus interface defined in:
78-// https://github.com/lxc/cgmanager/blob/master/org.linuxcontainers.cgmanager.xml
79-
80-CGManager::CGManager(QObject *parent)
81- : QObject(parent)
82-{
83-}
84-
85-CGManager::~CGManager()
86-{
87- QDBusConnection::disconnectFromPeer("cgmanager");
88-}
89-
90-QDBusConnection CGManager::getConnection()
91-{
92- auto connection = QDBusConnection("cgmanager");
93-
94- if (!connection.isConnected()) {
95- connection = QDBusConnection::connectToPeer(CGMANAGER_DBUS_PATH, "cgmanager");
96- if (!connection.isConnected()) {
97- qCWarning(QTMIR_DBUS, "CGManager: Failed to connect to %s", CGMANAGER_DBUS_PATH);
98- }
99- }
100-
101- return connection;
102-}
103-
104-QString CGManager::getCGroupOfPid(const QString &controller, pid_t pid)
105-{
106- auto connection = getConnection();
107- if (!connection.isConnected()) {
108- return QString();
109- }
110-
111- auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetPidCgroup");
112-
113- QList<QVariant> arguments;
114- arguments << QVariant(controller);
115- arguments << QVariant((int)pid);
116-
117- message.setArguments(arguments);
118-
119- QDBusMessage reply = connection.call(message);
120-
121- if (reply.type() == QDBusMessage::ReplyMessage) {
122- return reply.arguments().at(0).toString();
123- } else {
124- Q_ASSERT(reply.type() == QDBusMessage::ErrorMessage);
125- qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage();
126- return QString();
127- }
128-}
129-
130-QSet<pid_t> CGManager::getTasks(const QString &controller, const QString &cgroup)
131-{
132- auto connection = getConnection();
133- if (!connection.isConnected()) {
134- return QSet<pid_t>();
135- }
136-
137- auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetTasks");
138-
139- QList<QVariant> arguments;
140- arguments << QVariant(controller);
141- arguments << QVariant(cgroup);
142-
143- message.setArguments(arguments);
144-
145- QDBusMessage reply = connection.call(message);
146-
147- if (reply.type() == QDBusMessage::ErrorMessage) {
148- qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage();
149- return QSet<pid_t>();
150- }
151-
152- Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
153-
154- auto arg = reply.arguments().at(0).value<QDBusArgument>();
155- Q_ASSERT(arg.currentType() == QDBusArgument::ArrayType);
156-
157- auto pidList = qdbus_cast<QList<int>>(arg);
158- Q_ASSERT(pidList.count() > 0);
159-
160- QSet<pid_t> pidSet;
161- for (int i = 0; i < pidList.count(); ++i) {
162- pidSet << (pid_t)pidList[i];
163- }
164- return pidSet;
165-}
166
167=== removed file 'src/modules/Unity/Application/cgmanager.h'
168--- src/modules/Unity/Application/cgmanager.h 2016-07-01 16:15:54 +0000
169+++ src/modules/Unity/Application/cgmanager.h 1970-01-01 00:00:00 +0000
170@@ -1,42 +0,0 @@
171-/*
172- * Copyright (C) 2016 Canonical, Ltd.
173- *
174- * This program is free software: you can redistribute it and/or modify it under
175- * the terms of the GNU Lesser General Public License version 3, as published by
176- * the Free Software Foundation.
177- *
178- * This program is distributed in the hope that it will be useful, but WITHOUT
179- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
180- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
181- * Lesser General Public License for more details.
182- *
183- * You should have received a copy of the GNU Lesser General Public License
184- * along with this program. If not, see <http://www.gnu.org/licenses/>.
185- */
186-
187-#ifndef QTMIR_CGMANAGER_H
188-#define QTMIR_CGMANAGER_H
189-
190-#include <QDBusConnection>
191-
192-namespace qtmir {
193-
194-class CGManager : public QObject {
195- Q_OBJECT
196-public:
197- CGManager(QObject *parent = nullptr);
198- virtual ~CGManager();
199-
200- QString getCGroupOfPid(const QString &controller, pid_t pid);
201-
202- QSet<pid_t> getTasks(const QString &controller, const QString &cgroup);
203-
204-private:
205- const QString m_interface{"org.linuxcontainers.cgmanager0_0"};
206- const QString m_path{"/org/linuxcontainers/cgmanager"};
207- QDBusConnection getConnection();
208-};
209-
210-} // namespace qtmir
211-
212-#endif // QTMIR_CGMANAGER_H
213
214=== modified file 'src/modules/Unity/Application/dbusfocusinfo.cpp'
215--- src/modules/Unity/Application/dbusfocusinfo.cpp 2017-03-31 15:18:43 +0000
216+++ src/modules/Unity/Application/dbusfocusinfo.cpp 2017-04-24 13:56:27 +0000
217@@ -17,7 +17,6 @@
218 #include "dbusfocusinfo.h"
219
220 // local
221-#include "cgmanager.h"
222 #include "mirsurfacelistmodel.h"
223 #include "mirsurfaceinterface.h"
224 #include "session_interface.h"
225@@ -35,8 +34,6 @@
226 {
227 QDBusConnection::sessionBus().registerService("com.canonical.Unity.FocusInfo");
228 QDBusConnection::sessionBus().registerObject("/com/canonical/Unity/FocusInfo", this, QDBusConnection::ExportScriptableSlots);
229-
230- m_cgManager = new CGManager(this);
231 }
232
233 bool DBusFocusInfo::isPidFocused(unsigned int pid)
234@@ -54,22 +51,8 @@
235
236 QSet<pid_t> DBusFocusInfo::fetchAssociatedPids(pid_t pid)
237 {
238- QString cgroup = m_cgManager->getCGroupOfPid("freezer", pid);
239-
240- // If a cgroup has a format like this:
241- // /user.slice/user-32011.slice/session-c3.scope/upstart/application-legacy-puritine_gedit_0.0-
242- // All PIds in it are associated with a single application.
243- if (cgroup.split("/").contains("upstart")) {
244- QSet<pid_t> pidSet = m_cgManager->getTasks("freezer", cgroup);
245- qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "along with:" << pidSet;
246- if (pidSet.isEmpty()) {
247- pidSet << pid;
248- }
249- return pidSet;
250- } else {
251- qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "which is not app-specific";
252- return QSet<pid_t>({pid});
253- }
254+ qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "unable to determine cgroup, assuming is not app-specific. TODO port me to systemd ubuntu-app-launch";
255+ return QSet<pid_t>({pid});
256 }
257
258 SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet)
259
260=== modified file 'src/modules/Unity/Application/dbusfocusinfo.h'
261--- src/modules/Unity/Application/dbusfocusinfo.h 2016-11-03 20:17:46 +0000
262+++ src/modules/Unity/Application/dbusfocusinfo.h 2017-04-24 13:56:27 +0000
263@@ -21,7 +21,6 @@
264
265 namespace qtmir {
266
267-class CGManager;
268 class MirSurfaceInterface;
269
270 /*
271@@ -57,8 +56,6 @@
272 MirSurfaceInterface *findQmlSurface(const QString &serializedId);
273
274 const QList<Application*> &m_applications;
275-
276- CGManager *m_cgManager;
277 };
278
279 } // namespace qtmir

Subscribers

People subscribed via source and target branches