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.

Windows 7 & ipv6

My windows 7 has been native ipv6 (dual stacked with legacy ip addresses) for quite some time. I’ve only just discovered how to get it to use a static IPv6 address over the autoconfigured IPv6 address (the reason is that the statically allocated ipv6 address is way more memorable than the MAC address of the windows 7’s wireless adapter).

Anyway; basically Windows 7 likes to use the autoconfigured ipv6 address in preference; we need to tell the stupid thing that the static one should be the default.
In an administrator command prompt, type:

netsh interface ipv6 show interfaces

And look for the interface name for the adapter that’s currently connecting you to the internet.

Using this name, type in the command:

netsh interface ipv6 set interface "<interface name>" advertise=enable managed=enable

Replace <interface name> with the name you found in step 1.  Keep the quotes, lose the angle brackets.

This will tell windows that you really know what you’re doing, and it can use the ipv6 address in the network connection’s ipv6 static dialog box (which you’d already configured fully, right?) and forget about that monstrousity it auto generated from the MAC address.  Job done.

How to see a call stack of a 32 bit executable in a 64 bit kernel debug session

Most of you aren’t going to care about this post, you can safely ignore it, but I need a semi-permanent place to store such vital information so that I’ve got it available in future.  Sorry people ;)

In the 64 bit kernel debugging session, issue the command:

!load wow64exts.dll

Then, to switch between the 32 bit and 64 bit contexts, issue:

!sw

Simples!

Sony support nonsense.

I have Windows XP installed on my sony laptop. Unfortunately (for me) it’s not the XP that came with the machine, as I replaced the Hard Disk, and have used an XP install disk, rather than the system recovery disk – the laptop is well over 4 years old, and the system recovery disk is lost in the mists of time.
Anyway, the install wasn’t performed with the system recovery disk, and one of the programs that Sony provide an install package for on their website won’t work, having installed from that package.

So, I contact sony support, and it turns out that because the bits on my hard disk weren’t placed there by the recovery disk, they won’t support that version of XP; even though it’s a vanilla XP installation.

This raises the question:
My laptop was bought before Windows XP SP2 was released, and given that SP2 fundamentally changed how Windows works (at least in user mode – there were small kernel mode changes), would I get support for a windows install (from their recovery disk) with SP2 applied? The question has been asked. I’ll keep you updated.

Firefox2.0 RC2

I’ve been having some serious problems with Firefox 1.5.0.7 crashing, and generally misbehaving over the last couple of weeks, so decided that I’d give 2.0 RC2 a go just to see if it fixed any/all of the problems I’ve experienced.

Good News! It’s cured them completely. Well, the fact that it disabled all my extensions did it; installing the Nightly Tester Tools and forcing the firefox version check to always allow extensions to load made firefox start crashing again.

I narrowed it down to SessionSaver, and absolute must in Firefox 1.5.x

The good part about this is that Firefox 2 has the session saver built-in – look in the options for what firefox should do on startup. Undo close tab is also built-in; so any misclicks to select a tab, catching the X button is easily undone.

The only thing I miss is a middle-click on the tab bar to open a new tab. But I can cope with that, I think.

Off on a rant, now.

Just to add insult to injury, Firefox has just caused me to waste the last hour of my life. Thankyou firefox. Is it really ready for the primetime?
If I typed in the address bar http://www.lucien.cx/ (with or without the trailing slash) it would try to download the PHP source to the index.php page, saying it was of type application/x-httpd-php and with a blank filename.
So I spend an hour looking at why the hell it was doing that (thinking it was the server, as that’s what I’ve been playing with all day, and quite a lot of last night. But no ; it’s sodding firefox. I got the packet logger out on the server, and watched all traffic to the server on port 80. Nothing from my machine at all. Firefox’s cache had gone completely mental and decided that (somehow) it was going to cache the php source code to the site.
Anyhow, I cleared the cache and it all worked. But it does beg the question why it had cached

  1. The php source code
  2. a “page” that had the no-cache attribute set.

It goes without saying that Internet Explorer (god bless it’s little cotton socks) worked properly. Time to make a switch back to that, I reckon…

Rant over. Normal service will be resumed as soon as possible.

Virtual Hosting part one.

There’s a master plan afoot. I’m now running a completely  dynamic virtual hosting system on this server. Web services, name services and email are all dynamically worked out from SQL queries. “Why is this newsworthy?” you ask? Well, it’s to do with me showing off, basically. This is (as you can see from the title) only part one (part zero which I achieved about 18 months ago was web and mail services run dynamically, but the web was a cheat, which required a filesystem hack). Now, though, it’s all done “properly” from SQL databases. Which of course means that I’m going to need some management software to add/remove/administer domains properly   rather than hacking rows into databases like I have to do now. Maybe part one-and-a-half should be rationalisation of the databases into one single database, just to make it a little easier on myself. But maybe that gets done after the management interface is finished. Just maybe. I’ll let you know.

XChat for Windows

There has been a spate, recently, of IRC clients for windows becoming pay-for, shareware applications. Whilst this is not a bad thing, afterall software engineers need to eat too, it means that the previously free IRC clients are now no longer available. However, and there is some good news here, XChat which is completely free-as-in-speech is still available in source form under the GPL. So, instead of you having to pay for the Windows compiled version of the program, I’ve compiled it for you (you lucky people) and made it available to download.
It’s only downside is that you also need to download and install GTK for Windows, although to make things easier, a nice installer is available here. I’ve tested the XChat executable I compiled against GTK 2.4.13-rc1 and rc2, so these or any later versions should do. XChat is downloadable from here. Install and chat to your heart’s content. The source code for XChat (as I’m distributing a binary, I have to put a link to it) is on sourceforge.