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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2017-03-24 11:29:56 +0000
+++ CMakeLists.txt 2017-04-24 13:56:27 +0000
@@ -91,7 +91,6 @@
91pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)91pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
92pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)92pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
93pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)93pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)
94pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
95pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)94pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)
96pkg_check_modules(VALGRIND valgrind REQUIRED)95pkg_check_modules(VALGRIND valgrind REQUIRED)
9796
9897
=== modified file 'debian/control'
--- debian/control 2017-03-24 11:29:56 +0000
+++ debian/control 2017-04-24 13:56:27 +0000
@@ -6,7 +6,6 @@
6 cmake-extras (>= 0.10),6 cmake-extras (>= 0.10),
7 debhelper (>= 9),7 debhelper (>= 9),
8 google-mock (>= 1.6.0+svn437),8 google-mock (>= 1.6.0+svn437),
9 libcgmanager-dev,
10 libcontent-hub-dev (>= 0.2),9 libcontent-hub-dev (>= 0.2),
11 libfontconfig1-dev,10 libfontconfig1-dev,
12 libgles2-mesa-dev,11 libgles2-mesa-dev,
1312
=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
--- src/modules/Unity/Application/CMakeLists.txt 2017-03-13 16:49:49 +0000
+++ src/modules/Unity/Application/CMakeLists.txt 2017-04-24 13:56:27 +0000
@@ -14,7 +14,6 @@
14 ${UBUNTU_PLATFORM_API_INCLUDE_DIRS}14 ${UBUNTU_PLATFORM_API_INCLUDE_DIRS}
15 ${UBUNTU_APP_LAUNCH_INCLUDE_DIRS}15 ${UBUNTU_APP_LAUNCH_INCLUDE_DIRS}
16 ${GSETTINGS_QT_INCLUDE_DIRS}16 ${GSETTINGS_QT_INCLUDE_DIRS}
17 ${CGMANAGER_INCLUDE_DIRS}
1817
19 ${LTTNG_INCLUDE_DIRS}18 ${LTTNG_INCLUDE_DIRS}
20 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}19 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
@@ -30,7 +29,6 @@
30set(QMLMIRPLUGIN_SRC29set(QMLMIRPLUGIN_SRC
31 application_manager.cpp30 application_manager.cpp
32 application.cpp31 application.cpp
33 cgmanager.cpp
34 ../../../common/abstractdbusservicemonitor.cpp32 ../../../common/abstractdbusservicemonitor.cpp
35 ../../../common/debughelpers.cpp33 ../../../common/debughelpers.cpp
36 dbusfocusinfo.cpp34 dbusfocusinfo.cpp
3735
=== removed file 'src/modules/Unity/Application/cgmanager.cpp'
--- src/modules/Unity/Application/cgmanager.cpp 2016-08-08 13:55:43 +0000
+++ src/modules/Unity/Application/cgmanager.cpp 1970-01-01 00:00:00 +0000
@@ -1,117 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "cgmanager.h"
18
19// QPA mirserver
20#include <logging.h>
21
22#include <cgmanager/cgmanager.h>
23
24#include <QDBusArgument>
25#include <QDBusMessage>
26
27using namespace qtmir;
28
29// According to D-Bus interface defined in:
30// https://github.com/lxc/cgmanager/blob/master/org.linuxcontainers.cgmanager.xml
31
32CGManager::CGManager(QObject *parent)
33 : QObject(parent)
34{
35}
36
37CGManager::~CGManager()
38{
39 QDBusConnection::disconnectFromPeer("cgmanager");
40}
41
42QDBusConnection CGManager::getConnection()
43{
44 auto connection = QDBusConnection("cgmanager");
45
46 if (!connection.isConnected()) {
47 connection = QDBusConnection::connectToPeer(CGMANAGER_DBUS_PATH, "cgmanager");
48 if (!connection.isConnected()) {
49 qCWarning(QTMIR_DBUS, "CGManager: Failed to connect to %s", CGMANAGER_DBUS_PATH);
50 }
51 }
52
53 return connection;
54}
55
56QString CGManager::getCGroupOfPid(const QString &controller, pid_t pid)
57{
58 auto connection = getConnection();
59 if (!connection.isConnected()) {
60 return QString();
61 }
62
63 auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetPidCgroup");
64
65 QList<QVariant> arguments;
66 arguments << QVariant(controller);
67 arguments << QVariant((int)pid);
68
69 message.setArguments(arguments);
70
71 QDBusMessage reply = connection.call(message);
72
73 if (reply.type() == QDBusMessage::ReplyMessage) {
74 return reply.arguments().at(0).toString();
75 } else {
76 Q_ASSERT(reply.type() == QDBusMessage::ErrorMessage);
77 qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage();
78 return QString();
79 }
80}
81
82QSet<pid_t> CGManager::getTasks(const QString &controller, const QString &cgroup)
83{
84 auto connection = getConnection();
85 if (!connection.isConnected()) {
86 return QSet<pid_t>();
87 }
88
89 auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetTasks");
90
91 QList<QVariant> arguments;
92 arguments << QVariant(controller);
93 arguments << QVariant(cgroup);
94
95 message.setArguments(arguments);
96
97 QDBusMessage reply = connection.call(message);
98
99 if (reply.type() == QDBusMessage::ErrorMessage) {
100 qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage();
101 return QSet<pid_t>();
102 }
103
104 Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
105
106 auto arg = reply.arguments().at(0).value<QDBusArgument>();
107 Q_ASSERT(arg.currentType() == QDBusArgument::ArrayType);
108
109 auto pidList = qdbus_cast<QList<int>>(arg);
110 Q_ASSERT(pidList.count() > 0);
111
112 QSet<pid_t> pidSet;
113 for (int i = 0; i < pidList.count(); ++i) {
114 pidSet << (pid_t)pidList[i];
115 }
116 return pidSet;
117}
1180
=== removed file 'src/modules/Unity/Application/cgmanager.h'
--- src/modules/Unity/Application/cgmanager.h 2016-07-01 16:15:54 +0000
+++ src/modules/Unity/Application/cgmanager.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef QTMIR_CGMANAGER_H
18#define QTMIR_CGMANAGER_H
19
20#include <QDBusConnection>
21
22namespace qtmir {
23
24class CGManager : public QObject {
25 Q_OBJECT
26public:
27 CGManager(QObject *parent = nullptr);
28 virtual ~CGManager();
29
30 QString getCGroupOfPid(const QString &controller, pid_t pid);
31
32 QSet<pid_t> getTasks(const QString &controller, const QString &cgroup);
33
34private:
35 const QString m_interface{"org.linuxcontainers.cgmanager0_0"};
36 const QString m_path{"/org/linuxcontainers/cgmanager"};
37 QDBusConnection getConnection();
38};
39
40} // namespace qtmir
41
42#endif // QTMIR_CGMANAGER_H
430
=== modified file 'src/modules/Unity/Application/dbusfocusinfo.cpp'
--- src/modules/Unity/Application/dbusfocusinfo.cpp 2017-03-31 15:18:43 +0000
+++ src/modules/Unity/Application/dbusfocusinfo.cpp 2017-04-24 13:56:27 +0000
@@ -17,7 +17,6 @@
17#include "dbusfocusinfo.h"17#include "dbusfocusinfo.h"
1818
19// local19// local
20#include "cgmanager.h"
21#include "mirsurfacelistmodel.h"20#include "mirsurfacelistmodel.h"
22#include "mirsurfaceinterface.h"21#include "mirsurfaceinterface.h"
23#include "session_interface.h"22#include "session_interface.h"
@@ -35,8 +34,6 @@
35{34{
36 QDBusConnection::sessionBus().registerService("com.canonical.Unity.FocusInfo");35 QDBusConnection::sessionBus().registerService("com.canonical.Unity.FocusInfo");
37 QDBusConnection::sessionBus().registerObject("/com/canonical/Unity/FocusInfo", this, QDBusConnection::ExportScriptableSlots);36 QDBusConnection::sessionBus().registerObject("/com/canonical/Unity/FocusInfo", this, QDBusConnection::ExportScriptableSlots);
38
39 m_cgManager = new CGManager(this);
40}37}
4138
42bool DBusFocusInfo::isPidFocused(unsigned int pid)39bool DBusFocusInfo::isPidFocused(unsigned int pid)
@@ -54,22 +51,8 @@
5451
55QSet<pid_t> DBusFocusInfo::fetchAssociatedPids(pid_t pid)52QSet<pid_t> DBusFocusInfo::fetchAssociatedPids(pid_t pid)
56{53{
57 QString cgroup = m_cgManager->getCGroupOfPid("freezer", pid);54 qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "unable to determine cgroup, assuming is not app-specific. TODO port me to systemd ubuntu-app-launch";
5855 return QSet<pid_t>({pid});
59 // If a cgroup has a format like this:
60 // /user.slice/user-32011.slice/session-c3.scope/upstart/application-legacy-puritine_gedit_0.0-
61 // All PIds in it are associated with a single application.
62 if (cgroup.split("/").contains("upstart")) {
63 QSet<pid_t> pidSet = m_cgManager->getTasks("freezer", cgroup);
64 qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "along with:" << pidSet;
65 if (pidSet.isEmpty()) {
66 pidSet << pid;
67 }
68 return pidSet;
69 } else {
70 qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "which is not app-specific";
71 return QSet<pid_t>({pid});
72 }
73}56}
7457
75SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet)58SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet)
7659
=== modified file 'src/modules/Unity/Application/dbusfocusinfo.h'
--- src/modules/Unity/Application/dbusfocusinfo.h 2016-11-03 20:17:46 +0000
+++ src/modules/Unity/Application/dbusfocusinfo.h 2017-04-24 13:56:27 +0000
@@ -21,7 +21,6 @@
2121
22namespace qtmir {22namespace qtmir {
2323
24class CGManager;
25class MirSurfaceInterface;24class MirSurfaceInterface;
2625
27/*26/*
@@ -57,8 +56,6 @@
57 MirSurfaceInterface *findQmlSurface(const QString &serializedId);56 MirSurfaceInterface *findQmlSurface(const QString &serializedId);
5857
59 const QList<Application*> &m_applications;58 const QList<Application*> &m_applications;
60
61 CGManager *m_cgManager;
62};59};
6360
64} // namespace qtmir61} // namespace qtmir

Subscribers

People subscribed via source and target branches