All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
@ 2021-10-12  8:24 Jean-Louis Dupond
  2021-10-12  8:36 ` Jean-Louis Dupond
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-10-12  8:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jean-Louis Dupond

hw_compat modes only take into account their base name.
But if a device is created with (non)-transitional, then the compat
values are not used, causing migrating issues.

This commit adds their (non)-transitional entries with the same settings
as the base entry.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
---
 include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4ff19c714b..5726825c2d 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -293,6 +293,30 @@ typedef struct GlobalProperty {
     bool optional;
 } GlobalProperty;
 
+
+/**
+ * Helper to add (non)transitional compat properties
+ */
+static inline void
+compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
+{
+    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
+    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
+    transitional->property = g_strdup(prop->property);
+    transitional->value = g_strdup(prop->value);
+    transitional->used = prop->used;
+    transitional->optional = prop->optional;
+    g_ptr_array_add(arr, (void *)transitional);
+
+    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
+    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
+    non_transitional->property = g_strdup(prop->property);
+    non_transitional->value = g_strdup(prop->value);
+    non_transitional->used = prop->used;
+    non_transitional->optional = prop->optional;
+    g_ptr_array_add(arr, (void *)non_transitional);
+}
+
 static inline void
 compat_props_add(GPtrArray *arr,
                  GlobalProperty props[], size_t nelem)
@@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
     int i;
     for (i = 0; i < nelem; i++) {
         g_ptr_array_add(arr, (void *)&props[i]);
+        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
+            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
+            g_str_equal(props[i].driver, "virtio-blk-pci") ||
+            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
+            g_str_equal(props[i].driver, "virtio-serial-pci") ||
+            g_str_equal(props[i].driver, "virtio-9p-pci") ||
+            g_str_equal(props[i].driver, "virtio-net-pci") ||
+            g_str_equal(props[i].driver, "virtio-rng-pci")) {
+            compat_props_add_transitional(arr, &props[i]);
+        }
     }
 }
 
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-12  8:24 [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs Jean-Louis Dupond
@ 2021-10-12  8:36 ` Jean-Louis Dupond
  2021-10-19 10:46   ` Stefan Hajnoczi
  2021-10-19 15:27 ` Eduardo Habkost
  2021-11-01 22:26 ` Michael S. Tsirkin
  2 siblings, 1 reply; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-10-12  8:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, berrange, ehabkost

Forgot to CC maintainers.

On 12/10/2021 10:24, Jean-Louis Dupond wrote:
> hw_compat modes only take into account their base name.
> But if a device is created with (non)-transitional, then the compat
> values are not used, causing migrating issues.
>
> This commit adds their (non)-transitional entries with the same settings
> as the base entry.
>
> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
>
> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> ---
>   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 4ff19c714b..5726825c2d 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
>       bool optional;
>   } GlobalProperty;
>   
> +
> +/**
> + * Helper to add (non)transitional compat properties
> + */
> +static inline void
> +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> +{
> +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> +    transitional->property = g_strdup(prop->property);
> +    transitional->value = g_strdup(prop->value);
> +    transitional->used = prop->used;
> +    transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)transitional);
> +
> +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> +    non_transitional->property = g_strdup(prop->property);
> +    non_transitional->value = g_strdup(prop->value);
> +    non_transitional->used = prop->used;
> +    non_transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)non_transitional);
> +}
> +
>   static inline void
>   compat_props_add(GPtrArray *arr,
>                    GlobalProperty props[], size_t nelem)
> @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
>       int i;
>       for (i = 0; i < nelem; i++) {
>           g_ptr_array_add(arr, (void *)&props[i]);
> +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> +            compat_props_add_transitional(arr, &props[i]);
> +        }
>       }
>   }
>   


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-12  8:36 ` Jean-Louis Dupond
@ 2021-10-19 10:46   ` Stefan Hajnoczi
  2021-10-19 10:59     ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Stefan Hajnoczi @ 2021-10-19 10:46 UTC (permalink / raw)
  To: Jean-Louis Dupond
  Cc: berrange, ehabkost, Michael S. Tsirkin, jasowang, qemu-devel, pbonzini

[-- Attachment #1: Type: text/plain, Size: 3117 bytes --]

On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> Forgot to CC maintainers.

Also CCing Jason Wang and Michael Tsirkin for VIRTIO.

Stefan

> 
> On 12/10/2021 10:24, Jean-Louis Dupond wrote:
> > hw_compat modes only take into account their base name.
> > But if a device is created with (non)-transitional, then the compat
> > values are not used, causing migrating issues.
> > 
> > This commit adds their (non)-transitional entries with the same settings
> > as the base entry.
> > 
> > Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
> > 
> > Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> > ---
> >   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
> >   1 file changed, 34 insertions(+)
> > 
> > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 4ff19c714b..5726825c2d 100644
> > --- a/include/hw/qdev-core.h
> > +++ b/include/hw/qdev-core.h
> > @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
> >       bool optional;
> >   } GlobalProperty;
> > +
> > +/**
> > + * Helper to add (non)transitional compat properties
> > + */
> > +static inline void
> > +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> > +{
> > +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> > +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> > +    transitional->property = g_strdup(prop->property);
> > +    transitional->value = g_strdup(prop->value);
> > +    transitional->used = prop->used;
> > +    transitional->optional = prop->optional;
> > +    g_ptr_array_add(arr, (void *)transitional);
> > +
> > +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> > +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> > +    non_transitional->property = g_strdup(prop->property);
> > +    non_transitional->value = g_strdup(prop->value);
> > +    non_transitional->used = prop->used;
> > +    non_transitional->optional = prop->optional;
> > +    g_ptr_array_add(arr, (void *)non_transitional);
> > +}
> > +
> >   static inline void
> >   compat_props_add(GPtrArray *arr,
> >                    GlobalProperty props[], size_t nelem)
> > @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
> >       int i;
> >       for (i = 0; i < nelem; i++) {
> >           g_ptr_array_add(arr, (void *)&props[i]);
> > +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> > +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> > +            compat_props_add_transitional(arr, &props[i]);
> > +        }
> >       }
> >   }
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 10:46   ` Stefan Hajnoczi
@ 2021-10-19 10:59     ` Michael S. Tsirkin
  2021-10-19 15:29       ` Eduardo Habkost
  0 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-19 10:59 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: berrange, ehabkost, jasowang, qemu-devel, Jean-Louis Dupond, pbonzini

On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > Forgot to CC maintainers.
> 
> Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> 
> Stefan

OMG
where all compat properties broken all the time?


> > 
> > On 12/10/2021 10:24, Jean-Louis Dupond wrote:
> > > hw_compat modes only take into account their base name.
> > > But if a device is created with (non)-transitional, then the compat
> > > values are not used, causing migrating issues.
> > > 
> > > This commit adds their (non)-transitional entries with the same settings
> > > as the base entry.
> > > 
> > > Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
> > > 
> > > Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> > > ---
> > >   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
> > >   1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > > index 4ff19c714b..5726825c2d 100644
> > > --- a/include/hw/qdev-core.h
> > > +++ b/include/hw/qdev-core.h
> > > @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
> > >       bool optional;
> > >   } GlobalProperty;
> > > +
> > > +/**
> > > + * Helper to add (non)transitional compat properties
> > > + */
> > > +static inline void
> > > +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> > > +{
> > > +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> > > +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> > > +    transitional->property = g_strdup(prop->property);
> > > +    transitional->value = g_strdup(prop->value);
> > > +    transitional->used = prop->used;
> > > +    transitional->optional = prop->optional;
> > > +    g_ptr_array_add(arr, (void *)transitional);
> > > +
> > > +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> > > +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> > > +    non_transitional->property = g_strdup(prop->property);
> > > +    non_transitional->value = g_strdup(prop->value);
> > > +    non_transitional->used = prop->used;
> > > +    non_transitional->optional = prop->optional;
> > > +    g_ptr_array_add(arr, (void *)non_transitional);
> > > +}
> > > +
> > >   static inline void
> > >   compat_props_add(GPtrArray *arr,
> > >                    GlobalProperty props[], size_t nelem)
> > > @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
> > >       int i;
> > >       for (i = 0; i < nelem; i++) {
> > >           g_ptr_array_add(arr, (void *)&props[i]);
> > > +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> > > +            compat_props_add_transitional(arr, &props[i]);
> > > +        }
> > >       }
> > >   }
> > 




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-12  8:24 [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs Jean-Louis Dupond
  2021-10-12  8:36 ` Jean-Louis Dupond
@ 2021-10-19 15:27 ` Eduardo Habkost
  2021-10-20  6:58   ` Jean-Louis Dupond
  2021-11-01 22:26 ` Michael S. Tsirkin
  2 siblings, 1 reply; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-19 15:27 UTC (permalink / raw)
  To: Jean-Louis Dupond; +Cc: qemu-devel

On Tue, Oct 12, 2021 at 10:24:28AM +0200, Jean-Louis Dupond wrote:
> hw_compat modes only take into account their base name.

What do you mean by "base name"?

> But if a device is created with (non)-transitional, then the compat
> values are not used, causing migrating issues.
> 
> This commit adds their (non)-transitional entries with the same settings
> as the base entry.


Wouldn't it be easier to fix the incorrect compat_props arrays to
use "virtio-*-pci-base" instead?

If a piece of code is supposed to affect/support both
non-transitional and transitional subclasses, that's why
VirtioPCIDeviceTypeInfo.base_name exists.


> 
> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
> 
> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> ---
>  include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 4ff19c714b..5726825c2d 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
>      bool optional;
>  } GlobalProperty;
>  
> +
> +/**
> + * Helper to add (non)transitional compat properties
> + */
> +static inline void
> +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> +{
> +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> +    transitional->property = g_strdup(prop->property);
> +    transitional->value = g_strdup(prop->value);
> +    transitional->used = prop->used;
> +    transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)transitional);
> +
> +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> +    non_transitional->property = g_strdup(prop->property);
> +    non_transitional->value = g_strdup(prop->value);
> +    non_transitional->used = prop->used;
> +    non_transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)non_transitional);
> +}
> +
>  static inline void
>  compat_props_add(GPtrArray *arr,
>                   GlobalProperty props[], size_t nelem)
> @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
>      int i;
>      for (i = 0; i < nelem; i++) {
>          g_ptr_array_add(arr, (void *)&props[i]);
> +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> +            compat_props_add_transitional(arr, &props[i]);
> +        }
>      }
>  }
>  
> -- 
> 2.33.0
> 
> 

-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 10:59     ` Michael S. Tsirkin
@ 2021-10-19 15:29       ` Eduardo Habkost
  2021-10-19 16:13         ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-19 15:29 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > Forgot to CC maintainers.
> > 
> > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > 
> > Stefan
> 
> OMG
> where all compat properties broken all the time?

Compat properties that existed when commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices") was
merged are not broken, because virtio-*-transitional and
virtio-*-non-transitional were brand new QOM types (so there's no
compatibility to be kept with old QEMU versions).

Compat properties referencing "virtio-*-pci" instead of
"virtio-*-pci-base" added after commit f6e501a28ef9 are probably
broken, yes.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 15:29       ` Eduardo Habkost
@ 2021-10-19 16:13         ` Michael S. Tsirkin
  2021-10-19 16:56           ` Eduardo Habkost
  0 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-19 16:13 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > Forgot to CC maintainers.
> > > 
> > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > 
> > > Stefan
> > 
> > OMG
> > where all compat properties broken all the time?
> 
> Compat properties that existed when commit f6e501a28ef9 ("virtio:
> Provide version-specific variants of virtio PCI devices") was
> merged are not broken, because virtio-*-transitional and
> virtio-*-non-transitional were brand new QOM types (so there's no
> compatibility to be kept with old QEMU versions).
> 
> Compat properties referencing "virtio-*-pci" instead of
> "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> broken, yes.
> 
> -- 
> Eduardo

Oh. So just this one:
    { "virtio-net-pci", "vectors", "3"},

right?

about the patch: how do people feel about virtio specific
stuff in qdev core? Ok by everyone?

-- 
MST



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 16:13         ` Michael S. Tsirkin
@ 2021-10-19 16:56           ` Eduardo Habkost
  2021-10-20  1:31             ` Jason Wang
                               ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-19 16:56 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > Forgot to CC maintainers.
> > > > 
> > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > 
> > > > Stefan
> > > 
> > > OMG
> > > where all compat properties broken all the time?
> > 
> > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > Provide version-specific variants of virtio PCI devices") was
> > merged are not broken, because virtio-*-transitional and
> > virtio-*-non-transitional were brand new QOM types (so there's no
> > compatibility to be kept with old QEMU versions).
> > 
> > Compat properties referencing "virtio-*-pci" instead of
> > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > broken, yes.
> > 
> > -- 
> > Eduardo
> 
> Oh. So just this one:
>     { "virtio-net-pci", "vectors", "3"},
> 
> right?

I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
hw/core/machine.c.

pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
virtio compat props on spapr.c and s390-virtio-ccw.c.

> 
> about the patch: how do people feel about virtio specific
> stuff in qdev core? Ok by everyone?

Not OK, if we have a mechanism to avoid that, already (the
"virtio-net-pci-base" type name).  I wonder what we can do to
make this kind of mistake less likely, though.

Jean-Louis, Jason, does the following fix work?

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
diff --git a/hw/core/machine.c b/hw/core/machine.c
index b8d95eec32d..bd9c6156c1a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
     { "ICH9-LPC", "smm-compat", "on"},
     { "PIIX4_PM", "smm-compat", "on"},
     { "virtio-blk-device", "report-discard-granularity", "off" },
-    { "virtio-net-pci", "vectors", "3"},
+    { "virtio-net-pci-base", "vectors", "3"},
 };
 const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
 
-- 
Eduardo



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 16:56           ` Eduardo Habkost
@ 2021-10-20  1:31             ` Jason Wang
  2021-10-20  5:02               ` Jason Wang
  2021-10-20  7:00             ` Jean-Louis Dupond
  2021-10-20  7:41             ` Michael S. Tsirkin
  2 siblings, 1 reply; 24+ messages in thread
From: Jason Wang @ 2021-10-20  1:31 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrangé,
	Michael S. Tsirkin, Stefan Hajnoczi, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 12:56 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > Forgot to CC maintainers.
> > > > >
> > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > >
> > > > > Stefan
> > > >
> > > > OMG
> > > > where all compat properties broken all the time?
> > >
> > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > Provide version-specific variants of virtio PCI devices") was
> > > merged are not broken, because virtio-*-transitional and
> > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > compatibility to be kept with old QEMU versions).
> > >
> > > Compat properties referencing "virtio-*-pci" instead of
> > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > broken, yes.
> > >
> > > --
> > > Eduardo
> >
> > Oh. So just this one:
> >     { "virtio-net-pci", "vectors", "3"},
> >
> > right?
>
> I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> hw/core/machine.c.
>
> pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> virtio compat props on spapr.c and s390-virtio-ccw.c.
>
> >
> > about the patch: how do people feel about virtio specific
> > stuff in qdev core? Ok by everyone?
>
> Not OK, if we have a mechanism to avoid that, already (the
> "virtio-net-pci-base" type name).  I wonder what we can do to
> make this kind of mistake less likely, though.
>
> Jean-Louis, Jason, does the following fix work?

Yes.

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b8d95eec32d..bd9c6156c1a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
>      { "ICH9-LPC", "smm-compat", "on"},
>      { "PIIX4_PM", "smm-compat", "on"},
>      { "virtio-blk-device", "report-discard-granularity", "off" },
> -    { "virtio-net-pci", "vectors", "3"},
> +    { "virtio-net-pci-base", "vectors", "3"},
>  };
>  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
>
> --
> Eduardo
>



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20  1:31             ` Jason Wang
@ 2021-10-20  5:02               ` Jason Wang
  2021-10-20 14:09                 ` Eduardo Habkost
  0 siblings, 1 reply; 24+ messages in thread
From: Jason Wang @ 2021-10-20  5:02 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrangé,
	Michael S. Tsirkin, Stefan Hajnoczi, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 9:31 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Wed, Oct 20, 2021 at 12:56 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > Forgot to CC maintainers.
> > > > > >
> > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > >
> > > > > > Stefan
> > > > >
> > > > > OMG
> > > > > where all compat properties broken all the time?
> > > >
> > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > Provide version-specific variants of virtio PCI devices") was
> > > > merged are not broken, because virtio-*-transitional and
> > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > compatibility to be kept with old QEMU versions).
> > > >
> > > > Compat properties referencing "virtio-*-pci" instead of
> > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > broken, yes.
> > > >
> > > > --
> > > > Eduardo
> > >
> > > Oh. So just this one:
> > >     { "virtio-net-pci", "vectors", "3"},
> > >
> > > right?
> >
> > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > hw/core/machine.c.
> >
> > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > virtio compat props on spapr.c and s390-virtio-ccw.c.
> >
> > >
> > > about the patch: how do people feel about virtio specific
> > > stuff in qdev core? Ok by everyone?
> >
> > Not OK, if we have a mechanism to avoid that, already (the
> > "virtio-net-pci-base" type name).  I wonder what we can do to
> > make this kind of mistake less likely, though.
> >
> > Jean-Louis, Jason, does the following fix work?
>
> Yes.
>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
> Thanks
>
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index b8d95eec32d..bd9c6156c1a 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> >      { "ICH9-LPC", "smm-compat", "on"},
> >      { "PIIX4_PM", "smm-compat", "on"},
> >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > -    { "virtio-net-pci", "vectors", "3"},
> > +    { "virtio-net-pci-base", "vectors", "3"},

Rethink about this, any chance that we can use "virtio-net-pci" as the
base_name? It looks to me this can cause less confusion and consistent
with the existing compat properties.

Thanks

> >  };
> >  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
> >
> > --
> > Eduardo
> >



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 15:27 ` Eduardo Habkost
@ 2021-10-20  6:58   ` Jean-Louis Dupond
  0 siblings, 0 replies; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-10-20  6:58 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel

On 19/10/2021 17:27, Eduardo Habkost wrote:
> On Tue, Oct 12, 2021 at 10:24:28AM +0200, Jean-Louis Dupond wrote:
>> hw_compat modes only take into account their base name.
> What do you mean by "base name"?
virtio-net-pci (without the (non-)transitional extension.
>> But if a device is created with (non)-transitional, then the compat
>> values are not used, causing migrating issues.
>>
>> This commit adds their (non)-transitional entries with the same settings
>> as the base entry.
>
> Wouldn't it be easier to fix the incorrect compat_props arrays to
> use "virtio-*-pci-base" instead?
>
> If a piece of code is supposed to affect/support both
> non-transitional and transitional subclasses, that's why
> VirtioPCIDeviceTypeInfo.base_name exists.
>
Thats easier indeed :)
>> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
>>
>> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
>> ---
>>   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 34 insertions(+)
>>
>> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
>> index 4ff19c714b..5726825c2d 100644
>> --- a/include/hw/qdev-core.h
>> +++ b/include/hw/qdev-core.h
>> @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
>>       bool optional;
>>   } GlobalProperty;
>>   
>> +
>> +/**
>> + * Helper to add (non)transitional compat properties
>> + */
>> +static inline void
>> +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
>> +{
>> +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
>> +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
>> +    transitional->property = g_strdup(prop->property);
>> +    transitional->value = g_strdup(prop->value);
>> +    transitional->used = prop->used;
>> +    transitional->optional = prop->optional;
>> +    g_ptr_array_add(arr, (void *)transitional);
>> +
>> +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
>> +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
>> +    non_transitional->property = g_strdup(prop->property);
>> +    non_transitional->value = g_strdup(prop->value);
>> +    non_transitional->used = prop->used;
>> +    non_transitional->optional = prop->optional;
>> +    g_ptr_array_add(arr, (void *)non_transitional);
>> +}
>> +
>>   static inline void
>>   compat_props_add(GPtrArray *arr,
>>                    GlobalProperty props[], size_t nelem)
>> @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
>>       int i;
>>       for (i = 0; i < nelem; i++) {
>>           g_ptr_array_add(arr, (void *)&props[i]);
>> +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-net-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
>> +            compat_props_add_transitional(arr, &props[i]);
>> +        }
>>       }
>>   }
>>   
>> -- 
>> 2.33.0
>>
>>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 16:56           ` Eduardo Habkost
  2021-10-20  1:31             ` Jason Wang
@ 2021-10-20  7:00             ` Jean-Louis Dupond
  2021-10-20  7:41             ` Michael S. Tsirkin
  2 siblings, 0 replies; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-10-20  7:00 UTC (permalink / raw)
  To: Eduardo Habkost, Michael S. Tsirkin
  Cc: Stefan Hajnoczi, qemu-devel, pbonzini, berrange, jasowang

On 19/10/2021 18:56, Eduardo Habkost wrote:
> On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
>> On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
>>> On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
>>>> On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
>>>>> On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
>>>>>> Forgot to CC maintainers.
>>>>> Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
>>>>>
>>>>> Stefan
>>>> OMG
>>>> where all compat properties broken all the time?
>>> Compat properties that existed when commit f6e501a28ef9 ("virtio:
>>> Provide version-specific variants of virtio PCI devices") was
>>> merged are not broken, because virtio-*-transitional and
>>> virtio-*-non-transitional were brand new QOM types (so there's no
>>> compatibility to be kept with old QEMU versions).
>>>
>>> Compat properties referencing "virtio-*-pci" instead of
>>> "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
>>> broken, yes.
>>>
>>> -- 
>>> Eduardo
>> Oh. So just this one:
>>      { "virtio-net-pci", "vectors", "3"},
>>
>> right?
> I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> hw/core/machine.c.
>
> pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> virtio compat props on spapr.c and s390-virtio-ccw.c.
>
>> about the patch: how do people feel about virtio specific
>> stuff in qdev core? Ok by everyone?
> Not OK, if we have a mechanism to avoid that, already (the
> "virtio-net-pci-base" type name).  I wonder what we can do to
> make this kind of mistake less likely, though.
>
> Jean-Louis, Jason, does the following fix work?
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b8d95eec32d..bd9c6156c1a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
>       { "ICH9-LPC", "smm-compat", "on"},
>       { "PIIX4_PM", "smm-compat", "on"},
>       { "virtio-blk-device", "report-discard-granularity", "off" },
> -    { "virtio-net-pci", "vectors", "3"},
> +    { "virtio-net-pci-base", "vectors", "3"},
>   };
>   const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
>   
That patch fixes it indeed!

Acked-by: Jean-Louis Dupond <jean-louis@dupond.be>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-19 16:56           ` Eduardo Habkost
  2021-10-20  1:31             ` Jason Wang
  2021-10-20  7:00             ` Jean-Louis Dupond
@ 2021-10-20  7:41             ` Michael S. Tsirkin
  2021-10-20 13:57               ` Eduardo Habkost
  2 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-20  7:41 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Tue, Oct 19, 2021 at 12:56:11PM -0400, Eduardo Habkost wrote:
> On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > Forgot to CC maintainers.
> > > > > 
> > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > 
> > > > > Stefan
> > > > 
> > > > OMG
> > > > where all compat properties broken all the time?
> > > 
> > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > Provide version-specific variants of virtio PCI devices") was
> > > merged are not broken, because virtio-*-transitional and
> > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > compatibility to be kept with old QEMU versions).
> > > 
> > > Compat properties referencing "virtio-*-pci" instead of
> > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > broken, yes.
> > > 
> > > -- 
> > > Eduardo
> > 
> > Oh. So just this one:
> >     { "virtio-net-pci", "vectors", "3"},
> > 
> > right?
> 
> I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> hw/core/machine.c.
> 
> pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> virtio compat props on spapr.c and s390-virtio-ccw.c.
> 
> > 
> > about the patch: how do people feel about virtio specific
> > stuff in qdev core? Ok by everyone?
> 
> Not OK, if we have a mechanism to avoid that, already (the
> "virtio-net-pci-base" type name).  I wonder what we can do to
> make this kind of mistake less likely, though.
> 
> Jean-Louis, Jason, does the following fix work?
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b8d95eec32d..bd9c6156c1a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
>      { "ICH9-LPC", "smm-compat", "on"},
>      { "PIIX4_PM", "smm-compat", "on"},
>      { "virtio-blk-device", "report-discard-granularity", "off" },
> -    { "virtio-net-pci", "vectors", "3"},
> +    { "virtio-net-pci-base", "vectors", "3"},
>  };
>  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);

Hmm I'm a bit confused at this point, as to why does
specifying properties for virtio-net-pci on command
line with -global work, but in compat list doesn't. Do others
understand?


> -- 
> Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20  7:41             ` Michael S. Tsirkin
@ 2021-10-20 13:57               ` Eduardo Habkost
  2021-10-20 14:55                 ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-20 13:57 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 03:41:38AM -0400, Michael S. Tsirkin wrote:
> On Tue, Oct 19, 2021 at 12:56:11PM -0400, Eduardo Habkost wrote:
> > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > Forgot to CC maintainers.
> > > > > > 
> > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > 
> > > > > > Stefan
> > > > > 
> > > > > OMG
> > > > > where all compat properties broken all the time?
> > > > 
> > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > Provide version-specific variants of virtio PCI devices") was
> > > > merged are not broken, because virtio-*-transitional and
> > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > compatibility to be kept with old QEMU versions).
> > > > 
> > > > Compat properties referencing "virtio-*-pci" instead of
> > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > broken, yes.
> > > > 
> > > > -- 
> > > > Eduardo
> > > 
> > > Oh. So just this one:
> > >     { "virtio-net-pci", "vectors", "3"},
> > > 
> > > right?
> > 
> > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > hw/core/machine.c.
> > 
> > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > 
> > > 
> > > about the patch: how do people feel about virtio specific
> > > stuff in qdev core? Ok by everyone?
> > 
> > Not OK, if we have a mechanism to avoid that, already (the
> > "virtio-net-pci-base" type name).  I wonder what we can do to
> > make this kind of mistake less likely, though.
> > 
> > Jean-Louis, Jason, does the following fix work?
> > 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > index b8d95eec32d..bd9c6156c1a 100644
> > --- a/hw/core/machine.c
> > +++ b/hw/core/machine.c
> > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> >      { "ICH9-LPC", "smm-compat", "on"},
> >      { "PIIX4_PM", "smm-compat", "on"},
> >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > -    { "virtio-net-pci", "vectors", "3"},
> > +    { "virtio-net-pci-base", "vectors", "3"},
> >  };
> >  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
> 
> Hmm I'm a bit confused at this point, as to why does
> specifying properties for virtio-net-pci on command
> line with -global work, but in compat list doesn't. Do others
> understand?

I don't think that's the case.  -global behaves similarly to compat_props.

Running an unpatched QEMU 6.1.0 binary:

$ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci -machine pc-q35-5.2 -monitor stdio | grep vectors
        vectors = 3 (0x3)
$ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -machine pc-q35-5.2 -monitor stdio | grep vectors
        vectors = 4 (0x4)
$ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci.vectors=3 -monitor stdio | grep vectors
        vectors = 4 (0x4)
$ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci-base.vectors=3 -monitor stdio | grep vectors
        vectors = 3 (0x3)


-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20  5:02               ` Jason Wang
@ 2021-10-20 14:09                 ` Eduardo Habkost
  2021-10-20 14:58                   ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-20 14:09 UTC (permalink / raw)
  To: Jason Wang
  Cc: Daniel P. Berrangé,
	Michael S. Tsirkin, Stefan Hajnoczi, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 01:02:24PM +0800, Jason Wang wrote:
> On Wed, Oct 20, 2021 at 9:31 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Wed, Oct 20, 2021 at 12:56 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >
> > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > Forgot to CC maintainers.
> > > > > > >
> > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > >
> > > > > > > Stefan
> > > > > >
> > > > > > OMG
> > > > > > where all compat properties broken all the time?
> > > > >
> > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > merged are not broken, because virtio-*-transitional and
> > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > compatibility to be kept with old QEMU versions).
> > > > >
> > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > broken, yes.
> > > > >
> > > > > --
> > > > > Eduardo
> > > >
> > > > Oh. So just this one:
> > > >     { "virtio-net-pci", "vectors", "3"},
> > > >
> > > > right?
> > >
> > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > hw/core/machine.c.
> > >
> > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > >
> > > >
> > > > about the patch: how do people feel about virtio specific
> > > > stuff in qdev core? Ok by everyone?
> > >
> > > Not OK, if we have a mechanism to avoid that, already (the
> > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > make this kind of mistake less likely, though.
> > >
> > > Jean-Louis, Jason, does the following fix work?
> >
> > Yes.
> >
> > Acked-by: Jason Wang <jasowang@redhat.com>
> >
> > Thanks
> >
> > >
> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > ---
> > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > index b8d95eec32d..bd9c6156c1a 100644
> > > --- a/hw/core/machine.c
> > > +++ b/hw/core/machine.c
> > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > >      { "ICH9-LPC", "smm-compat", "on"},
> > >      { "PIIX4_PM", "smm-compat", "on"},
> > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > -    { "virtio-net-pci", "vectors", "3"},
> > > +    { "virtio-net-pci-base", "vectors", "3"},
> 
> Rethink about this, any chance that we can use "virtio-net-pci" as the
> base_name? It looks to me this can cause less confusion and consistent
> with the existing compat properties.

It's probably too late now: we can't change the semantics of
"-global virtio-net-pci" without breaking compatibility.

The original reasoning for making generic_name != base_name is at
this comment in struct VirtioPCIDeviceTypeInfo:

    /*
     * Common base class for the subclasses below.
     *
     * Required only if transitional_name or non_transitional_name is set.
     *
     * We need a separate base type instead of making all types
     * inherit from generic_name for two reasons:
     * 1) generic_name implements INTERFACE_PCIE_DEVICE, but
     *    transitional_name does not.
     * 2) generic_name has the "disable-legacy" and "disable-modern"
     *    properties, transitional_name and non_transitional name don't.
     */
    const char *base_name;

(I had to look it up.  I didn't remember the original reason for that)

-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20 13:57               ` Eduardo Habkost
@ 2021-10-20 14:55                 ` Michael S. Tsirkin
  2021-10-20 15:01                   ` Eduardo Habkost
  0 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-20 14:55 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 09:57:37AM -0400, Eduardo Habkost wrote:
> On Wed, Oct 20, 2021 at 03:41:38AM -0400, Michael S. Tsirkin wrote:
> > On Tue, Oct 19, 2021 at 12:56:11PM -0400, Eduardo Habkost wrote:
> > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > Forgot to CC maintainers.
> > > > > > > 
> > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > > 
> > > > > > > Stefan
> > > > > > 
> > > > > > OMG
> > > > > > where all compat properties broken all the time?
> > > > > 
> > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > merged are not broken, because virtio-*-transitional and
> > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > compatibility to be kept with old QEMU versions).
> > > > > 
> > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > broken, yes.
> > > > > 
> > > > > -- 
> > > > > Eduardo
> > > > 
> > > > Oh. So just this one:
> > > >     { "virtio-net-pci", "vectors", "3"},
> > > > 
> > > > right?
> > > 
> > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > hw/core/machine.c.
> > > 
> > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > > 
> > > > 
> > > > about the patch: how do people feel about virtio specific
> > > > stuff in qdev core? Ok by everyone?
> > > 
> > > Not OK, if we have a mechanism to avoid that, already (the
> > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > make this kind of mistake less likely, though.
> > > 
> > > Jean-Louis, Jason, does the following fix work?
> > > 
> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > ---
> > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > index b8d95eec32d..bd9c6156c1a 100644
> > > --- a/hw/core/machine.c
> > > +++ b/hw/core/machine.c
> > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > >      { "ICH9-LPC", "smm-compat", "on"},
> > >      { "PIIX4_PM", "smm-compat", "on"},
> > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > -    { "virtio-net-pci", "vectors", "3"},
> > > +    { "virtio-net-pci-base", "vectors", "3"},
> > >  };
> > >  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
> > 
> > Hmm I'm a bit confused at this point, as to why does
> > specifying properties for virtio-net-pci on command
> > line with -global work, but in compat list doesn't. Do others
> > understand?
> 
> I don't think that's the case.  -global behaves similarly to compat_props.
> 
> Running an unpatched QEMU 6.1.0 binary:
> 
> $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci -machine pc-q35-5.2 -monitor stdio | grep vectors
>         vectors = 3 (0x3)
> $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -machine pc-q35-5.2 -monitor stdio | grep vectors
>         vectors = 4 (0x4)
> $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci.vectors=3 -monitor stdio | grep vectors
>         vectors = 4 (0x4)
> $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci-base.vectors=3 -monitor stdio | grep vectors
>         vectors = 3 (0x3)

OK so ... that's another breakage then. Suggestions how to fix?

> 
> -- 
> Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20 14:09                 ` Eduardo Habkost
@ 2021-10-20 14:58                   ` Michael S. Tsirkin
  2021-10-20 15:46                     ` Eduardo Habkost
  0 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-20 14:58 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrangé,
	Stefan Hajnoczi, Jason Wang, qemu-devel, Jean-Louis Dupond,
	pbonzini

On Wed, Oct 20, 2021 at 10:09:17AM -0400, Eduardo Habkost wrote:
> On Wed, Oct 20, 2021 at 01:02:24PM +0800, Jason Wang wrote:
> > On Wed, Oct 20, 2021 at 9:31 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Wed, Oct 20, 2021 at 12:56 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > >
> > > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > > Forgot to CC maintainers.
> > > > > > > >
> > > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > > >
> > > > > > > > Stefan
> > > > > > >
> > > > > > > OMG
> > > > > > > where all compat properties broken all the time?
> > > > > >
> > > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > > merged are not broken, because virtio-*-transitional and
> > > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > > compatibility to be kept with old QEMU versions).
> > > > > >
> > > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > > broken, yes.
> > > > > >
> > > > > > --
> > > > > > Eduardo
> > > > >
> > > > > Oh. So just this one:
> > > > >     { "virtio-net-pci", "vectors", "3"},
> > > > >
> > > > > right?
> > > >
> > > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > > hw/core/machine.c.
> > > >
> > > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > > >
> > > > >
> > > > > about the patch: how do people feel about virtio specific
> > > > > stuff in qdev core? Ok by everyone?
> > > >
> > > > Not OK, if we have a mechanism to avoid that, already (the
> > > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > > make this kind of mistake less likely, though.
> > > >
> > > > Jean-Louis, Jason, does the following fix work?
> > >
> > > Yes.
> > >
> > > Acked-by: Jason Wang <jasowang@redhat.com>
> > >
> > > Thanks
> > >
> > > >
> > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > ---
> > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > index b8d95eec32d..bd9c6156c1a 100644
> > > > --- a/hw/core/machine.c
> > > > +++ b/hw/core/machine.c
> > > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > > >      { "ICH9-LPC", "smm-compat", "on"},
> > > >      { "PIIX4_PM", "smm-compat", "on"},
> > > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > > -    { "virtio-net-pci", "vectors", "3"},
> > > > +    { "virtio-net-pci-base", "vectors", "3"},
> > 
> > Rethink about this, any chance that we can use "virtio-net-pci" as the
> > base_name? It looks to me this can cause less confusion and consistent
> > with the existing compat properties.
> 
> It's probably too late now: we can't change the semantics of
> "-global virtio-net-pci" without breaking compatibility.

You mean someone playing with virtio-net-pci-base and friends?
We could maybe make virtio-net-pci-base be an alias to
virtio-net-pci.

> The original reasoning for making generic_name != base_name is at
> this comment in struct VirtioPCIDeviceTypeInfo:
> 
>     /*
>      * Common base class for the subclasses below.
>      *
>      * Required only if transitional_name or non_transitional_name is set.
>      *
>      * We need a separate base type instead of making all types
>      * inherit from generic_name for two reasons:
>      * 1) generic_name implements INTERFACE_PCIE_DEVICE, but
>      *    transitional_name does not.
>      * 2) generic_name has the "disable-legacy" and "disable-modern"
>      *    properties, transitional_name and non_transitional name don't.
>      */
>     const char *base_name;
> 
> (I had to look it up.  I didn't remember the original reason for that)


Maybe we can find a different way to address these. Jason, any ideas?

> -- 
> Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20 14:55                 ` Michael S. Tsirkin
@ 2021-10-20 15:01                   ` Eduardo Habkost
  2021-10-20 15:16                     ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-20 15:01 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 10:55:59AM -0400, Michael S. Tsirkin wrote:
> On Wed, Oct 20, 2021 at 09:57:37AM -0400, Eduardo Habkost wrote:
> > On Wed, Oct 20, 2021 at 03:41:38AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, Oct 19, 2021 at 12:56:11PM -0400, Eduardo Habkost wrote:
> > > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > > Forgot to CC maintainers.
> > > > > > > > 
> > > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > > > 
> > > > > > > > Stefan
> > > > > > > 
> > > > > > > OMG
> > > > > > > where all compat properties broken all the time?
> > > > > > 
> > > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > > merged are not broken, because virtio-*-transitional and
> > > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > > compatibility to be kept with old QEMU versions).
> > > > > > 
> > > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > > broken, yes.
> > > > > > 
> > > > > > -- 
> > > > > > Eduardo
> > > > > 
> > > > > Oh. So just this one:
> > > > >     { "virtio-net-pci", "vectors", "3"},
> > > > > 
> > > > > right?
> > > > 
> > > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > > hw/core/machine.c.
> > > > 
> > > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > > > 
> > > > > 
> > > > > about the patch: how do people feel about virtio specific
> > > > > stuff in qdev core? Ok by everyone?
> > > > 
> > > > Not OK, if we have a mechanism to avoid that, already (the
> > > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > > make this kind of mistake less likely, though.
> > > > 
> > > > Jean-Louis, Jason, does the following fix work?
> > > > 
> > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > ---
> > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > index b8d95eec32d..bd9c6156c1a 100644
> > > > --- a/hw/core/machine.c
> > > > +++ b/hw/core/machine.c
> > > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > > >      { "ICH9-LPC", "smm-compat", "on"},
> > > >      { "PIIX4_PM", "smm-compat", "on"},
> > > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > > -    { "virtio-net-pci", "vectors", "3"},
> > > > +    { "virtio-net-pci-base", "vectors", "3"},
> > > >  };
> > > >  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
> > > 
> > > Hmm I'm a bit confused at this point, as to why does
> > > specifying properties for virtio-net-pci on command
> > > line with -global work, but in compat list doesn't. Do others
> > > understand?
> > 
> > I don't think that's the case.  -global behaves similarly to compat_props.
> > 
> > Running an unpatched QEMU 6.1.0 binary:
> > 
> > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci -machine pc-q35-5.2 -monitor stdio | grep vectors
> >         vectors = 3 (0x3)
> > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -machine pc-q35-5.2 -monitor stdio | grep vectors
> >         vectors = 4 (0x4)
> > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci.vectors=3 -monitor stdio | grep vectors
> >         vectors = 4 (0x4)
> > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci-base.vectors=3 -monitor stdio | grep vectors
> >         vectors = 3 (0x3)
> 
> OK so ... that's another breakage then. Suggestions how to fix?

What exactly is another breakage?  virtio-net-pci,
virtio-net-pci-non-transitional, and virtio-net-pci-transitional
are three distinct device types.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20 15:01                   ` Eduardo Habkost
@ 2021-10-20 15:16                     ` Michael S. Tsirkin
  0 siblings, 0 replies; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-10-20 15:16 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: berrange, Stefan Hajnoczi, jasowang, qemu-devel,
	Jean-Louis Dupond, pbonzini

On Wed, Oct 20, 2021 at 11:01:43AM -0400, Eduardo Habkost wrote:
> On Wed, Oct 20, 2021 at 10:55:59AM -0400, Michael S. Tsirkin wrote:
> > On Wed, Oct 20, 2021 at 09:57:37AM -0400, Eduardo Habkost wrote:
> > > On Wed, Oct 20, 2021 at 03:41:38AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Oct 19, 2021 at 12:56:11PM -0400, Eduardo Habkost wrote:
> > > > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > > > Forgot to CC maintainers.
> > > > > > > > > 
> > > > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > > > > 
> > > > > > > > > Stefan
> > > > > > > > 
> > > > > > > > OMG
> > > > > > > > where all compat properties broken all the time?
> > > > > > > 
> > > > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > > > merged are not broken, because virtio-*-transitional and
> > > > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > > > compatibility to be kept with old QEMU versions).
> > > > > > > 
> > > > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > > > broken, yes.
> > > > > > > 
> > > > > > > -- 
> > > > > > > Eduardo
> > > > > > 
> > > > > > Oh. So just this one:
> > > > > >     { "virtio-net-pci", "vectors", "3"},
> > > > > > 
> > > > > > right?
> > > > > 
> > > > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > > > hw/core/machine.c.
> > > > > 
> > > > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > > > > 
> > > > > > 
> > > > > > about the patch: how do people feel about virtio specific
> > > > > > stuff in qdev core? Ok by everyone?
> > > > > 
> > > > > Not OK, if we have a mechanism to avoid that, already (the
> > > > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > > > make this kind of mistake less likely, though.
> > > > > 
> > > > > Jean-Louis, Jason, does the following fix work?
> > > > > 
> > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > ---
> > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > > index b8d95eec32d..bd9c6156c1a 100644
> > > > > --- a/hw/core/machine.c
> > > > > +++ b/hw/core/machine.c
> > > > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > > > >      { "ICH9-LPC", "smm-compat", "on"},
> > > > >      { "PIIX4_PM", "smm-compat", "on"},
> > > > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > > > -    { "virtio-net-pci", "vectors", "3"},
> > > > > +    { "virtio-net-pci-base", "vectors", "3"},
> > > > >  };
> > > > >  const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
> > > > 
> > > > Hmm I'm a bit confused at this point, as to why does
> > > > specifying properties for virtio-net-pci on command
> > > > line with -global work, but in compat list doesn't. Do others
> > > > understand?
> > > 
> > > I don't think that's the case.  -global behaves similarly to compat_props.
> > > 
> > > Running an unpatched QEMU 6.1.0 binary:
> > > 
> > > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci -machine pc-q35-5.2 -monitor stdio | grep vectors
> > >         vectors = 3 (0x3)
> > > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -machine pc-q35-5.2 -monitor stdio | grep vectors
> > >         vectors = 4 (0x4)
> > > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci.vectors=3 -monitor stdio | grep vectors
> > >         vectors = 4 (0x4)
> > > $ echo -e 'info qtree\nquit' | qemu-system-x86_64 -device virtio-net-pci-non-transitional -global virtio-net-pci-base.vectors=3 -monitor stdio | grep vectors
> > >         vectors = 3 (0x3)
> > 
> > OK so ... that's another breakage then. Suggestions how to fix?
> 
> What exactly is another breakage?  virtio-net-pci,
> virtio-net-pci-non-transitional, and virtio-net-pci-transitional
> are three distinct device types.

Hmm. I guess ... good point.

> -- 
> Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-20 14:58                   ` Michael S. Tsirkin
@ 2021-10-20 15:46                     ` Eduardo Habkost
  0 siblings, 0 replies; 24+ messages in thread
From: Eduardo Habkost @ 2021-10-20 15:46 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Daniel P. Berrangé,
	Stefan Hajnoczi, Jason Wang, qemu-devel, Jean-Louis Dupond,
	pbonzini

On Wed, Oct 20, 2021 at 10:58:12AM -0400, Michael S. Tsirkin wrote:
> On Wed, Oct 20, 2021 at 10:09:17AM -0400, Eduardo Habkost wrote:
> > On Wed, Oct 20, 2021 at 01:02:24PM +0800, Jason Wang wrote:
> > > On Wed, Oct 20, 2021 at 9:31 AM Jason Wang <jasowang@redhat.com> wrote:
> > > >
> > > > On Wed, Oct 20, 2021 at 12:56 AM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > >
> > > > > On Tue, Oct 19, 2021 at 12:13:17PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, Oct 19, 2021 at 11:29:13AM -0400, Eduardo Habkost wrote:
> > > > > > > On Tue, Oct 19, 2021 at 06:59:09AM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Tue, Oct 19, 2021 at 11:46:17AM +0100, Stefan Hajnoczi wrote:
> > > > > > > > > On Tue, Oct 12, 2021 at 10:36:01AM +0200, Jean-Louis Dupond wrote:
> > > > > > > > > > Forgot to CC maintainers.
> > > > > > > > >
> > > > > > > > > Also CCing Jason Wang and Michael Tsirkin for VIRTIO.
> > > > > > > > >
> > > > > > > > > Stefan
> > > > > > > >
> > > > > > > > OMG
> > > > > > > > where all compat properties broken all the time?
> > > > > > >
> > > > > > > Compat properties that existed when commit f6e501a28ef9 ("virtio:
> > > > > > > Provide version-specific variants of virtio PCI devices") was
> > > > > > > merged are not broken, because virtio-*-transitional and
> > > > > > > virtio-*-non-transitional were brand new QOM types (so there's no
> > > > > > > compatibility to be kept with old QEMU versions).
> > > > > > >
> > > > > > > Compat properties referencing "virtio-*-pci" instead of
> > > > > > > "virtio-*-pci-base" added after commit f6e501a28ef9 are probably
> > > > > > > broken, yes.
> > > > > > >
> > > > > > > --
> > > > > > > Eduardo
> > > > > >
> > > > > > Oh. So just this one:
> > > > > >     { "virtio-net-pci", "vectors", "3"},
> > > > > >
> > > > > > right?
> > > > >
> > > > > I think so.  That's the only post-4.0 virtio-*-pci compat property I see in
> > > > > hw/core/machine.c.
> > > > >
> > > > > pc.c doesn't have any post-4.0 virtio-*-pci compat props.  I didn't see any
> > > > > virtio compat props on spapr.c and s390-virtio-ccw.c.
> > > > >
> > > > > >
> > > > > > about the patch: how do people feel about virtio specific
> > > > > > stuff in qdev core? Ok by everyone?
> > > > >
> > > > > Not OK, if we have a mechanism to avoid that, already (the
> > > > > "virtio-net-pci-base" type name).  I wonder what we can do to
> > > > > make this kind of mistake less likely, though.
> > > > >
> > > > > Jean-Louis, Jason, does the following fix work?
> > > >
> > > > Yes.
> > > >
> > > > Acked-by: Jason Wang <jasowang@redhat.com>
> > > >
> > > > Thanks
> > > >
> > > > >
> > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > > > > ---
> > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c
> > > > > index b8d95eec32d..bd9c6156c1a 100644
> > > > > --- a/hw/core/machine.c
> > > > > +++ b/hw/core/machine.c
> > > > > @@ -56,7 +56,7 @@ GlobalProperty hw_compat_5_2[] = {
> > > > >      { "ICH9-LPC", "smm-compat", "on"},
> > > > >      { "PIIX4_PM", "smm-compat", "on"},
> > > > >      { "virtio-blk-device", "report-discard-granularity", "off" },
> > > > > -    { "virtio-net-pci", "vectors", "3"},
> > > > > +    { "virtio-net-pci-base", "vectors", "3"},
> > > 
> > > Rethink about this, any chance that we can use "virtio-net-pci" as the
> > > base_name? It looks to me this can cause less confusion and consistent
> > > with the existing compat properties.
> > 
> > It's probably too late now: we can't change the semantics of
> > "-global virtio-net-pci" without breaking compatibility.
> 
> You mean someone playing with virtio-net-pci-base and friends?
> We could maybe make virtio-net-pci-base be an alias to
> virtio-net-pci.

I mean someone using "-global virtio-net-pci" with
a VM that has virtio-net-pci*transitional devices.

> 
> > The original reasoning for making generic_name != base_name is at
> > this comment in struct VirtioPCIDeviceTypeInfo:
> > 
> >     /*
> >      * Common base class for the subclasses below.
> >      *
> >      * Required only if transitional_name or non_transitional_name is set.
> >      *
> >      * We need a separate base type instead of making all types
> >      * inherit from generic_name for two reasons:
> >      * 1) generic_name implements INTERFACE_PCIE_DEVICE, but
> >      *    transitional_name does not.
> >      * 2) generic_name has the "disable-legacy" and "disable-modern"
> >      *    properties, transitional_name and non_transitional name don't.
> >      */
> >     const char *base_name;
> > 
> > (I had to look it up.  I didn't remember the original reason for that)
> 
> 
> Maybe we can find a different way to address these. Jason, any ideas?

(2) above is not a big deal, but (1) was supposed to be useful
for management software to identify which devices can be plugged
where.

I completely agree that the:

* virtio-pci
  * virtio-net-pci-base
    * virtio-net-pci
    * virtio-net-pci-transitional
    * virtio-net-pci-non-transitional

hierarchy is not obvious, but I do believe it is too late to
change it, because the QOM type hierarchy defines user-visible
behavior when using -global.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-10-12  8:24 [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs Jean-Louis Dupond
  2021-10-12  8:36 ` Jean-Louis Dupond
  2021-10-19 15:27 ` Eduardo Habkost
@ 2021-11-01 22:26 ` Michael S. Tsirkin
  2021-11-03  7:51   ` Jean-Louis Dupond
  2 siblings, 1 reply; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-11-01 22:26 UTC (permalink / raw)
  To: Jean-Louis Dupond; +Cc: qemu-devel

On Tue, Oct 12, 2021 at 10:24:28AM +0200, Jean-Louis Dupond wrote:
> hw_compat modes only take into account their base name.
> But if a device is created with (non)-transitional, then the compat
> values are not used, causing migrating issues.
> 
> This commit adds their (non)-transitional entries with the same settings
> as the base entry.
> 
> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
> 
> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>


Jean-Louis, any chance you are going to address the comments
and post a new patch?


> ---
>  include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 4ff19c714b..5726825c2d 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
>      bool optional;
>  } GlobalProperty;
>  
> +
> +/**
> + * Helper to add (non)transitional compat properties
> + */
> +static inline void
> +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> +{
> +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> +    transitional->property = g_strdup(prop->property);
> +    transitional->value = g_strdup(prop->value);
> +    transitional->used = prop->used;
> +    transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)transitional);
> +
> +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> +    non_transitional->property = g_strdup(prop->property);
> +    non_transitional->value = g_strdup(prop->value);
> +    non_transitional->used = prop->used;
> +    non_transitional->optional = prop->optional;
> +    g_ptr_array_add(arr, (void *)non_transitional);
> +}
> +
>  static inline void
>  compat_props_add(GPtrArray *arr,
>                   GlobalProperty props[], size_t nelem)
> @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
>      int i;
>      for (i = 0; i < nelem; i++) {
>          g_ptr_array_add(arr, (void *)&props[i]);
> +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> +            compat_props_add_transitional(arr, &props[i]);
> +        }
>      }
>  }
>  
> -- 
> 2.33.0
> 
> 
> 



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-11-01 22:26 ` Michael S. Tsirkin
@ 2021-11-03  7:51   ` Jean-Louis Dupond
  2021-11-03  7:58     ` Michael S. Tsirkin
  0 siblings, 1 reply; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-11-03  7:51 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On 1/11/2021 23:26, Michael S. Tsirkin wrote:
> On Tue, Oct 12, 2021 at 10:24:28AM +0200, Jean-Louis Dupond wrote:
>> hw_compat modes only take into account their base name.
>> But if a device is created with (non)-transitional, then the compat
>> values are not used, causing migrating issues.
>>
>> This commit adds their (non)-transitional entries with the same settings
>> as the base entry.
>>
>> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
>>
>> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
>
> Jean-Louis, any chance you are going to address the comments
> and post a new patch?
>
Should'nt we just apply the patch from Eduardo?
As this is a more elegant solution with the same result.
>> ---
>>   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 34 insertions(+)
>>
>> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
>> index 4ff19c714b..5726825c2d 100644
>> --- a/include/hw/qdev-core.h
>> +++ b/include/hw/qdev-core.h
>> @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
>>       bool optional;
>>   } GlobalProperty;
>>   
>> +
>> +/**
>> + * Helper to add (non)transitional compat properties
>> + */
>> +static inline void
>> +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
>> +{
>> +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
>> +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
>> +    transitional->property = g_strdup(prop->property);
>> +    transitional->value = g_strdup(prop->value);
>> +    transitional->used = prop->used;
>> +    transitional->optional = prop->optional;
>> +    g_ptr_array_add(arr, (void *)transitional);
>> +
>> +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
>> +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
>> +    non_transitional->property = g_strdup(prop->property);
>> +    non_transitional->value = g_strdup(prop->value);
>> +    non_transitional->used = prop->used;
>> +    non_transitional->optional = prop->optional;
>> +    g_ptr_array_add(arr, (void *)non_transitional);
>> +}
>> +
>>   static inline void
>>   compat_props_add(GPtrArray *arr,
>>                    GlobalProperty props[], size_t nelem)
>> @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
>>       int i;
>>       for (i = 0; i < nelem; i++) {
>>           g_ptr_array_add(arr, (void *)&props[i]);
>> +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-net-pci") ||
>> +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
>> +            compat_props_add_transitional(arr, &props[i]);
>> +        }
>>       }
>>   }
>>   
>> -- 
>> 2.33.0
>>
>>
>>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
  2021-11-03  7:51   ` Jean-Louis Dupond
@ 2021-11-03  7:58     ` Michael S. Tsirkin
  0 siblings, 0 replies; 24+ messages in thread
From: Michael S. Tsirkin @ 2021-11-03  7:58 UTC (permalink / raw)
  To: Jean-Louis Dupond; +Cc: qemu-devel

On Wed, Nov 03, 2021 at 08:51:42AM +0100, Jean-Louis Dupond wrote:
> On 1/11/2021 23:26, Michael S. Tsirkin wrote:
> > On Tue, Oct 12, 2021 at 10:24:28AM +0200, Jean-Louis Dupond wrote:
> > > hw_compat modes only take into account their base name.
> > > But if a device is created with (non)-transitional, then the compat
> > > values are not used, causing migrating issues.
> > > 
> > > This commit adds their (non)-transitional entries with the same settings
> > > as the base entry.
> > > 
> > > Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
> > > 
> > > Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> > 
> > Jean-Louis, any chance you are going to address the comments
> > and post a new patch?
> > 
> Should'nt we just apply the patch from Eduardo?
> As this is a more elegant solution with the same result.

don't see it in queue. Repost?

> > > ---
> > >   include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
> > >   1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > > index 4ff19c714b..5726825c2d 100644
> > > --- a/include/hw/qdev-core.h
> > > +++ b/include/hw/qdev-core.h
> > > @@ -293,6 +293,30 @@ typedef struct GlobalProperty {
> > >       bool optional;
> > >   } GlobalProperty;
> > > +
> > > +/**
> > > + * Helper to add (non)transitional compat properties
> > > + */
> > > +static inline void
> > > +compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
> > > +{
> > > +    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
> > > +    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
> > > +    transitional->property = g_strdup(prop->property);
> > > +    transitional->value = g_strdup(prop->value);
> > > +    transitional->used = prop->used;
> > > +    transitional->optional = prop->optional;
> > > +    g_ptr_array_add(arr, (void *)transitional);
> > > +
> > > +    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
> > > +    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
> > > +    non_transitional->property = g_strdup(prop->property);
> > > +    non_transitional->value = g_strdup(prop->value);
> > > +    non_transitional->used = prop->used;
> > > +    non_transitional->optional = prop->optional;
> > > +    g_ptr_array_add(arr, (void *)non_transitional);
> > > +}
> > > +
> > >   static inline void
> > >   compat_props_add(GPtrArray *arr,
> > >                    GlobalProperty props[], size_t nelem)
> > > @@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
> > >       int i;
> > >       for (i = 0; i < nelem; i++) {
> > >           g_ptr_array_add(arr, (void *)&props[i]);
> > > +        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-blk-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-serial-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-9p-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-net-pci") ||
> > > +            g_str_equal(props[i].driver, "virtio-rng-pci")) {
> > > +            compat_props_add_transitional(arr, &props[i]);
> > > +        }
> > >       }
> > >   }
> > > -- 
> > > 2.33.0
> > > 
> > > 
> > > 



^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs
@ 2021-10-12  7:49 Jean-Louis Dupond
  0 siblings, 0 replies; 24+ messages in thread
From: Jean-Louis Dupond @ 2021-10-12  7:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jean-Louis Dupond

hw_compat modes only take into account their base name.
But if a device is created with (non)-transitional, then the compat
values are not used, causing migrating issues.

This commit adds their (non)-transitional entries with the same settings
as the base entry.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1999141
---
 include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4ff19c714b..5726825c2d 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -293,6 +293,30 @@ typedef struct GlobalProperty {
     bool optional;
 } GlobalProperty;
 
+
+/**
+ * Helper to add (non)transitional compat properties
+ */
+static inline void
+compat_props_add_transitional(GPtrArray *arr, GlobalProperty *prop)
+{
+    GlobalProperty *transitional = g_new0(typeof(*transitional), 1);
+    transitional->driver = g_strdup_printf("%s-transitional", prop->driver);
+    transitional->property = g_strdup(prop->property);
+    transitional->value = g_strdup(prop->value);
+    transitional->used = prop->used;
+    transitional->optional = prop->optional;
+    g_ptr_array_add(arr, (void *)transitional);
+
+    GlobalProperty *non_transitional = g_new0(typeof(*non_transitional), 1);
+    non_transitional->driver = g_strdup_printf("%s-non-transitional", prop->driver);
+    non_transitional->property = g_strdup(prop->property);
+    non_transitional->value = g_strdup(prop->value);
+    non_transitional->used = prop->used;
+    non_transitional->optional = prop->optional;
+    g_ptr_array_add(arr, (void *)non_transitional);
+}
+
 static inline void
 compat_props_add(GPtrArray *arr,
                  GlobalProperty props[], size_t nelem)
@@ -300,6 +324,16 @@ compat_props_add(GPtrArray *arr,
     int i;
     for (i = 0; i < nelem; i++) {
         g_ptr_array_add(arr, (void *)&props[i]);
+        if (g_str_equal(props[i].driver, "vhost-user-blk-pci") ||
+            g_str_equal(props[i].driver, "virtio-scsi-pci") ||
+            g_str_equal(props[i].driver, "virtio-blk-pci") ||
+            g_str_equal(props[i].driver, "virtio-balloon-pci") ||
+            g_str_equal(props[i].driver, "virtio-serial-pci") ||
+            g_str_equal(props[i].driver, "virtio-9p-pci") ||
+            g_str_equal(props[i].driver, "virtio-net-pci") ||
+            g_str_equal(props[i].driver, "virtio-rng-pci")) {
+            compat_props_add_transitional(arr, &props[i]);
+        }
     }
 }
 
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2021-11-03  7:59 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  8:24 [PATCH] hw/qdev-core: Add compatibility for (non)-transitional devs Jean-Louis Dupond
2021-10-12  8:36 ` Jean-Louis Dupond
2021-10-19 10:46   ` Stefan Hajnoczi
2021-10-19 10:59     ` Michael S. Tsirkin
2021-10-19 15:29       ` Eduardo Habkost
2021-10-19 16:13         ` Michael S. Tsirkin
2021-10-19 16:56           ` Eduardo Habkost
2021-10-20  1:31             ` Jason Wang
2021-10-20  5:02               ` Jason Wang
2021-10-20 14:09                 ` Eduardo Habkost
2021-10-20 14:58                   ` Michael S. Tsirkin
2021-10-20 15:46                     ` Eduardo Habkost
2021-10-20  7:00             ` Jean-Louis Dupond
2021-10-20  7:41             ` Michael S. Tsirkin
2021-10-20 13:57               ` Eduardo Habkost
2021-10-20 14:55                 ` Michael S. Tsirkin
2021-10-20 15:01                   ` Eduardo Habkost
2021-10-20 15:16                     ` Michael S. Tsirkin
2021-10-19 15:27 ` Eduardo Habkost
2021-10-20  6:58   ` Jean-Louis Dupond
2021-11-01 22:26 ` Michael S. Tsirkin
2021-11-03  7:51   ` Jean-Louis Dupond
2021-11-03  7:58     ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2021-10-12  7:49 Jean-Louis Dupond

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.