Working at Red Hat

About two years ago, I was at a conference with a load of GNOME people. I mentioned over drinks to two friendly Red Hat hackers, that I had an idea about a packaging framework. It was just an idea, as I was working for a large defence company, and had precious little time to maintain gnome-power-manager, let alone start anything new.

Nearly a year ago, I was hired by Red Hat to work on power management stuff. Now, my boss is one of those cool bosses that gives you quite a bit of ‘space’ and with his blessing I started to hack on PackageKit. 18 months later PackageKit is feature-complete, and the defacto standard across a dozen or so distributions.

Every week or so, I put up a new screenshot on this blog of cool stuff I’m working on. Every week people critique my ideas, and I go away to fix them up so the next version is that little bit better. Every week a few people say thanks, and tell me I’m doing some cool stuff, which is nice.

I don’t want people to think that PK or DK-p are Red Hat projects, but the simple economics is that they pay me to hack on cool projects. Whilst working at Red Hat I’m working alongside the very best people in the industry, in an environment that rewards innovation and thinking a little bit different.

What I’m trying to say is, most things you see on this blog are possible because of Red Hat. Sometimes I feel Red Hat doesn’t get the credit it deserves. Red Hat Rocks.

[CVE-2008-4311] DBus 1.2.6

Please don’t yet update DBus for CVE-2008-4311. It’s known to break PackageKit, cups, ConsoleKit, DeviceKit, DeviceKit-power, gdm, and system-config-services. There’s a partial bugfix that has been pushed so PackageKit tools still run (without the GetTid or SetLocale errors), but as introspection is still broken they’ll be odd little warnings and errors for other stuff.

I do understand how important this update is, but given this wasn’t a root login vulnerability, or anything crazy like that, I’m surprised it didn’t sit in updates-testing for a few days to fix up all the other system daemons. The worst bit is that it’s broken automatic updates for thousands of people.

I’m planning to spend this morning closing duplicate bugzillas. Fun.

Command not found

I’ve been quietly admiring the Debian BASH command not found functionality for a while. For those unfamiliar with the functionality, it suggests installing packages if you typed a command that is not installed. It also seemed to be pretty helpful suggesting replacements for typos.

When Rahul opened a bug to include this in Fedora, I figured this is just the sort of thing a framework like PackageKit needs to hook into. Roman Rakus put a simple patch in Fedora for bash, and now we’ll try to get it upstream. Then it will work on all distros that support PackageKit.

I spent this afternoon hacking a simple implementation. It’s up to the distro whether it should be installed by default on a base install. It’s also pretty configurable, so if you just want it to launch lshal everytime you type lshla, you can have that. If you want it to ask you before it installs shed to provide /usr/bin/shed, then that’s possible too. The simple configuration file is available here for review.

There’s also a screencast available if you want to see all the hotness.

PackageKit and Pango are now friends

PackageKit in git master has a new trick up its sleeve. Thanks to Behdad, It now optionally installs a gtk-module that integrates with Pango to detect when a document needs a new font installed to render correctly. No code changes are needed to any application using Pango, as all the magic is done in the gtk-module. When used with a session interface like KPackageKit or gnome-packagekit, the following UI is shown:

Font installer
Font installer

I really want a way of being able to say “don’t ask about this language again” if not found so to not piss off the user. I also know my grammar is pretty shitty. All comments and recommendations gratefully received. Thanks.

GStreamer vs. Windows Media Player

I’ve always been quietly impressed with GStreamer — in a world of multimedia where everything is so complicated, applications using GStreamer pretty much “just work” without any problems.

This was until today. I subscribe to a Polish TV archive, that has archived versions of soaps my girlfriend enjoys (M jak miłość). Windows Media Player 11 plays the mms stream perfectly, with no visual artifects or sound skipping, but in totem the video is unwatchable. As a further point, mplayer seems to play this mms stream with no video glitches, and only an occasional audio blip.

On gstreamer-0.10.21-2.fc10.i386, using playbin and debug level 2, I get:

0:00:11.977812682 15562  0x8ab4e50 WARN              asfdemux asfpacket.c:104:asf_payload_find_previous_fragment: Previous fragment does not match continued fragment
...
0:00:19.046052292 15562  0x8ab4e50 WARN              asfdemux asfpacket.c:336:gst_asf_demux_parse_payload:<asfdemux0> Offset doesn't match previous data?!
0:00:19.046086304 15562  0x8ab4e50 WARN              asfdemux asfpacket.c:104:asf_payload_find_previous_fragment: Previous fragment does not match continued fragment


Which I guess means the payload timestamps are wrong, then then I get about a bazillion of:

0:00:31.263371321 15562  0x8e0b408 WARN              GST_PADS gstpad.c:2992:gst_pad_iterate_internal_links_default:<selector_video_src1:src> Making unsafe iterator
...

and then when it skips:

0:00:36.949382321 15644  0x9d0c538 WARN         baseaudiosink gstbaseaudiosink.c:1395:gst_base_audio_sink_render:<audiosink-actual-sink-pulse> warning: Compensating for audio synchronisation problems
0:00:36.949410537 15644  0x9d0c538 WARN         baseaudiosink gstbaseaudiosink.c:1395:gst_base_audio_sink_render:<audiosink-actual-sink-pulse> warning: Unexpected discontinuity in audio timestamps of more than half a second (0:00:00.649705215), resyncing
WARNING: from element /GstPlayBin:playbin0/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: Compensating for audio synchronisation problems
Additional debug info:
gstbaseaudiosink.c(1395): gst_base_audio_sink_render (): /GstPlayBin:playbin0/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse:
Unexpected discontinuity in audio timestamps of more than half a second (0:00:00.649705215), resyncing
...

This makes the video unwatchable. I’m guessing the server is somehow broken, but it works in Windows Media Player perfectly and 99% okay on mplayer.
Any help on how to debug this or report a proper bug gratefully received. Thanks.

pkcon list-install foo.package-list

In newer versions of gnome-packagekit there’s a tool called gpk-service-pack:

Service Pack Creator
Service Pack Creator

This tool I’ve explained in the past, and there is now lots of information and diagrams in the help file about how it all works and what the point of the tool is. Anyway, the point of this blog post isn’t to promote service packs; it’s to scratch an itch that I see coming up when Fedora 10 is released.

The tool exposed one detail to the user: a package list.

This is a simple text file such as hughsie-laptop-f9.package-list. This file allows tools to operate on other similar computers with different packages installed. It’s really just a simple list of all the packages installed. It’s contents and format are unimportant for now as it lets you do some cool stuff.

My personal situation, right now: I’m running a F9/F10/rawhide-ish laptop that I’ve been running for a few months, installing packages using yum, rpm and PackageKit, and have now got all the packages I need for building all my stuff, and all the programs I need on a day-to-day basis.
When F10 comes out, I normally nuke / and reinstall from the live CD as I’ve got so much cruft and brokenness from the months of a rawhide development cycle. On the first boot, I run:

yum -Y install <paste long list of packages from a tomboy note that's got bigger over the years>

Now, what I need is an admin tools that says:

  1. Capture all the package names on my old system
  2. Show me all the differences between what I had then, and what I have now
  3. Use the old package list to install all my normal stuff, not specifying versions

So, two hours of hacking later:

  1. pkcon list-create hughsie-laptop-f9.package-list
  2. pkcon list-diff hughsie-laptop-f9.package-list
  3. pkcon list-install hughsie-laptop-f9.package-list

I know I can do some of step 3 using a custom kickstart if I wanted, but I normally don’t know what I install manually. Maybe it’s only me that’ll find this useful. Code is in git. itch2scratch–;

gnome-power-manager and DeviceKit-power

DeviceKit-power is a system activated service I’ll be writing about in detail in a blog post in the near future. It’s a bit like HAL, but makes common API calls easy for applications (is battery power low?) and also moves the battery profiling down to the system layer from the session so it works for all users and more importantly from the GDM login screen. It’s very lightweight and low on resource usage when it’s active.

Here are some screenshots from gnome-power-manager trunk (compile with –enable-devkit-power).

Statistics profile for my battery
Statistics profile for my battery
History for my Watts Up Pro
History for my Watts Up Pro

The monitor device is a Watts Up Pro device. As you plug it in, DeviceKit-power opens the device, and starts reading data. I’m using it here to monitor my power strip with my laptop and all the power-warts attached. I’ll be converting gnome-power-manager to use DeviceKit-power rather than HAL during the next release cycle. Hopefully, I’ll maintain both HAL and DeviceKit-power backends, although this isn’t making the number of #ifdefs any smaller, which sucks from a readability point of view.

The GUI’s are pretty raw, so suggestions and criticisms are welcome.

DeviceKit-power latency control

We all know controlling latency is the best way to control power consumption and still have a usable system. Putting the processor into deeper sleep states saves power, but it takes longer to come back to running. On pretty much all devices it’s all a trade off between time and power.

org.freedesktop.DeviceKit.Power.Latency is a DBus interface implemented by DeviceKit-power. It allows applications to request target latencies, for example a couple of seconds CPU-DMA latency for an IM application, or a few hundred microseconds of network latency for a multiplayer game. The lowest value of each latency type is used for the userspace->kernel interface, and then what do do is left for the kernel drivers themselves.

Use cases:

  • I want my IM application to request 0.5s latency for messages
  • I’m running an OpenGL simulation and want maximum performance, even on battery
  • I’m running an SQL server for a credit card company, and want the server to request low latency CPU and network as any delay costs money
  • I’m an admin, and want to change the power consumption vs. latency from cron scripts so it uses high latency during the night for maximum power saving, and low latency during business hours.
  • I want high throughput when copying files, but want low throughput for downloading updates in the background.
  • I want my power manager to set all latencies to lowest when on AC power
  • I don’t want my users messing with latency settings
  • I’m and admin and I want to be able to override all latency settings on my machines

Now, I want to build a system-activated service to manage this, so people that don’t care don’t have an extra process running. We can use PolicyKit to control all the authentication, and build up a service for applications and admins to use. This will be suitable for system services and desktop applications.

Why don’t applications use the PMQoS interface directly? Well, by providing a framework we can override requests by admin policy, and also control requests. You also can’t set latencies unless you’re the root user, which is not suitable for the desktop use case.

I’ve put an interface file up here.

Comments? Suggestions? Thanks.

QPackageKit into PackageKit

A C++ QT library for PackageKit has just been merged into PackageKit git master. It was written by Adrien Bustany, and it being used by KPackageKit.

The QT library is being built with cmake, but the PackageKit project uses autotools. I want to keep the cmake bit in lib/libpackagekit-qt and just get automake to run cmake for me to generate the makefile.

Worst case scenario, we just have to built the library using some futzing in the distro spec file, but this isn’t ideal.

Has anyone got any experience or pointers for this?

Thanks.