Skip to contentSkip to conversation

xen_emul_unplug on xen 4.1, HVM guest 2.6.38

DISCUSSION Alex Bligh 6 participants 19 messages Oct 26, 2011 – Oct 27, 2011

lore
Share & tools
lore

Alex Bligh

author
#0 lore raw

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Signature · 1 line
Alex Bligh
#1 lore raw
Quoted 13 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Quoted 7 lines

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

xen_pci_platform=0 in your guest config should do it.

#2 lore raw
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Quoted 7 lines

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

:)

-- Pasi

author
#3 lore raw

Pasi, Conrad,

Quoted 23 lines · --On 26 October 2011 17:12:33 +0300 Pasi Kärkkäinen <[email protected]> wrote:
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 5 lines
Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

Thanks. Just to confirm, that will still allow HVM PV drivers to operate (as well)?

Signature · 1 line
Alex Bligh
#4 lore raw
Quoted 27 lines · Alex Bligh

Pasi, Conrad,

Quoted 23 lines · --On 26 October 2011 17:12:33 +0300 Pasi Kärkkäinen <[email protected]> wrote:
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

Thanks. Just to confirm, that will still allow HVM PV drivers to operate (as well)?

No, this will disable PV drivers.

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

Ian.

#5 lore raw
Quoted 48 lines · Ian Campbell
Quoted 27 lines · Alex Bligh

Pasi, Conrad,

Quoted 23 lines · --On 26 October 2011 17:12:33 +0300 Pasi Kärkkäinen <[email protected]> wrote:
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

Thanks. Just to confirm, that will still allow HVM PV drivers to operate (as well)?

No, this will disable PV drivers.

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

Quoted 9 lines

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

"disable qemu PCI devices in HVM domains":
http://xenbits.xen.org/gitweb/?p=qemu-xen-unstable.git;a=commit;h=e7911109f4321e9ba0cc56a253b653600aa46bea

"disable qemu PCI devices in HVM domains - protocol document":
http://xenbits.xen.org/gitweb/?p=qemu-xen-unstable.git;a=commit;h=bc5c93ede039525765a7aa98e1da3386efa1465f

-- Pasi

#6 lore raw
Quoted 59 lines · Pasi Kärkkäinen
Quoted 48 lines · Ian Campbell
Quoted 27 lines · Alex Bligh

Pasi, Conrad,

Quoted 23 lines · --On 26 October 2011 17:12:33 +0300 Pasi Kärkkäinen <[email protected]> wrote:
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

Thanks. Just to confirm, that will still allow HVM PV drivers to operate (as well)?

No, this will disable PV drivers.

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

Quoted 9 lines

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

Quoted 5 lines

"disable qemu PCI devices in HVM domains":
http://xenbits.xen.org/gitweb/?p=qemu-xen-unstable.git;a=commit;h=e7911109f4321e9ba0cc56a253b653600aa46bea

"disable qemu PCI devices in HVM domains - protocol document":
http://xenbits.xen.org/gitweb/?p=qemu-xen-unstable.git;a=commit;h=bc5c93ede039525765a7aa98e1da3386efa1465f

Thanks, I found it and am just about to send a patch to add it to xen-unstable.hg...

Ian.

Quoted 5 lines

-- Pasi

author
#7 lore raw
In reply to Ian Campbell

Ian,

Quoted 1 line

No, this will disable PV drivers.

I can confirm that our testing illustrates this :-(

Quoted 9 lines

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

Quoted 8 lines

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

So, the issue is this. We have thousands (literally) of disks in use by third parties on xen 3.3. Some are Windows, some are ancient linux, some are modern linux, etc. The hypervisor has no way of whether the images are going to use /dev/sda or /dev/xvda (i.e. PV or emulated) drivers. Indeed the most common linux case is that grub uses the emulated devices to load the kernel, then uses /dev/xvda as a root device, i.e. both are used (but not simultaneously).

We need to have the xen pci stuff on, so PV drivers operate (in both
new and old kernels). But as modern linux kernels detect the unplug functionality, they will unplug the emulated devices and then fail to boot because (for instance) under Xen3.3 using /dev/sdaX to access
(say) your /boot partition worked perfectly well. What we need is a
switch to revert to the old Xen3.3 (pre-unplug) behaviour, so any
Linux kernel will see the same set of devices. I cannot believe this
is a unique requirement for people attempting to do a Xen3.3 to
Xen4.1 migration.

I think this is in xen_unplug_emulated_devices() in arch/x86/xen/platform-pci-unplug.c

This uses check_platform_magic(), which I have appended. In order to avoid unplugging (without relying on the boot line), I need this to return a non-zero value (XEN_PLATFORM_ERR_MAGIC is irrelevant as xen_emul_unplug is 0 by assumption).

I can achieve that by either (a) returning a bad magic number,
(b) making the host 'blacklist' the product (how does that work?) or (c) using a protocol value of (say) 0. I take it Xen 3.3 simply returns a bad magic number as I don't think XEN_IOPORT_MAGIC existed in 3.3. As far as I can tell, XEN_IOPORT_MAGIC is only use for PCI unplug.

So, is the correct approach to disable XEN_IOPORT_MAGIC (or rather make it return a different value) depending on a configuration option? If so, I am happy to submit a patch to do that. Or can I do this without a patch by "blacklisting" everything? (not sure how that is done).

Out of interest, with a default guest Ubuntu Natty install CD, using the default Xen 4.1 settings, we are seeing the guest (a) unplugging the emulated devices (fine), then (b) failing to find the emulated devices, and (c) the install failing. Is that to be expected?

Signature · 38 lines
Alex Bligh


static int __init check_platform_magic(void)
{
       short magic;
       char protocol;

       magic = inw(XEN_IOPORT_MAGIC);
       if (magic != XEN_IOPORT_MAGIC_VAL) {
               printk(KERN_ERR "Xen Platform PCI: unrecognised magic 
value\n");
               return XEN_PLATFORM_ERR_MAGIC;
       }

       protocol = inb(XEN_IOPORT_PROTOVER);

       printk(KERN_DEBUG "Xen Platform PCI: I/O protocol version %d\n",
                       protocol);

       switch (protocol) {
       case 1:
               outw(XEN_IOPORT_LINUX_PRODNUM, XEN_IOPORT_PRODNUM);
               outl(XEN_IOPORT_LINUX_DRVVER, XEN_IOPORT_DRVVER);
               if (inw(XEN_IOPORT_MAGIC) != XEN_IOPORT_MAGIC_VAL) {
                       printk(KERN_ERR "Xen Platform: blacklisted by 
host\n");
                       return XEN_PLATFORM_ERR_BLACKLIST;
               }
               break;
       default:
               printk(KERN_WARNING "Xen Platform PCI: unknown I/O protocol 
version");
               return XEN_PLATFORM_ERR_PROTOCOL;
       }

       return 0;
}
#8 lore raw
Quoted 32 lines · Alex Bligh

Ian,

Quoted 1 line

No, this will disable PV drivers.

I can confirm that our testing illustrates this :-(

Quoted 9 lines

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

Quoted 8 lines

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

So, the issue is this. We have thousands (literally) of disks in use by third parties on xen 3.3. Some are Windows, some are ancient linux, some are modern linux, etc. The hypervisor has no way of whether the images are going to use /dev/sda or /dev/xvda (i.e. PV or emulated) drivers. Indeed the most common linux case is that grub uses the emulated devices to load the kernel, then uses /dev/xvda as a root device, i.e. both are used (but not simultaneously).

Quoted 9 lines

We need to have the xen pci stuff on, so PV drivers operate (in both new and old kernels). But as modern linux kernels detect the unplug functionality, they will unplug the emulated devices and then fail to boot because (for instance) under Xen3.3 using /dev/sdaX to access (say) your /boot partition worked perfectly well. What we need is a switch to revert to the old Xen3.3 (pre-unplug) behaviour, so any Linux kernel will see the same set of devices. I cannot believe this is a unique requirement for people attempting to do a Xen3.3 to Xen4.1 migration.

I'm a bit fuzzy on the details but I'm not sure what this has to do with the host, the device naming and behaviour on unplug are kernel side things, I'd expect that if /dev/sdaX as /boot worked on 3.3 it'll work on 4.1 too. (I believe you that it doesn't work, I'm just wondering aloud what I'm missing).

Can you give us the specifics of a setup which fails, e.g. a complete guest cfg file, the kernel version, command line options, /etc/fstab, dmesg etc.

Quoted 15 lines

I think this is in xen_unplug_emulated_devices() in arch/x86/xen/platform-pci-unplug.c

This uses check_platform_magic(), which I have appended. In order to avoid unplugging (without relying on the boot line), I need this to return a non-zero value (XEN_PLATFORM_ERR_MAGIC is irrelevant as xen_emul_unplug is 0 by assumption).

I can achieve that by either (a) returning a bad magic number,
(b) making the host 'blacklist' the product (how does that work?) or (c) using a protocol value of (say) 0. I take it Xen 3.3 simply returns a bad magic number as I don't think XEN_IOPORT_MAGIC existed in 3.3. As far as I can tell, XEN_IOPORT_MAGIC is only use for PCI unplug.

Quoted 4 lines

So, is the correct approach to disable XEN_IOPORT_MAGIC (or rather make it return a different value) depending on a configuration option? If so, I am happy to submit a patch to do that. Or can I do this without a patch by "blacklisting" everything? (not sure how that is done).

Hmm, yes I think the special treatment of XEN_IOPORT_MAGIC mismatch on the kernel side is what I was missing.

It might make sense to have a guest level config option which disables these magic ports, i.e. makes them return 0xffff like they would have done in 3.3 (I think 0xffff is what you'll get from an invalid port in general).

Quoted 4 lines

Out of interest, with a default guest Ubuntu Natty install CD, using the default Xen 4.1 settings, we are seeing the guest (a) unplugging the emulated devices (fine), then (b) failing to find the emulated devices, and (c) the install failing. Is that to be expected?

Sounds like an Ubuntu bug to me, but I don't follow Ubuntu closely enough to know if it is known or not.

Ian.

#9 lore raw
Quoted 81 lines · Ian Campbell
Quoted 32 lines · Alex Bligh

Ian,

Quoted 1 line

No, this will disable PV drivers.

I can confirm that our testing illustrates this :-(

Quoted 9 lines

The decision to unplug is a kernel side decision and in PVHVM Linux kernels is not currently possible to have both types of devices by default due to the risk of dataloss if the guest is not correctly configured (i.e. the kernel can't tell if it is mounting the same filesystem via two paths). The xen_emul_unplug option is the current way you can override this once you have confirmed that your guest configuration is not dangerous. I'm afraid this necessarily involves guest config and guest admin interaction.

Quoted 8 lines

In principal we might be able to extend the unplug protocol (which would involve patches to qemu, the kernel(s) and the toolstack) to allow devices to be marked as being not necessary to unplug. Someone would have to send patches though and it would be opening up a way for people to lose data so we'd need to be careful.

I'm sure that the unplug protocol is documented somewhere in the source tree but I can't for the life of me find it :-(

So, the issue is this. We have thousands (literally) of disks in use by third parties on xen 3.3. Some are Windows, some are ancient linux, some are modern linux, etc. The hypervisor has no way of whether the images are going to use /dev/sda or /dev/xvda (i.e. PV or emulated) drivers. Indeed the most common linux case is that grub uses the emulated devices to load the kernel, then uses /dev/xvda as a root device, i.e. both are used (but not simultaneously).

Quoted 9 lines

We need to have the xen pci stuff on, so PV drivers operate (in both new and old kernels). But as modern linux kernels detect the unplug functionality, they will unplug the emulated devices and then fail to boot because (for instance) under Xen3.3 using /dev/sdaX to access (say) your /boot partition worked perfectly well. What we need is a switch to revert to the old Xen3.3 (pre-unplug) behaviour, so any Linux kernel will see the same set of devices. I cannot believe this is a unique requirement for people attempting to do a Xen3.3 to Xen4.1 migration.

I'm a bit fuzzy on the details but I'm not sure what this has to do with the host, the device naming and behaviour on unplug are kernel side things, I'd expect that if /dev/sdaX as /boot worked on 3.3 it'll work on 4.1 too. (I believe you that it doesn't work, I'm just wondering aloud what I'm missing).

Can you give us the specifics of a setup which fails, e.g. a complete guest cfg file, the kernel version, command line options, /etc/fstab, dmesg etc.

Quoted 15 lines

I think this is in xen_unplug_emulated_devices() in arch/x86/xen/platform-pci-unplug.c

This uses check_platform_magic(), which I have appended. In order to avoid unplugging (without relying on the boot line), I need this to return a non-zero value (XEN_PLATFORM_ERR_MAGIC is irrelevant as xen_emul_unplug is 0 by assumption).

I can achieve that by either (a) returning a bad magic number,
(b) making the host 'blacklist' the product (how does that work?) or (c) using a protocol value of (say) 0. I take it Xen 3.3 simply returns a bad magic number as I don't think XEN_IOPORT_MAGIC existed in 3.3. As far as I can tell, XEN_IOPORT_MAGIC is only use for PCI unplug.

Quoted 4 lines

So, is the correct approach to disable XEN_IOPORT_MAGIC (or rather make it return a different value) depending on a configuration option? If so, I am happy to submit a patch to do that. Or can I do this without a patch by "blacklisting" everything? (not sure how that is done).

Hmm, yes I think the special treatment of XEN_IOPORT_MAGIC mismatch on the kernel side is what I was missing.

It might make sense to have a guest level config option which disables these magic ports, i.e. makes them return 0xffff like they would have done in 3.3 (I think 0xffff is what you'll get from an invalid port in general).

Quoted 8 lines
Quoted 4 lines

Out of interest, with a default guest Ubuntu Natty install CD, using the default Xen 4.1 settings, we are seeing the guest (a) unplugging the emulated devices (fine), then (b) failing to find the emulated devices, and (c) the install failing. Is that to be expected?

Sounds like an Ubuntu bug to me, but I don't follow Ubuntu closely enough to know if it is known or not.

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

The other part of the problem is that even when you name the disk xvda in the config file, the installer does not know about blkfront. This is Ubuntu specific and we either need to have blkfront built-in or put them into a special udeb which is a special handling just for the installer.

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

-Stefan

Quoted 7 lines

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#10 lore raw

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

#11 lore raw
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

The problem I saw in my test was that in blkfront_probe the following case was hit when the device name was hda in the cfg:

                if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
                        int major;

                        if (!VDEV_IS_EXTENDED(vdevice))
                                major = BLKIF_MAJOR(vdevice);
                        else
                                major = XENVBD_MAJOR;

                        if (major != XENVBD_MAJOR) {
                                printk(KERN_INFO
                                                "%s: HVM does not support vbd %d
as xen block device\n",
                                                __FUNCTION__, vdevice);
                                return -ENODEV;
                        }
                }

So major is not XENVBD_MAJOR and the device is ignored.

-Stefan

#12 lore raw
Quoted 45 lines · Stefan Bader
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

The problem I saw in my test was that in blkfront_probe the following case was hit when the device name was hda in the cfg:

                if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
                        int major;

                        if (!VDEV_IS_EXTENDED(vdevice))
                                major = BLKIF_MAJOR(vdevice);
                        else
                                major = XENVBD_MAJOR;

                        if (major != XENVBD_MAJOR) {
                                printk(KERN_INFO
                                                "%s: HVM does not support vbd %d
as xen block device\n",
                                                __FUNCTION__, vdevice);
                                return -ENODEV;
                        }
                }
Quoted 2 lines

So major is not XENVBD_MAJOR and the device is ignored.

Why are you passing xen_emul_unplug=unnecessary?
The idea is that if you pass that option you have to use the emulated path to access your disk unless you esplicitely add an xvd disk to your config.

In the normal case, if you don't specify xen_emul_unplug, you are going to get xvda for your hda disk.
Then if you use LABEL or UUID in your root= argument, you don't need to change any configuration to make it work.

#13 lore raw
Quoted 54 lines · Stefano Stabellini
Quoted 45 lines · Stefan Bader
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

The problem I saw in my test was that in blkfront_probe the following case was hit when the device name was hda in the cfg:

                if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
                        int major;

                        if (!VDEV_IS_EXTENDED(vdevice))
                                major = BLKIF_MAJOR(vdevice);
                        else
                                major = XENVBD_MAJOR;

                        if (major != XENVBD_MAJOR) {
                                printk(KERN_INFO
                                                "%s: HVM does not support vbd %d
as xen block device\n",
                                                __FUNCTION__, vdevice);
                                return -ENODEV;
                        }
                }
Quoted 2 lines

So major is not XENVBD_MAJOR and the device is ignored.

Why are you passing xen_emul_unplug=unnecessary?
The idea is that if you pass that option you have to use the emulated path to access your disk unless you esplicitely add an xvd disk to your config.

Quoted 4 lines

In the normal case, if you don't specify xen_emul_unplug, you are going to get xvda for your hda disk.
Then if you use LABEL or UUID in your root= argument, you don't need to change any configuration to make it work.

Because of the above I have to specify the xen_emul_unplug to get *any* device. If I do not specify anything, then (because pci and pv driver are available) the emulated disk gets unplugged. Ok. But then the probe does not give me any xvd because the major does not match.

The only form I could make this work was: use xvda in the config file.

#14 lore raw
Quoted 55 lines · Stefan Bader
Quoted 54 lines · Stefano Stabellini
Quoted 45 lines · Stefan Bader
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

The problem I saw in my test was that in blkfront_probe the following case was hit when the device name was hda in the cfg:

                if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
                        int major;

                        if (!VDEV_IS_EXTENDED(vdevice))
                                major = BLKIF_MAJOR(vdevice);
                        else
                                major = XENVBD_MAJOR;

                        if (major != XENVBD_MAJOR) {
                                printk(KERN_INFO
                                                "%s: HVM does not support vbd %d
as xen block device\n",
                                                __FUNCTION__, vdevice);
                                return -ENODEV;
                        }
                }
Quoted 2 lines

So major is not XENVBD_MAJOR and the device is ignored.

Why are you passing xen_emul_unplug=unnecessary?
The idea is that if you pass that option you have to use the emulated path to access your disk unless you esplicitely add an xvd disk to your config.

Quoted 6 lines
Quoted 4 lines

In the normal case, if you don't specify xen_emul_unplug, you are going to get xvda for your hda disk.
Then if you use LABEL or UUID in your root= argument, you don't need to change any configuration to make it work.

Because of the above I have to specify the xen_emul_unplug to get *any* device.

Why?
If you do *not* specify xen_emul_unplug, you should get /dev/xvda (provided you have blkfront available and hda in your disk config line).

Quoted 3 lines

If I do not specify anything, then (because pci and pv driver are available) the emulated disk gets unplugged. Ok. But then the probe does not give me any xvd because the major does not match.

that is only because you passed xen_emul_unplug=unnecessary; you shouldn't do that

Quoted 1 line

The only form I could make this work was: use xvda in the config file.

you should use hda in the disk config line, and then configure the guest kernel root= argument with /dev/xvda1 directly or LABEL or UUID (better).

#15 lore raw
Quoted 61 lines · Stefano Stabellini
Quoted 60 lines · Stefan Bader
Quoted 58 lines · Stefano Stabellini
Quoted 45 lines · Stefan Bader
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

The problem I saw in my test was that in blkfront_probe the following case was hit when the device name was hda in the cfg:

                if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
                        int major;

                        if (!VDEV_IS_EXTENDED(vdevice))
                                major = BLKIF_MAJOR(vdevice);
                        else
                                major = XENVBD_MAJOR;

                        if (major != XENVBD_MAJOR) {
                                printk(KERN_INFO
                                                "%s: HVM does not support vbd %d
as xen block device\n",
                                                __FUNCTION__, vdevice);
                                return -ENODEV;
                        }
                }
Quoted 2 lines

So major is not XENVBD_MAJOR and the device is ignored.

Why are you passing xen_emul_unplug=unnecessary?
The idea is that if you pass that option you have to use the emulated path to access your disk unless you esplicitely add an xvd disk to your config.
(and force the blkfront to get loaded but that is some other patches missing In the normal case, if you don't specify xen_emul_unplug, you are going to get xvda for your hda disk.
Then if you use LABEL or UUID in your root= argument, you don't need to change any configuration to make it work.

Quoted 6 lines
Quoted 1 line

Because of the above I have to specify the xen_emul_unplug to get *any* device.

Why?
If you do *not* specify xen_emul_unplug, you should get /dev/xvda (provided you have blkfront available and hda in your disk config line).

Ah! Sorry, yes. I think I remember now how my confusion started. While trying to find the lost interrupt problem for the network devices I had two of them configured (8139cp and e1000) and during those tests there was no way I was able to get any xvd device. But that was because for some reason with both NICs the pci device would fail to get an IRQ, so xenbus was never started.

Removing the second NIC made the pci device work, but then with allowing unplug, there was still some problem with the pv nic not working. So I probably ended up with the unnecessary, and when the disk finally worked when defined as xvda, and I was already too confused by other things to realize that that segment only applies for the unecessary case. :/

Quoted 13 lines
Quoted 4 lines

If I do not specify anything, then (because pci and pv driver are available) the emulated disk gets unplugged. Ok. But then the probe does not give me any xvd because the major does not match.

that is only because you passed xen_emul_unplug=unnecessary; you shouldn't do that

Quoted 1 line

The only form I could make this work was: use xvda in the config file.

you should use hda in the disk config line, and then configure the guest kernel root= argument with /dev/xvda1 directly or LABEL or UUID (better).

#16 lore raw
In reply to Stefano Stabellini
Quoted 16 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 7 lines
Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

Hm, did you mean unsuccessful? Because then I think it *should* ignore the pv disk. If it was successful then it *should not*. Or am I understanding this wrong?

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#17 lore raw
Quoted 22 lines · Stefan Bader
Quoted 21 lines · Stefano Stabellini

I take we are still talking about PV on HVM guests here.

Quoted 6 lines · Stefan Bader

At least one part is not Ubuntu specific. And that is that the unplug logic decides to unplug emulated devices based on having the pci and the blkfront driver *available* (built-in or module). But later on the blkfront driver ignores all devices that are not *named* in a way to map to the xvd major. Which leaves you without any usable devices when you named your disk hda in the config file and you do not prevent unplugging.

If you name your disk hda (as you should), blkfront is going to create /dev/xvda in your guest.
It is not ignoring your disk, it just using "xvd" to name the device in the guest.

Quoted 4 lines

Still I would love to see this unplug handling become a bit more obvious. If unplug was successful, then blkfront should not ignore the devices. Or maybe just make the config more what-you-write-is-what-you-get and having hd or sd there only gives you emulated devices and xvd gives you pv devices.

Quoted 5 lines
Quoted 2 lines

Yes, if the unplug is unsuccessful blkfront should not ignore the
device: it is going to create a /dev/xvd* for you.

Hm, did you mean unsuccessful? Because then I think it *should* ignore the pv disk. If it was successful then it *should not*. Or am I understanding this wrong?

Yes, sorry for the misspell.
If the unplug is successful then it should not ignore the disk.

#18 lore raw
In reply to Alex Bligh
Quoted 27 lines · Alex Bligh

Pasi, Conrad,

Quoted 23 lines · --On 26 October 2011 17:12:33 +0300 Pasi Kärkkäinen <[email protected]> wrote:
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Alex Bligh

I am running Xen 4 and want users to be able to install arbitrary HVM images. We want both PV and emulated drivers to appear. The reason for this is for compatibility with images that were prepared for Xen 3.3, which assume emulated devices exist at boot time (particularly for running the boot loader).

If I do not specify on the boot line xen_emul_unplug=never, then under some guest OS's (e.g. Ubuntu Natty (2.6.38)), the domU kernel unplugs the non-PV devices, which is undesirable in my application.

I cannot arbitrarily change the kernel command line because it is in effect set by the user's image.

Therefore what I need to do is prevent Xen4 offering the facility to unplug the devices in the first place. Setting "(unpluggable 0)" in the config for the emulated NICs and disks does not appear to prevent them getting unplugged; what may be happening is that domU tries to unplug them (but fails) but still doesn't use them. Is there a way to signal from dom0 that the kernel really shouldn't unplug this stuff.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

xen_pci_platform=0 in your guest config should do it.

It's actually called:
xen_platform_pci=0

Thanks. Just to confirm, that will still allow HVM PV drivers to operate (as well)?

Nope. PVHVM drivers will require the xen pci platform device to operate.

-- Pasi