[v2,3/3] virtio: Make disable-legacy/disable-modern compat properties optional
diff mbox series

Message ID 20190110020259.8492-4-ehabkost@redhat.com
State New
Headers show
Series
  • Fix virtio-*(-non)-transitional crash on 2.6 machine-types
Related show

Commit Message

Eduardo Habkost Jan. 10, 2019, 2:02 a.m. UTC
The disable-legacy and disable-modern properties apply only to
some virtio-pci devices.  Make those properties optional.

This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
version-specific variants of virtio PCI devices"):

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Reported-by: Thomas Huth <thuth@redhat.com>
Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/machine.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Jan. 10, 2019, 8:35 a.m. UTC | #1
Hi

On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> The disable-legacy and disable-modern properties apply only to
> some virtio-pci devices.  Make those properties optional.
>
> This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> version-specific variants of virtio PCI devices"):
>
>   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
>     -device virtio-net-pci-non-transitional
>   Unexpected error in object_property_find() at qom/object.c:1092:
>   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
>   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
>   Aborted (core dumped)
>
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/core/machine.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 5530b71981..a19143aa44 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
>
>  GlobalProperty hw_compat_2_6[] = {
>      { "virtio-mmio", "format_transport_address", "off" },
> -    { "virtio-pci", "disable-modern", "on" },
> -    { "virtio-pci", "disable-legacy", "off" },
> +    /* Optional because not all virtio-pci devices support legacy mode */
> +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> +    { "virtio-pci", "disable-legacy", "off", .optional = true },

Could the generic devices implement a specific interface instead?
virtio-pci-generic?

Adding "optional" handling looks like it may hide some other errors.

>  };
>  const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
>
> --
> 2.18.0.rc1.1.g3f1ff2140
>
>
Dr. David Alan Gilbert Jan. 10, 2019, 11:15 a.m. UTC | #2
* Marc-André Lureau (marcandre.lureau@gmail.com) wrote:
> Hi
> 
> On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > The disable-legacy and disable-modern properties apply only to
> > some virtio-pci devices.  Make those properties optional.
> >
> > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > version-specific variants of virtio PCI devices"):
> >
> >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> >     -device virtio-net-pci-non-transitional
> >   Unexpected error in object_property_find() at qom/object.c:1092:
> >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> >   Aborted (core dumped)
> >
> > Reported-by: Thomas Huth <thuth@redhat.com>
> > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  hw/core/machine.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index 5530b71981..a19143aa44 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> >
> >  GlobalProperty hw_compat_2_6[] = {
> >      { "virtio-mmio", "format_transport_address", "off" },
> > -    { "virtio-pci", "disable-modern", "on" },
> > -    { "virtio-pci", "disable-legacy", "off" },
> > +    /* Optional because not all virtio-pci devices support legacy mode */
> > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> 
> Could the generic devices implement a specific interface instead?
> virtio-pci-generic?
> 
> Adding "optional" handling looks like it may hide some other errors.

I think it would be OK if it only ignored the non-existent property
errors (or better, tested for their existence and then skipped if
they weren't there).

Dave

> >  };
> >  const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
> >
> > --
> > 2.18.0.rc1.1.g3f1ff2140
> >
> >
> 
> 
> -- 
> Marc-André Lureau
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Eduardo Habkost Jan. 10, 2019, 1:31 p.m. UTC | #3
On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > The disable-legacy and disable-modern properties apply only to
> > some virtio-pci devices.  Make those properties optional.
> >
> > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > version-specific variants of virtio PCI devices"):
> >
> >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> >     -device virtio-net-pci-non-transitional
> >   Unexpected error in object_property_find() at qom/object.c:1092:
> >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> >   Aborted (core dumped)
> >
> > Reported-by: Thomas Huth <thuth@redhat.com>
> > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  hw/core/machine.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index 5530b71981..a19143aa44 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> >
> >  GlobalProperty hw_compat_2_6[] = {
> >      { "virtio-mmio", "format_transport_address", "off" },
> > -    { "virtio-pci", "disable-modern", "on" },
> > -    { "virtio-pci", "disable-legacy", "off" },
> > +    /* Optional because not all virtio-pci devices support legacy mode */
> > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> 
> Could the generic devices implement a specific interface instead?
> virtio-pci-generic?

This is the kind of complexity I wanted to avoid.  We already
have too many interface names for subsets of PCI and virtio
devices.

> 
> Adding "optional" handling looks like it may hide some other errors.

What if we just make "optional" mean "skip if the property
doesn't exist", as suggested by Cornelia and Dave?
Michael S. Tsirkin Jan. 10, 2019, 2:12 p.m. UTC | #4
On Thu, Jan 10, 2019 at 11:31:23AM -0200, Eduardo Habkost wrote:
> On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:
> > Hi
> > 
> > On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >
> > > The disable-legacy and disable-modern properties apply only to
> > > some virtio-pci devices.  Make those properties optional.
> > >
> > > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > > version-specific variants of virtio PCI devices"):
> > >
> > >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> > >     -device virtio-net-pci-non-transitional
> > >   Unexpected error in object_property_find() at qom/object.c:1092:
> > >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> > >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> > >   Aborted (core dumped)
> > >
> > > Reported-by: Thomas Huth <thuth@redhat.com>
> > > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > ---
> > >  hw/core/machine.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > index 5530b71981..a19143aa44 100644
> > > --- a/hw/core/machine.c
> > > +++ b/hw/core/machine.c
> > > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> > >
> > >  GlobalProperty hw_compat_2_6[] = {
> > >      { "virtio-mmio", "format_transport_address", "off" },
> > > -    { "virtio-pci", "disable-modern", "on" },
> > > -    { "virtio-pci", "disable-legacy", "off" },
> > > +    /* Optional because not all virtio-pci devices support legacy mode */
> > > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> > 
> > Could the generic devices implement a specific interface instead?
> > virtio-pci-generic?
> 
> This is the kind of complexity I wanted to avoid.  We already
> have too many interface names for subsets of PCI and virtio
> devices.
> 
> > 
> > Adding "optional" handling looks like it may hide some other errors.
> 
> What if we just make "optional" mean "skip if the property
> doesn't exist", as suggested by Cornelia and Dave?

That's the more standard meaning of the word optional, isn't it?

> -- 
> Eduardo
Dr. David Alan Gilbert Jan. 10, 2019, 3:01 p.m. UTC | #5
* Michael S. Tsirkin (mst@redhat.com) wrote:
> On Thu, Jan 10, 2019 at 11:31:23AM -0200, Eduardo Habkost wrote:
> > On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:
> > > Hi
> > > 
> > > On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > >
> > > > The disable-legacy and disable-modern properties apply only to
> > > > some virtio-pci devices.  Make those properties optional.
> > > >
> > > > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > > > version-specific variants of virtio PCI devices"):
> > > >
> > > >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> > > >     -device virtio-net-pci-non-transitional
> > > >   Unexpected error in object_property_find() at qom/object.c:1092:
> > > >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> > > >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> > > >   Aborted (core dumped)
> > > >
> > > > Reported-by: Thomas Huth <thuth@redhat.com>
> > > > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > ---
> > > >  hw/core/machine.c | 5 +++--
> > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > index 5530b71981..a19143aa44 100644
> > > > --- a/hw/core/machine.c
> > > > +++ b/hw/core/machine.c
> > > > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> > > >
> > > >  GlobalProperty hw_compat_2_6[] = {
> > > >      { "virtio-mmio", "format_transport_address", "off" },
> > > > -    { "virtio-pci", "disable-modern", "on" },
> > > > -    { "virtio-pci", "disable-legacy", "off" },
> > > > +    /* Optional because not all virtio-pci devices support legacy mode */
> > > > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > > > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> > > 
> > > Could the generic devices implement a specific interface instead?
> > > virtio-pci-generic?
> > 
> > This is the kind of complexity I wanted to avoid.  We already
> > have too many interface names for subsets of PCI and virtio
> > devices.
> > 
> > > 
> > > Adding "optional" handling looks like it may hide some other errors.
> > 
> > What if we just make "optional" mean "skip if the property
> > doesn't exist", as suggested by Cornelia and Dave?
> 
> That's the more standard meaning of the word optional, isn't it?

Well the word is a separate issue; 'optional' is probably a bad choice
but that's less important than what it actually does.
I'd go for skip_if_missing  which is explicit.

Dave

> 
> > -- 
> > Eduardo
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Eduardo Habkost Jan. 10, 2019, 6:07 p.m. UTC | #6
On Thu, Jan 10, 2019 at 03:01:25PM +0000, Dr. David Alan Gilbert wrote:
> * Michael S. Tsirkin (mst@redhat.com) wrote:
> > On Thu, Jan 10, 2019 at 11:31:23AM -0200, Eduardo Habkost wrote:
> > > On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:
> > > > Hi
> > > > 
> > > > On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > >
> > > > > The disable-legacy and disable-modern properties apply only to
> > > > > some virtio-pci devices.  Make those properties optional.
> > > > >
> > > > > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > > > > version-specific variants of virtio PCI devices"):
> > > > >
> > > > >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> > > > >     -device virtio-net-pci-non-transitional
> > > > >   Unexpected error in object_property_find() at qom/object.c:1092:
> > > > >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> > > > >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> > > > >   Aborted (core dumped)
> > > > >
> > > > > Reported-by: Thomas Huth <thuth@redhat.com>
> > > > > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > ---
> > > > >  hw/core/machine.c | 5 +++--
> > > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > > index 5530b71981..a19143aa44 100644
> > > > > --- a/hw/core/machine.c
> > > > > +++ b/hw/core/machine.c
> > > > > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> > > > >
> > > > >  GlobalProperty hw_compat_2_6[] = {
> > > > >      { "virtio-mmio", "format_transport_address", "off" },
> > > > > -    { "virtio-pci", "disable-modern", "on" },
> > > > > -    { "virtio-pci", "disable-legacy", "off" },
> > > > > +    /* Optional because not all virtio-pci devices support legacy mode */
> > > > > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > > > > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> > > > 
> > > > Could the generic devices implement a specific interface instead?
> > > > virtio-pci-generic?
> > > 
> > > This is the kind of complexity I wanted to avoid.  We already
> > > have too many interface names for subsets of PCI and virtio
> > > devices.
> > > 
> > > > 
> > > > Adding "optional" handling looks like it may hide some other errors.
> > > 
> > > What if we just make "optional" mean "skip if the property
> > > doesn't exist", as suggested by Cornelia and Dave?
> > 
> > That's the more standard meaning of the word optional, isn't it?
> 
> Well the word is a separate issue; 'optional' is probably a bad choice
> but that's less important than what it actually does.
> I'd go for skip_if_missing  which is explicit.

I'm unsure about that.  To me "optional" means "it can be
missing" and carries the same information as "skip if missing".

What do others think?
Marc-André Lureau Jan. 10, 2019, 9:06 p.m. UTC | #7
On Thu, Jan 10, 2019 at 10:07 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> On Thu, Jan 10, 2019 at 03:01:25PM +0000, Dr. David Alan Gilbert wrote:
> > * Michael S. Tsirkin (mst@redhat.com) wrote:
> > > On Thu, Jan 10, 2019 at 11:31:23AM -0200, Eduardo Habkost wrote:
> > > > On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:
> > > > > Hi
> > > > >
> > > > > On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > > >
> > > > > > The disable-legacy and disable-modern properties apply only to
> > > > > > some virtio-pci devices.  Make those properties optional.
> > > > > >
> > > > > > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > > > > > version-specific variants of virtio PCI devices"):
> > > > > >
> > > > > >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> > > > > >     -device virtio-net-pci-non-transitional
> > > > > >   Unexpected error in object_property_find() at qom/object.c:1092:
> > > > > >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> > > > > >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> > > > > >   Aborted (core dumped)
> > > > > >
> > > > > > Reported-by: Thomas Huth <thuth@redhat.com>
> > > > > > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > > ---
> > > > > >  hw/core/machine.c | 5 +++--
> > > > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > > > index 5530b71981..a19143aa44 100644
> > > > > > --- a/hw/core/machine.c
> > > > > > +++ b/hw/core/machine.c
> > > > > > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> > > > > >
> > > > > >  GlobalProperty hw_compat_2_6[] = {
> > > > > >      { "virtio-mmio", "format_transport_address", "off" },
> > > > > > -    { "virtio-pci", "disable-modern", "on" },
> > > > > > -    { "virtio-pci", "disable-legacy", "off" },
> > > > > > +    /* Optional because not all virtio-pci devices support legacy mode */
> > > > > > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > > > > > +    { "virtio-pci", "disable-legacy", "off", .optional = true },
> > > > >
> > > > > Could the generic devices implement a specific interface instead?
> > > > > virtio-pci-generic?
> > > >
> > > > This is the kind of complexity I wanted to avoid.  We already
> > > > have too many interface names for subsets of PCI and virtio
> > > > devices.
> > > >
> > > > >
> > > > > Adding "optional" handling looks like it may hide some other errors.
> > > >
> > > > What if we just make "optional" mean "skip if the property
> > > > doesn't exist", as suggested by Cornelia and Dave?
> > >
> > > That's the more standard meaning of the word optional, isn't it?
> >
> > Well the word is a separate issue; 'optional' is probably a bad choice
> > but that's less important than what it actually does.
> > I'd go for skip_if_missing  which is explicit.
>
> I'm unsure about that.  To me "optional" means "it can be
> missing" and carries the same information as "skip if missing".
>
> What do others think?

skip_if_missing is more explicit.
Cornelia Huck Jan. 11, 2019, 8:22 a.m. UTC | #8
On Fri, 11 Jan 2019 01:06:45 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> On Thu, Jan 10, 2019 at 10:07 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > On Thu, Jan 10, 2019 at 03:01:25PM +0000, Dr. David Alan Gilbert wrote:  
> > > * Michael S. Tsirkin (mst@redhat.com) wrote:  
> > > > On Thu, Jan 10, 2019 at 11:31:23AM -0200, Eduardo Habkost wrote:  
> > > > > On Thu, Jan 10, 2019 at 12:35:26PM +0400, Marc-André Lureau wrote:  
> > > > > > Hi
> > > > > >
> > > > > > On Thu, Jan 10, 2019 at 6:05 AM Eduardo Habkost <ehabkost@redhat.com> wrote:  
> > > > > > >
> > > > > > > The disable-legacy and disable-modern properties apply only to
> > > > > > > some virtio-pci devices.  Make those properties optional.
> > > > > > >
> > > > > > > This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide
> > > > > > > version-specific variants of virtio PCI devices"):
> > > > > > >
> > > > > > >   $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
> > > > > > >     -device virtio-net-pci-non-transitional
> > > > > > >   Unexpected error in object_property_find() at qom/object.c:1092:
> > > > > > >   qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
> > > > > > >   global virtio-pci.disable-modern=on: Property '.disable-modern' not found
> > > > > > >   Aborted (core dumped)
> > > > > > >
> > > > > > > Reported-by: Thomas Huth <thuth@redhat.com>
> > > > > > > Fixes: f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
> > > > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > > > ---
> > > > > > >  hw/core/machine.c | 5 +++--
> > > > > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > > > > >
> > > > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > > > > index 5530b71981..a19143aa44 100644
> > > > > > > --- a/hw/core/machine.c
> > > > > > > +++ b/hw/core/machine.c
> > > > > > > @@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
> > > > > > >
> > > > > > >  GlobalProperty hw_compat_2_6[] = {
> > > > > > >      { "virtio-mmio", "format_transport_address", "off" },
> > > > > > > -    { "virtio-pci", "disable-modern", "on" },
> > > > > > > -    { "virtio-pci", "disable-legacy", "off" },
> > > > > > > +    /* Optional because not all virtio-pci devices support legacy mode */
> > > > > > > +    { "virtio-pci", "disable-modern", "on",  .optional = true },
> > > > > > > +    { "virtio-pci", "disable-legacy", "off", .optional = true },  
> > > > > >
> > > > > > Could the generic devices implement a specific interface instead?
> > > > > > virtio-pci-generic?  
> > > > >
> > > > > This is the kind of complexity I wanted to avoid.  We already
> > > > > have too many interface names for subsets of PCI and virtio
> > > > > devices.
> > > > >  
> > > > > >
> > > > > > Adding "optional" handling looks like it may hide some other errors.  
> > > > >
> > > > > What if we just make "optional" mean "skip if the property
> > > > > doesn't exist", as suggested by Cornelia and Dave?  
> > > >
> > > > That's the more standard meaning of the word optional, isn't it?  
> > >
> > > Well the word is a separate issue; 'optional' is probably a bad choice
> > > but that's less important than what it actually does.
> > > I'd go for skip_if_missing  which is explicit.  
> >
> > I'm unsure about that.  To me "optional" means "it can be
> > missing" and carries the same information as "skip if missing".
> >
> > What do others think?  
> 
> skip_if_missing is more explicit.

I'd slightly prefer optional, but skip_if_missing is fine.

Patch
diff mbox series

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 5530b71981..a19143aa44 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -91,8 +91,9 @@  const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
 
 GlobalProperty hw_compat_2_6[] = {
     { "virtio-mmio", "format_transport_address", "off" },
-    { "virtio-pci", "disable-modern", "on" },
-    { "virtio-pci", "disable-legacy", "off" },
+    /* Optional because not all virtio-pci devices support legacy mode */
+    { "virtio-pci", "disable-modern", "on",  .optional = true },
+    { "virtio-pci", "disable-legacy", "off", .optional = true },
 };
 const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);