<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
span.EmailStyle19
{mso-style-type:personal-compose;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">Hi Lennart,<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">It is working now. Thanks a lot for your help.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">We are working on cgroups blkio subsystem, where we would require more info on this areas( ex: setting some cgroup parameters per device, using one unit file for one cgroups but managing per device level etc).<o:p></o:p></p>
<p class="MsoPlainText">As we are new to sd-bus programming, any documentation related to these areas of programming if you can share will be helpful.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">We will also be subscribing to system-devel mailing list.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Thanks,<o:p></o:p></p>
<p class="MsoPlainText">Soumya.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: Lennart Poettering [<a href="mailto:mzqohf@0pointer.de">mailto:mzqohf@0pointer.de</a>]
<br>
Sent: Friday, April 01, 2016 11:43 PM<br>
To: N, Soumya P <<a href="mailto:soumya.p.n@hpe.com">soumya.p.n@hpe.com</a>><br>
Cc: <a href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a>; A M, Ashalatha <<a href="mailto:ashalatha-a.a@hpe.com">ashalatha-a.a@hpe.com</a>><br>
Subject: Re: Need help on Dbus API's<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">On Mon, 28.03.16 06:40, N, Soumya P (<a href="mailto:soumya.p.n@hpe.com"><span style="color:windowtext;text-decoration:none">soumya.p.n@hpe.com</span></a>) wrote:<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> Hello,<o:p></o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> We have a requirement to get/set some properties on /sys/fs/cgroup/blkio and also child cgroups under this (ex: /sys/fs/cgroup/blkio/Gold_cg).<o:p></o:p></p>
<p class="MsoPlainText">> We found that libcgroups are going to be obsoleted from RHEL 7 onwards and hence we started with systemd cgroups and we found that we need to use sdbus API's.<o:p></o:p></p>
<p class="MsoPlainText">> (We have RHEL 7.2 installed on our system)<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">You sent your message to the dbus mailing list, which is only for issues in the dbus protocol and the dbus reference implementation. However, you are using the sd-bus implementation and systemd as service, hence systemd-devel would be
the right place to discuss this.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> <o:p></o:p></p>
<p class="MsoPlainText">> r = sd_bus_call_method(bus,<o:p></o:p></p>
<p class="MsoPlainText">> "org/freedesktop/systemd1",<o:p></o:p></p>
<p class="MsoPlainText">> "/org/freedesktop/systemd1",<o:p></o:p></p>
<p class="MsoPlainText">> "org.freedesktop.systemd1.Manager",<o:p></o:p></p>
<p class="MsoPlainText">> "SetUnitProperties", &error,<o:p></o:p></p>
<p class="MsoPlainText">> &reply, "s", "sample.slice",0,<o:p></o:p></p>
<p class="MsoPlainText">> ("BlockIOWeight", 500));<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Please read up on the sd_bus_message_append(3) man page. You need to specify the full signature string for SetUnitProperties() instead of just "s". (i.e. the right signature argument is "sba(sv)"). Then you need to follow with the matching
arguments.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Something like this should work (untested):<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"> r = sd_bus_call_method(bus,<o:p></o:p></p>
<p class="MsoPlainText"> "org/freedesktop/systemd1",<o:p></o:p></p>
<p class="MsoPlainText"> "/org/freedesktop/systemd1",<o:p></o:p></p>
<p class="MsoPlainText"> "org.freedesktop.systemd1.Manager",<o:p></o:p></p>
<p class="MsoPlainText"> "SetUnitProperties", &error,<o:p></o:p></p>
<p class="MsoPlainText"> &reply,<o:p></o:p></p>
<p class="MsoPlainText"> "sba(sv)",<o:p></o:p></p>
<p class="MsoPlainText"> "sample.slice", /* this is the unit name string */<o:p></o:p></p>
<p class="MsoPlainText"> 0, /* this is the "runtime" bool */<o:p></o:p></p>
<p class="MsoPlainText"> 1, /* number of array entries */<o:p></o:p></p>
<p class="MsoPlainText"> "BlockIOWeight", /* Property name */<o:p></o:p></p>
<p class="MsoPlainText"> "t", /* Property variant type */<o:p></o:p></p>
<p class="MsoPlainText"> UINT64_C(500)); /* Property value */<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Basically, the parameters you specifiy in the signature strings must follow the signature string immediately. For arrays, you need to specify the number of entries following first, and for variants you need to specify the type of the
variant first.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">It's important to use the UINT64_C() macro for the 500 argument, since this is a varargs function, and if you don't fix the type, then C will push this onto the stack as the smallest type that is at least "int", and that's int32_t. However,
as we specify "t" as variant type (which is a unsigned 64bit type), we need to make sure C gets that right, and explicitly request a 64bit unsigned constant to be put on the stack, hence the UINT64_C() macro...<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Lennart<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">--<o:p></o:p></p>
<p class="MsoPlainText">Lennart Poettering, Red Hat<o:p></o:p></p>
</div>
</body>
</html>