[systemd-commits] src/systemctl
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Sep 10 09:31:58 PDT 2013
src/systemctl/systemctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
New commits:
commit 7239c1707a69aff63425e8b6570cfabbd7386f61
Author: Gao feng <gaofeng at cn.fujitsu.com>
Date: Tue Aug 27 13:36:54 2013 +0800
systemcl: add support for setting BlockIODeviceWeight for unit
This patch allows user to set up BlockIODeviceWeight for unit
through systemctl. Such as
systemctl set-property sshd.service BlockIODeviceWeight="/dev/sda 100"
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 889d120..0aeae91 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3746,6 +3746,48 @@ static int append_assignment(DBusMessageIter *iter, const char *assignment) {
if (!dbus_message_iter_close_container(&sub, &sub2))
return log_oom();
+ } else if (streq(field, "BlockIODeviceWeight")) {
+ DBusMessageIter sub2;
+
+ if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, "a(st)", &sub) ||
+ !dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "(st)", &sub2))
+ return log_oom();
+
+ if (!isempty(eq)) {
+ const char *path, *weight;
+ DBusMessageIter sub3;
+ uint64_t u;
+ char *e;
+
+ e = strchr(eq, ' ');
+ if (e) {
+ path = strndupa(eq, e - eq);
+ weight = e+1;
+ } else {
+ log_error("Failed to parse %s value %s.", field, eq);
+ return -EINVAL;
+ }
+
+ if (!path_startswith(path, "/dev")) {
+ log_error("%s is not a device file in /dev.", path);
+ return -EINVAL;
+ }
+
+ r = safe_atou64(weight, &u);
+ if (r < 0) {
+ log_error("Failed to parse %s value %s.", field, weight);
+ return -EINVAL;
+ }
+ if (!dbus_message_iter_open_container(&sub2, DBUS_TYPE_STRUCT, NULL, &sub3) ||
+ !dbus_message_iter_append_basic(&sub3, DBUS_TYPE_STRING, &path) ||
+ !dbus_message_iter_append_basic(&sub3, DBUS_TYPE_UINT64, &u) ||
+ !dbus_message_iter_close_container(&sub2, &sub3))
+ return log_oom();
+ }
+
+ if (!dbus_message_iter_close_container(&sub, &sub2))
+ return log_oom();
+
} else {
log_error("Unknown assignment %s.", assignment);
return -EINVAL;
More information about the systemd-commits
mailing list