Skip to contentSkip to conversation

Remove PCI class code from virtio balloon device

PATCH In review David Gibson 4 participants 18 messages Mar 19, 2012 – Mar 21, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove PCI class code from virtio balloon device

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM. This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>
---
 hw/virtio-pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-pci.c +1 -1
index a0fb7c1..da8a382 100644
@@ -919,7 +919,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
     k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
     k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;
     k->revision = VIRTIO_PCI_ABI_VERSION;
-    k->class_id = PCI_CLASS_MEMORY_RAM;
+    k->class_id = PCI_CLASS_OTHERS;
     dc->reset = virtio_pci_reset;
     dc->props = virtio_balloon_properties;
 }
Signature · 1 line
1.7.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM. This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>
---
 hw/virtio-pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types? The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

Michael: Do you want to take it through your tree?

#2 lore raw
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM. This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>
---
 hw/virtio-pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types? The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes. But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong. It was not suggetsed by the virtio spec, and it makes no sense. It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 49 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM.  This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>

---
 hw/virtio-pci.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types?  The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes.  But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong.  It was not suggetsed by the virtio spec, and it makes no sense.  It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

Quoted 3 lines

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

I agree that in practice the risk is low because working guests are probably not using the class code. On the other hand I don't see a downside to making this part of the 1.1 machine type, which is what users will run when they get this code change anyway. That way we can tell users that we never change the device model in a release with a straight face :).

Anthony: I'm not sure how strict we are about a user-visible change like this?

Stefan

#4 lore raw
Quoted 51 lines · Stefan Hajnoczi
Quoted 49 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM.  This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>

---
 hw/virtio-pci.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types?  The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes.  But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong.  It was not suggetsed by the virtio spec, and it makes no sense.  It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

Quoted 7 lines
Quoted 3 lines

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

I agree that in practice the risk is low because working guests are probably not using the class code. On the other hand I don't see a downside to making this part of the 1.1 machine type,

Well.. there's the fact that I can't what mechanism we would use to make this per-machine...

Quoted 9 lines

which is what
users will run when they get this code change anyway. That way we can tell users that we never change the device model in a release with a straight face :).

Anthony: I'm not sure how strict we are about a user-visible change like this?

Stefan

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 56 lines · David Gibson
Quoted 55 lines · Stefan Hajnoczi
Quoted 52 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM.  This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>

---
 hw/virtio-pci.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types?  The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes.  But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong.  It was not suggetsed by the virtio spec, and it makes no sense.  It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

Quoted 6 lines
Quoted 3 lines

I agree that in practice the risk is low because working guests are probably not using the class code. On the other hand I don't see a downside to making this part of the 1.1 machine type,

Well.. there's the fact that I can't what mechanism we would use to make this per-machine...

Not sure I parsed this correctly, but I think you're asking how to do it.

Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

#6 lore raw

Hi,
It seems your Mail-Followup-To: header causes my client to drop you from the To: list.

Quoted 75 lines · Stefan Hajnoczi
Quoted 56 lines · David Gibson
Quoted 55 lines · Stefan Hajnoczi
Quoted 52 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM.  This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>

---
 hw/virtio-pci.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types?  The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes.  But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong.  It was not suggetsed by the virtio spec, and it makes no sense.  It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

Quoted 6 lines
Quoted 3 lines

I agree that in practice the risk is low because working guests are probably not using the class code.  On the other hand I don't see a downside to making this part of the 1.1 machine type,

Well.. there's the fact that I can't what mechanism we would use to make this per-machine...

Not sure I parsed this correctly, but I think you're asking how to do it.

Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release.  Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

#7 lore raw
Quoted 3 lines · Stefan Hajnoczi

Hi,
It seems your Mail-Followup-To: header causes my client to drop you from the To: list.

Not mine, it's added by the list AFAICT. And it's frickin' annoying.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw
In reply to Stefan Hajnoczi
Quoted 67 lines · Stefan Hajnoczi
Quoted 56 lines · David Gibson
Quoted 55 lines · Stefan Hajnoczi
Quoted 52 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM.  This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>

---
 hw/virtio-pci.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types?  The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes.  But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong.  It was not suggetsed by the virtio spec, and it makes no sense.  It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

Quoted 6 lines
Quoted 3 lines

I agree that in practice the risk is low because working guests are probably not using the class code. On the other hand I don't see a downside to making this part of the 1.1 machine type,

Well.. there's the fact that I can't what mechanism we would use to make this per-machine...

Not sure I parsed this correctly, but I think you're asking how to do it.

Quoted 8 lines

Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

#9 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

    .name = "pc-0.10",
    .desc = "Standard PC, qemu 0.10",
    .init = pc_init_pci_no_kvmclock,
    .max_cpus = 255,
    .compat_props = (GlobalProperty[]) {
        {
            .driver   = "virtio-blk-pci",
            .property = "class",
            .value    = stringify(PCI_CLASS_STORAGE_OTHER),
        },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Anthony Liguori

Quoted 2 lines
#10 lore raw
Quoted 32 lines · Anthony Liguori
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

    .name = "pc-0.10",
    .desc = "Standard PC, qemu 0.10",
    .init = pc_init_pci_no_kvmclock,
    .max_cpus = 255,
    .compat_props = (GlobalProperty[]) {
        {
            .driver   = "virtio-blk-pci",
            .property = "class",
            .value    = stringify(PCI_CLASS_STORAGE_OTHER),
        },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Quoted 7 lines

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Anthony Liguori

Which reminds me - qemu sticks the release version in guest visible places like CPU version.
This is wrong and causes windows guests to print messages about driver updates when you switch.
We should find all these places and stop doing this.

Quoted 2 lines
Quoted 2 lines
#11 lore raw
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Anthony Liguori
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

     .name = "pc-0.10",
     .desc = "Standard PC, qemu 0.10",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
             .property = "class",
             .value    = stringify(PCI_CLASS_STORAGE_OTHER),
         },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Quoted 7 lines
Quoted 1 line

Anthony Liguori

Which reminds me - qemu sticks the release version in guest visible places like CPU version.
This is wrong and causes windows guests to print messages about driver updates when you switch.
We should find all these places and stop doing this.

We could probably get away with doing a query/replace of QEMU_VERSION with qemu_get_version(), make version a static variable that defaults to QEMU_VERSION, and then provide a way for machines to override it.

Then pc-0.10 could report a version of 0.10.

Regards,

Anthony Liguori

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
#12 lore raw
Quoted 53 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Anthony Liguori
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

    .name = "pc-0.10",
    .desc = "Standard PC, qemu 0.10",
    .init = pc_init_pci_no_kvmclock,
    .max_cpus = 255,
    .compat_props = (GlobalProperty[]) {
        {
            .driver   = "virtio-blk-pci",
            .property = "class",
            .value    = stringify(PCI_CLASS_STORAGE_OTHER),
        },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Quoted 7 lines
Quoted 1 line

Anthony Liguori

Which reminds me - qemu sticks the release version in guest visible places like CPU version.
This is wrong and causes windows guests to print messages about driver updates when you switch.
We should find all these places and stop doing this.

We could probably get away with doing a query/replace of QEMU_VERSION with qemu_get_version(), make version a static variable that defaults to QEMU_VERSION, and then provide a way for machines to override it.

Quoted 5 lines

Then pc-0.10 could report a version of 0.10.

Regards,

Anthony Liguori

Frankly I don't see value in making it visible to the user, at all. We are just triggering windows reactivations without any user benefit. Why not return a fixed value there to avoid that?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
#13 lore raw
Quoted 56 lines · Michael S. Tsirkin
Quoted 55 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Anthony Liguori
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

     .name = "pc-0.10",
     .desc = "Standard PC, qemu 0.10",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
             .property = "class",
             .value    = stringify(PCI_CLASS_STORAGE_OTHER),
         },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Quoted 7 lines
Quoted 1 line

Anthony Liguori

Which reminds me - qemu sticks the release version in guest visible places like CPU version.
This is wrong and causes windows guests to print messages about driver updates when you switch.
We should find all these places and stop doing this.

We could probably get away with doing a query/replace of QEMU_VERSION with qemu_get_version(), make version a static variable that defaults to QEMU_VERSION, and then provide a way for machines to override it.

Then pc-0.10 could report a version of 0.10.

Quoted 8 lines
Quoted 3 lines

Regards,

Anthony Liguori

Frankly I don't see value in making it visible to the user, at all. We are just triggering windows reactivations without any user benefit. Why not return a fixed value there to avoid that?

I don't see a problem making it fixed for 1.1, but for 1.0 and older, we should expose what we were supposed to expose.

We need to fix the bug first, then we can change the behavior.

Regards,

Anthony Liguori

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#14 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · Michael S. Tsirkin

Frankly I don't see value in making it visible to the user, at all. We are just triggering windows reactivations without any user benefit. Why not return a fixed value there to avoid that?

I don't see a problem making it fixed for 1.1, but for 1.0 and older, we should expose what we were supposed to expose.

We need to fix the bug first, then we can change the behavior.

In some cases, like USB, we really do want to expose a version, but we should probably only expose the major version, for instance, QEMU 1.x or 2.x. This would only be exposed by the appropriate machine types.

Regards,

Anthony Liguori

Quoted 10 lines

Regards,

Anthony Liguori

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#15 lore raw
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Michael S. Tsirkin

Frankly I don't see value in making it visible to the user, at all. We are just triggering windows reactivations without any user benefit. Why not return a fixed value there to avoid that?

Quoted 6 lines
Quoted 4 lines

I don't see a problem making it fixed for 1.1, but for 1.0 and older, we should expose what we were supposed to expose.

We need to fix the bug first, then we can change the behavior.

In some cases, like USB, we really do want to expose a version,

why, exactly?

Quoted 19 lines

but
we should probably only expose the major version, for instance, QEMU 1.x or 2.x. This would only be exposed by the appropriate machine types.

Regards,

Anthony Liguori

Quoted 10 lines

Regards,

Anthony Liguori

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#16 lore raw
In reply to Anthony Liguori
Quoted 66 lines · Anthony Liguori
Quoted 56 lines · Michael S. Tsirkin
Quoted 55 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Anthony Liguori
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Hajnoczi

On Tue, Mar 20, 2012 at 09:19:47PM +1100, David Gibson wrote:
Looking at hw/pc_piix.c there are QEMUMachine types for each QEMU release. Legacy machine types (e.g. pc_machine_v0_14) have a .compat_props array that can override qdev properties.

Quoted 7 lines
Quoted 4 lines

Perhaps Michael Tsirkin or someone else can comment on how to wire up hw/virtio-pci.c so that the class code can be overridden.

Stefan

afaik we already let users over-write it for some other pci devices, look there for examples.

From hw/pc_piix.c:

    .name = "pc-0.10",
    .desc = "Standard PC, qemu 0.10",
    .init = pc_init_pci_no_kvmclock,
    .max_cpus = 255,
    .compat_props = (GlobalProperty[]) {
        {
            .driver   = "virtio-blk-pci",
            .property = "class",
            .value    = stringify(PCI_CLASS_STORAGE_OTHER),
        },{

And from the earlier part of the thread, yes, it's imperative that we do not change anything in the PCI configuration space for older pc versions regardless of whether it may or may not work.

Certain guests (like Windows) use a complex fingerprinting algorithm to determine when hardware changes. It can be hard to detect in simple testing because it's based on a threshold.

Regards,

Quoted 7 lines
Quoted 1 line

Anthony Liguori

Which reminds me - qemu sticks the release version in guest visible places like CPU version.
This is wrong and causes windows guests to print messages about driver updates when you switch.
We should find all these places and stop doing this.

We could probably get away with doing a query/replace of QEMU_VERSION with qemu_get_version(), make version a static variable that defaults to QEMU_VERSION, and then provide a way for machines to override it.

Then pc-0.10 could report a version of 0.10.

Quoted 8 lines
Quoted 3 lines

Regards,

Anthony Liguori

Frankly I don't see value in making it visible to the user, at all. We are just triggering windows reactivations without any user benefit. Why not return a fixed value there to avoid that?

Quoted 11 lines

I don't see a problem making it fixed for 1.1, but for 1.0 and older, we should expose what we were supposed to expose. We need to fix the bug first, then we can change the behavior.

Regards,

Anthony Liguori

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Makes sense to me.

#17 lore raw
In reply to David Gibson
Quoted 49 lines · David Gibson
Quoted 23 lines · Stefan Hajnoczi
Quoted 14 lines · David Gibson

Currently the virtio balloon device, when using the virtio-pci interface advertises itself with PCI class code MEMORY_RAM. This is wrong; the balloon is vaguely related to memory, but is nothing like a PCI memory device in the meaning of the class code, and this code is not required or suggested by the virtio PCI specification.

Worse, this patch causes problems on the pseries machine, because the firmware, seeing this class code, advertises the device as memory in the device tree, and then a guest kernel bug causes it to see this "memory" before the real system memory, leading to a crash in early boot.

This patch fixes the problem by removing the bogus PCI class code on the balloon device.

Quoted 7 lines
Cc Michael S. Tsirkin <[email protected]>
Cc Rusty Russell <[email protected]>
---
 hw/virtio-pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 7 lines

Since this is a guest-visible change we might need to be careful about how it's introduced.

Do we need to keep the old class code for existing machine types? The new class code could be introduced only for 1.1 and later machine types if we want to be extra careful about introducing guest-visible changes.

So as a general rule, I like to be very careful about user-visible changes. But in this case, I don't think we want to be too hesitant. In particular, it's not just a question of the machine type, but also of how the guest OS will deal with the PCI class code.

The class code we were using was Just Plain Wrong. It was not suggetsed by the virtio spec, and it makes no sense. It happens that so far this caused problems only for a guest on a particular machine type, but there's no reason it couldn't cause (different) problems for guests on any machine type.

More to the point, it seems reasonably unlikely for existing guests to rely on the broken behaviour: again, there's no reason they'd think they need to based on the spec, and the usual way of matching drivers to PCI devices is with the vendor/device IDs which are correct and not changed by this patch.

Quoted 3 lines

So, unless we have a known example of an existing guest that would be broken by this change, I think we should implement it ASAP for all machine types.

Talked with windows driver guys. It seems their driver does not check the class code, but one thing that will happen if this is changed across migration, is that
on bus rescan, windows will detect a change and driver will get re-installed. For the baloon, this will give all memory back to guest, which seems undesirable.

So I think keeping the old class for old machine types is the prudent thing to do.

I also removed Cc qemu-trivial - it's a short but non-trivial patch.

Quoted 5 lines
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson