linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dummy-psu
@ 2020-06-05 14:02 Frédéric Pierret
  2020-06-15 16:44 ` dummy-psu Frédéric Pierret
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Pierret @ 2020-06-05 14:02 UTC (permalink / raw)
  To: linux-pm; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 877 bytes --]

Dear all,

I'm working on a kernel module currently called "dummy-psu" (https://github.com/fepitre/dummy-psu) which creates a power supply AC and a battery like in 'drivers/power/supply/test_power.c'. After loaded, this driver allows to modify integer values of the virtual psu created through its sysfs attribute directly. String values are currently set through module parameters. Such module allows for example to test ACPI tools or desktop plugins.

In the context of the Qubes OS project, it allows to setup into a VM, PSU components with real information coming from the host system battery or ac with some refresh time.

I'm writing to you to know if you would be interested to have such module integrating side to test_power.c.

Another name could be "virtual-psu". Any kind of improvements are very welcomed. Thank you.

Best regards,
Frédéric Pierret


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dummy-psu
  2020-06-05 14:02 dummy-psu Frédéric Pierret
@ 2020-06-15 16:44 ` Frédéric Pierret
  2020-06-19 16:59   ` dummy-psu Sebastian Reichel
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Pierret @ 2020-06-15 16:44 UTC (permalink / raw)
  To: sre, linux-pm; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 1078 bytes --]

Dear all,
Just a little ping to know if anyone has been interested in this project.

Best regards,
Frédéric Pierret

On 2020-06-05 16:02, Frédéric Pierret wrote:
> Dear all,
> 
> I'm working on a kernel module currently called "dummy-psu" (https://github.com/fepitre/dummy-psu) which creates a power supply AC and a battery like in 'drivers/power/supply/test_power.c'. After loaded, this driver allows to modify integer values of the virtual psu created through its sysfs attribute directly. String values are currently set through module parameters. Such module allows for example to test ACPI tools or desktop plugins.
> 
> In the context of the Qubes OS project, it allows to setup into a VM, PSU components with real information coming from the host system battery or ac with some refresh time.
> 
> I'm writing to you to know if you would be interested to have such module integrating side to test_power.c.
> 
> Another name could be "virtual-psu". Any kind of improvements are very welcomed. Thank you.
> 
> Best regards,
> Frédéric Pierret
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dummy-psu
  2020-06-15 16:44 ` dummy-psu Frédéric Pierret
@ 2020-06-19 16:59   ` Sebastian Reichel
  2020-07-08  8:28     ` dummy-psu Frédéric Pierret
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Reichel @ 2020-06-19 16:59 UTC (permalink / raw)
  To: Frédéric Pierret; +Cc: linux-pm, Marek Marczykowski-Górecki

[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]

Hi Frédéric,

On Mon, Jun 15, 2020 at 06:44:11PM +0200, Frédéric Pierret wrote:
> On 2020-06-05 16:02, Frédéric Pierret wrote:
> > Dear all,
> > 
> > I'm working on a kernel module currently called "dummy-psu"
> > (https://github.com/fepitre/dummy-psu) which creates a power
> > supply AC and a battery like in
> > 'drivers/power/supply/test_power.c'. After loaded, this driver
> > allows to modify integer values of the virtual psu created
> > through its sysfs attribute directly. String values are
> > currently set through module parameters. Such module allows for
> > example to test ACPI tools or desktop plugins.
> > 
> > In the context of the Qubes OS project, it allows to setup into
> > a VM, PSU components with real information coming from the host
> > system battery or ac with some refresh time.
> > 
> > I'm writing to you to know if you would be interested to have
> > such module integrating side to test_power.c.
> > 
> > Another name could be "virtual-psu". Any kind of improvements
> > are very welcomed. Thank you.
> > 
> > Best regards,
> > Frédéric Pierret
>
> Dear all,
> Just a little ping to know if anyone has been interested in this
> project.
> 
> Best regards,
> Frédéric Pierret

I think it would be worthwile to have something like this for
the power-supply framework. This is useful for your VM case,
testing the power-supply API in a better way than test_power.c
and for peripheral devices with userspace drivers.

But I don't think it's a good idea to use the sysfs files as
input. There should be support to register multiple virtual
devices (e.g. battery and AC in your case, or multiple BT
peripherals). Also the sysfs interface does not allow you to
change multiple values atomically. I think the proper way is
to do it the same way as uinput and register a miscdevice.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dummy-psu
  2020-06-19 16:59   ` dummy-psu Sebastian Reichel
@ 2020-07-08  8:28     ` Frédéric Pierret
  0 siblings, 0 replies; 4+ messages in thread
From: Frédéric Pierret @ 2020-07-08  8:28 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 3053 bytes --]

Hi Sebastian,

First of all, thank you for your answer. I'm currently working on a second version according to your suggestion. Here I'm using ioctl + misc device in order to register any type of PSU device. I'm only having an issue on how to get the maximum allowed power_supply_property https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/power_supply.h?h=v5.7.7#n164. I'm seeing in git log that this enum has new entries in the middle of it's declaration so getting the upper limit of allowed properties seems tricky.

For example in my current implementation, I'm allowing with ioctl to add any number of properties the user want to add before registering. A check is done if the supplied value is in range of zero and currently the upper limit, POWER_SUPPLY_PROP_SERIAL_NUMBER. Do you have any suggestion on how should I get this upper limit without hardcoding some specific value? This current issue is because I don't want to trust user input...

I'm not C or kernel fluent so I apologize if my question looks stupid.

Best regards,
Frédéric

On 2020-06-19 18:59, Sebastian Reichel wrote:
> Hi Frédéric,
> 
> On Mon, Jun 15, 2020 at 06:44:11PM +0200, Frédéric Pierret wrote:
>> On 2020-06-05 16:02, Frédéric Pierret wrote:
>>> Dear all,
>>>
>>> I'm working on a kernel module currently called "dummy-psu"
>>> (https://github.com/fepitre/dummy-psu) which creates a power
>>> supply AC and a battery like in
>>> 'drivers/power/supply/test_power.c'. After loaded, this driver
>>> allows to modify integer values of the virtual psu created
>>> through its sysfs attribute directly. String values are
>>> currently set through module parameters. Such module allows for
>>> example to test ACPI tools or desktop plugins.
>>>
>>> In the context of the Qubes OS project, it allows to setup into
>>> a VM, PSU components with real information coming from the host
>>> system battery or ac with some refresh time.
>>>
>>> I'm writing to you to know if you would be interested to have
>>> such module integrating side to test_power.c.
>>>
>>> Another name could be "virtual-psu". Any kind of improvements
>>> are very welcomed. Thank you.
>>>
>>> Best regards,
>>> Frédéric Pierret
>>
>> Dear all,
>> Just a little ping to know if anyone has been interested in this
>> project.
>>
>> Best regards,
>> Frédéric Pierret
> 
> I think it would be worthwile to have something like this for
> the power-supply framework. This is useful for your VM case,
> testing the power-supply API in a better way than test_power.c
> and for peripheral devices with userspace drivers.
> 
> But I don't think it's a good idea to use the sysfs files as
> input. There should be support to register multiple virtual
> devices (e.g. battery and AC in your case, or multiple BT
> peripherals). Also the sysfs interface does not allow you to
> change multiple values atomically. I think the proper way is
> to do it the same way as uinput and register a miscdevice.
> 
> -- Sebastian
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-08  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 14:02 dummy-psu Frédéric Pierret
2020-06-15 16:44 ` dummy-psu Frédéric Pierret
2020-06-19 16:59   ` dummy-psu Sebastian Reichel
2020-07-08  8:28     ` dummy-psu Frédéric Pierret

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).