Comment 3 for bug 586756

Revision history for this message
William Blunn (bill+launchpad) wrote :

Update:

Previously I was running over the 2.6.32 kernel out of Debian Squeeze, and saw the behaviour mentioned previously.

I have now switched to the 2.6.32 kernel implied by the Ubuntu package "linux-image-2.6.32-22-virtual" (version 2.6.32-22.33), which is 2.6.32-22-server.

If I now run the original unpatched "update-grub", it finds all the relevant kernels I have installed, and does not ignore any of them, i.e. the behaviour as reported previously no longer happens.

However I *am* running inside a Xen domU. In theory, if the bug I reported were true, "update-grub" should be ignoring all of my kernels.

So what is going on?

The answer is that "update-grub" does NOT believe it is running inside a Xen domU, when in fact it is running inside a Xen domU, which appears to be another bug.

The two bugs together mean that update-grub does not ignore relevant kernels inside a domU. However it is not ignoring them for the wrong reasons. (I suppose you could call it a white box bug.)

There is a bit starting around line 1406:

   1406 if [ "$indomU" = "detect" ]; then
   1407 if [ -e /proc/xen/capabilities ] && ! grep -q "control_d" /proc/xen/capabilities; then
   1408 indomU="true"
   1409 else
   1410 indomU="false"
   1411 fi
   1412 fi

On my system (which is running inside a Xen domU), when running the Ubuntu kernel, the directory /proc/xen is empty. As such, the second "if" test finds nothing and sets "indomU" to "false".

(Under the Debian kernel, this must have been resolving to "true". Though switching back to the Debian kernel again, I am seeing false. Queer.)

So the "indomU" indicator is being computed incorrectly as "false" when actually running inside a domU.

I would speculate that the means of detecting whether inside a domU was based on earlier kernel behaviour and no longer works correctly.

So I would say we may need to use a second way of checking if we are inside a domU.

Sniffing around, we may be able do this by reading /sys/hypervisor/type. On my system that results in the string "xen".

So perhaps we could say something like:

if ( [ -e /proc/xen/capabilities ] && ! grep -q "control_d" /proc/xen/capabilities ) \
  || [ "`cat /sys/hypervisor/type 2>/dev/null`" = xen ] ; then
    indomU="true"
else
    indomU="false"
fi

This should then give us a better idea of whether we are inside a Xen domU.