KVM/QEMU guest not shutting down?

One of my KVM/QEMU guests wasn’t shutting down correctly when the host issued the ACPI shutdown command.
Having checked that the guest’s XML definition included the <acpi/> tag in the <features>…</features> section, and that acpid was installed on the guest and that acpi-tools was installed on the guest, I realised that this was an Ubuntu 14.04 client O/S and therefore that it was doing something other than shutdown when it was told to. I believe that this will only happen on the “client” installs of Ubuntu – installing the server grade Ubuntu will not do this, although I’ve not confirmed this.
Essentially, the problem is that when the ACPI command to shutdown is received, the client version of Ubuntu will notice, and instead of actioning the request, will display a dialogue box on the console to the effect of “What do you really want to do, shutdown, restart, log-off or lock the screen?”. To change this, edit the file /etc/acpi/events/powerbtn (as root) and comment out the line reading:
action=/etc/acpi/powerbtn.sh

add below it the line:

action=/sbin/poweroff

This will instruct the computer to poweroff when the power button ACPI event is received. Like I said, probably only a problem for the non-server versions of Ubuntu. Serves me right for not installing the correct Server OS, I suppose…

Linux clipboards.

Linux has – for historical reasons – two clipboards.  One is the one that old X hands will know and love, the other is the new one.  And the two are completely separate.  If you put text in the copy-buffer (the X windows style clipboard), then you attempt to paste out into a new-style application, nothing will happen.  Likewise the other way around, copy out of an application that uses the new style clipboard and the X applications won’t know there’s any text in the clipboard.  Because there isn’t.

So.  How to get around this problem?  On debian/ubuntu, there’s a package (which isn’t installed by default) available to install.  autocutsel.  It’s a background application which knows about both styles of clipboard and attaches to both.  When one changes, it’ll synchronise the two clipboards.

Downside?  If you’re used to two clipboards and know which applications use which clipboard (and you exploit this mercilessly) then you’re going to lose the contents of the “other” clipboard with this running.  Enough of a bummer to stop me using it?  Nope.  It’s a beautiful little application which allows me to copy and paste between all my applications – including those pesky mono applications.  Yay!

The problem with Linux and proprietary modules

A kernel upgrade (from 3.5.0-18 to 3.5.0-19) has just borked my two binary modules that I load.  The video card and the wireless network. So absolutely nothing to worry about there then. Just the two most important pieces of a modern Linux system.

The video card problem manifested by the window manager (compiz) crashing, so there were no title bars, the launcher had gone and the task panel was absent. Absolute PITA getting anything to run, and god help you if X decided that the window you wanted to type into just isn’t going to accept focus!

Firstly, after a kernel upgrade, one always needs the correct kernel headers to compile the wrappers for the modules:

apt-get install linux-headers-$(uname -r)

The wireless network card was taken care of by the following two commands:

/usr/bin/apt-get purge bcmwl-kernel-source broadcom-sta-common broadcom-sta-source
/usr/bin/apt-get install b43-fwcutter firmware-b43-installer

The ATI module was done by just running the ATI proprietary driver installer again (which I had lying about in my home directory).

All from a text-console, of course. I was lucky in that my laptop has both wired and wireless. If you’ve only got wireless network connectivity, you’ll need to download the .deb files that apt gets above and install them manually with dpkg.

Adding a script to debian/ubuntu startup. Also, setting numlock state in X

sudo update-rc.d /etc/init.d/<scriptname> defaults

Also, for those newfangled keyboards without a numlock key (irritating, isn’t it?) then you need the numlockx binary, from debian/ubuntu package numlockx.

Just run “numlockx toggle” to toggle the current state of the numlock key – or “numlockx on” or “numlockx off” to set the state explicitly.

Now, combine that with the startup script hint above, and you’ve got a numpad again.  Top stuff…

Alternatively, you can – it seems – go to the system settings tab in Ubuntu, choose Keyboard, choose “Layout Settings”, click “Options” and in “Miscellaneous compatibility options”, select the “Numeric keypad keys always enter digits (as in Mac OS)”.  This has much the same effect.  But you don’t learn anything about the ubuntu startup scripts this way :P

Ubuntu 12.04 post-install tweaks.

Uninstall gnome-screensaver, install ubuntu packages:
xscreensaver
xscreensaver-data
xscreensaver-data-extra
xscreensaver-gl
xscreensaver-gl-extra
xscreensaver-screensaver-bsod
xscreensaver-screensaver-dizzy
xscreensaver-screensaver-webcollage
rss-glx

After installing rss-glx, you’ll need to run glx_install to install the rss screensavers. And that’s Really Slick Screensavers, not RSS

You’ll also need to setup the screensaver to auto-start when you log-in.  Search for “Startup” in Unity, then add an item in that utility, pointing to /usr/bin/xscreensaver

Additionally, you’ll (probably) want to remove the unity-lens-shopping package too – it slows the unity search panel down massively, and – for me at least – will never do anything useful. If I want to search amazon, I’d be on the amazon website.

Other packages you’ll be wanting at some point:

keepass2
mono-complete (required by keepass2; don’t just install the ‘mono’ package)

There’s massive kinks involved with keepass2 on linux (because of mono) – and the fact that Ubuntu has a script to start keepass2 (/usr/bin/keepass2 is a shell script, and so is not what you configure the keefox plugin for the location of KeeFox (that’d be /usr/lib/keepass2 instead).

Add another auto-startup for keefox by adding /usr/bin/keefox2 in the startup programs (like you did for xscreensaver, above).

I’m sure there’s more, but that’ll do for now. When something occurs to me, I’ll put it up here.

So far, though, Ubuntu 12.04 has just workedTM for me on this HP laptop.